error = '报名通道未开启'; return false; } if($detail["limit_num"] > 0 && $detail["reg_num"]>=$detail["limit_num"]){ $this->error = '报名名额已满'; return false; } if($detail['activity_fee']>0 && empty($param['pay_type'])){ $this->error = '请选择支付方式'; return false; } //生成记录 $record = [ 'user_id' => $user['user_id'], 'order_no' => $this->orderNo(), 'activity_id' => $detail['activity_id'], 'activity_fee' => $detail['activity_fee'], 'pay_price' => $detail['activity_fee'], 'user_name' => $param['user_name'] , 'mobile' => $param['mobile'], 'status' => $detail['activity_fee']>0 ? 0 : 1,//报名状态,没有费用则报名成功 'pay_type' => $param['pay_type'], 'app_id' => self::$app_id, ]; $status = $this->save($record); /*if ($detail['activity_fee'] > 0) { $param['pay_type'] = OrderPayTypeEnum::BALANCE; }*/ // 余额支付标记订单已支付 if ($status && $param['pay_type'] == OrderPayTypeEnum::BALANCE) { if ($user['balance'] < $detail['activity_fee']) { $this->error = '用户余额不足,无法使用余额支付'; return false; } $this->onPaymentByBalance($record['order_no']); } return $this['order_id']; } /** * 余额支付标记订单已支付 */ public function onPaymentByBalance($orderNo) { // 获取订单详情 $PaySuccess = new RegactivitySuccessService($orderNo); // 发起余额支付 return $PaySuccess->onPaySuccess(OrderPayTypeEnum::BALANCE); } /** * 构建支付请求的参数 */ public static function onOrderPayment($user, $order, $payType, $pay_source) { //如果来源是h5,首次不处理,payH5再处理 if ($pay_source == 'h5') { return []; } if ($payType == OrderPayTypeEnum::WECHAT) { return self::onPaymentByWechat($user, $order, $pay_source); } return []; } /** * 构建微信支付请求 */ protected static function onPaymentByWechat($user, $order, $pay_source) { return PaymentService::wechat( $user, [$order], OrderTypeEnum::REGACTIVITY, $pay_source ); } }