getFile(), $e->getLine(), $e->getMessage() ])); self::setError($e->getMessage()); return $e->getMessage(); } } /** * @notes 调用回调方法统一处理 更新订单支付状态 * @param $orderSn * @param array $extra * @author ljj * @date 2022/3/1 11:35 上午 */ public static function order($orderSn, $extra = []) { $order = Order::with(['order_goods'])->where(['sn' => $orderSn])->findOrEmpty(); //更新订单状态 Order::update([ 'pay_status' => PayEnum::ISPAID, 'pay_time' => time(), 'order_status' => OrderEnum::ORDER_STATUS_WAIT_RECEIVING, 'transaction_id' => $extra['transaction_id'] ?? '' ], ['id' => $order['id']]); //添加订单日志 (new OrderLogLogic())->record(OrderLogEnum::TYPE_USER,OrderLogEnum::USER_PAY_ORDER,$order['id'],$order['user_id']); //通知师傅接单 event('Notice', [ 'scene_id' => NoticeEnum::ACCEPT_ORDER_NOTICE_STAFF, 'params' => [ 'coach_id' => $order['coach_id'], 'order_id' => $order['id'] ] ]); // 订单付款通知 - 通知买家 event('Notice', [ 'scene_id' => NoticeEnum::ORDER_PAY_NOTICE, 'params' => [ 'user_id' => $order['user_id'], 'order_id' => $order['id'] ] ]); //通知平台 $mobile = ConfigService::get('platform', 'mobile',''); if($mobile){ event('Notice', [ 'scene_id' => NoticeEnum::ORDER_PAY_NOTICE_PLATFORM, 'params' => [ 'mobile' => $mobile, 'order_id' => $order['id'] ] ]); } foreach ($order['order_goods'] as $order_goods){ Goods::update(['order_num'=>['inc',$order_goods['goods_num']]],['id'=>$order_goods['goods_id']]); } // 订单付款通知 - 通知卖家 // $mobile = ConfigService::get('website', 'mobile'); // if (!empty($mobile)) { // event('Notice', [ // 'scene_id' => NoticeEnum::ORDER_PAY_NOTICE_PLATFORM, // 'params' => [ // 'mobile' => $mobile, // 'order_id' => $order['id'] // ] // ]); // } } /** * @notes 订单差价 * @param $orderSn * @param $extra * @return void * @author cjhao * @date 2024/9/19 01:54 */ private static function orderGap($orderSn, $extra = []){ $orderGap = OrderGap::where(['sn' => $orderSn])->findOrEmpty(); //更新订单状态 OrderGap::update([ 'pay_status' => PayEnum::ISPAID, 'pay_time' => time(), 'transaction_id' => $extra['transaction_id'] ?? '' ], ['id' => $orderGap['id']]); Order::where(['id'=>$orderGap['order_id']])->update([ // 'total_amount' => Db::raw('total_amount+'.$orderGap['order_amount']), 'total_order_amount' => Db::raw('total_order_amount+'.$orderGap['order_amount']), 'total_gap_amount' => Db::raw('total_gap_amount+'.$orderGap['order_amount']) ]); //添加订单日志 (new OrderLogLogic())->record(OrderLogEnum::TYPE_USER,OrderLogEnum::USER_PAY_ORDER_GAP,$orderGap['order_id'],$orderGap['user_id']); } /** * @notes 订单差价 * @param $orderSn * @param $extra * @return void * @author cjhao * @date 2024/9/19 01:54 */ private static function orderAppend($orderSn, $extra = []){ $orderAppend = OrderAppend::where(['sn' => $orderSn])->findOrEmpty(); //更新订单状态 OrderAppend::update([ 'pay_status' => PayEnum::ISPAID, 'pay_time' => time(), 'transaction_id' => $extra['transaction_id'] ?? '' ], ['id' => $orderAppend['id']]); Order::where(['id'=>$orderAppend['order_id']])->update([ // 'total_amount' => Db::raw('total_amount+'.$orderAppend['order_amount']), 'total_order_amount' => Db::raw('total_order_amount+'.$orderAppend['order_amount']), 'total_append_amount' => Db::raw('total_append_amount+'.$orderAppend['order_amount']) ]); //添加订单日志 (new OrderLogLogic())->record(OrderLogEnum::TYPE_USER,OrderLogEnum::USER_PAY_ORDER_APPEND,$orderAppend['order_id'],$orderAppend['user_id']); } /** * @notes 充值回调 * @param $orderSn * @param array $extra * @author ljj * @date 2022/12/26 5:00 下午 */ public static function recharge($orderSn, $extra = []) { $order = RechargeOrder::where('sn', $orderSn)->findOrEmpty()->toArray(); // 增加用户累计充值金额及用户余额 User::update([ 'user_money' => ['inc',$order['order_amount']], 'total_recharge_amount' => ['inc',$order['order_amount']], ],['id'=>$order['user_id']]); // 记录账户流水 AccountLogLogic::add($order['user_id'], AccountLogEnum::MONEY,AccountLogEnum::USER_RECHARGE_ADD_MONEY,AccountLogEnum::INC, $order['order_amount'], $order['sn']); // 更新充值订单状态 RechargeOrder::update([ 'transaction_id' => $extra['transaction_id'], 'pay_status' => PayEnum::ISPAID, 'pay_time' => time(), ],['id'=>$order['id']]); } /** * @notes * @param $orderSn * @param $extra * @return void * @author cjhao * @date 2024/11/29 00:27 */ private static function deposit($orderSn, $extra = []){ $order = DepositOrder::where('sn', $orderSn)->findOrEmpty()->toArray(); if(1 == $order['type']){ Coach::update([ 'deposit' => ['inc',$order['order_amount']], ],['id'=>$order['relation_id']]); // 记录账户流水 CoachAccountLog::add($order['relation_id'], CoachAccountLogEnum::DEPOSIT,CoachAccountLogEnum::RECHARGE_INC_DEPOSIT,CoachAccountLogEnum::INC, $order['order_amount'], $order['sn']); }else{ Shop::update([ 'deposit' => ['inc',$order['order_amount']], ],['id'=>$order['relation_id']]); // 记录账户流水 ShopAccountLog::add($order['relation_id'], ShopAccountLogEnum::DEPOSIT,ShopAccountLogEnum::RECHARGE_INC_DEPOSIT,ShopAccountLogEnum::INC, $order['order_amount'], $order['sn']); } // 增加用户累计充值金额及用户余额 // 更新充值订单状态 DepositOrder::update([ 'transaction_id' => $extra['transaction_id'] ?? '', 'pay_status' => PayEnum::ISPAID, 'pay_time' => time(), ],['id'=>$order['id']]); } }