企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# 满即送 文件路径:shop/controllers/Seller/Promotion/MeetConditionGiftCtl.php 一、满送列表【方法:index();】 - 控制器:shop/controllers/Seller/Promotion/MeetConditionGiftCtl.php ->index() - 模型:shop/models/ManSong/QuotaModel.php shop/models/ManSong/BaseModel.php - 视图:shop/views/default/Seller/Promotion/MeetConditionGiftCtl/index.php 1.套餐过期时间及备注 ``` <pre class="calibre14">``` <span class="token2">if</span> <span class="token1">(</span><span class="token">!</span>$this<span class="token">-</span><span class="token">></span>self_support_flag<span class="token1">)</span> <span class="token5">//普通店铺</span> <span class="token1">{</span> $com_flag <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>combo_flag<span class="token1">;</span> <span class="token2">if</span> <span class="token1">(</span>$this<span class="token">-</span><span class="token">></span>combo_flag<span class="token1">)</span><span class="token5">//套餐可用</span> <span class="token1">{</span> $combo <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>manSongQuotaModel<span class="token">-</span><span class="token">></span><span class="token3">getManSongQuotaDetailByWhere</span><span class="token1">(</span><span class="token3">array</span><span class="token1">(</span><span class="token4">'shop_id'</span> <span class="token">=</span><span class="token">></span> Perm<span class="token1">:</span><span class="token1">:</span>$shopId<span class="token1">)</span><span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> <span class="token1">}</span> <span class="token5">//店铺下的满送活动列表</span> $data <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>manSongBaseModel<span class="token">-</span><span class="token">></span><span class="token3">getManSongActList</span><span class="token1">(</span>$cond_row<span class="token1">,</span> <span class="token3">array</span><span class="token1">(</span><span class="token4">'mansong_id'</span> <span class="token">=</span><span class="token">></span> <span class="token4">'ASC'</span><span class="token1">)</span><span class="token1">,</span> $page<span class="token1">,</span> $rows<span class="token1">)</span><span class="token1">;</span> ``` ``` 2.活动状态 模型:shop/models/ManSong/BaseModel.php 参数:mansong\_state(0.全部1.正常 2.已结束 3.管理员关闭) ``` <pre class="calibre14">``` <span class="token5">// 活动状态 1-正常/2-已结束/3-管理员关闭)</span> const NORMAL <span class="token">=</span> <span class="token6">1</span><span class="token1">;</span><span class="token5">//正常</span> const END <span class="token">=</span> <span class="token6">2</span><span class="token1">;</span><span class="token5">//结束</span> const CANCEL <span class="token">=</span> <span class="token6">3</span><span class="token1">;</span><span class="token5">//管理员关闭</span> ``` ``` 3.活动详情 参数:detail、id 方法:index(); 视图:shop/views/default/Seller/Promotion/MeetConditionGiftCtl/detail.php 根据URL获得参数detail、id来判断当前页面 ``` <pre class="calibre14">``` <span class="token2">if</span> <span class="token1">(</span><span class="token3">request_string</span><span class="token1">(</span><span class="token4">'op'</span><span class="token1">)</span> <span class="token">==</span> <span class="token4">'detail'</span><span class="token1">)</span> <span class="token1">{</span> <span class="token2">if</span> <span class="token1">(</span><span class="token3">request_int</span><span class="token1">(</span><span class="token4">'id'</span><span class="token1">)</span><span class="token1">)</span> <span class="token1">{</span> $data <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>manSongBaseModel<span class="token">-</span><span class="token">></span><span class="token3">getManSongActItem</span><span class="token1">(</span><span class="token3">array</span><span class="token1">(</span> <span class="token4">'shop_id'</span> <span class="token">=</span><span class="token">></span> Perm<span class="token1">:</span><span class="token1">:</span>$shopId<span class="token1">,</span> <span class="token4">'mansong_id'</span> <span class="token">=</span><span class="token">></span> <span class="token3">request_int</span><span class="token1">(</span><span class="token4">'id'</span><span class="token1">)</span> <span class="token1">)</span><span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> $this<span class="token">-</span><span class="token">></span>view<span class="token">-</span><span class="token">></span><span class="token3">setMet</span><span class="token1">(</span><span class="token4">'detail'</span><span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> ``` ``` 4.删除满即送 - 控制器:shop/controllers/Seller/Promotion/MeetConditionGiftCtl.php ->removeManSong() - 模型:shop/models/ManSong/BaseModel.php - 视图:shop/views/default/Seller/Promotion/MeetConditionGiftCtl/index.php 二、新增活动 1.活动开始时间:不得小于当前时间,且小于套餐结束时间 2.活动结束时间:不得小于当前时间,且小于套餐结束时间 3.满即送规则:通过AJAX获得店铺可以参加活动的商品 方法:getShopGoods(); 视图:Seller/Promotion/MeetConditionGiftCtl/getShopGoods.php ``` <pre class="calibre14">``` $<span class="token1">(</span><span class="token4">'#btn_show_search_goods'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">on</span><span class="token1">(</span><span class="token4">'click'</span><span class="token1">,</span> <span class="token2">function</span><span class="token1">(</span><span class="token1">)</span><span class="token1">{</span> $<span class="token1">(</span><span class="token4">'.search-goods-list'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">show</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span> $<span class="token1">(</span><span class="token4">'.btn_search_goods'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">click</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span><span class="token1">)</span><span class="token1">;</span> $<span class="token1">(</span><span class="token4">'.btn_search_goods'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">on</span><span class="token1">(</span><span class="token4">'click'</span><span class="token1">,</span> <span class="token2">function</span><span class="token1">(</span><span class="token1">)</span> <span class="token1">{</span> var url <span class="token">=</span> <span class="token4">"index.php?ctl=Seller_Promotion_MeetConditionGift&met=getShopGoods&typ=e"</span><span class="token1">;</span> var key <span class="token">=</span> $<span class="token1">(</span><span class="token4">"#key"</span><span class="token1">)</span><span class="token1">.</span><span class="token3">val</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span> url <span class="token">=</span> key <span class="token">?</span> url <span class="token">+</span> <span class="token4">"&goods_name="</span> <span class="token">+</span> key <span class="token1">:</span> url<span class="token1">;</span> $<span class="token1">(</span><span class="token4">'.search-goods-list-bd'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">load</span><span class="token1">(</span>url<span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span><span class="token1">)</span><span class="token1">;</span> ``` ``` 4.提交 新增活动提交时进行表单验证:`$('#form').validator({})` 方法:addManSong() 满送活动针对的是整个店铺的商品 只要订单的总金额满足满送规则限制,即可参加活动 满送活动一经编辑发布后不可修改 同一个时间段内只能有一个满送活动 ``` <pre class="calibre14">``` <span class="token2">if</span><span class="token1">(</span><span class="token3">strtotime</span><span class="token1">(</span><span class="token3">request_string</span><span class="token1">(</span><span class="token4">'mansong_start_time'</span><span class="token1">)</span><span class="token1">)</span> <span class="token"><=</span> <span class="token3">strtotime</span><span class="token1">(</span>$mansong_start_date_limit<span class="token1">)</span><span class="token1">)</span> <span class="token1">{</span> $check_post_data_flag <span class="token">=</span> <span class="token6">false</span><span class="token1">;</span> $msg_label <span class="token">=</span> <span class="token3">__</span><span class="token1">(</span><span class="token4">'满级送活动时间段不能重叠!'</span><span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> ``` ``` 三、套餐管理【方法:combo();】 1、套餐活动列表 - 控制器:shop/controllers/Seller/Promotion/MeetConditionGiftCtl.php ->combo() - 模型:shop/models/Shop/CostModel.php - 视图:shop/views/default/Seller/Promotion/MeetConditionGiftCtl/combo.php 套餐活动列表 `$data = $this->shopCostModel->listByWhere($cond_row,$order_row,$page, $rows);` 2.、购买套餐 - 视图:shop/views/default/Seller/Promotion/MeetConditionGiftCtl/combo.php - 控制器:shop/controllers/Seller/Promotion/MeetConditionGiftCtl.php ->addCombo() - 模型:shop/models/ManSong/QuotaModel.php shop/models/Shop/BaseModel.php shop/models/ManSong/BaseModel.php (1)购买套餐时提交时进行表单验证:`$('#form').validator({})` (2)在店铺的账期结算中扣除相关费用并且在paycenter中添加交易记录 参数:店铺id,根据店铺id号获取店铺套餐详情 1、原套餐已经过期,更新套餐开始时间和结束时间 2、原套餐尚未过期,只需更新结束时间 3、如果没有套餐详情,则套餐购买