| | |
| | | use app\common\service\order\OrderRefundService; |
| | | use app\common\model\supplier\Balance as supplierBalanceModel; |
| | | use app\common\model\supplier\Supplier as SupplierModel; |
| | | |
| | | use app\common\model\payment\PaymentLog as PaymentLogModel; |
| | | /** |
| | | * 普通订单模型 |
| | | */ |
| | |
| | | // 判断订单状态 |
| | | $checkPay = CheckPayFactory::getFactory($order['order_source']); |
| | | |
| | | if (!$checkPay->checkOrderStatus($order)) { |
| | | if (!$checkPay->checkOrderStatus($order, $params)) { |
| | | $this->error = $checkPay->getError(); |
| | | return false; |
| | | } |
| | |
| | | foreach ($productList as &$item) { |
| | | // 商品单价 |
| | | $item['product_price'] = $item['product_sku']['product_price']; |
| | | $item['settlement_price'] = $item['product_sku']['settlement_price']; |
| | | // 商品购买数量 |
| | | $item['total_num'] = $params['product_num']; |
| | | $item['spec_sku_id'] = $item['product_sku']['spec_sku_id']; |
| | | // 商品购买总金额 |
| | | $item['total_price'] = helper::bcmul($item['product_price'], $params['product_num']); |
| | | // 商品总结算价 |
| | | $item['total_settlement_price'] = helper::bcmul($item['settlement_price'], $params['product_num']); |
| | | } |
| | | $supplierData[] = [ |
| | | 'shop_supplier_id' => $product['shop_supplier_id'], |
| | |
| | | public static function getUserOrderDetail($order_id, $user_id) |
| | | { |
| | | $model = new static(); |
| | | $order = $model->where(['order_id' => $order_id, 'user_id' => $user_id])->with(['product' => ['image', 'refund'], 'address', 'express', 'extractStore','extractClerk', 'supplier', 'advance'])->find(); |
| | | $where = ['order_id' => $order_id, 'user_id' => $user_id]; |
| | | if(strlen($order_id)>=14){ //按照微信支付的 预下单填入的out_trade_no |
| | | $where = ['trade_no' => $order_id, 'user_id' => $user_id]; |
| | | $order = $model->where($where)->with(['product' => ['image', 'refund'], 'address', 'express', 'extractStore','extractClerk', 'supplier', 'advance'])->find(); |
| | | if(!$order){ |
| | | $where = ['ins_order_sn' => $order_id, 'user_id' => $user_id]; |
| | | $order = $model->where($where)->with(['product' => ['image', 'refund'], 'address', 'express', 'extractStore','extractClerk', 'supplier', 'advance'])->find(); |
| | | } |
| | | }else{ |
| | | $order = $model->where($where)->with(['product' => ['image', 'refund'], 'address', 'express', 'extractStore','extractClerk', 'supplier', 'advance'])->find(); |
| | | } |
| | | if (empty($order)) { |
| | | throw new BaseException(['msg' => '订单不存在']); |
| | | } |
| | |
| | | $orderInfo->save(['balance' => $user_balance, 'online_money' => $online_money]); |
| | | } |
| | | } |
| | | }elseif(!empty($params['activation_code'])){ |
| | | $payType = 50; |
| | | $orderInfo->save(['activation_code' => $params['activation_code']]); |
| | | $data['attach'] = '{"pay_source":"' . $params['pay_source'] . '"}'; |
| | | $this->onPaymentByActivation($orderInfo['trade_no'], $data); |
| | | } else { |
| | | if ($payType <= 10) { |
| | | $this->error = '请选择支付方式'; |
| | |
| | | } else { |
| | | $orderInfo->save(['online_money' => $online_money]); |
| | | } |
| | | } |
| | | }$payment = new PaymentLogModel(); |
| | | $paylog_data = [ |
| | | 'app_id' => $orderInfo['app_id'], |
| | | 'order_no' => $order_no, |
| | | 'order_id' => $orderInfo['order_id'], |
| | | 'online_money' => $online_money, |
| | | 'order_source' => $orderInfo['order_source'] |
| | | ]; |
| | | $payment->savePaymentLog($paylog_data); |
| | | $online_money > 0 && $payment = self::onOrderPayment($user, $order_no, $payType, $params['pay_source'], $online_money, $multiple, $shop_supplier_id); |
| | | |
| | | $result['order_id'] = $params['order_id']; |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 激活码支付标记订单已支付 |
| | | */ |
| | | public function onPaymentByActivation($orderNo, $data) |
| | | { |
| | | // 获取订单详情 |
| | | $PaySuccess = new MasterPaySuccessService($orderNo,['multiple'=>0]); |
| | | // 发起激活码支付 |
| | | $status = $PaySuccess->onPaySuccess(OrderPayTypeEnum::CTIVATIONCODE, $data); |
| | | if (!$status) { |
| | | $this->error = $PaySuccess->getError(); |
| | | } |
| | | return $status; |
| | | } |
| | | |
| | | } |