From 6380fffd352331bc5afd8dc959438f905c6b0228 Mon Sep 17 00:00:00 2001 From: wangxinglong <2371974647@qq.com> Date: Wed, 6 Apr 2022 11:47:35 +0800 Subject: [PATCH] setter --- app/controller/api/Consumer.php | 47 ++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/app/controller/api/Consumer.php b/app/controller/api/Consumer.php index 8529e08..6cc0508 100644 --- a/app/controller/api/Consumer.php +++ b/app/controller/api/Consumer.php @@ -196,35 +196,38 @@ class Consumer extends Base } ]); }); - if(empty($coupon)){ - return $this->json(4001,"优惠券不存在"); - } - if(!isset($coupon->business)||empty($coupon->business)){ - return $this->json(4001,"优惠券商家不存在"); - } - //如果优惠券所属商家指派了渠道商 - if ($coupon->business->is_assign == Business::COMMON_ON && !empty($coupon->business->agency_code)) { + if( + !empty($coupon) + && + isset($coupon->business) + && + !empty($coupon->business) + ){ + if($coupon->business->is_assign + && + !empty($coupon->business->agency_code) + ){ - $agency = Member::findOne([["business_code","=",$coupon->business->agency_code]]); + $agency = Member::findOne([["business_code","=",$coupon->business->agency_code]]); - if(!empty($agency)){ - $awhereMap = []; - $awhereMap[] = ['position', '=', Slide::advertisement]; - $awhereMap[] = ['agency_id', '=', $agency["id"]]; - $list = $repo->slideList($awhereMap, ["id","title","src as image","url","url_type as type"], $page, $size, function ($q){ - return $q->withAttr("image",function ($value){ - return $this->request->domain() . $value; - }); - }, $orders); - if(!empty($list["list"])){ - return $this->json(1,"ok",$list["list"]); + if(!empty($agency)){ + $awhereMap = []; + $awhereMap[] = ['position', '=', Slide::advertisement]; + $awhereMap[] = ['agency_id', '=', $agency["id"]]; + $list = $repo->slideList($awhereMap, ["id","title","src as image","url","url_type as type"], $page, $size, function ($q){ + return $q->withAttr("image",function ($value){ + return $this->request->domain() . $value; + }); + }, $orders); + if(!empty($list["list"])){ + return $this->json(1,"ok",$list["list"]); + } } } } - - + $whereMap = []; $whereMap[] = ['position', '=', Slide::advertisement]; $list = $repo->slideList($whereMap, ["id","title","src as image","url","url_type as type"], $page, $size, function ($q){