From e0f3665d2694d23ef36a481a7a2746a3324f9431 Mon Sep 17 00:00:00 2001 From: wuhui_zzw <1760308791@qq.com> Date: Mon, 29 Jan 2024 14:33:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=A0=B8=E9=94=80=E5=88=B8?= =?UTF-8?q?=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/dao/marketing/AgentDao.php | 4 +++ .../store/coupon/StoreCouponRepository.php | 12 +++++-- .../system/groupData/GroupDataRepository.php | 4 +++ app/controller/admin/marketing/Agent.php | 2 +- app/controller/admin/store/Coupon.php | 2 +- app/event.php | 4 ++- app/listener/giveCoupon/CardOpeningEvent.php | 31 +++++++++++++++++++ app/validate/merchant/StoreCouponValidate.php | 2 +- 8 files changed, 54 insertions(+), 7 deletions(-) create mode 100644 app/listener/giveCoupon/CardOpeningEvent.php diff --git a/app/common/dao/marketing/AgentDao.php b/app/common/dao/marketing/AgentDao.php index 60cd5fd..200385f 100644 --- a/app/common/dao/marketing/AgentDao.php +++ b/app/common/dao/marketing/AgentDao.php @@ -38,6 +38,10 @@ class AgentDao extends BaseDao{ ->when(isset($params['agent_type']) && $params['agent_type'] !== '',function($query) use ($params){ $query->where('agent_type', (int)$params['agent_type']); }) + ->when(isset($params['is_invite_supplier']) && $params['is_invite_supplier'] !== '',function($query) use ($params){ + // 仅获取拥有【供应商】邀请权限的代理人员 类型:1=发起人,2=省公司,3=省合伙人(外勤),4=省合伙人(内勤),5=区县运营商 + $query->whereIn('agent_type',[1,2,3,4,5]); + }) ->with([ 'user' => function($query){ $query->field('uid,nickname,avatar'); diff --git a/app/common/repositories/store/coupon/StoreCouponRepository.php b/app/common/repositories/store/coupon/StoreCouponRepository.php index a14b58a..20a0b9a 100644 --- a/app/common/repositories/store/coupon/StoreCouponRepository.php +++ b/app/common/repositories/store/coupon/StoreCouponRepository.php @@ -47,6 +47,8 @@ class StoreCouponRepository extends BaseRepository //平台跨店券 const TYPE_PLATFORM_STORE = 12; + const TYPE_PLATFORM_WRITE = 13; + //获取方式 const GET_COUPON_TYPE_RECEIVE = 0; //消费满赠 @@ -382,6 +384,7 @@ class StoreCouponRepository extends BaseRepository ['value' => self::TYPE_PLATFORM_ALL, 'label' => '通用券'], ['value' => self::TYPE_PLATFORM_CATE, 'label' => '品类券'], ['value' => self::TYPE_PLATFORM_STORE, 'label' => '跨店券'], + ['value' => self::TYPE_PLATFORM_WRITE, 'label' => '核销券'], ])->control([ [ 'value' => self::TYPE_PLATFORM_CATE, @@ -430,8 +433,12 @@ class StoreCouponRepository extends BaseRepository ] ], ]), - - + ] + ], + [ + 'value' => self::TYPE_PLATFORM_WRITE, + 'rule' => [ + Elm::textarea('description', '使用说明'), ] ], ]), @@ -519,7 +526,6 @@ class StoreCouponRepository extends BaseRepository ])->setTitle('发布优惠券'); } - public function create($data) { if (isset($data['total_count'])) $data['remain_count'] = $data['total_count']; diff --git a/app/common/repositories/system/groupData/GroupDataRepository.php b/app/common/repositories/system/groupData/GroupDataRepository.php index 316d7ad..f9c7f37 100644 --- a/app/common/repositories/system/groupData/GroupDataRepository.php +++ b/app/common/repositories/system/groupData/GroupDataRepository.php @@ -10,6 +10,7 @@ use app\common\dao\BaseDao; use app\common\dao\system\groupData\GroupDataDao; use app\common\repositories\BaseRepository; use app\common\repositories\store\product\ProductLabelRepository; +use app\common\repositories\store\coupon\StoreCouponRepository; use app\common\repositories\store\StoreCategoryRepository; use FormBuilder\Exception\FormBuilderException; use FormBuilder\Factory\Elm; @@ -380,6 +381,9 @@ class GroupDataRepository extends BaseRepository 'innerHTML' => '试用期每个用户只能购买一次,购买过付费会员之后将不在展示,不可购买', ] ]), + Elm::select('coupon', '优惠券')->options(function () { + return app()->make(StoreCouponRepository::class)->getSearch(['mer_id' => request()->merId(), 'status' => 1, 'send_type' => 5])->column('title as label,coupon_id as value'); + })->multiple(true)->filterable(true)->appendValidate(Elm::validateArr()->message('请选择优惠券')), Elm::number('cost_price','原价')->required()->col(12)->min(0), Elm::number('price','优惠价')->required()->col(12)->min(0), Elm::number('sort','排序')->col(12)->min(0), diff --git a/app/controller/admin/marketing/Agent.php b/app/controller/admin/marketing/Agent.php index fd2d71e..343901f 100644 --- a/app/controller/admin/marketing/Agent.php +++ b/app/controller/admin/marketing/Agent.php @@ -17,7 +17,7 @@ class Agent extends BaseController{ */ public function agentList(){ [$page, $limit] = $this->getPage(); - $params = $this->request->params(['uid','agent_type','contact_name','contact_phone']); + $params = $this->request->params(['uid','agent_type','contact_name','contact_phone','is_invite_supplier']); $data = app()->make(AgentRepository::class)->getList((array)$params,(int)$page,(int)$limit); return app('json')->success($data); diff --git a/app/controller/admin/store/Coupon.php b/app/controller/admin/store/Coupon.php index 0891e10..8a3e195 100644 --- a/app/controller/admin/store/Coupon.php +++ b/app/controller/admin/store/Coupon.php @@ -235,7 +235,7 @@ class Coupon extends BaseController } else unset($data['use_start_time']); unset($data['range_date']); if ($data['is_limited'] == 0) $data['total_count'] = 0; - if (!in_array($data['type'], [10, 11, 12])) { + if (!in_array($data['type'], [10, 11, 12, 13])) { throw new ValidateException('请选择有效的优惠券类型'); } return $data; diff --git a/app/event.php b/app/event.php index a00e453..d397269 100644 --- a/app/event.php +++ b/app/event.php @@ -76,7 +76,9 @@ return [ // 会员卡开通 支付成功 'user.vipPay' => [ // 酒卡额度相关处理 - 'app\listener\exchangeQuota\OrderVipPayEvent' + 'app\listener\exchangeQuota\OrderVipPayEvent', + //开卡成功送优惠券 + 'app\listener\giveCoupon\CardOpeningEvent', ], ], diff --git a/app/listener/giveCoupon/CardOpeningEvent.php b/app/listener/giveCoupon/CardOpeningEvent.php new file mode 100644 index 0000000..c3be53b --- /dev/null +++ b/app/listener/giveCoupon/CardOpeningEvent.php @@ -0,0 +1,31 @@ +order_info, TRUE); + + // 会员卡开通成功 - 赠送优惠券 + $coupon = (array)$vipInfo['coupon'] ?? []; + if(count($coupon) > 0){ + + $StoreCouponRepository = app()->make(StoreCouponRepository::class); + foreach ($coupon as $val){ + $StoreCouponRepository->receiveSvipCounpon($val, $order['uid']); + } + } + + } catch (\Exception $e) { + Log::info('会员卡开通成功 - 错误: ' . $e->getMessage()); + } + } +} +?> \ No newline at end of file diff --git a/app/validate/merchant/StoreCouponValidate.php b/app/validate/merchant/StoreCouponValidate.php index 293c99b..a8591f3 100644 --- a/app/validate/merchant/StoreCouponValidate.php +++ b/app/validate/merchant/StoreCouponValidate.php @@ -21,7 +21,7 @@ class StoreCouponValidate extends Validate 'use_start_time|有效期限' => 'requireIf:coupon_type,1|array|>:2', 'sort|排序' => 'require|integer', 'status|状态' => 'require|in:0,1', - 'type|优惠券类型' => 'require|in:0,1,10,11,12', + 'type|优惠券类型' => 'require|in:0,1,10,11,12,13', 'product_id|商品' => 'requireIf:type,1|array|>:0', 'send_type|类型' => 'require|in:0,1,2,3,4,5', 'full_reduction|满赠金额' => 'requireIf:send_type,1|float|>=:0',