price1; //所有的商品总金额 } elseif ($type == 2) { $totalPrice = $goodsInfo->price2; //所有的商品总金额 } else if ($type == 3) { $totalPrice = $goodsInfo->price3; //所有的商品总金额 } else if ($type == 4) { $totalPrice = $goodsInfo->price4; //所有的商品总金额 } else if ($type == 5) { $totalPrice = $goodsInfo->price5; //所有的商品总金额 } else { $totalPrice = $goodsInfo->price4; } $order_amount_total = $totalPrice; //实际付款金额 // $preferential_type = 0; // 1 会员卡 $totalPreferentialPrice = 0; $order_status = 1; //1 未支付 2 已支付 // GO 前缀是支付成功后,回调判断是哪个订单类型 $order_no = $order_no ?: createNewOrderNo(); if (!str_contains("GO", $order_no)) { $order_no = 'GO' . $order_no; } $info = [ 'user_id' => $this->userId, 'order_no' => $order_no, 'order_status' => $order_status, //1 未支付 'product_amount_total' => $totalPrice, //所有购买商品总价 'order_amount_total' => $order_amount_total, //实际付款金额 'pay_amount_total' => 0, 'preferential_price' => $totalPreferentialPrice, //订单优惠金额(优惠券等) 'preferential_type' => $preferential_type, // //优惠类型 1会员卡 'pay_channel' => 0, 'product_id' => $goodsInfo->id, 'product_sku' => $type, // 产品类型 'mid' => Str::random(12), 'created_at' => time(), 'updated_at' => time(), ]; $isSuccess = DB::table('order_product')->insertGetId($info); if ($isSuccess) { $info['id'] = $isSuccess; return $info; } else { return []; } } /** * @param string $orderNo * @param array $where * @return array */ public function getOrderInfo(string $orderNo, array $where = [], array $selectArr = []): array { if (!str_contains("GO", $orderNo)) { $orderNo = 'GO' . $orderNo; } $find = DB::table('order_product')->where('order_no', $orderNo); if ($where) { $find->where($where); } $info = $find->first(); if ($info) { return get_object_vars($info); } else { return []; } } }