💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# 消费者保障服务 文件路径:shop/controllers/Seller/Shop/ContractCtl.php 流程:加入->平台审核->审核通过 一、消费者保障服务 - 七天退货 - 品质承诺 - 破损寄补 - 极速物流 - 服务状态(开启、关闭) 参数:contract\_type\_state 模型:shop/models/shop/ContractTypeModel.php ``` <pre class="calibre14">``` public static $state <span class="token">=</span> <span class="token3">array</span><span class="token1">(</span> <span class="token4">'1'</span> <span class="token">=</span><span class="token">></span> <span class="token4">'open'</span><span class="token1">,</span> <span class="token4">'2'</span> <span class="token">=</span><span class="token">></span> <span class="token4">'close'</span><span class="token1">,</span> <span class="token1">)</span><span class="token1">;</span> ``` ``` - 保障服务申请状态(未加入、已加入、加入审核中、退出审核) 模型:shop/models/shop/class Shop\_ContractModel extends Shop\_Contract.php ``` <pre class="calibre14">``` const CONTRACT_INUSE <span class="token">=</span> <span class="token6">1</span><span class="token1">;</span> const CONTRACT_UNUSE <span class="token">=</span> <span class="token6">2</span><span class="token1">;</span> const CONTRACT_JOIN <span class="token">=</span> <span class="token6">1</span><span class="token1">;</span> const CONTRACT_QUIT <span class="token">=</span> <span class="token6">2</span><span class="token1">;</span> public static $state <span class="token">=</span> <span class="token3">array</span><span class="token1">(</span> <span class="token4">'1'</span> <span class="token">=</span><span class="token">></span> <span class="token4">'inuse'</span><span class="token1">,</span> <span class="token4">'2'</span> <span class="token">=</span><span class="token">></span> <span class="token4">'unuse'</span><span class="token1">,</span> <span class="token1">)</span><span class="token1">;</span> public <span class="token2">function</span> <span class="token3">getContractList</span><span class="token1">(</span>$cond_row <span class="token">=</span> <span class="token3">array</span><span class="token1">(</span><span class="token1">)</span><span class="token1">,</span> $order_row <span class="token">=</span> <span class="token3">array</span><span class="token1">(</span><span class="token1">)</span><span class="token1">,</span> $page <span class="token">=</span> <span class="token6">1</span><span class="token1">,</span> $rows <span class="token">=</span> <span class="token6">100</span><span class="token1">)</span> <span class="token1">{</span> $data <span class="token">=</span> $this<span class="token">-</span><span class="token">></span><span class="token3">listByWhere</span><span class="token1">(</span>$cond_row<span class="token1">,</span> $order_row<span class="token1">,</span> $page<span class="token1">,</span> $rows<span class="token1">)</span><span class="token1">;</span> $Shop_ContractLogModel <span class="token">=</span> <span class="token2">new</span> <span class="token3">Shop_ContractLogModel</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span> foreach <span class="token1">(</span>$data<span class="token1">[</span><span class="token4">'items'</span><span class="token1">]</span> as $key <span class="token">=</span><span class="token">></span> $val<span class="token1">)</span> <span class="token1">{</span> $log <span class="token">=</span> $Shop_ContractLogModel<span class="token">-</span><span class="token">></span><span class="token3">getOneLog</span><span class="token1">(</span>$val<span class="token1">[</span><span class="token4">'contract_log_id'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">;</span> $data<span class="token1">[</span><span class="token4">'items'</span><span class="token1">]</span><span class="token1">[</span>$key<span class="token1">]</span><span class="token1">[</span><span class="token4">'log_state'</span><span class="token1">]</span> <span class="token">=</span> $log<span class="token1">[</span><span class="token4">'contract_log_state_etext'</span><span class="token1">]</span><span class="token1">;</span> <span class="token2">if</span> <span class="token1">(</span>$val<span class="token1">[</span><span class="token4">'contract_state'</span><span class="token1">]</span> <span class="token">==</span> self<span class="token1">:</span><span class="token1">:</span>CONTRACT_INUSE<span class="token1">)</span> <span class="token1">{</span> <span class="token2">if</span> <span class="token1">(</span>$val<span class="token1">[</span><span class="token4">'contract_use_state'</span><span class="token1">]</span> <span class="token">==</span> self<span class="token1">:</span><span class="token1">:</span>CONTRACT_JOIN<span class="token1">)</span> <span class="token1">{</span> <span class="token2">if</span> <span class="token1">(</span>$log<span class="token1">[</span><span class="token4">'contract_log_state'</span><span class="token1">]</span> <span class="token">==</span> Shop_ContractLogModel<span class="token1">:</span><span class="token1">:</span>LOG_STATE_PASS<span class="token1">)</span> <span class="token1">{</span> $data<span class="token1">[</span><span class="token4">'items'</span><span class="token1">]</span><span class="token1">[</span>$key<span class="token1">]</span><span class="token1">[</span><span class="token4">'contract_state_text'</span><span class="token1">]</span> <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> <span class="token2">else</span> <span class="token1">{</span> $data<span class="token1">[</span><span class="token4">'items'</span><span class="token1">]</span><span class="token1">[</span>$key<span class="token1">]</span><span class="token1">[</span><span class="token4">'contract_state_text'</span><span class="token1">]</span> <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> <span class="token1">}</span> elseif <span class="token1">(</span>$val<span class="token1">[</span><span class="token4">'contract_use_state'</span><span class="token1">]</span> <span class="token">==</span> self<span class="token1">:</span><span class="token1">:</span>CONTRACT_QUIT<span class="token1">)</span> <span class="token1">{</span> <span class="token2">if</span> <span class="token1">(</span>$log<span class="token1">[</span><span class="token4">'contract_log_state'</span><span class="token1">]</span> <span class="token">==</span> Shop_ContractLogModel<span class="token1">:</span><span class="token1">:</span>LOG_STATE_PASS<span class="token1">)</span> <span class="token1">{</span> $data<span class="token1">[</span><span class="token4">'items'</span><span class="token1">]</span><span class="token1">[</span>$key<span class="token1">]</span><span class="token1">[</span><span class="token4">'contract_state_text'</span><span class="token1">]</span> <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> <span class="token2">else</span> <span class="token1">{</span> $data<span class="token1">[</span><span class="token4">'items'</span><span class="token1">]</span><span class="token1">[</span>$key<span class="token1">]</span><span class="token1">[</span><span class="token4">'contract_state_text'</span><span class="token1">]</span> <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> <span class="token1">}</span> <span class="token1">}</span> elseif <span class="token1">(</span>$val<span class="token1">[</span><span class="token4">'contract_state'</span><span class="token1">]</span> <span class="token">==</span> self<span class="token1">:</span><span class="token1">:</span>CONTRACT_UNUSE<span class="token1">)</span> <span class="token1">{</span> $data<span class="token1">[</span><span class="token4">'items'</span><span class="token1">]</span><span class="token1">[</span>$key<span class="token1">]</span><span class="token1">[</span><span class="token4">'contract_state_text'</span><span class="token1">]</span> <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> <span class="token1">}</span> <span class="token2">return</span> $data<span class="token1">;</span> <span class="token1">}</span> ``` ``` 视图:根据URL获得参数act的值,判断视图 ``` <pre class="calibre14">``` <span class="token2">if</span> <span class="token1">(</span>$act <span class="token">==</span> <span class="token4">"detail"</span><span class="token1">)</span> <span class="token1">{</span> $data <span class="token">=</span> $this<span class="token">-</span><span class="token">></span><span class="token3">detail</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> include $this<span class="token">-</span><span class="token">></span>view<span class="token">-</span><span class="token">></span><span class="token3">getView</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span> ``` ``` 1.加入活动 - 控制器:shop/controllers/Seller/Shop/ContractCtl.php - 视图:shop/views/default/Seller/Shop/ContractCtl/index.php 加入表单验证:`$("[nc_type='applybtn']").click(function (){})` 方法:joinContract() ``` <pre class="calibre14">``` $contract <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>shopContractModel<span class="token">-</span><span class="token">></span><span class="token3">getOneByWhere</span><span class="token1">(</span>$cond_row<span class="token1">)</span><span class="token1">;</span> <span class="token2">if</span> <span class="token1">(</span><span class="token3">empty</span><span class="token1">(</span>$contract<span class="token1">)</span><span class="token1">)</span> <span class="token1">{</span> $field_row<span class="token1">[</span><span class="token4">'contract_type_id'</span><span class="token1">]</span> <span class="token">=</span> $contract_type_id<span class="token1">;</span> $field_row<span class="token1">[</span><span class="token4">'contract_type_name'</span><span class="token1">]</span> <span class="token">=</span> $data<span class="token1">[</span><span class="token4">'contract_type_name'</span><span class="token1">]</span><span class="token1">;</span> $field_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> $field_row<span class="token1">[</span><span class="token4">'shop_name'</span><span class="token1">]</span> <span class="token">=</span> $shop<span class="token1">[</span><span class="token4">'shop_name'</span><span class="token1">]</span><span class="token1">;</span> $field_row<span class="token1">[</span><span class="token4">'contract_use_state'</span><span class="token1">]</span> <span class="token">=</span> Shop_ContractModel<span class="token1">:</span><span class="token1">:</span>CONTRACT_JOIN<span class="token1">;</span> $contract_id <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>shopContractModel<span class="token">-</span><span class="token">></span><span class="token3">addContract</span><span class="token1">(</span>$field_row<span class="token1">,</span> <span class="token6">true</span><span class="token1">)</span><span class="token1">;</span> <span class="token3">check_rs</span><span class="token1">(</span>$contract_id<span class="token1">,</span> $rs_row<span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> <span class="token2">else</span> <span class="token1">{</span> $contract_id <span class="token">=</span> $contract<span class="token1">[</span><span class="token4">'contract_id'</span><span class="token1">]</span><span class="token1">;</span> $field_row<span class="token1">[</span><span class="token4">'contract_use_state'</span><span class="token1">]</span> <span class="token">=</span> Shop_ContractModel<span class="token1">:</span><span class="token1">:</span>CONTRACT_JOIN<span class="token1">;</span> $flag <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>shopContractModel<span class="token">-</span><span class="token">></span><span class="token3">editContract</span><span class="token1">(</span>$contract_id<span class="token1">,</span> $field_row<span class="token1">)</span><span class="token1">;</span> <span class="token3">check_rs</span><span class="token1">(</span>$flag<span class="token1">,</span> $rs_row<span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> ``` ``` - 平台审核加入: 控制器:shop/controllers/Api/Operation/ContractCtl.php 视图:shop\_admin/views/default/Operation/ContractCtl/log.php JS:shop\_admin/static/default/js/controllers/operation/contract\_list.js 2.退出活动 - 控制器:shop/controllers/Seller/Shop/ContractCtl.php - 视图:shop/views/default/Seller/Shop/ContractCtl/index.php 表单验证:`$("[nc_type='quitbtn']").click(function (){})` 方法:quitContract() `$flag = $this->shopContractModel->editContract($contract_id, $clog_row);` - 平台审核退出: 控制器:shop/controllers/Api/Operation/ContractCtl.php 视图:shop\_admin/views/default/Operation/ContractCtl/log.php JS:shop\_admin/static/default/js/controllers/operation/contract\_list.js 3.查看服务详情 视图:shop/views/default/Seller/Shop/ContractCtl/detail.php 服务详情: ``` <pre class="calibre15">``` $data<span class="token1">[</span><span class="token4">'contract_type'</span><span class="token1">]</span> <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>shopContractTypeModel<span class="token">-</span><span class="token">></span><span class="token3">getOne</span><span class="token1">(</span>$cond_row<span class="token1">[</span><span class="token4">'contract_type_id'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">;</span> $contract <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>shopContractModel<span class="token">-</span><span class="token">></span><span class="token3">getOneByWhere</span><span class="token1">(</span>$cond_row<span class="token1">)</span><span class="token1">;</span> $data<span class="token1">[</span><span class="token4">'contract'</span><span class="token1">]</span> <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>shopContractModel<span class="token">-</span><span class="token">></span><span class="token3">getOneContract</span><span class="token1">(</span>$contract<span class="token1">[</span><span class="token4">'contract_id'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">;</span> $data<span class="token1">[</span><span class="token4">'log'</span><span class="token1">]</span> <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>shopContractLogModel<span class="token">-</span><span class="token">></span><span class="token3">getContractLogList</span><span class="token1">(</span>$cond_row<span class="token1">,</span> <span class="token3">array</span><span class="token1">(</span><span class="token4">'contract_log_date'</span> <span class="token">=</span><span class="token">></span> <span class="token4">'DESC'</span><span class="token1">)</span><span class="token1">,</span> $page<span class="token1">,</span> $rows<span class="token1">)</span><span class="token1">;</span> ``` ```