diff --git a/admin/controllers/base/ChargeCashController.php b/admin/controllers/base/ChargeCashController.php new file mode 100644 index 0000000..d653357 --- /dev/null +++ b/admin/controllers/base/ChargeCashController.php @@ -0,0 +1,70 @@ +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() + { + + } +} \ No newline at end of file diff --git a/admin/controllers/base/DivideAccountController.php b/admin/controllers/base/DivideAccountController.php index b5ad990..d0794e1 100644 --- a/admin/controllers/base/DivideAccountController.php +++ b/admin/controllers/base/DivideAccountController.php @@ -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(); +// } } /** diff --git a/common/models/ChargeCashPayRecord.php b/common/models/ChargeCashPayRecord.php new file mode 100644 index 0000000..fc6accc --- /dev/null +++ b/common/models/ChargeCashPayRecord.php @@ -0,0 +1,30 @@ + TimestampBehavior::class, + 'attributes' => [ + ActiveRecord::EVENT_BEFORE_INSERT => ['created_at','updated_at'], + ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at'], + ], + ], + ]; + } + + + //门店 + public function getStore() + { + return $this->hasOne(Store::class, ['id'=>'store_id']); + } +} \ No newline at end of file diff --git a/common/modelsgii/ChargeCashPayRecord.php b/common/modelsgii/ChargeCashPayRecord.php new file mode 100644 index 0000000..0f8f629 --- /dev/null +++ b/common/modelsgii/ChargeCashPayRecord.php @@ -0,0 +1,57 @@ + 'ID', + 'order_no' => '订单号', + 'store_id' => '诊所ID', + 'charge_cash' => '手续费', + 'type' => 'type', + 'status' => 'status', + 'created_at' => 'Created At', + 'updated_at' => 'Updated At', + ]; + } +}