|
|
@@ -11,6 +11,7 @@ use app\common\enum\YesNoEnum;
|
|
|
use app\common\logic\BaseLogic;
|
|
|
use app\common\logic\PaymentLogic;
|
|
|
use app\common\logic\RefundLogic;
|
|
|
+use app\common\model\coupon\CouponCategory;
|
|
|
use app\common\model\coupon\UserCoupon;
|
|
|
use app\common\model\dict\DictData;
|
|
|
use app\common\model\goods\Goods;
|
|
|
@@ -566,7 +567,7 @@ class ServiceOrderLogic extends BaseLogic
|
|
|
$order_info = \app\common\model\recharge\RechargeOrder::with(['order_goods'=>function ($query) {
|
|
|
$query->visible(['goods_payment_type','goods_category_id']);
|
|
|
},'service_work'=>function ($query) {
|
|
|
- $query->visible(['service_fee','spare_total','service_work_spare_id']);
|
|
|
+ $query->visible(['service_fee','spare_total','service_work_spare_id','goods_category_id']);
|
|
|
}])
|
|
|
->visible(['id','sn','work_id'])
|
|
|
->where([
|
|
|
@@ -646,6 +647,23 @@ class ServiceOrderLogic extends BaseLogic
|
|
|
$order_info['spare_parts'] = array_values($spare_parts)??[];
|
|
|
}
|
|
|
|
|
|
+ //获取是否存在可使用优惠券
|
|
|
+ $coupon_ids = CouponCategory::where('goods_category_id',$order_info['service_work']['goods_category_id'])
|
|
|
+ ->whereIn('coupon_id',UserCoupon::where('user_id',$params['user_id'])
|
|
|
+ ->where('voucher_count','>',0)
|
|
|
+ ->where('voucher_status',0)
|
|
|
+ ->where('expire_time','>',time())
|
|
|
+ ->where('amount_require','<=',$order_info['order_amount'])
|
|
|
+ ->column('coupon_id')
|
|
|
+ )->column('coupon_id');
|
|
|
+ $usable_coupon = UserCoupon::where('user_id',$params['user_id'])
|
|
|
+ ->whereIn('coupon_id',$coupon_ids)
|
|
|
+ ->append(['discount_ratio_text'])
|
|
|
+ ->where('expire_time','>',time())
|
|
|
+ ->count();
|
|
|
+
|
|
|
+ $order_info['usable_coupon'] = $usable_coupon>0?true:false;
|
|
|
+
|
|
|
return $order_info;
|
|
|
}
|
|
|
catch (\Exception $e) {
|