| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- namespace app\api\model\taxi;
- use app\api\model\user\MotorAgent;
- use app\common\model\BaseModel;
- use app\common\model\TaxiOrder;
- use think\db\Query;
- use think\Exception;
- use think\Model;
- class Award extends BaseModel
- {
- public function send(Model $order)
- {
- $MotorAgent = new MotorAgent();
- $MotorRecord = new MotorRecord();
-
- $result = false;
- $this->startTrans();
- try {
- $percent = sys_config('agent_share', 'agent');
- $motorAgent = $MotorAgent->with([
- 'user'
- ])
- ->where('area_id', $order['area_id'])
- ->find();
- if ($motorAgent) {
- $money = bcmul($order['price'], $percent/100, 2);
- $motorAgent->user->motor_agent_money += $money;
- $motorAgent->user->save();
- $MotorRecord->setMoneyLog($motorAgent->user, 'motor_agent_money', $money, 0, '摩的代理分红');
- $result = $MotorRecord->saveMoneyLog();
- }
- $this->commit();
- }
- catch(Exception $e) {
- $this->rollback();
- throw new Exception($e->getMessage());
- }
- return $result;
- }
- }
|