lock(true)->find()) { Db::rollback(); return [false,'未找到订单']; } if ($order['order_status'] != 0) { Db::rollback(); return [true,'订单已支付']; } //更新订单状态 if (!self::where(['out_trade_no' => $out_trade_no])->update(['order_status' => 1, 'notifytime' => time()])) { Db::rollback(); return [false,'订单状态更新失败']; } //钱包更新 $walletService = new Wallet(); if (!$walletService->change($order['user_id'], $order['order_amount'], 'money', 10, '充值', 'pay_order', $order['table_id'])) { Db::rollback(); return [false,'余额充值失败']; } Db::commit(); return [true,'操作成功']; } /** * 老年大学活动支付回调 * @param $out_trade_no * @return array */ public static function university_event($out_trade_no) { Db::startTrans(); if (!$info = self::where('out_trade_no',$out_trade_no)->lock(true)->find()){ Db::rollback(); return [false,'未找到订单']; } if ($info['order_status'] == 1){ Db::rollback(); return [true,'订单已支付']; } //更新订单状态 if (!self::where(['id' => $info['id']])->update(['status' => 1])) { Db::rollback(); return [false,'订单状态更新失败']; } if (!UniversityEventApplyModel::where('id',$info['table_id'])->update(['status' => 1,'pay_time' => time()])) { Db::rollback(); return [false,'活动订单状态更新失败']; } Db::commit(); return [true,'操作成功']; } /** * 老年大学活动支付回调 * @param $out_trade_no * @return array */ public static function vip($out_trade_no) { Db::startTrans(); if (!$info = self::where('out_trade_no',$out_trade_no)->lock(true)->find()){ Db::rollback(); return [false,'未找到订单']; } if ($info['order_status'] == 1){ Db::rollback(); return [true,'订单已支付']; } //更新订单状态 if (!self::where(['id' => $info['id']])->update(['status' => 1])) { Db::rollback(); return [false,'订单状态更新失败']; } if (!VipOrderModel::where('id',$info['table_id'])->update(['status' => 1,'pay_time' => time()])) { Db::rollback(); return [false,'VIP订单状态更新失败']; } if (!VipCouponUserModel::where('order_id',$info['table_id'])->update(['status' => 1,'update_time' => time()])) { Db::rollback(); return [false,'VIP订单状态更新失败']; } Db::commit(); return [true,'操作成功']; } }