|
@@ -193,11 +193,8 @@ class Order
|
|
|
// 条件四
|
|
|
if ($extra['coupon_id']) {
|
|
|
|
|
|
- /*$coupon = Coupon::get($extra['coupon_id']);
|
|
|
+// $coupon = Coupon::get($extra['coupon_id']);
|
|
|
|
|
|
- if ($coupon['switch'] == Coupon::SWITCH_OFF || $coupon['deletetime'] || $coupon['starttime'] > time() || $coupon['endtime'] < time()) {
|
|
|
- throw new Exception('此优惠券不可用');
|
|
|
- }*/
|
|
|
$coupon = Db::name('unishop_coupon_user')->alias('cu')
|
|
|
->field(['c.id','c.title','c.least','c.value','c.starttime','c.endtime'])
|
|
|
->join('unishop_coupon c','cu.coupon_id = c.id','LEFT')
|
|
@@ -205,14 +202,25 @@ class Order
|
|
|
->where('cu.status',0)
|
|
|
->where('c.deletetime',NULL)
|
|
|
->where('c.switch',Coupon::SWITCH_ON)
|
|
|
- ->where('c.starttime','<',time())
|
|
|
- ->where('c.endtime','>',time())
|
|
|
- ->find('c.id',$extra['coupon_id']);
|
|
|
+// ->where('c.starttime','<',time())
|
|
|
+// ->where('c.endtime','>',time())
|
|
|
+ ->where('c.id',$extra['coupon_id'])
|
|
|
+ ->find();
|
|
|
+
|
|
|
+ if(!empty($coupon)){
|
|
|
+
|
|
|
+ if ($coupon['starttime'] > time() || $coupon['endtime'] < time()) {
|
|
|
+ throw new Exception('此优惠券不可用');
|
|
|
+ }
|
|
|
|
|
|
- // 至少消费多少钱
|
|
|
- if (!empty($coupon) && $coupon['least'] > $orderPrice) {
|
|
|
- throw new Exception('选中的优惠券不满足使用条件');
|
|
|
+ // 至少消费多少钱
|
|
|
+ if ($coupon['least'] > $orderPrice) {
|
|
|
+ throw new Exception('选中的优惠券不满足使用条件');
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $coupon = [];
|
|
|
}
|
|
|
+
|
|
|
} else {
|
|
|
$coupon = [];
|
|
|
}
|