|
@@ -25,6 +25,7 @@ class Order
|
|
|
* 创建订单之后
|
|
|
* 行为一:根据订单减少商品库存 增加"已下单未支付数量"
|
|
|
* 行为二:如果选了购物车的就删除购物车的信息
|
|
|
+ * 行为三:如果选了优惠券的就修改掉购物券的状态
|
|
|
* @param array $params 商品属性
|
|
|
* @param array $extra [specNumber] => ['spec1' => 'number1','spec2' => 'number2']
|
|
|
*/
|
|
@@ -103,6 +104,12 @@ class Order
|
|
|
Db::execute('DELETE FROM ' . $prefix . "unishop_cart WHERE id IN ($cart) AND user_id = $extra[userId]");
|
|
|
}
|
|
|
|
|
|
+ // 行为三
|
|
|
+ $coupon = $extra['coupon'];
|
|
|
+ if (!empty($coupon)) {
|
|
|
+ Db::name('unishop_coupon_user')->where('id',$coupon['cu_id'])->update(['status'=>1]);
|
|
|
+ }
|
|
|
+
|
|
|
// More ...
|
|
|
}
|
|
|
|
|
@@ -196,7 +203,7 @@ class Order
|
|
|
// $coupon = Coupon::get($extra['coupon_id']);
|
|
|
|
|
|
$coupon = Db::name('unishop_coupon_user')->alias('cu')
|
|
|
- ->field(['c.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',$extra['userId'])
|
|
|
->where('cu.status',0)
|
|
@@ -204,7 +211,7 @@ class Order
|
|
|
->where('c.switch',Coupon::SWITCH_ON)
|
|
|
// ->where('c.starttime','<',time())
|
|
|
// ->where('c.endtime','>',time())
|
|
|
- ->where('c.id',$extra['coupon_id'])
|
|
|
+ ->where('cu.id',$extra['coupon_id'])
|
|
|
->find();
|
|
|
|
|
|
if(!empty($coupon)){
|