|
@@ -154,6 +154,7 @@ class Order extends Base
|
|
|
// $cityId = $address['city_id'] ? $address['city_id'] : 0;
|
|
|
// $delivery = (new DeliveryRuleModel())->getDelivetyByArea($cityId);
|
|
|
|
|
|
+ //订单费用
|
|
|
$order_price = '0';
|
|
|
foreach ($productData as &$product) {
|
|
|
$product['image'] = Config::getImagesFullUrl($product['image']);
|
|
@@ -164,7 +165,7 @@ class Order extends Base
|
|
|
}
|
|
|
|
|
|
$coupon = Db::name('unishop_coupon_user')->alias('cu')
|
|
|
- ->field(['cu.id','c.title','c.least','c.value','c.starttime','c.endtime'])
|
|
|
+ ->field(['cu.id as cu_id','c.id','c.title','c.least','c.value','c.starttime','c.endtime'])
|
|
|
->join('unishop_coupon c','cu.coupon_id = c.id','LEFT')
|
|
|
->where('cu.user_id',$this->auth->id)
|
|
|
->where('cu.status',0)
|
|
@@ -172,16 +173,32 @@ class Order extends Base
|
|
|
->where('c.switch',1)
|
|
|
->where('c.starttime','<',time())
|
|
|
->where('c.endtime','>',time())
|
|
|
- ->where('c.least','>=',$order_price)
|
|
|
+ ->where('c.least','<=',$order_price)
|
|
|
->select();
|
|
|
|
|
|
+ //优惠费用
|
|
|
+ $coupon_id = input('coupon_id',0);
|
|
|
+ $discountPrice = 0;
|
|
|
+ if($coupon_id && !empty($coupon)){
|
|
|
+ $coupon_ids = array_column($coupon,'id');
|
|
|
+ if(in_array($coupon_id,$coupon_ids)){
|
|
|
+ foreach($coupon as $key => $cou){
|
|
|
+ if($cou['id'] == $coupon_id){
|
|
|
+ $discountPrice = $cou['value'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
$this->success('', [
|
|
|
'product' => $productData,
|
|
|
// 'address' => $address,
|
|
|
'coupon' => $coupon,
|
|
|
// 'delivery' => $delivery['list']
|
|
|
'order_price' => $order_price,
|
|
|
- 'total_price' => $order_price
|
|
|
+ 'discount_price' => $discountPrice,
|
|
|
+ 'total_price' => bcsub($order_price,$discountPrice,2),
|
|
|
]);
|
|
|
|
|
|
} catch (Exception $e) {
|