|
@@ -234,15 +234,28 @@ class Order extends Model
|
|
|
$snowflake = new Snowflake();
|
|
|
$id = $snowflake->id();
|
|
|
// 优惠费用
|
|
|
- $discountPrice = isset($coupon['value']) ? $coupon['value'] : 0;
|
|
|
+// $discountPrice = isset($coupon['value']) ? $coupon['value'] : 0;
|
|
|
+ $discountPrice = 0;
|
|
|
// 订单费用
|
|
|
//$orderPrice;
|
|
|
// 运费
|
|
|
- $deliveryPrice = Delivery::algorithm($delivery, array_sum($numbers));
|
|
|
+// $deliveryPrice = Delivery::algorithm($delivery, array_sum($numbers));
|
|
|
+ $deliveryPrice = '0';
|
|
|
+ foreach ($products as &$product) {
|
|
|
+ $deliveryPrice = bcadd($deliveryPrice,$product['yunfei_price'],2);
|
|
|
+ }
|
|
|
+
|
|
|
// 总费用
|
|
|
$totalPrice = bcadd(bcsub($orderPrice, $discountPrice, 2), $deliveryPrice, 2);
|
|
|
|
|
|
$out_trade_no = date('Ymd',time()).uniqid().$userId;
|
|
|
+
|
|
|
+ $db_pay_type = [
|
|
|
+ 'wallet' => 2,
|
|
|
+ 'wechat' => 3,
|
|
|
+ 'alipay' => 4,
|
|
|
+ ];
|
|
|
+
|
|
|
(new self)->save([
|
|
|
'id' => $id,
|
|
|
'user_id' => $userId,
|
|
@@ -251,7 +264,7 @@ class Order extends Model
|
|
|
'discount_price' => $discountPrice,
|
|
|
'delivery_price' => $deliveryPrice,
|
|
|
'total_price' => $totalPrice,
|
|
|
- 'pay_type' => $data['pay_type'],
|
|
|
+ 'pay_type' => $db_pay_type[$data['pay_type']],
|
|
|
'ip' => $_SERVER['REMOTE_ADDR'] ?? '',
|
|
|
'remark' => $data['remark'] ?? '',
|
|
|
'status' => self::STATUS_NORMAL,
|
|
@@ -262,7 +275,7 @@ class Order extends Model
|
|
|
'order_id' => $id,
|
|
|
'coupon_id' => $coupon ? $coupon['id'] : 0,
|
|
|
'coupon_json' => json_encode($coupon),
|
|
|
- 'delivery_id' => $delivery['id'],
|
|
|
+ 'delivery_id' => $delivery ? $delivery['id'] : 0,
|
|
|
'delivery_json' => json_encode($delivery),
|
|
|
'address_id' => $address['id'],
|
|
|
'address_json' => json_encode($address),
|