💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# 代金券管理 文件路径:shop/controllers/Seller/Promotion/VoucherCtl.php 一、代金券管理列表【方法:index();】 - 控制器:shop/controllers/Seller/Promotion/VoucherCtl.php ->index() - 模型:shop/models/Voucher/TempModel.php shop/models/Voucher/quotaModel.php shop/models/Shop/BaseModel.php - 视图:shop/views/default/Seller/Promotion/VoucherCtl/index.php 1.活动状态 模型:shop/models/Voucher/TempModel.php 参数:voucher\_t\_state(1.有效 2.失效) ``` <pre class="calibre14">``` <span class="token5">// 活动状态 (1.有效 2.失效)</span> const VALID <span class="token">=</span> <span class="token6">1</span><span class="token1">;</span><span class="token5">//有效</span> const INVALID <span class="token">=</span> <span class="token6">2</span><span class="token1">;</span><span class="token5">//失效</span> ``` ``` 2.领取方式 模型:shop/models/Voucher/TempModel.php 参数:voucher\_t\_access\_method(1.积分兑换 2.卡密 3.免费领取) ``` <pre class="calibre14">``` <span class="token5">// 领取方式 (1.积分兑换 2.卡密 3.免费领取)</span> const GETBYPOINTS <span class="token">=</span> <span class="token6">1</span><span class="token1">;</span><span class="token5">//积分兑换</span> const GETFBYPWD <span class="token">=</span> <span class="token6">2</span><span class="token1">;</span><span class="token5">//卡密</span> const GETFREE <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/VoucherCtl/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> $cond_row<span class="token1">[</span><span class="token4">'voucher_t_id'</span><span class="token1">]</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> $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="token5">//视图</span> $data <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>voucherTempModel<span class="token">-</span><span class="token">></span><span class="token3">getVoucherTempInfoByWhere</span><span class="token1">(</span>$cond_row<span class="token1">)</span><span class="token1">;</span> <span class="token2">if</span> <span class="token1">(</span>$data<span class="token1">[</span><span class="token4">'shop_class_id'</span><span class="token1">]</span><span class="token1">)</span> <span class="token1">{</span> $Shop_ClassModel <span class="token">=</span> <span class="token2">new</span> <span class="token3">Shop_ClassModel</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span> $shop_class_row <span class="token">=</span> $Shop_ClassModel<span class="token">-</span><span class="token">></span><span class="token3">getOne</span><span class="token1">(</span>$data<span class="token1">[</span><span class="token4">'shop_class_id'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">;</span> $data<span class="token1">[</span><span class="token4">'shop_class_name'</span><span class="token1">]</span> <span class="token">=</span> $shop_class_row<span class="token1">[</span><span class="token4">'shop_class_name'</span><span class="token1">]</span><span class="token1">;</span> <span class="token1">}</span> <span class="token2">else</span> <span class="token1">{</span> $data<span class="token1">[</span><span class="token4">'shop_class_name'</span><span class="token1">]</span> <span class="token">=</span> <span class="token4">''</span><span class="token1">;</span> <span class="token1">}</span> <span class="token2">if</span> <span class="token1">(</span>$data<span class="token1">[</span><span class="token4">'voucher_t_user_grade_limit'</span><span class="token1">]</span><span class="token1">)</span> <span class="token1">{</span> $User_GradeModel <span class="token">=</span> <span class="token2">new</span> <span class="token3">User_GradeModel</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span> $grade_row <span class="token">=</span> $User_GradeModel<span class="token">-</span><span class="token">></span><span class="token3">getOne</span><span class="token1">(</span>$data<span class="token1">[</span><span class="token4">'voucher_t_user_grade_limit'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">;</span> $data<span class="token1">[</span><span class="token4">'voucher_t_user_grade_limit_label'</span><span class="token1">]</span> <span class="token">=</span> $grade_row<span class="token1">[</span><span class="token4">'user_grade_name'</span><span class="token1">]</span><span class="token1">;</span> <span class="token1">}</span> <span class="token1">}</span> ``` ``` 4.删除代金券 - 控制器:shop/controllers/Seller/Promotion/VoucherCtl.php ->removeVoucherTemp() - 模型:shop/models/Voucher/TempModel.php - 视图:shop/views/default/Seller/Promotion/VoucherCtl/index.php 二、添加代金券 - 控制器:shop/controllers/Seller/Promotion/VoucherCtl.php ->add() - 模型:shop/models/Voucher/TempModel.php shop/models/Voucher/quotaModel.php shop/models/Shop/BaseModel.php - 视图:shop/views/default/Seller/Promotion/VoucherCtl/add.php 1.活动有效期:不能大于2030-06-11 00:00:00 2.提交 新增活动提交时进行表单验证:`$('#form').validator({})` 方法:addVoucherTemp()