From 6bf1d26d185e76dff95786358fcb06e6a9d30a5e Mon Sep 17 00:00:00 2001 From: lccsw <805383944@qq.com> Date: Wed, 31 Dec 2025 09:55:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=A7=A3=E9=94=81=E5=8F=91?= =?UTF-8?q?=E5=88=B8=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- agent/admin/controllers/auto/Ucenter.php | 4 +-- .../receiver/Receiver_customers_model.php | 34 ++++++++++++++++--- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/agent/admin/controllers/auto/Ucenter.php b/agent/admin/controllers/auto/Ucenter.php index c2d77cc7..8166ac64 100644 --- a/agent/admin/controllers/auto/Ucenter.php +++ b/agent/admin/controllers/auto/Ucenter.php @@ -201,8 +201,8 @@ class Ucenter extends BaseController { $id = $this->get('id'); $userCoupon = $this->auto_user_coupon_model->get(['id' => $id, 'userId' => $this->userId]); - $product = $this->auto_product_model->get(['id'=>$userCoupon['productId']]); - $where = ['cf_uid' => $this->userId, 'app_id' => Receiver_clues_model::APP_ID_ACTIVITY, 'out_id' => $userCoupon['productId']]; + $product = $this->auto_product_model->get(['id' => $userCoupon['productId']]); + $where = ['cf_uid' => $this->userId, 'app_id' => Receiver_clues_model::APP_ID_ACTIVITY]; $cluesRow = $this->clues_model->get($where); $cityRow = $this->area_model->get(['city_id' => $cluesRow['city_id']]); $brand = $this->auto_brand_model->get(['id' => $product['brand_id']], 'name'); diff --git a/common/models/receiver/Receiver_customers_model.php b/common/models/receiver/Receiver_customers_model.php index 8ed991a6..9334a8e2 100644 --- a/common/models/receiver/Receiver_customers_model.php +++ b/common/models/receiver/Receiver_customers_model.php @@ -331,6 +331,7 @@ class Receiver_customers_model extends HD_Model $log_path = "customer_unlock.log"; $this->load->model('receiver/receiver_clues_model'); $this->load->model('agent/auto_user_coupon_model'); + $this->load->model('biz/biz_car_brand_model'); $this->auto_user_coupon_model->set_db('agentdb'); $this->db->trans_begin(); $this->auto_user_coupon_model->db->trans_begin(); @@ -356,11 +357,34 @@ class Receiver_customers_model extends HD_Model throw new Exception('您已解锁该线索'); } $unLockBizIds[] = $row['biz_id']; - $updateCoupon = [ - 'unLockBizIds' => implode(',', $unLockBizIds), - 'status' => Auto_user_coupon_model::STATUS_NOT_USED - ]; - $res = $this->auto_user_coupon_model->update($updateCoupon, ['id' => $coupon['id']]); + //获取门店的品牌 + $bizBrands = $this->biz_car_brand_model->select(['biz_id' => $row['biz_id']], '', '', '', 'brand_id'); + $bizBrandIds = $bizBrands ? array_column($bizBrands, 'brand_id') : []; + $bizBrandIdString = $bizBrandIds ? implode(',', $bizBrandIds) : ''; + + if ($bizBrandIdString) { + //按门店品牌发券 + $updateCoupon = [ + "unLockBizIds = IF( + unLockBizIds IS NOT NULL AND unLockBizIds != '', + CONCAT_WS(',',unLockBizIds, '{$row['biz_id']}'), + '{$row['biz_id']}' + )" => null, + 'status' => Auto_user_coupon_model::STATUS_NOT_USED + ]; + $where = [ + "productId in (select id from lc_auto_product where brandId in ({$bizBrandIdString}) and status =1)" => null, + "status" => Auto_user_coupon_model::STATUS_AUDITING, + 'userId' => $coupon['userId'] + ]; + $res = $this->auto_user_coupon_model->update($updateCoupon, $where); + } else { + $updateCoupon = [ + 'unLockBizIds' => implode(',', $unLockBizIds), + 'status' => Auto_user_coupon_model::STATUS_NOT_USED + ]; + $res = $this->auto_user_coupon_model->update($updateCoupon, ['id' => $coupon['id']]); + } if (!is_numeric($res)) { throw new Exception('更新优惠券状态失败'); }