多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
# 加价购 文件路径:shop/controllers/Seller/Promotion/IncreaseCtl.php 一、活动列表【方法:index();】 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_row <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>increaseComboModel<span class="token">-</span><span class="token">></span><span class="token3">getComboInfo</span><span class="token1">(</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="token5">//店铺下的加价购活动列表</span> $data <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>increaseBaseModel<span class="token">-</span><span class="token">></span><span class="token3">getIncreaseActList</span><span class="token1">(</span>$cond_row<span class="token1">,</span> <span class="token3">array</span><span class="token1">(</span><span class="token4">'increase_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/Increase/BaseModel.php 参数:increase\_state(0.全部1.正常 2.已结束 3.管理员关闭) ``` <pre class="calibre14">``` 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.操作 3.1编辑 参数:id、edit 根据URL获取id、edit判断活动列表和活动内容编辑 视图:views/default/Seller/Promotion/IncreaseCtl/edit.php 编辑活动内容后提交表单验证:$('#form').validator({}) 方法:editIncrease(); ``` <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">'edit'</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="token5">//编辑活动内容</span> $increase_id <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> $check_row <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>increaseBaseModel<span class="token">-</span><span class="token">></span><span class="token3">getIncreaseActItem</span><span class="token1">(</span>$increase_id<span class="token1">)</span><span class="token1">;</span> <span class="token2">if</span> <span class="token1">(</span>$check_row<span class="token1">[</span><span class="token4">'shop_id'</span><span class="token1">]</span> <span class="token">==</span> Perm<span class="token1">:</span><span class="token1">:</span>$shopId<span class="token1">)</span> <span class="token1">{</span> $data <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>increaseBaseModel<span class="token">-</span><span class="token">></span><span class="token3">getIncreaseActDetail</span><span class="token1">(</span>$increase_id<span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> <span class="token2">else</span> <span class="token1">{</span> <span class="token3">location_to</span><span class="token1">(</span><span class="token4">'index.php?ctl=Seller_Promotion_Increase&met=index&typ=e'</span><span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> <span class="token5">//视图:views/default/Seller/Promotion/IncreaseCtl/edit.php</span> <span class="token5">//编辑活动内容后提交表单验证:$('#form').validator({})</span> <span class="token5">//方法:editIncrease();</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">'edit'</span><span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> ``` ``` 3.1.1添加活动商品 通过AJAX获得店铺所有商品 ``` <pre class="calibre14">``` $<span class="token1">(</span><span class="token4">'.btn-ctl-select-goods'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">click</span><span class="token1">(</span><span class="token2">function</span><span class="token1">(</span><span class="token1">)</span><span class="token1">{</span> var increase_id <span class="token">=</span> $<span class="token1">(</span>this<span class="token1">)</span><span class="token1">.</span><span class="token3">attr</span><span class="token1">(</span><span class="token4">'data-increase-id'</span><span class="token1">)</span><span class="token1">;</span> var url <span class="token">=</span> SITE_URL <span class="token">+</span> <span class="token4">'?ctl=Seller_Promotion_Increase&met=getShopGoods&typ=e&op=edit'</span><span class="token1">;</span> $<span class="token1">(</span><span class="token4">'#cou-sku-options'</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>id<span class="token1">:</span>increase_id<span class="token1">}</span><span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span><span class="token1">)</span><span class="token1">;</span> ``` ``` 3.1.2添加活动规则 选择换购商品: ``` <pre class="calibre14">``` $<span class="token1">(</span><span class="token4">'body'</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="token4">'[btn-choose-rule-ex-goods]'</span><span class="token1">,</span> <span class="token2">function</span><span class="token1">(</span><span class="token1">)</span> <span class="token1">{</span> var id <span class="token">=</span> $<span class="token1">(</span>this<span class="token1">)</span><span class="token1">.</span><span class="token3">attr</span><span class="token1">(</span><span class="token4">'btn-choose-rule-ex-goods'</span><span class="token1">)</span><span class="token1">;</span> $<span class="token1">(</span><span class="token4">"[btn-choose-rule-ex-goods='"</span><span class="token">+</span>id<span class="token">+</span><span class="token4">"']"</span><span class="token1">)</span><span class="token1">.</span><span class="token3">hide</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span> $<span class="token1">(</span><span class="token4">"[data-cou-level-sku-close-button='"</span><span class="token">+</span>id<span class="token">+</span><span class="token4">"']"</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="token3">getShopGoodsSku</span><span class="token1">(</span>id<span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span><span class="token1">)</span><span class="token1">;</span> ``` ``` URL异步请求获取店铺可以参加换购的商品:方法:getShopGoodsSku(); 视图:shop/views/default/Seller/Promotion/IncreaseCtl/getShopGoodsSku.php 4.删除加价购 - 控制器:shop/controllers/Seller/Promotion/IncreaseCtl.php ->removeIncreaseAct() - 模型:shop/models/Increase/BaseModel.php - 视图:shop/views/default/Seller/Promotion/IncreaseCtl/index.php 二、添加活动 1.活动开始时间:不得小于当前时间,且小于套餐结束时间 2.活动结束时间:不得小于当前时间,且小于套餐结束时间 3.提交 新增活动提交时进行表单验证:`$('#form').validator({})` - 控制器:shop/controllers/Seller/Promotion/IncreaseCtl.php ->addIncrease() - 模型:shop/models/Increase/BaseModel.php - 视图:shop/views/default/Seller/Promotion/IncreaseCtl/add.php 三、套餐管理【方法:combo();】 1、套餐活动列表 - 控制器:shop/controllers/Seller/Promotion/IncreaseCtl.php ->combo() - 模型:shop/models/Shop/CostModel.php - 视图:shop/views/default/Seller/Promotion/IncreaseCtl/combo.php 套餐活动列表 `$data = $this->shopCostModel->listByWhere($cond_row,$order_row,$page, $rows);` 2.、购买套餐 - 视图:shop/views/default/Seller/Promotion/IncreaseCtl/combo.php - 控制器:shop/controllers/Seller/Promotion/IncreaseCtl.php ->addCombo() - 模型:shop/models/Increase/ComboModel.php (1)购买套餐时提交时进行表单验证:`$('#form').validator({})` (2)在店铺的账期结算中扣除相关费用并且在paycenter中添加交易记录 参数:店铺id,根据店铺id号获取店铺套餐详情 1、原套餐已经过期,更新套餐开始时间和结束时间 2、原套餐尚未过期,只需更新结束时间 3、如果没有套餐详情,则套餐购买