取消提现手续费-附加一些功能测试
This commit is contained in:
70
admin/controllers/base/ChargeCashController.php
Normal file
70
admin/controllers/base/ChargeCashController.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace admin\controllers\base;
|
||||
|
||||
use admin\components\BaseAdminController;
|
||||
use common\models\ChargeCashPayRecord;
|
||||
use common\models\Ledger;
|
||||
|
||||
/**
|
||||
* @doc-module 分账
|
||||
*/
|
||||
class ChargeCashController extends BaseAdminController
|
||||
{
|
||||
public function actionList()
|
||||
{
|
||||
// TODO 待完善
|
||||
$params = \Yii::$app->request->get();
|
||||
|
||||
|
||||
$query = ChargeCashPayRecord::find();
|
||||
|
||||
|
||||
if (!empty($params['status'])) {
|
||||
$query->where(['status' => $params['status']]);
|
||||
}
|
||||
|
||||
if (!empty($params['store_id'])) {
|
||||
$query->andWhere(['store_id' => $params['store_id']]);
|
||||
}
|
||||
|
||||
// if (!empty($params['start_time']) && !empty($params['end_time'])) {
|
||||
// // 确保 start_time 不大于 end_time
|
||||
// if ($params['start_time'] <= $params['end_time']) {
|
||||
// $query->andWhere(['between', 'created_at', $params['start_time'], $params['end_time']]);
|
||||
// } else {
|
||||
// // 如果 start_time 大于 end_time,可以抛出异常或者记录错误
|
||||
// throw new \InvalidArgumentException("Start time must be before end time.");
|
||||
// }
|
||||
// } elseif (!empty($params['start_time'])) {
|
||||
// // 只有开始时间的情况下,查询 created_at 大于等于 start_time 的数据
|
||||
// $query->andWhere(['>=', 'created_at', $params['start_time']]);
|
||||
// } elseif (!empty($params['end_time'])) {
|
||||
// // 只有结束时间的情况下,查询 created_at 小于等于 end_time 的数据
|
||||
// $query->andWhere(['<=', 'created_at', $params['end_time']]);
|
||||
// }
|
||||
|
||||
|
||||
$query->with(['store'])->orderBy(['id' => SORT_DESC]);
|
||||
$this->field = [
|
||||
ChargeCashPayRecord::class => [
|
||||
'id',
|
||||
'store_id',
|
||||
'order_no',
|
||||
'charge_cash',
|
||||
'type',
|
||||
'status',
|
||||
'store',
|
||||
'created_at' => function ($le) {
|
||||
return date('Y-m-d H:i:s', $le->created_at);
|
||||
}
|
||||
],
|
||||
];
|
||||
return $this->create($query, $params);
|
||||
}
|
||||
|
||||
public function actionCount()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -93,12 +93,10 @@ class DivideAccountController extends BaseAdminController
|
||||
$CashAccount->last_apply_time = date('Y-m-d H:i:s', time());
|
||||
$CashAccount->saveOrFail();
|
||||
|
||||
// TODO 暂时关闭手续费
|
||||
// TODO 暂时关闭手续费 扣除平台的手续费
|
||||
$pQianliuwu=bcdiv(0.65,100,4);
|
||||
$pShouxufei=bcadd(bcmul($post['apply_cash'],$pQianliuwu,2),2,3);
|
||||
|
||||
$Platform->charge_cash = bcadd($Platform->charge_cash, $pShouxufei, 2);
|
||||
$Platform->saveOrFail();
|
||||
$shouxufei = 0;
|
||||
// $Platform->updateAllCounters(['able_cash'=>1]);
|
||||
// $Platform->updateAllCounters(['total_cash'=>1]);
|
||||
@@ -548,10 +546,11 @@ class DivideAccountController extends BaseAdminController
|
||||
*
|
||||
* @param $orderNo
|
||||
* @param $status
|
||||
* @param string $chargeCash // 在status = 2的时候是冻结金额
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
private function updateChargeCashPayRecordStatusByOrderNo($orderNo, $status, $chargeCash)
|
||||
private function updateChargeCashPayRecordStatusByOrderNo($orderNo, $status, $chargeCash = '')
|
||||
{
|
||||
if (empty($orderNo) || empty($status)) throw new Exception('参数错误');
|
||||
// 记录代付的手续费
|
||||
@@ -560,21 +559,29 @@ class DivideAccountController extends BaseAdminController
|
||||
$chargeCpr->saveOrFail();
|
||||
if ($status == 2) {
|
||||
if (empty($chargeCash)) {
|
||||
throw new Exception('充值金额不能为空');
|
||||
throw new Exception('金额不能为空');
|
||||
}
|
||||
$account = CashAccount::find()->where([
|
||||
'user_id' => $chargeCpr->user_id,
|
||||
'user_type' => $chargeCpr->user_type
|
||||
'user_id' => $chargeCpr->store_id,
|
||||
'user_type' => $chargeCpr->type
|
||||
])->one();
|
||||
// 将冻结金额和充值金额进行合并计算,并将结果赋值给可用金额
|
||||
$account->charge_cash = bcadd($account->frozen_cash, $chargeCpr->charge_cash, 2);
|
||||
|
||||
$account->charge_cash = bcadd($account->charge_cash, $chargeCpr->charge_cash, 2);
|
||||
// 从冻结金额中减去充值金额,并将结果赋值回冻结金额
|
||||
$account->frozen_cash = bcsub($account->frozen_cash, $chargeCash, 2);
|
||||
// 减少账户可用余额
|
||||
$account->able_cash = bcsub($account->able_cash, $chargeCpr->charge_cash, 2);
|
||||
$account->saveOrFail();
|
||||
return $account->saveOrFail();
|
||||
}
|
||||
// if ($status == 3) {
|
||||
// $account = CashAccount::find()->where([
|
||||
// 'user_id' => 0,
|
||||
// 'user_type' => 2
|
||||
// ])->one();
|
||||
// // 将冻结金额和充值金额进行合并计算,并将结果赋值给可用金额
|
||||
// $account->charge_cash = bcadd($account->charge_cash, $chargeCpr->charge_cash, 2);
|
||||
// return $account->saveOrFail();
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user