| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
- namespace app\workerapi\logic;
- use app\common\enum\worker\WorkerAccountLogEnum;
- use app\common\logic\BaseLogic;
- use app\common\model\master_worker\MasterWorker;
- use app\common\model\master_worker\MasterWorkerRetentionMoneyLog;
- /**
- * @author 林海涛
- * @date 2024/7/28 上午10:32
- */
- class RetentionMoneyLogic extends BaseLogic
- {
- public static function totalAmount($params)
- {
- try{
- $model = MasterWorker::findOrEmpty($params['worker_id']);
- if($model->isEmpty()){
- throw new \Exception('用户不存在');
- }
- $where = [];
- $where[] = ['worker_id','=',$params['worker_id']] ;
- $incWhere =$where;
- $incWhere[] = ['action', '=',WorkerAccountLogEnum::INC];
- $data['amount_inc_total'] = MasterWorkerRetentionMoneyLog::where($incWhere)
- ->sum('amount');
- $outWhere = $where;
- $outWhere[] =['action', '=',WorkerAccountLogEnum::DEC];
- $data['amount_dec_total'] = MasterWorkerRetentionMoneyLog::where($outWhere)
- ->sum('amount');
- $data['amount_available_total'] = $data['amount_inc_total'] - $data['amount_dec_total'];
- $data['retention_money_status'] = $model->retention_money_status;
- $data['retention_money_status_text'] = $model->retention_money_status_text;
- $data['retention_pay_status'] = $model->retention_pay_status;
- $data['retention_pay_status_text'] = $model->retention_pay_status_text;
- return $data;
- } catch(\Exception $e){
- self::setError($e->getMessage());
- return false;
- }
- }
- }
|