|
@@ -174,27 +174,43 @@ class Order
|
|
|
}
|
|
|
|
|
|
// 条件三
|
|
|
- $delivery = (new DeliveryRuleModel())->cityInScopeOfDelivery($extra['city_id'], $extra['delivery_id']);
|
|
|
+ /*$delivery = (new DeliveryRuleModel())->cityInScopeOfDelivery($extra['city_id'], $extra['delivery_id']);
|
|
|
if (!$delivery) {
|
|
|
throw new Exception(__('Your receiving address is not within the scope of delivery'));
|
|
|
} else {
|
|
|
if ($delivery['min'] > array_sum($numbers)) {
|
|
|
throw new Exception(__('You must purchase at least %s item to use this shipping method', $delivery['min']));
|
|
|
}
|
|
|
- }
|
|
|
- $address = (new Address)->where(['id' => $extra['address_id'], 'user_id' => $extra['userId']])->find();
|
|
|
+ }*/
|
|
|
+ $delivery = [];
|
|
|
+
|
|
|
+ /*$address = (new Address)->where(['id' => $extra['address_id'], 'user_id' => $extra['userId']])->find();
|
|
|
if (!$address) {
|
|
|
throw new Exception(__('Address not exist'));
|
|
|
- }
|
|
|
+ }*/
|
|
|
+ $address = [];
|
|
|
|
|
|
// 条件四
|
|
|
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')
|
|
|
+ ->where('cu.user_id',$extra['userId'])
|
|
|
+ ->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']);
|
|
|
+
|
|
|
// 至少消费多少钱
|
|
|
- if ($coupon['least'] > $orderPrice) {
|
|
|
+ if (!empty($coupon) && $coupon['least'] > $orderPrice) {
|
|
|
throw new Exception('选中的优惠券不满足使用条件');
|
|
|
}
|
|
|
} else {
|