# 订单物流
### 订单物流
#### 1、已售订单管理
文件路径:shop/controllers/Seller/Trade/OrderCtl.php
###### 1.1、所有订单(physical())
```
<pre class="calibre14">```
$condition<span class="token1">[</span><span class="token4">'chain_id'</span><span class="token1">]</span> <span class="token">=</span> <span class="token6">0</span><span class="token1">;</span>
```
```
###### 1.2、待付款(getPhysicalNew())
```
<pre class="calibre14">```
$condi<span class="token1">[</span><span class="token4">'order_status'</span><span class="token1">]</span> <span class="token">=</span> Order_StateModel<span class="token1">:</span><span class="token1">:</span>ORDER_WAIT_PAY<span class="token1">;</span>
$condi<span class="token1">[</span><span class="token4">'chain_id'</span><span class="token1">]</span> <span class="token">=</span> <span class="token6">0</span><span class="token1">;</span>
```
```
###### 1.3、已付款(getPhysicalPay())
```
<pre class="calibre14">```
$condi<span class="token1">[</span><span class="token4">'order_status'</span><span class="token1">]</span> <span class="token">=</span> Order_StateModel<span class="token1">:</span><span class="token1">:</span>ORDER_PAYED<span class="token1">;</span>
$condi<span class="token1">[</span><span class="token4">'chain_id'</span><span class="token1">]</span> <span class="token">=</span> <span class="token6">0</span><span class="token1">;</span>
```
```
###### 1.4、已发货(getPhysicalSend())
```
<pre class="calibre14">```
$condi<span class="token1">[</span><span class="token4">'order_status'</span><span class="token1">]</span> <span class="token">=</span> Order_StateModel<span class="token1">:</span><span class="token1">:</span>ORDER_WAIT_CONFIRM_GOODS<span class="token1">;</span>
$condi<span class="token1">[</span><span class="token4">'chain_id'</span><span class="token1">]</span> <span class="token">=</span> <span class="token6">0</span><span class="token1">;</span>
```
```
###### 1.5、已完成(getPhysicalSuccess())
```
<pre class="calibre14">```
$condi<span class="token1">[</span><span class="token4">'order_status'</span><span class="token1">]</span> <span class="token">=</span> Order_StateModel<span class="token1">:</span><span class="token1">:</span>ORDER_FINISH<span class="token1">;</span>
$condi<span class="token1">[</span><span class="token4">'chain_id'</span><span class="token1">]</span> <span class="token">=</span> <span class="token6">0</span><span class="token1">;</span>
```
```
###### 1.6、已取消(getPhysicalCancel())
```
<pre class="calibre14">```
$condi<span class="token1">[</span><span class="token4">'order_status'</span><span class="token1">]</span> <span class="token">=</span> Order_StateModel<span class="token1">:</span><span class="token1">:</span>ORDER_CANCEL<span class="token1">;</span>
$condi<span class="token1">[</span><span class="token4">'chain_id'</span><span class="token1">]</span> <span class="token">=</span> <span class="token6">0</span><span class="token1">;</span>
```
```
###### 1.7、回收站(getPhysicalHideOrder())
```
<pre class="calibre14">```
$condi<span class="token1">[</span><span class="token4">'order_status'</span><span class="token1">]</span> <span class="token">=</span> Order_StateModel<span class="token1">:</span><span class="token1">:</span>ORDER_CANCEL<span class="token1">;</span>
$condi<span class="token1">[</span><span class="token4">'chain_id'</span><span class="token1">]</span> <span class="token">=</span> <span class="token6">0</span><span class="token1">;</span>
```
```
###### 1.8、搜索订单:
```
<pre class="calibre14">```
<span class="token2">function</span> <span class="token3">formSub</span><span class="token1">(</span><span class="token1">)</span><span class="token1">{</span>
$<span class="token1">(</span><span class="token4">'.search-form'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">parents</span><span class="token1">(</span><span class="token4">'form'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">submit</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
```
```
###### 1.9、取消订单
```
<pre class="calibre14">```
$<span class="token1">(</span><span class="token4">'a[dialog_id="seller_order_cancel_order"]'</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 order_id <span class="token">=</span> $<span class="token1">(</span>this<span class="token1">)</span><span class="token1">.</span><span class="token3">data</span><span class="token1">(</span><span class="token4">'order_id'</span><span class="token1">)</span><span class="token1">,</span>url <span class="token">=</span> SITE_URL <span class="token">+</span> <span class="token4">'?ctl=Seller_Trade_Order&met=orderCancel&typ='</span><span class="token1">;</span>
$<span class="token1">.</span><span class="token3">dialog</span><span class="token1">(</span><span class="token1">{</span>
title<span class="token1">:</span> <span class="token4">'<?=__('</span>取消订单<span class="token4">')?>'</span><span class="token1">,</span>
content<span class="token1">:</span> <span class="token4">'url: '</span> <span class="token">+</span> url <span class="token">+</span> <span class="token4">'e'</span><span class="token1">,</span>
data<span class="token1">:</span> <span class="token1">{</span> order_id<span class="token1">:</span> order_id <span class="token1">}</span><span class="token1">,</span>
height<span class="token1">:</span> <span class="token6">250</span><span class="token1">,</span>
width<span class="token1">:</span> <span class="token6">400</span><span class="token1">,</span>
lock<span class="token1">:</span> <span class="token6">true</span><span class="token1">,</span>
drag<span class="token1">:</span> <span class="token6">false</span><span class="token1">,</span>
ok<span class="token1">:</span> <span class="token2">function</span> <span class="token1">(</span><span class="token1">)</span> <span class="token1">{</span>
var form_ser <span class="token">=</span> $<span class="token1">(</span>this<span class="token1">.</span>content<span class="token1">.</span>order_cancel_form<span class="token1">)</span><span class="token1">.</span><span class="token3">serialize</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
$<span class="token1">.</span><span class="token3">post</span><span class="token1">(</span>url <span class="token">+</span> <span class="token4">'json'</span><span class="token1">,</span> form_ser<span class="token1">,</span> <span class="token2">function</span> <span class="token1">(</span>data<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="token1">}</span><span class="token1">)</span><span class="token1">;</span>
<span class="token5">//获取订单详情,判断订单的当前状态与下单这是否为当前用户</span>
$order_base <span class="token">=</span> $Order_BaseModel<span class="token">-</span><span class="token">></span><span class="token3">getOne</span><span class="token1">(</span>$order_id<span class="token1">)</span><span class="token1">;</span>
<span class="token2">if</span><span class="token1">(</span> <span class="token1">(</span>$order_base<span class="token1">[</span><span class="token4">'payment_id'</span><span class="token1">]</span> <span class="token">==</span> PaymentChannlModel<span class="token1">:</span><span class="token1">:</span>PAY_CONFIRM<span class="token">&&</span> $order_base<span class="token1">[</span><span class="token4">'order_status'</span><span class="token1">]</span> <span class="token">==</span>Order_StateModel<span class="token1">:</span><span class="token1">:</span>ORDER_WAIT_PREPARE_GOODS<span class="token1">)</span> <span class="token5">//货到付款+等待发货</span>
$order_base<span class="token1">[</span><span class="token4">'order_status'</span><span class="token1">]</span> <span class="token">==</span> Order_StateModel<span class="token1">:</span><span class="token1">:</span>ORDER_WAIT_PAY<span class="token">&&</span> $order_base<span class="token1">[</span><span class="token4">'seller_user_id'</span><span class="token1">]</span> <span class="token">==</span> Perm<span class="token1">:</span><span class="token1">:</span>$userId<span class="token1">)</span> <span class="token1">{</span>
<span class="token5">//加入取消时间</span>
$edit_flag <span class="token">=</span> $Order_BaseModel<span class="token">-</span><span class="token">></span><span class="token3">editBase</span><span class="token1">(</span>$order_id<span class="token1">,</span> $condition<span class="token1">)</span><span class="token1">;</span>
<span class="token5">//修改订单商品表中的订单状态</span>
$edit_flag1 <span class="token">=</span> $Order_GoodsModel<span class="token">-</span><span class="token">></span><span class="token3">editGoods</span><span class="token1">(</span>$order_goods_id<span class="token1">,</span> $edit_row<span class="token1">)</span><span class="token1">;</span>
<span class="token5">//退还订单商品的库存</span>
<span class="token2">if</span><span class="token1">(</span>$order_base<span class="token1">[</span><span class="token4">'chain_id'</span><span class="token1">]</span><span class="token">!=</span><span class="token6">0</span><span class="token1">)</span><span class="token1">{</span>
$edit_flag2 <span class="token">=</span> $Chain_GoodsModel<span class="token">-</span><span class="token">></span><span class="token3">editGoods</span><span class="token1">(</span>$chain_goods_id<span class="token1">,</span> $goods_stock<span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span><span class="token2">else</span><span class="token1">{</span>
$edit_flag2 <span class="token">=</span> $Goods_BaseModel<span class="token">-</span><span class="token">></span><span class="token3">returnGoodsStock</span><span class="token1">(</span>$order_goods_id<span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
<span class="token5">//将需要取消的订单号远程发送给Paycenter修改订单状态</span>
<span class="token5">//远程修改paycenter中的订单状态</span>
$rs <span class="token">=</span> <span class="token3">get_url_with_encrypt</span><span class="token1">(</span>$key<span class="token1">,</span> <span class="token3">sprintf</span><span class="token1">(</span><span class="token4">'%s?ctl=Api_Pay_Pay&met=cancelOrder&typ=json'</span><span class="token1">,</span> $url<span class="token1">)</span><span class="token1">,</span> $formvars<span class="token1">)</span><span class="token1">;</span>
<span class="token5">//如果是供货商取消进货订单,同时取消买家的订单或减少买家订单的金额</span>
$dist_goods_order <span class="token">=</span> $Order_GoodsModel <span class="token">-</span><span class="token">></span> <span class="token3">getByWhere</span><span class="token1">(</span><span class="token3">array</span><span class="token1">(</span><span class="token4">'order_id'</span> <span class="token">=</span><span class="token">></span> $dist_order<span class="token1">[</span><span class="token4">'order_id'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">)</span><span class="token1">;</span>
<span class="token2">if</span><span class="token1">(</span><span class="token3">count</span><span class="token1">(</span>$dist_goods_order<span class="token1">)</span> <span class="token">==</span> <span class="token6">1</span><span class="token1">)</span><span class="token1">{</span>
$Order_BaseModel<span class="token">-</span><span class="token">></span> <span class="token3">editBase</span><span class="token1">(</span>$dist_order<span class="token1">[</span><span class="token4">'order_id'</span><span class="token1">]</span><span class="token1">,</span> $condition<span class="token1">)</span><span class="token1">;</span>
$Order_GoodsModel<span class="token">-</span><span class="token">></span> <span class="token3">editGoods</span><span class="token1">(</span>$dist_goods_order<span class="token1">[</span><span class="token6">0</span><span class="token1">]</span><span class="token1">[</span><span class="token4">'order_goods_id'</span><span class="token1">]</span><span class="token1">,</span> $edit_row<span class="token1">)</span><span class="token1">;</span>
$Goods_BaseModel <span class="token">-</span><span class="token">></span> <span class="token3">returnGoodsStock</span><span class="token1">(</span>$dist_goods_order<span class="token1">[</span><span class="token6">0</span><span class="token1">]</span><span class="token1">[</span><span class="token4">'order_goods_id'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span><span class="token2">else</span><span class="token1">{</span>
$Order_BaseModel<span class="token">-</span><span class="token">></span> <span class="token3">editBase</span><span class="token1">(</span>$dist_order<span class="token1">[</span><span class="token4">'order_id'</span><span class="token1">]</span><span class="token1">,</span> $dist_edit_row<span class="token1">)</span><span class="token1">;</span>
$Order_GoodsModel<span class="token">-</span><span class="token">></span> <span class="token3">editGoods</span><span class="token1">(</span>$dist_goods_order<span class="token1">[</span>$key<span class="token1">]</span><span class="token1">[</span><span class="token4">'order_goods_id'</span><span class="token1">]</span><span class="token1">,</span> $edit_row<span class="token1">)</span><span class="token1">;</span>
$Goods_BaseModel <span class="token">-</span><span class="token">></span> <span class="token3">returnGoodsStock</span><span class="token1">(</span>$dist_goods_order<span class="token1">[</span>$key<span class="token1">]</span><span class="token1">[</span><span class="token4">'order_goods_id'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
$formvars<span class="token1">[</span><span class="token4">'order_id'</span><span class="token1">]</span> <span class="token">=</span> $dist_order<span class="token1">[</span><span class="token4">'order_id'</span><span class="token1">]</span><span class="token1">;</span>
$rs <span class="token">=</span> <span class="token3">get_url_with_encrypt</span><span class="token1">(</span>$key<span class="token1">,</span> <span class="token3">sprintf</span><span class="token1">(</span><span class="token4">'%s?ctl=Api_Pay_Pay&met=cancelOrder&typ=json'</span><span class="token1">,</span> $url<span class="token1">)</span><span class="token1">,</span> $formvars<span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
```
```
###### 1.10、删除订单
```
<pre class="calibre14">```
window<span class="token1">.</span>hideOrder <span class="token">=</span> <span class="token2">function</span> <span class="token1">(</span>e<span class="token1">)</span>
<span class="token1">{</span>
$<span class="token1">.</span><span class="token3">dialog</span><span class="token1">(</span><span class="token1">{</span>
title<span class="token1">:</span> <span class="token4">'删除订单'</span><span class="token1">,</span>
content<span class="token1">:</span> <span class="token4">'您确定要删除吗?删除后的订单可在回收站找回,或彻底删除! '</span><span class="token1">,</span>
height<span class="token1">:</span> <span class="token6">100</span><span class="token1">,</span>
width<span class="token1">:</span> <span class="token6">405</span><span class="token1">,</span>
lock<span class="token1">:</span> <span class="token6">true</span><span class="token1">,</span>
drag<span class="token1">:</span> <span class="token6">false</span><span class="token1">,</span>
ok<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="token3">post</span><span class="token1">(</span>SITE_URL <span class="token">+</span> <span class="token4">'?ctl=Buyer_Order&met=hideOrder&typ=json'</span><span class="token1">,</span><span class="token1">{</span>order_id<span class="token1">:</span>e<span class="token1">,</span>user<span class="token1">:</span><span class="token4">'buyer'</span><span class="token1">}</span><span class="token1">,</span><span class="token2">function</span><span class="token1">(</span>data<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="token1">}</span>
<span class="token5">//判断订单状态是否是已完成(6)或者已取消(7)状态</span>
<span class="token2">if</span><span class="token1">(</span>$order_base<span class="token1">[</span><span class="token4">'order_status'</span><span class="token1">]</span> <span class="token">>=</span> Order_StateModel<span class="token1">:</span><span class="token1">:</span>ORDER_FINISH<span class="token1">)</span>
<span class="token1">{</span>
<span class="token5">//判断当前用户是否是卖家</span>
<span class="token2">if</span><span class="token1">(</span>$order_base<span class="token1">[</span><span class="token4">'seller_user_id'</span><span class="token1">]</span> <span class="token">==</span> Perm<span class="token1">:</span><span class="token1">:</span>$userId<span class="token1">)</span>
<span class="token1">{</span>
$edit_row<span class="token1">[</span><span class="token4">'order_shop_hidden'</span><span class="token1">]</span> <span class="token">=</span> Order_BaseModel<span class="token1">:</span><span class="token1">:</span>IS_SELLER_HIDDEN<span class="token1">;</span>
<span class="token1">}</span>
<span class="token1">}</span>
$flag <span class="token">=</span> $Order_BaseModel<span class="token">-</span><span class="token">></span><span class="token3">editBase</span><span class="token1">(</span>$order_id<span class="token1">,</span> $edit_row<span class="token1">)</span><span class="token1">;</span>
```
```
###### 1.11、彻底删除
```
<pre class="calibre14">```
window<span class="token1">.</span>delOrder <span class="token">=</span> <span class="token2">function</span> <span class="token1">(</span>e<span class="token1">)</span>
<span class="token1">{</span>
$<span class="token1">.</span><span class="token3">dialog</span><span class="token1">(</span><span class="token1">{</span>
title<span class="token1">:</span> <span class="token4">'删除订单'</span><span class="token1">,</span>
content<span class="token1">:</span> <span class="token4">'您确定要永久删除吗?永久删除后您将无法再查看该订单,也无法进行投诉维权,请谨慎操作!'</span><span class="token1">,</span>
height<span class="token1">:</span> <span class="token6">100</span><span class="token1">,</span>
width<span class="token1">:</span> <span class="token6">610</span><span class="token1">,</span>
lock<span class="token1">:</span> <span class="token6">true</span><span class="token1">,</span>
drag<span class="token1">:</span> <span class="token6">false</span><span class="token1">,</span>
ok<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="token3">post</span><span class="token1">(</span>SITE_URL <span class="token">+</span><span class="token">?</span><span class="token4">'ctl=Buyer_Order&met=hideOrder&typ=json'</span><span class="token1">{</span>order_id<span class="token1">:</span>e<span class="token1">,</span>user<span class="token1">:</span><span class="token4">'buyer'</span><span class="token1">,</span>op<span class="token1">:</span><span class="token4">'del'</span><span class="token1">}</span><span class="token1">,</span><span class="token2">function</span><span class="token1">(</span>data<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="token1">)</span>
<span class="token1">}</span>
<span class="token5">//判断订单状态是否是已完成(6)或者已取消(7)状态</span>
<span class="token2">if</span><span class="token1">(</span>$order_base<span class="token1">[</span><span class="token4">'order_status'</span><span class="token1">]</span> <span class="token">>=</span> Order_StateModel<span class="token1">:</span><span class="token1">:</span>ORDER_FINISH<span class="token1">)</span>
<span class="token1">{</span>
<span class="token5">//判断当前用户是否是卖家</span>
<span class="token2">if</span><span class="token1">(</span>$order_base<span class="token1">[</span><span class="token4">'seller_user_id'</span><span class="token1">]</span> <span class="token">==</span> Perm<span class="token1">:</span><span class="token1">:</span>$userId<span class="token1">)</span>
<span class="token1">{</span>
$edit_row<span class="token1">[</span><span class="token4">'order_shop_hidden'</span><span class="token1">]</span> <span class="token">=</span> Order_BaseModel<span class="token1">:</span><span class="token1">:</span>IS_SELLER_REMOVE<span class="token1">;</span>
<span class="token1">}</span>
<span class="token1">}</span>
$flag <span class="token">=</span> $Order_BaseModel<span class="token">-</span><span class="token">></span><span class="token3">editBase</span><span class="token1">(</span>$order_id<span class="token1">,</span> $edit_row<span class="token1">)</span><span class="token1">;</span>
```
```
###### 1.12、还原订单
```
<pre class="calibre14">```
window<span class="token1">.</span>restoreOrder <span class="token">=</span> <span class="token2">function</span> <span class="token1">(</span>e<span class="token1">)</span>
<span class="token1">{</span>
$<span class="token1">.</span><span class="token3">dialog</span><span class="token1">(</span><span class="token1">{</span>
title<span class="token1">:</span> <span class="token4">'还原删除订单'</span><span class="token1">,</span>
content<span class="token1">:</span> <span class="token4">'您确定要还原吗?'</span><span class="token1">,</span>
height<span class="token1">:</span> <span class="token6">100</span><span class="token1">,</span>
width<span class="token1">:</span> <span class="token6">610</span><span class="token1">,</span>
lock<span class="token1">:</span> <span class="token6">true</span><span class="token1">,</span>
drag<span class="token1">:</span> <span class="token6">false</span><span class="token1">,</span>
ok<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="token3">post</span><span class="token1">(</span>SITE_URL <span class="token">+</span> <span class="token4">'?ctl=Buyer_Order&met=restoreOrder&typ=json'</span><span class="token1">,</span><span class="token1">{</span>order_id<span class="token1">:</span>e<span class="token1">,</span>user<span class="token1">:</span><span class="token4">'buyer'</span><span class="token1">}</span><span class="token1">,</span><span class="token2">function</span><span class="token1">(</span>data<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="token1">)</span>
<span class="token1">}</span>
$edit_row<span class="token1">[</span><span class="token4">'order_shop_hidden'</span><span class="token1">]</span> <span class="token">=</span> Order_BaseModel<span class="token1">:</span><span class="token1">:</span>NO_SELLER_HIDDEN<span class="token1">;</span>
$flag <span class="token">=</span> $Order_BaseModel<span class="token">-</span><span class="token">></span><span class="token3">editBase</span><span class="token1">(</span>$order_id<span class="token1">,</span> $edit_row<span class="token1">)</span><span class="token1">;</span>
```
```
#### 2、虚拟兑换订单
文件路径:shop/controllers/Seller/Trade/OrderCtl.php
###### 2.1、所有订单(virtual())
```
<pre class="calibre14">```
$condition<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>
$condition<span class="token1">[</span><span class="token4">'order_is_virtual'</span><span class="token1">]</span> <span class="token">=</span> Order_BaseModel<span class="token1">:</span><span class="token1">:</span>ORDER_IS_VIRTUAL<span class="token1">;</span>
$condition<span class="token1">[</span><span class="token4">'order_shop_hidden'</span><span class="token1">]</span> <span class="token">=</span> Order_BaseModel<span class="token1">:</span><span class="token1">:</span>ORDER_IS_REAL<span class="token1">;</span>
```
```
###### 2.2、待付款(getVirtualNew())
```
<pre class="calibre14">```
$condition<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>
$condition<span class="token1">[</span><span class="token4">'order_is_virtual'</span><span class="token1">]</span> <span class="token">=</span> Order_BaseModel<span class="token1">:</span><span class="token1">:</span>ORDER_IS_VIRTUAL<span class="token1">;</span>
$condition<span class="token1">[</span><span class="token4">'order_shop_hidden'</span><span class="token1">]</span> <span class="token">=</span> Order_BaseModel<span class="token1">:</span><span class="token1">:</span>ORDER_IS_REAL<span class="token1">;</span>
$condition<span class="token1">[</span><span class="token4">'order_status'</span><span class="token1">]</span> <span class="token">=</span> Order_StateModel<span class="token1">:</span><span class="token1">:</span>ORDER_WAIT_PAY<span class="token1">;</span>
```
```
###### 2.3、已发货(getVirtualPay())
```
<pre class="calibre14">```
$condition<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>
$condition<span class="token1">[</span><span class="token4">'order_is_virtual'</span><span class="token1">]</span> <span class="token">=</span> Order_BaseModel<span class="token1">:</span><span class="token1">:</span>ORDER_IS_VIRTUAL<span class="token1">;</span>
$condition<span class="token1">[</span><span class="token4">'order_shop_hidden'</span><span class="token1">]</span> <span class="token">=</span> Order_BaseModel<span class="token1">:</span><span class="token1">:</span>ORDER_IS_REAL<span class="token1">;</span>
$condition<span class="token1">[</span><span class="token4">'order_status'</span><span class="token1">]</span> <span class="token">=</span> Order_StateModel<span class="token1">:</span><span class="token1">:</span>ORDER_WAIT_CONFIRM_GOODS<span class="token1">;</span>
```
```
###### 2.4、已完成(getVirtualSuccess())
```
<pre class="calibre14">```
$condition<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>
$condition<span class="token1">[</span><span class="token4">'order_is_virtual'</span><span class="token1">]</span> <span class="token">=</span> Order_BaseModel<span class="token1">:</span><span class="token1">:</span>ORDER_IS_VIRTUAL<span class="token1">;</span>
$condition<span class="token1">[</span><span class="token4">'order_shop_hidden'</span><span class="token1">]</span> <span class="token">=</span> Order_BaseModel<span class="token1">:</span><span class="token1">:</span>ORDER_IS_REAL<span class="token1">;</span>
$condition<span class="token1">[</span><span class="token4">'order_status'</span><span class="token1">]</span> <span class="token">=</span> Order_StateModel<span class="token1">:</span><span class="token1">:</span>ORDER_FINISH<span class="token1">;</span>
```
```
###### 2.5、已取消(getVirtualCancel())
```
<pre class="calibre14">```
$condition<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>
$condition<span class="token1">[</span><span class="token4">'order_is_virtual'</span><span class="token1">]</span> <span class="token">=</span> Order_BaseModel<span class="token1">:</span><span class="token1">:</span>ORDER_IS_VIRTUAL<span class="token1">;</span>
$condition<span class="token1">[</span><span class="token4">'order_shop_hidden'</span><span class="token1">]</span> <span class="token">=</span> Order_BaseModel<span class="token1">:</span><span class="token1">:</span>ORDER_IS_REAL<span class="token1">;</span>
$condition<span class="token1">[</span><span class="token4">'order_status'</span><span class="token1">]</span> <span class="token">=</span> Order_StateModel<span class="token1">:</span><span class="token1">:</span>ORDER_CANCEL<span class="token1">;</span>
```
```
###### 2.6、回收站(getVirtualHideOrder())
```
<pre class="calibre14">```
$condition<span class="token1">[</span><span class="token4">'order_shop_hidden'</span><span class="token1">]</span> <span class="token">=</span> $Order_BaseModel<span class="token1">:</span><span class="token1">:</span>IS_SELLER_HIDDEN<span class="token1">;</span>
$condition<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>
$condition<span class="token1">[</span><span class="token4">'order_is_virtual'</span><span class="token1">]</span> <span class="token">=</span> Order_BaseModel<span class="token1">:</span><span class="token1">:</span>ORDER_IS_VIRTUAL<span class="token1">;</span>
```
```
###### 2.7、校验兑换码(virtualExchange())
```
<pre class="calibre14">```
$<span class="token1">(</span><span class="token4">'#_submit'</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="token3">exPost</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="token2">function</span> <span class="token3">exPost</span><span class="token1">(</span><span class="token1">)</span> <span class="token1">{</span>
$<span class="token1">(</span><span class="token4">'#vr_code_waring'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">html</span><span class="token1">(</span><span class="token4">''</span><span class="token1">)</span><span class="token1">;</span>
$<span class="token1">.</span><span class="token3">getJSON</span><span class="token1">(</span> SITE_URL <span class="token">+</span> <span class="token4">'?ctl=Seller_Trade_Order&met=virtualExchange&typ=json&vr_code='</span><span class="token">+</span>$<span class="token1">(</span><span class="token4">"#vr_code"</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> <span class="token2">null</span><span class="token1">,</span> <span class="token2">function</span><span class="token1">(</span>data<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="token5">//修改兑换码状态</span>
$update<span class="token1">[</span><span class="token4">'virtual_code_status'</span><span class="token1">]</span> <span class="token">=</span> Order_GoodsVirtualCodeModel<span class="token1">:</span><span class="token1">:</span>VIRTUAL_CODE_USED<span class="token1">;</span>
$update<span class="token1">[</span><span class="token4">'virtual_code_usetime'</span><span class="token1">]</span> <span class="token">=</span> <span class="token3">date</span><span class="token1">(</span><span class="token4">'Y-m-d H:i:s'</span><span class="token1">,</span> <span class="token3">time</span><span class="token1">(</span><span class="token1">)</span><span class="token1">)</span><span class="token1">;</span> <span class="token5">//兑换时间</span>
$result <span class="token">=</span> $this<span class="token">-</span><span class="token">></span><span class="token3">editCode</span><span class="token1">(</span>$virtual_code_id<span class="token1">,</span> $update<span class="token1">)</span><span class="token1">;</span>
<span class="token5">//判断该笔订单中有多少虚拟商品,如果是最后一笔虚拟商品,则修改订单状态为已完成,将订单金额转到商家账户</span>
$edit_flag <span class="token">=</span> $orderBaseModel<span class="token">-</span><span class="token">></span><span class="token3">editBase</span><span class="token1">(</span>$order_data<span class="token1">[</span><span class="token4">'order_id'</span><span class="token1">]</span><span class="token1">,</span> <span class="token3">array</span><span class="token1">(</span><span class="token4">'order_status'</span> <span class="token">=</span><span class="token">></span> Order_StateModel<span class="token1">:</span><span class="token1">:</span>ORDER_FINISH <span class="token1">,</span> <span class="token4">'order_finished_time'</span> <span class="token">=</span><span class="token">></span> <span class="token3">get_date_time</span><span class="token1">(</span><span class="token1">)</span><span class="token1">)</span><span class="token1">)</span><span class="token1">;</span>
<span class="token5">//远程同步paycenter中的订单状态</span>
$rs <span class="token">=</span> <span class="token3">get_url_with_encrypt</span><span class="token1">(</span>$key<span class="token1">,</span> <span class="token3">sprintf</span><span class="token1">(</span><span class="token4">'%s?ctl=Api_Pay_Pay&met=confirmOrder&typ=json'</span><span class="token1">,</span> $url<span class="token1">)</span><span class="token1">,</span> $formvars<span class="token1">)</span>
```
```
###### 2.8、其他
```
<pre class="calibre14">```
订单搜索、取消订单、删除订单、彻底删除订单、还原订单与上文已售订单管理中一致
```
```
#### 3、门店自提订单
文件路径:shop/controllers/Seller/Trade/OrderCtl.php
###### 3.1、所有订单(chain())
```
<pre class="calibre14">```
$condition<span class="token1">[</span><span class="token4">'chain_id:!='</span><span class="token1">]</span> <span class="token">=</span> <span class="token6">0</span><span class="token1">;</span>
```
```
###### 3.2、待付款(getChainNew())
```
<pre class="calibre14">```
$condi<span class="token1">[</span><span class="token4">'order_status'</span><span class="token1">]</span> <span class="token">=</span> Order_StateModel<span class="token1">:</span><span class="token1">:</span>ORDER_WAIT_PAY<span class="token1">;</span>
$condi<span class="token1">[</span><span class="token4">'chain_id:!='</span><span class="token1">]</span> <span class="token">=</span> <span class="token6">0</span><span class="token1">;</span>
```
```
###### 3.3、待自提(getChainNotakes())
```
<pre class="calibre14">```
$condi<span class="token1">[</span><span class="token4">'order_status'</span><span class="token1">]</span> <span class="token">=</span> Order_StateModel<span class="token1">:</span><span class="token1">:</span>ORDER_SELF_PICKUP<span class="token1">;</span>
$condi<span class="token1">[</span><span class="token4">'chain_id:!='</span><span class="token1">]</span> <span class="token">=</span> <span class="token6">0</span><span class="token1">;</span>
```
```
###### 3.4、已完成(getChainSuccess())
```
<pre class="calibre14">```
$condi<span class="token1">[</span><span class="token4">'order_status'</span><span class="token1">]</span> <span class="token">=</span> Order_StateModel<span class="token1">:</span><span class="token1">:</span>ORDER_FINISH<span class="token1">;</span>
$condi<span class="token1">[</span><span class="token4">'chain_id:!='</span><span class="token1">]</span> <span class="token">=</span> <span class="token6">0</span><span class="token1">;</span>
```
```
###### 3.5、已取消(getChainCancel())
```
<pre class="calibre14">```
$condi<span class="token1">[</span><span class="token4">'order_status'</span><span class="token1">]</span> <span class="token">=</span> Order_StateModel<span class="token1">:</span><span class="token1">:</span>ORDER_CANCEL<span class="token1">;</span>
$condi<span class="token1">[</span><span class="token4">'chain_id:!='</span><span class="token1">]</span> <span class="token">=</span> <span class="token6">0</span><span class="token1">;</span>
```
```
###### 3.6、回收站(getChainHideOrder())
```
<pre class="calibre14">```
$condition<span class="token1">[</span><span class="token4">'order_shop_hidden'</span><span class="token1">]</span> <span class="token">=</span> $Order_BaseModel<span class="token1">:</span><span class="token1">:</span>IS_SELLER_HIDDEN<span class="token1">;</span>
$condition<span class="token1">[</span><span class="token4">'chain_id:!='</span><span class="token1">]</span> <span class="token">=</span> <span class="token6">0</span><span class="token1">;</span>
```
```
###### 3.7、其他
```
<pre class="calibre14">```
订单搜索、取消订单、删除订单、彻底删除订单、还原订单与上文已售订单管理中一致
```
```
#### 4、发货
文件路径:shop/controllers/Seller/Trade/DeliverCtl.php
###### 4.1、待发货(deliver())
```
<pre class="calibre14">```
$condition<span class="token1">[</span><span class="token4">'order_status:IN'</span><span class="token1">]</span> <span class="token">=</span> <span class="token3">array</span><span class="token1">(</span> Order_StateModel<span class="token1">:</span><span class="token1">:</span>ORDER_PAYED<span class="token1">,</span> Order_StateModel<span class="token1">:</span><span class="token1">:</span>ORDER_WAIT_PREPARE_GOODS <span class="token1">)</span><span class="token1">;</span>
```
```
###### 4.2、发货(shop/controllers/Seller/Trade/OrderCtl.php,send())
编辑收货人信息:
```
<pre class="calibre14">```
$<span class="token1">(</span><span class="token4">'a[dialog_id="edit_buyer_address"]'</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 _this <span class="token">=</span> $<span class="token1">(</span>this<span class="token1">)</span><span class="token1">,</span>
buyer_address <span class="token">=</span> $<span class="token1">(</span><span class="token4">'#buyer_address_span'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">html</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
address_data <span class="token">=</span> _this<span class="token1">.</span><span class="token3">data</span><span class="token1">(</span><span class="token1">)</span><span class="token1">,</span>
address_data<span class="token1">.</span>order_id <span class="token">=</span> $<span class="token1">(</span><span class="token4">'#order_id'</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>
$<span class="token1">.</span><span class="token3">dialog</span><span class="token1">(</span><span class="token1">{</span>
title<span class="token1">:</span> <span class="token4">'<?=__('</span>选择收货地址<span class="token4">')?>'</span><span class="token1">,</span>
content<span class="token1">:</span> <span class="token4">'url: '</span> <span class="token">+</span> SITE_URL <span class="token">+</span> <span class="token4">'?ctl=Seller_Trade_Order&met=editBuyerAddress&typ=e'</span><span class="token1">,</span>
height<span class="token1">:</span> <span class="token6">200</span><span class="token1">,</span>
width<span class="token1">:</span> <span class="token6">550</span><span class="token1">,</span>
lock<span class="token1">:</span> <span class="token6">true</span><span class="token1">,</span>
drag<span class="token1">:</span> <span class="token6">false</span><span class="token1">,</span>
data<span class="token1">:</span> <span class="token1">{</span> address_data<span class="token1">:</span> address_data<span class="token1">,</span>
callback<span class="token1">:</span> <span class="token2">function</span> <span class="token1">(</span> data <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="token1">)</span><span class="token1">;</span>
$update_data<span class="token1">[</span><span class="token4">'order_receiver_name'</span><span class="token1">]</span> <span class="token">=</span> <span class="token3">request_string</span><span class="token1">(</span><span class="token4">'order_receiver_name'</span><span class="token1">)</span><span class="token1">;</span>
$update_data<span class="token1">[</span><span class="token4">'order_receiver_address'</span><span class="token1">]</span> <span class="token">=</span> <span class="token3">request_string</span><span class="token1">(</span><span class="token4">'order_receiver_address'</span><span class="token1">)</span><span class="token1">;</span>
$update_data<span class="token1">[</span><span class="token4">'order_receiver_contact'</span><span class="token1">]</span> <span class="token">=</span> <span class="token3">request_string</span><span class="token1">(</span><span class="token4">'order_receiver_contact'</span><span class="token1">)</span><span class="token1">;</span>
$flag <span class="token">=</span> $Order_BaseModel<span class="token">-</span><span class="token">></span><span class="token3">editBase</span><span class="token1">(</span>$order_id<span class="token1">,</span> $update_data<span class="token1">)</span><span class="token1">;</span>
```
```
编辑我的发货信息:
```
<pre class="calibre14">```
$<span class="token1">(</span><span class="token4">'a[dialog_id="edit_seller_address"]'</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 order_id <span class="token">=</span> $<span class="token1">(</span><span class="token4">'#order_id'</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>
shop_id <span class="token">=</span> $<span class="token1">(</span>this<span class="token1">)</span><span class="token1">.</span><span class="token3">data</span><span class="token1">(</span><span class="token4">'shop_id'</span><span class="token1">)</span><span class="token1">,</span>
url <span class="token">=</span> SITE_URL <span class="token">+</span> <span class="token4">'?ctl=Seller_Trade_Order&met=chooseSendAddress&typ='</span><span class="token1">;</span>
$<span class="token1">.</span><span class="token3">dialog</span><span class="token1">(</span><span class="token1">{</span>
title<span class="token1">:</span> <span class="token4">'<?=__('</span>选择发货地址<span class="token4">')?>'</span><span class="token1">,</span>
content<span class="token1">:</span> <span class="token4">'url: '</span> <span class="token">+</span> url <span class="token">+</span> <span class="token4">'e&shop_id='</span> <span class="token">+</span> shop_id<span class="token1">,</span>
height<span class="token1">:</span> <span class="token6">400</span><span class="token1">,</span>
width<span class="token1">:</span> <span class="token6">640</span><span class="token1">,</span>
lock<span class="token1">:</span> <span class="token6">true</span><span class="token1">,</span>
drag<span class="token1">:</span> <span class="token6">false</span><span class="token1">,</span>
data<span class="token1">:</span> <span class="token1">{</span> callback<span class="token1">:</span> <span class="token2">function</span> <span class="token1">(</span> send_address<span class="token1">,</span> win <span class="token1">)</span> <span class="token1">{</span>
$<span class="token1">.</span><span class="token3">post</span><span class="token1">(</span>url <span class="token">+</span> <span class="token4">'json&order_id='</span> <span class="token">+</span> order_id<span class="token1">,</span> <span class="token1">{</span> send_address<span class="token1">:</span> send_address <span class="token1">}</span><span class="token1">,</span> <span class="token2">function</span> <span class="token1">(</span>data<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="token1">)</span>
<span class="token1">}</span><span class="token1">)</span><span class="token1">;</span>
$update_data<span class="token1">[</span><span class="token4">'order_seller_name'</span><span class="token1">]</span> <span class="token">=</span> $send_address<span class="token1">[</span><span class="token4">'order_seller_name'</span><span class="token1">]</span><span class="token1">;</span>
$update_data<span class="token1">[</span><span class="token4">'order_seller_address'</span><span class="token1">]</span> <span class="token">=</span> $send_address<span class="token1">[</span><span class="token4">'order_seller_address'</span><span class="token1">]</span><span class="token1">;</span>
$update_data<span class="token1">[</span><span class="token4">'order_seller_contact'</span><span class="token1">]</span> <span class="token">=</span> $send_address<span class="token1">[</span><span class="token4">'order_seller_contact'</span><span class="token1">]</span><span class="token1">;</span>
$flag <span class="token">=</span> $Order_BaseModel<span class="token">-</span><span class="token">></span><span class="token3">editBase</span><span class="token1">(</span>$order_id<span class="token1">,</span> $update_data<span class="token1">)</span><span class="token1">;</span>
```
```
提交表单:
```
<pre class="calibre14">```
$<span class="token1">(</span><span class="token4">'a[nc_value]'</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="token3">post</span><span class="token1">(</span>SITE_URL <span class="token">+</span> <span class="token4">'?ctl=Seller_Trade_Order&met=send&typ=json'</span><span class="token1">,</span> send_data<span class="token1">,</span> <span class="token2">function</span> <span class="token1">(</span>data<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="token5">//判断该笔订单是否是自己的单子</span>
$order_base <span class="token">=</span> $Order_BaseModel<span class="token">-</span><span class="token">></span><span class="token3">getOne</span><span class="token1">(</span>$order_id<span class="token1">)</span><span class="token1">;</span>
<span class="token5">//判断账号是否可以发货</span>
$check_send <span class="token">=</span> $this<span class="token">-</span><span class="token">></span><span class="token3">checkSend</span><span class="token1">(</span>$order_base<span class="token1">[</span><span class="token4">'seller_user_id'</span><span class="token1">]</span><span class="token1">,</span>$order_base<span class="token1">[</span><span class="token4">'shop_id'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">;</span>
<span class="token5">//设置发货</span>
<span class="token5">//配送时间 收货时间</span>
$edit_flag <span class="token">=</span> $Order_BaseModel<span class="token">-</span><span class="token">></span><span class="token3">editBase</span><span class="token1">(</span>$order_id<span class="token1">,</span> $update_data<span class="token1">)</span><span class="token1">;</span>
$order_list <span class="token">=</span> $Order_GoodsModel <span class="token">-</span><span class="token">></span> <span class="token3">getByWhere</span><span class="token1">(</span><span class="token3">array</span><span class="token1">(</span><span class="token4">'order_id'</span> <span class="token">=</span><span class="token">></span>$order_base<span class="token1">[</span><span class="token4">'order_source_id'</span><span class="token1">]</span><span class="token1">,</span><span class="token4">'order_goods_source_id'</span> <span class="token">=</span><span class="token">></span> <span class="token4">''</span><span class="token1">)</span><span class="token1">)</span><span class="token1">;</span><span class="token5">//查看不是分销商品的订单</span>
<span class="token2">if</span><span class="token1">(</span><span class="token">!</span><span class="token3">empty</span><span class="token1">(</span>$order_list<span class="token1">)</span> <span class="token">&&</span> $order_base<span class="token1">[</span><span class="token4">'order_source_id'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">{</span>
foreach <span class="token1">(</span>$order_list as $key <span class="token">=</span><span class="token">></span> $value<span class="token1">)</span> <span class="token1">{</span>
$edit_flag1 <span class="token">=</span> $Order_GoodsModel <span class="token">-</span><span class="token">></span> <span class="token3">editGoods</span><span class="token1">(</span>$key<span class="token1">,</span><span class="token3">array</span><span class="token1">(</span><span class="token4">'order_goods_source_ship'</span> <span class="token">=</span><span class="token">></span> $update_data<span class="token1">[</span><span class="token4">'order_shipping_code'</span><span class="token1">]</span><span class="token1">.</span><span class="token4">'-'</span><span class="token1">.</span>$update_data<span class="token1">[</span><span class="token4">'order_shipping_express_id'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">)</span><span class="token1">;</span>
<span class="token3">check_rs</span><span class="token1">(</span>$edit_flag1<span class="token1">,</span>$rs_row<span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
<span class="token1">}</span>
<span class="token5">//如果为采购单,改变 "买家<-->分销商" 订单状态</span>
<span class="token5">/*
只有订单中不含分销商自己的商品时改变订单状态,如果含有分销商自己的商品,
供货商发货改变订单状态,分销商自己就发不了货了.
所以如果订单中含有分销商自己的商品,只有分销商的商品发货了,才能改变订单状态
*/</span>
$dist_flag <span class="token">=</span> $Order_BaseModel<span class="token">-</span><span class="token">></span><span class="token3">editBase</span><span class="token1">(</span>$dist_order<span class="token1">[</span><span class="token4">'order_id'</span><span class="token1">]</span><span class="token1">,</span> $update_data<span class="token1">)</span><span class="token1">;</span>
<span class="token5">//买家商品订单表里添加物流单号</span>
$order_goods_id <span class="token">=</span> $Order_GoodsModel<span class="token">-</span><span class="token">></span><span class="token3">getKeyByWhere</span><span class="token1">(</span><span class="token3">array</span><span class="token1">(</span><span class="token4">'order_goods_source_id'</span> <span class="token">=</span><span class="token">></span> $order_id<span class="token1">)</span><span class="token1">)</span><span class="token1">;</span>
$edit_flag2 <span class="token">=</span> $Order_GoodsModel <span class="token">-</span><span class="token">></span> <span class="token3">editGoods</span><span class="token1">(</span>$order_goods_id<span class="token1">,</span><span class="token3">array</span><span class="token1">(</span><span class="token4">'order_goods_source_ship'</span> <span class="token">=</span><span class="token">></span> $update_data<span class="token1">[</span><span class="token4">'order_shipping_code'</span><span class="token1">]</span><span class="token1">.</span><span class="token4">'-'</span><span class="token1">.</span>$update_data<span class="token1">[</span><span class="token4">'order_shipping_express_id'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">)</span><span class="token1">;</span>
```
```
##### 4.3、发货中(delivering())
获取订单列表
```
<pre class="calibre14">```
$Order_BaseModel <span class="token">=</span> <span class="token2">new</span> <span class="token3">Order_BaseModel</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
$condition<span class="token1">[</span><span class="token4">'order_status'</span><span class="token1">]</span> <span class="token">=</span> Order_StateModel<span class="token1">:</span><span class="token1">:</span>ORDER_WAIT_CONFIRM_GOODS<span class="token1">;</span>
$data <span class="token">=</span> $Order_BaseModel<span class="token">-</span><span class="token">></span><span class="token3">getPhysicalList</span><span class="token1">(</span>$condition<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>
<span class="token2">if</span> <span class="token1">(</span><span class="token3">strtotime</span><span class="token1">(</span>$val<span class="token1">[</span><span class="token4">'order_receiver_date'</span><span class="token1">]</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">'order_receiver_date'</span><span class="token1">]</span> <span class="token">=</span> $val<span class="token1">[</span><span class="token4">'order_receiver_date'</span><span class="token1">]</span><span class="token1">;</span>
<span class="token1">}</span>
<span class="token1">}</span>
```
```
延迟收货
```
<pre class="calibre14">```
$<span class="token1">(</span><span class="token4">'a[dialog_id="seller_order_delay_receive"]'</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 $this <span class="token">=</span> $<span class="token1">(</span>this<span class="token1">)</span><span class="token1">,</span>
order_id <span class="token">=</span> $this<span class="token1">.</span><span class="token3">data</span><span class="token1">(</span><span class="token4">'order_id'</span><span class="token1">)</span><span class="token1">,</span>
buyer_name <span class="token">=</span> $this<span class="token1">.</span><span class="token3">data</span><span class="token1">(</span><span class="token4">'buyer_user_name'</span><span class="token1">)</span><span class="token1">,</span>
order_receiver_date <span class="token">=</span> $this<span class="token1">.</span><span class="token3">data</span><span class="token1">(</span><span class="token4">'order_receiver_date'</span><span class="token1">)</span><span class="token1">,</span>
url <span class="token">=</span> SITE_URL <span class="token">+</span> <span class="token4">'?ctl=Seller_Trade_Deliver&met=delayReceive&typ='</span><span class="token1">;</span>
$<span class="token1">.</span><span class="token3">dialog</span><span class="token1">(</span><span class="token1">{</span>
title<span class="token1">:</span> <span class="token4">'<?=__('</span>延迟收货<span class="token4">')?>'</span><span class="token1">,</span>
content<span class="token1">:</span> <span class="token4">'url: '</span> <span class="token">+</span> url <span class="token">+</span> <span class="token4">'e'</span><span class="token1">,</span>
data<span class="token1">:</span> <span class="token1">{</span> order_id<span class="token1">:</span> order_id<span class="token1">,</span> order_receiver_date<span class="token1">:</span> order_receiver_date<span class="token1">,</span> buyer_name<span class="token1">:</span> buyer_name <span class="token1">}</span><span class="token1">,</span>
height<span class="token1">:</span> <span class="token6">250</span><span class="token1">,</span>
width<span class="token1">:</span> <span class="token6">500</span><span class="token1">,</span>
lock<span class="token1">:</span> <span class="token6">true</span><span class="token1">,</span>
drag<span class="token1">:</span> <span class="token6">false</span><span class="token1">,</span>
ok<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="token1">}</span><span class="token1">)</span>
<span class="token1">}</span><span class="token1">)</span>
$order_receiver_date <span class="token">=</span> <span class="token3">strtotime</span><span class="token1">(</span>$order_receiver_date<span class="token1">)</span><span class="token1">;</span>
$order_receiver_date <span class="token">=</span> <span class="token3">strtotime</span><span class="token1">(</span><span class="token4">"+$delayDays days"</span><span class="token1">,</span> $order_receiver_date<span class="token1">)</span><span class="token1">;</span>
$update<span class="token1">[</span><span class="token4">'order_receiver_date'</span><span class="token1">]</span> <span class="token">=</span> <span class="token3">date</span><span class="token1">(</span><span class="token4">'Y-m-d H:i:s'</span><span class="token1">,</span> $order_receiver_date<span class="token1">)</span><span class="token1">;</span>
$flag <span class="token">=</span> $Order_BaseModel<span class="token">-</span><span class="token">></span><span class="token3">editBase</span><span class="token1">(</span>$order_id<span class="token1">,</span> $update<span class="token1">)</span><span class="token1">;</span>
```
```
##### 4.4、已发货(delivered())
```
<pre class="calibre14">```
$condition<span class="token1">[</span><span class="token4">'order_status'</span><span class="token1">]</span> <span class="token">=</span> Order_StateModel<span class="token1">:</span><span class="token1">:</span>ORDER_FINISH<span class="token1">;</span>
```
```
##### 4.5、其他
```
<pre class="calibre14">```
订单搜索、取消订单、删除订单、彻底删除订单、还原订单与上文已售订单管理中一致
```
```
#### 5、发货设置
文件路径:shop/controllers/Seller/Trade/DeliverCtl.php
##### 5.1、地址库(deliverSetting())
获取地址列表:
$cond\_row\['shop\_id'\] = Perm::$shopId;
$data = $this->shopShippingAddressModel->getBaseList($cond\_row, array('shipping\_address\_time' => 'desc'), $page, $rows);
新增/编辑地址:
```
<pre class="calibre14">```
$<span class="token1">(</span><span class="token4">'#form'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">validator</span><span class="token1">(</span><span class="token1">{</span>
debug<span class="token1">:</span><span class="token6">true</span><span class="token1">,</span>
ignore<span class="token1">:</span> <span class="token4">':hidden'</span><span class="token1">,</span>
theme<span class="token1">:</span> <span class="token4">'yellow_right'</span><span class="token1">,</span>
timely<span class="token1">:</span> <span class="token6">1</span><span class="token1">,</span>
stopOnError<span class="token1">:</span> <span class="token6">false</span><span class="token1">,</span>
rules<span class="token1">:</span> <span class="token1">{</span>
phone<span class="token1">:</span> <span class="token1">[</span><span class="token">/</span><span class="token">^</span><span class="token6">1</span><span class="token1">[</span>\d<span class="token1">]</span><span class="token1">{</span><span class="token6">10</span><span class="token1">}</span>$<span class="token">/</span><span class="token1">,</span> <span class="token4">'<?=__('</span>请输入正确的手机号<span class="token4">')?>'</span><span class="token1">]</span>
<span class="token1">}</span><span class="token1">,</span>
fields<span class="token1">:</span> <span class="token1">{</span>
<span class="token4">'shipping_address_contact'</span><span class="token1">:</span> <span class="token4">'required;length[2~10]'</span><span class="token1">,</span>
<span class="token4">'select_1'</span><span class="token1">:</span><span class="token4">'required'</span><span class="token1">,</span>
<span class="token4">'select_2'</span><span class="token1">:</span><span class="token4">'required'</span><span class="token1">,</span>
<span class="token4">'select_3'</span><span class="token1">:</span><span class="token4">'required'</span><span class="token1">,</span>
<span class="token4">'shipping_address_address'</span> <span class="token1">:</span> <span class="token4">'required'</span><span class="token1">,</span>
<span class="token4">'shipping_address_phone'</span><span class="token1">:</span><span class="token4">'required;phone'</span>
<span class="token1">}</span><span class="token1">,</span>
valid<span class="token1">:</span> <span class="token2">function</span><span class="token1">(</span>form<span class="token1">)</span><span class="token1">{</span>
var me <span class="token">=</span> this<span class="token1">;</span>
<span class="token5">// 提交表单之前,hold住表单,并且在以后每次hold住时执行回调</span>
me<span class="token1">.</span><span class="token3">holdSubmit</span><span class="token1">(</span><span class="token2">function</span><span class="token1">(</span><span class="token1">)</span><span class="token1">{</span>
Public<span class="token1">.</span>tips<span class="token1">.</span><span class="token3">error</span><span class="token1">(</span><span class="token4">'<?=__('</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>
$<span class="token1">.</span><span class="token3">ajax</span><span class="token1">(</span><span class="token1">{</span>
url<span class="token1">:</span> ajax_url<span class="token1">,</span>
data<span class="token1">:</span> $<span class="token1">(</span>form<span class="token1">)</span><span class="token1">.</span><span class="token3">serialize</span><span class="token1">(</span><span class="token1">)</span><span class="token1">,</span>
type<span class="token1">:</span> <span class="token4">"POST"</span><span class="token1">,</span>
success<span class="token1">:</span><span class="token2">function</span><span class="token1">(</span>e<span class="token1">)</span><span class="token1">{</span>
me<span class="token1">.</span><span class="token3">holdSubmit</span><span class="token1">(</span><span class="token6">false</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="token1">}</span><span class="token1">)</span><span class="token1">;</span>
```
```
删除地址:
```
<pre class="calibre14">```
<span class="token"><</span>span class<span class="token">=</span><span class="token4">"del"</span><span class="token">></span><span class="token"><</span>a data<span class="token">-</span>param<span class="token">=</span><span class="token4">"{'ctl':'Seller_Trade_Deliver','met':'delAddress','id':'<?= $val['shipping_address_id'] ?>'}"</span> href<span class="token">=</span><span class="token4">"javascript:void(0)"</span><span class="token">></span><span class="token"><</span>i class<span class="token">=</span><span class="token4">"iconfont icon-lajitong"</span><span class="token">></span><span class="token"><</span><span class="token">/</span>i<span class="token">></span><span class="token"><</span><span class="token">?</span><span class="token">=</span><span class="token3">__</span><span class="token1">(</span><span class="token4">'删除'</span><span class="token1">)</span><span class="token">?</span><span class="token">></span><span class="token"><</span><span class="token">/</span>a<span class="token">></span><span class="token"><</span><span class="token">/</span>span<span class="token">></span>
```
```
更改默认地址:
```
<pre class="calibre14">```
$<span class="token1">(</span><span class="token4">'input[name="is_default"]'</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="token3">get</span><span class="token1">(</span><span class="token4">'index.php?ctl=Seller_Trade_Deliver&met=setDefaultAddress&shipping_address_id='</span><span class="token">+</span>$<span class="token1">(</span>this<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><span class="token2">function</span><span class="token1">(</span>result<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="token5">//获取店铺已设置默认地址信息</span>
$data <span class="token">=</span> $this<span class="token">-</span><span class="token">></span><span class="token3">getByWhere</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> $shop_id<span class="token1">,</span><span class="token4">'shipping_address_default'</span> <span class="token">=</span><span class="token">></span> <span class="token6">1</span><span class="token1">)</span><span class="token1">)</span><span class="token1">;</span>
<span class="token2">if</span> <span class="token1">(</span><span class="token">!</span><span class="token3">empty</span><span class="token1">(</span>$data<span class="token1">)</span><span class="token1">)</span>
<span class="token1">{</span>
foreach <span class="token1">(</span>$data as $key <span class="token">=</span><span class="token">></span> $val<span class="token1">)</span>
<span class="token1">{</span>
<span class="token5">//已有默认地址置为0</span>
$this<span class="token">-</span><span class="token">></span><span class="token3">edit</span><span class="token1">(</span>$val<span class="token1">[</span><span class="token4">'shipping_address_id'</span><span class="token1">]</span><span class="token1">,</span> <span class="token3">array</span><span class="token1">(</span><span class="token4">'shipping_address_default'</span> <span class="token">=</span><span class="token">></span> <span class="token6">0</span><span class="token1">)</span><span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
<span class="token1">}</span>
<span class="token5">//设置新的默认地址</span>
$this<span class="token">-</span><span class="token">></span><span class="token3">edit</span><span class="token1">(</span>$shipping_address_id<span class="token1">,</span> $field_row<span class="token1">)</span><span class="token1">;</span>
```
```
##### 5.2、默认物流公司(express)
循环显示所有物流公司
```
<pre class="calibre14">```
<span class="token"><</span><span class="token">?</span>php <span class="token3">foreach</span><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> <span class="token">?</span><span class="token">></span>
<span class="token"><</span>td class<span class="token">=</span><span class="token4">"tl"</span><span class="token">></span>
<span class="token"><</span>label class<span class="token">=</span><span class="token4">"checkbox"</span><span class="token">></span><span class="token"><</span>input type<span class="token">=</span><span class="token4">"checkbox"</span> <span class="token"><</span><span class="token">?</span>php <span class="token2">if</span><span class="token1">(</span>$val<span class="token1">[</span><span class="token4">'checked'</span><span class="token1">]</span><span class="token">==</span><span class="token6">1</span><span class="token1">)</span> echo <span class="token4">"checked"</span><span class="token1">;</span> <span class="token">?</span><span class="token">></span> name<span class="token">=</span><span class="token4">"id[]"</span> value<span class="token">=</span><span class="token4">"<?=$val['express_id']?>"</span><span class="token">></span><span class="token"><</span><span class="token">/</span>label<span class="token">></span><span class="token"><</span><span class="token">?</span><span class="token">=</span><span class="token3">__</span><span class="token1">(</span>$val<span class="token1">[</span><span class="token4">'express_name'</span><span class="token1">]</span><span class="token1">)</span><span class="token">?</span><span class="token">></span>
<span class="token"><</span><span class="token">/</span>td<span class="token">></span>
<span class="token"><</span><span class="token">?</span>php <span class="token2">if</span><span class="token1">(</span><span class="token1">(</span>$key<span class="token">+</span><span class="token6">1</span><span class="token1">)</span><span class="token">%</span><span class="token6">4</span><span class="token">==</span><span class="token6">0</span><span class="token1">)</span><span class="token1">{</span> <span class="token">?</span><span class="token">></span><span class="token"><</span><span class="token">/</span>tr<span class="token">></span><span class="token"><</span>tr<span class="token">></span><span class="token"><</span><span class="token">?</span>php <span class="token1">}</span> <span class="token">?</span><span class="token">></span>
<span class="token"><</span><span class="token">?</span>php <span class="token1">}</span> <span class="token">?</span><span class="token">></span>
```
```
保存修改
```
<pre class="calibre14">```
$<span class="token1">(</span><span class="token4">'#form'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">validator</span><span class="token1">(</span><span class="token1">{</span>
$<span class="token1">.</span><span class="token3">ajax</span><span class="token1">(</span><span class="token1">{</span>
url<span class="token1">:</span> <span class="token4">"index.php?ctl=Seller_Trade_Deliver&met=express&typ=json&op=save"</span><span class="token1">,</span>
data<span class="token1">:</span> $<span class="token1">(</span>form<span class="token1">)</span><span class="token1">.</span><span class="token3">serialize</span><span class="token1">(</span><span class="token1">)</span><span class="token1">,</span>
type<span class="token1">:</span> <span class="token4">"POST"</span><span class="token1">,</span>
success<span class="token1">:</span><span class="token2">function</span><span class="token1">(</span>e<span class="token1">)</span><span class="token1">{</span>
me<span class="token1">.</span><span class="token3">holdSubmit</span><span class="token1">(</span><span class="token6">false</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="token1">)</span><span class="token1">;</span>
<span class="token5">//获取店铺默认物流公司ID</span>
$express_rows <span class="token">=</span> $this<span class="token">-</span><span class="token">></span><span class="token3">getShopExpressId</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> $shop_id<span class="token1">)</span><span class="token1">)</span><span class="token1">;</span>
<span class="token5">//不在已有默认物流公司ID内,插入</span>
$this<span class="token">-</span><span class="token">></span><span class="token3">add</span><span class="token1">(</span>$field<span class="token1">)</span><span class="token1">;</span>
<span class="token5">//如果已有ID,不在提交的数组里,删除</span>
$cond_row<span class="token1">[</span><span class="token4">'shop_id'</span><span class="token1">]</span> <span class="token">=</span> $shop_id<span class="token1">;</span>
$cond_row<span class="token1">[</span><span class="token4">'express_id'</span><span class="token1">]</span> <span class="token">=</span> $v<span class="token1">;</span>
<span class="token5">//获取主键值,合并数组</span>
$key_row <span class="token">=</span> $this<span class="token">-</span><span class="token">></span><span class="token3">getKeyByWhere</span><span class="token1">(</span>$cond_row<span class="token1">)</span><span class="token1">;</span>
$del_row <span class="token">=</span> <span class="token3">array_merge</span><span class="token1">(</span>$del_row<span class="token1">,</span> $key_row<span class="token1">)</span><span class="token1">;</span>
```
```
##### 5.3、免运费额度(freightAmount())
保存修改
```
<pre class="calibre14">```
$<span class="token1">(</span><span class="token4">'#form'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">validator</span><span class="token1">(</span><span class="token1">{</span>
$<span class="token1">.</span><span class="token3">ajax</span><span class="token1">(</span><span class="token1">{</span>
url<span class="token1">:</span> <span class="token4">"index.php?ctl=Seller_Trade_Deliver&met=freightAmount&op=save&typ=json"</span><span class="token1">,</span>
data<span class="token1">:</span> $<span class="token1">(</span>form<span class="token1">)</span><span class="token1">.</span><span class="token3">serialize</span><span class="token1">(</span><span class="token1">)</span><span class="token1">,</span>
type<span class="token1">:</span> <span class="token4">"POST"</span><span class="token1">,</span>
success<span class="token1">:</span><span class="token2">function</span><span class="token1">(</span>e<span class="token1">)</span><span class="token1">{</span>
me<span class="token1">.</span><span class="token3">holdSubmit</span><span class="token1">(</span><span class="token6">false</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="token1">)</span><span class="token1">;</span>
$update_flag <span class="token">=</span> $this<span class="token">-</span><span class="token">></span><span class="token3">edit</span><span class="token1">(</span>$shop_id<span class="token1">,</span> <span class="token3">array</span><span class="token1">(</span><span class="token4">'shop_free_shipping'</span> <span class="token">=</span><span class="token">></span> <span class="token3">request_int</span><span class="token1">(</span><span class="token4">'free_shipping'</span><span class="token1">)</span><span class="token1">)</span><span class="token1">)</span><span class="token1">;</span>
```
```
##### 5.4、发货单打印设置(printSetting())
图片上传
```
<pre class="calibre14">```
$<span class="token1">(</span><span class="token4">'#logo_upload'</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="token3">dialog</span><span class="token1">(</span><span class="token1">{</span>
title<span class="token1">:</span> <span class="token4">'<?=__('</span>图片裁剪<span class="token4">')?>'</span><span class="token1">,</span>
content<span class="token1">:</span> <span class="token4">"url: <?= Yf_Registry::get('url') ?>?ctl=Upload&met=cropperImage&typ=e"</span><span class="token1">,</span>
data<span class="token1">:</span> <span class="token1">{</span>width<span class="token1">:</span><span class="token6">120</span><span class="token1">,</span>height<span class="token1">:</span><span class="token6">120</span> <span class="token1">,</span> callback<span class="token1">:</span> callback1 <span class="token1">}</span><span class="token1">,</span> <span class="token5">// 需要截取图片的宽高比例</span>
width<span class="token1">:</span> <span class="token4">'800px'</span><span class="token1">,</span>
lock<span class="token1">:</span> <span class="token6">true</span>
<span class="token1">}</span><span class="token1">)</span>
<span class="token1">}</span><span class="token1">)</span><span class="token1">;</span>
<span class="token2">function</span> <span class="token3">callback1</span><span class="token1">(</span> respone <span class="token1">,</span> api <span class="token1">)</span> <span class="token1">{</span>
$<span class="token1">(</span><span class="token4">'#image_review'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">attr</span><span class="token1">(</span><span class="token4">'src'</span><span class="token1">,</span> respone<span class="token1">.</span>url<span class="token1">)</span><span class="token1">;</span>
$<span class="token1">(</span><span class="token4">'.image_review'</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">'#shop_stamp'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">attr</span><span class="token1">(</span><span class="token4">'value'</span><span class="token1">,</span> respone<span class="token1">.</span>url<span class="token1">)</span><span class="token1">;</span>
api<span class="token1">.</span><span class="token3">close</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
<span class="token2">if</span> <span class="token1">(</span> window<span class="token1">.</span>isIE8 <span class="token1">)</span> <span class="token1">{</span>
$<span class="token1">(</span><span class="token4">'#logo_upload'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">off</span><span class="token1">(</span><span class="token4">'click'</span><span class="token1">)</span><span class="token1">;</span>
logo_uploadss <span class="token">=</span> <span class="token2">new</span> <span class="token3">UploadImage</span><span class="token1">(</span><span class="token1">{</span>
thumbnailWidth<span class="token1">:</span> <span class="token6">200</span><span class="token1">,</span>
thumbnailHeight<span class="token1">:</span> <span class="token6">60</span><span class="token1">,</span>
imageContainer<span class="token1">:</span> <span class="token4">'#image_review'</span><span class="token1">,</span>
uploadButton<span class="token1">:</span> <span class="token4">'#logo_upload'</span><span class="token1">,</span>
inputHidden<span class="token1">:</span> <span class="token4">'#shop_stamp'</span>
<span class="token1">}</span><span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
```
```
保存修改:
```
<pre class="calibre14">```
$<span class="token1">(</span><span class="token4">'#form'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">validator</span><span class="token1">(</span><span class="token1">{</span>
$<span class="token1">.</span><span class="token3">ajax</span><span class="token1">(</span><span class="token1">{</span>
url<span class="token1">:</span> <span class="token4">"index.php?ctl=Seller_Trade_Deliver&met=printSetting&op=save&typ=json"</span><span class="token1">,</span>
data<span class="token1">:</span> $<span class="token1">(</span>form<span class="token1">)</span><span class="token1">.</span><span class="token3">serialize</span><span class="token1">(</span><span class="token1">)</span><span class="token1">,</span>
type<span class="token1">:</span> <span class="token4">"POST"</span><span class="token1">,</span>
success<span class="token1">:</span><span class="token2">function</span><span class="token1">(</span>e<span class="token1">)</span><span class="token1">{</span>
me<span class="token1">.</span><span class="token3">holdSubmit</span><span class="token1">(</span><span class="token6">false</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="token1">;</span>
$field_row<span class="token1">[</span><span class="token4">'shop_print_desc'</span><span class="token1">]</span> <span class="token">=</span> <span class="token3">request_string</span><span class="token1">(</span><span class="token4">'shop_print_desc'</span><span class="token1">)</span><span class="token1">;</span> <span class="token5">//打印描述</span>
$field_row<span class="token1">[</span><span class="token4">'shop_stamp'</span><span class="token1">]</span> <span class="token">=</span> <span class="token3">request_string</span><span class="token1">(</span><span class="token4">'shop_stamp'</span><span class="token1">)</span><span class="token1">;</span> <span class="token5">//店铺印章</span>
$flag <span class="token">=</span> $Shop_BaseModel<span class="token">-</span><span class="token">></span><span class="token3">setPrint</span><span class="token1">(</span>$shop_id<span class="token1">,</span> $field_row<span class="token1">)</span><span class="token1">;</span>
```
```
#### 6、运单模板
文件路径:shop/controllers/Seller/Trade/WaybillCtl.php
##### 6.1、模板绑定(waybillManage())
设为默认/解绑
```
<pre class="calibre14">```
$<span class="token1">(</span><span class="token4">'span[data-action]'</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 user_express_id <span class="token1">,</span> tpl_id <span class="token1">,</span> param <span class="token">=</span> <span class="token1">{</span><span class="token1">}</span> <span class="token1">,</span>
action <span class="token">=</span> $<span class="token1">(</span>this<span class="token1">)</span><span class="token1">.</span><span class="token3">data</span><span class="token1">(</span><span class="token4">'action'</span><span class="token1">)</span> <span class="token1">,</span>
url <span class="token">=</span> SITE_URL <span class="token">+</span> <span class="token4">'?ctl=Seller_Trade_Waybill&met=operateByManage&typ=json&action='</span> <span class="token1">;</span>
<span class="token2">if</span> <span class="token1">(</span>action <span class="token">==</span> <span class="token4">'set_default'</span> <span class="token">||</span> action <span class="token">==</span> <span class="token4">'unbind_tpl'</span><span class="token1">)</span> <span class="token1">{</span>
param <span class="token">=</span> <span class="token1">{</span>
user_express_id<span class="token1">:</span> $<span class="token1">(</span>this<span class="token1">)</span><span class="token1">.</span><span class="token3">parent</span><span class="token1">(</span><span class="token1">)</span><span class="token1">.</span><span class="token3">data</span><span class="token1">(</span><span class="token4">'user_express_id'</span><span class="token1">)</span><span class="token1">,</span>
waybill_tpl_id<span class="token1">:</span> $<span class="token1">(</span>this<span class="token1">)</span><span class="token1">.</span><span class="token3">parent</span><span class="token1">(</span><span class="token1">)</span><span class="token1">.</span><span class="token3">data</span><span class="token1">(</span><span class="token4">'waybill_tpl_id'</span><span class="token1">)</span>
<span class="token1">}</span><span class="token1">;</span>
url <span class="token">+</span><span class="token">=</span> action<span class="token1">;</span>
$<span class="token1">.</span><span class="token3">post</span><span class="token1">(</span>url<span class="token1">,</span> param<span class="token1">,</span> <span class="token2">function</span> <span class="token1">(</span>data<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="token5">//只能有一条数据为default</span>
$shop_express_search<span class="token1">[</span><span class="token4">'user_is_default'</span><span class="token1">]</span> <span class="token">=</span> Shop_ExpressModel<span class="token1">:</span><span class="token1">:</span>DEFAULT_TRUE<span class="token1">;</span>
$shop_express_base <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>shopExpressModel<span class="token">-</span><span class="token">></span><span class="token3">getOneByWhere</span><span class="token1">(</span>$shop_express_search<span class="token1">)</span><span class="token1">;</span>
$this<span class="token">-</span><span class="token">></span>shopExpressModel<span class="token">-</span><span class="token">></span><span class="token3">editExpress</span><span class="token1">(</span>$u_express_id<span class="token1">,</span> $shop_express_search<span class="token1">)</span><span class="token1">;</span>
$shop_express_search<span class="token1">[</span><span class="token4">'user_is_default'</span><span class="token1">]</span> <span class="token">=</span> Shop_ExpressModel<span class="token1">:</span><span class="token1">:</span>DEFAULT_TRUE<span class="token1">;</span>
$flag <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>shopExpressModel<span class="token">-</span><span class="token">></span><span class="token3">editExpress</span><span class="token1">(</span>$user_express_id<span class="token1">,</span> $shop_express_search<span class="token1">)</span><span class="token1">;</span>
```
```
##### 6.2、选择模板(waybillBind())
绑定
```
<pre class="calibre14">```
var user_express_id <span class="token">=</span> <span class="token"><</span><span class="token">?</span>php <span class="token2">if</span> <span class="token1">(</span> <span class="token">!</span><span class="token3">empty</span><span class="token1">(</span>$user_express_id<span class="token1">)</span> <span class="token1">)</span> <span class="token1">{</span> echo $user_express_id<span class="token1">;</span> <span class="token1">}</span> <span class="token2">else</span> <span class="token1">{</span> echo <span class="token6">0</span><span class="token1">;</span> <span class="token1">}</span><span class="token1">;</span> <span class="token">?</span><span class="token">></span><span class="token1">;</span>
$<span class="token1">(</span><span class="token4">'a[nctype="btn_bind"]'</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 waybill_tpl_id <span class="token">=</span> $<span class="token1">(</span>this<span class="token1">)</span><span class="token1">.</span><span class="token3">data</span><span class="token1">(</span><span class="token4">'waybill_tpl_id'</span><span class="token1">)</span><span class="token1">;</span>
$<span class="token1">.</span><span class="token3">post</span><span class="token1">(</span>SITE_URL <span class="token">+</span> <span class="token4">'?ctl=Seller_Trade_Waybill&met=waybillBind&typ=json'</span><span class="token1">,</span> <span class="token1">{</span>waybill_tpl_id<span class="token1">:</span> waybill_tpl_id<span class="token1">,</span> user_express_id<span class="token1">:</span> user_express_id<span class="token1">}</span><span class="token1">,</span> <span class="token2">function</span> <span class="token1">(</span>data<span class="token1">)</span> <span class="token1">{</span>
<span class="token1">}</span><span class="token1">)</span>
<span class="token1">}</span><span class="token1">)</span>
$waybill_tpl_id <span class="token">=</span> <span class="token3">request_int</span><span class="token1">(</span><span class="token4">'waybill_tpl_id'</span><span class="token1">)</span><span class="token1">;</span>
$shop_express_data<span class="token1">[</span><span class="token4">'waybill_tpl_id'</span><span class="token1">]</span> <span class="token">=</span> $waybill_tpl_id<span class="token1">;</span>
$flag <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>shopExpressModel<span class="token">-</span><span class="token">></span><span class="token3">editExpress</span><span class="token1">(</span>$user_express_id<span class="token1">,</span> $shop_express_data<span class="token1">)</span><span class="token1">;</span>
```
```
##### 6.3、模板设置(waybillSetting())
初始化
```
<pre class="calibre14">```
<span class="token"><</span><span class="token">?</span>php <span class="token2">if</span> <span class="token1">(</span> <span class="token">!</span><span class="token3">empty</span><span class="token1">(</span>$shop_express_data<span class="token1">[</span><span class="token4">'user_tpl_item'</span><span class="token1">]</span><span class="token1">)</span> <span class="token1">)</span> <span class="token1">{</span> <span class="token">?</span><span class="token">></span>
<span class="token"><</span><span class="token">?</span>php foreach <span class="token1">(</span> $shop_express_data<span class="token1">[</span><span class="token4">'user_tpl_item'</span><span class="token1">]</span> as $key <span class="token">=</span><span class="token">></span> $val <span class="token1">)</span> <span class="token1">{</span> <span class="token">?</span><span class="token">></span>
<span class="token"><</span><span class="token">?</span>php echo $val<span class="token1">;</span> <span class="token">?</span><span class="token">></span><span class="token1">.</span>checked <span class="token">=</span> <span class="token6">true</span><span class="token1">;</span>
<span class="token"><</span><span class="token">?</span>php <span class="token1">}</span> <span class="token">?</span><span class="token">></span>
<span class="token"><</span><span class="token">?</span>php <span class="token1">}</span> <span class="token">?</span><span class="token">></span>
```
```
表单提交
```
<pre class="calibre14">```
$<span class="token1">(</span><span class="token4">'#form'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">validator</span><span class="token1">(</span><span class="token1">{</span>
theme<span class="token1">:</span> <span class="token4">'yellow_right'</span><span class="token1">,</span>
timely<span class="token1">:</span> <span class="token6">true</span><span class="token1">,</span>
rules<span class="token1">:</span> <span class="token1">{</span><span class="token1">}</span><span class="token1">,</span>
fields<span class="token1">:</span> <span class="token1">{</span>
<span class="token4">'store_waybill_left'</span><span class="token1">:</span><span class="token4">'required;range[0.01~9999];'</span><span class="token1">,</span>
<span class="token4">'store_waybill_top'</span><span class="token1">:</span> <span class="token4">'required;range[0.01~9999];'</span><span class="token1">,</span>
<span class="token1">}</span><span class="token1">,</span>
valid<span class="token1">:</span> <span class="token2">function</span><span class="token1">(</span>form<span class="token1">)</span><span class="token1">{</span>
<span class="token5">//表单验证通过,提交表单到服务器</span>
$<span class="token1">.</span><span class="token3">post</span><span class="token1">(</span> SITE_URL <span class="token">+</span> <span class="token4">"?ctl=Seller_Trade_Waybill&met=waybillSetting&typ=json"</span><span class="token1">,</span> $<span class="token1">(</span><span class="token4">'#form'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">serialize</span><span class="token1">(</span><span class="token1">)</span><span class="token1">,</span> <span class="token2">function</span><span class="token1">(</span>data<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="token1">;</span>
$express_data<span class="token1">[</span><span class="token4">'user_tpl_item'</span><span class="token1">]</span> <span class="token">=</span> <span class="token3">array_keys</span><span class="token1">(</span>$data<span class="token1">)</span><span class="token1">;</span>
$express_data<span class="token1">[</span><span class="token4">'user_tpl_top'</span><span class="token1">]</span> <span class="token">=</span> <span class="token3">request_int</span><span class="token1">(</span><span class="token4">'store_waybill_top'</span><span class="token1">)</span><span class="token1">;</span>
$express_data<span class="token1">[</span><span class="token4">'user_tpl_left'</span><span class="token1">]</span> <span class="token">=</span> <span class="token3">request_int</span><span class="token1">(</span><span class="token4">'store_waybill_left'</span><span class="token1">)</span><span class="token1">;</span>
$flag <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>shopExpressModel<span class="token">-</span><span class="token">></span><span class="token3">editExpress</span><span class="token1">(</span>$user_express_id<span class="token1">,</span> $express_data<span class="token1">)</span><span class="token1">;</span>
```
```
##### 6.4、自建模板(waybillIndex())
6.4.1、添加模板(addTpl())
视图文件:
```
<pre class="calibre14">```
$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">'waybillAdd'</span><span class="token1">)</span><span class="token1">;</span>
```
```
提交表单
```
<pre class="calibre14">```
$<span class="token1">.</span><span class="token3">post</span><span class="token1">(</span> SITE_URL <span class="token">+</span> <span class="token4">"?ctl=Seller_Trade_Waybill&typ=json&met="</span> <span class="token">+</span> met<span class="token1">,</span> $<span class="token1">(</span><span class="token4">'#form'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">serialize</span><span class="token1">(</span><span class="token1">)</span><span class="token1">,</span> <span class="token2">function</span><span class="token1">(</span>data<span class="token1">)</span> <span class="token1">{</span>
<span class="token2">if</span><span class="token1">(</span> data<span class="token1">.</span>status <span class="token">==</span> <span class="token6">200</span> <span class="token1">)</span> <span class="token1">{</span>
Public<span class="token1">.</span><span class="token3">tips</span><span class="token1">(</span><span class="token1">{</span> content<span class="token1">:</span> <span class="token4">'<?=__('</span>保存成功<span class="token4">')?>!'</span><span class="token1">,</span> type<span class="token1">:</span> <span class="token6">3</span> <span class="token1">}</span><span class="token1">)</span><span class="token1">;</span>
<span class="token3">setTimeout</span><span class="token1">(</span><span class="token2">function</span> <span class="token1">(</span><span class="token1">)</span> <span class="token1">{</span>
window<span class="token1">.</span>location<span class="token1">.</span>href <span class="token">=</span> SITE_URL <span class="token">+</span> <span class="token4">'?ctl=Seller_Trade_Waybill&met=waybillIndex&typ=e'</span><span class="token1">;</span>
<span class="token1">}</span><span class="token1">,</span> <span class="token6">1000</span><span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span> <span class="token2">else</span> <span class="token1">{</span>
Public<span class="token1">.</span><span class="token3">tips</span><span class="token1">(</span><span class="token1">{</span> content<span class="token1">:</span> <span class="token4">'<?=__('</span>保存失败<span class="token4">')?>!'</span><span class="token1">,</span> type<span class="token1">:</span> <span class="token6">1</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>
```
```
6.4.2、编辑模板(editTpl())
视图文件:
```
<pre class="calibre14">```
$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">'waybillAdd'</span><span class="token1">)</span><span class="token1">;</span>
```
```
表单提交与6.4.1中表单提交一致。
6.4.3、删除模板
```
<pre class="calibre14">```
$<span class="token1">(</span><span class="token4">'a[nctype="btn_del"]'</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 _this <span class="token">=</span> $<span class="token1">(</span>this<span class="token1">)</span><span class="token1">,</span>waybill_tpl_id <span class="token">=</span> _this<span class="token1">.</span><span class="token3">data</span><span class="token1">(</span><span class="token4">'waybill_tpl_id'</span><span class="token1">)</span><span class="token1">;</span>
$<span class="token1">.</span><span class="token3">post</span><span class="token1">(</span>SITE_URL <span class="token">+</span> <span class="token4">'?ctl=Seller_Trade_Waybill&met=removeTpl&typ=json'</span><span class="token1">,</span> <span class="token1">{</span>waybill_tpl_id<span class="token1">:</span> waybill_tpl_id<span class="token1">}</span><span class="token1">,</span> <span class="token2">function</span> <span class="token1">(</span>data<span class="token1">)</span> <span class="token1">{</span>
<span class="token1">}</span><span class="token1">)</span>
<span class="token1">}</span><span class="token1">)</span>
$flag <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>logisticsWaybillModel<span class="token">-</span><span class="token">></span><span class="token3">removeTpl</span><span class="token1">(</span>$waybill_tpl_id<span class="token1">)</span><span class="token1">;</span>
```
```
6.4.4、测试模板(testTpl())
视图文件:
```
<pre class="calibre14">```
$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">'waybillTest'</span><span class="token1">)</span><span class="token1">;</span>
```
```
打印运单:
```
<pre class="calibre14">```
$<span class="token1">(</span><span class="token4">'#btn'</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="token3">pos</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
$<span class="token1">(</span><span class="token4">'.waybill_back'</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">'.control'</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>
window<span class="token1">.</span><span class="token3">print</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>
var pos <span class="token">=</span> <span class="token2">function</span> <span class="token1">(</span><span class="token1">)</span> <span class="token1">{</span>
var top <span class="token">=</span> <span class="token"><</span><span class="token">?</span><span class="token">=</span> $waybill_data<span class="token1">[</span><span class="token4">'waybill_tpl_top'</span><span class="token1">]</span><span class="token1">;</span> <span class="token">?</span><span class="token">></span><span class="token1">;</span>
var left <span class="token">=</span> <span class="token"><</span><span class="token">?</span><span class="token">=</span> $waybill_data<span class="token1">[</span><span class="token4">'waybill_tpl_left'</span><span class="token1">]</span><span class="token1">;</span> <span class="token">?</span><span class="token">></span><span class="token1">;</span>
$<span class="token1">(</span><span class="token4">".waybill_design"</span><span class="token1">)</span><span class="token1">.</span><span class="token3">each</span><span class="token1">(</span><span class="token2">function</span><span class="token1">(</span>index<span class="token1">)</span> <span class="token1">{</span>
var offset <span class="token">=</span> $<span class="token1">(</span>this<span class="token1">)</span><span class="token1">.</span><span class="token3">offset</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
var offset_top <span class="token">=</span> offset<span class="token1">.</span>top <span class="token">+</span> top<span class="token1">;</span>
var offset_left <span class="token">=</span> offset<span class="token1">.</span>left <span class="token">+</span> left<span class="token1">;</span>
$<span class="token1">(</span>this<span class="token1">)</span><span class="token1">.</span><span class="token3">offset</span><span class="token1">(</span><span class="token1">{</span> top<span class="token1">:</span> offset_top<span class="token1">,</span> left<span class="token1">:</span> offset_left<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>
```
```
6.4.5、设计模板(designTpl())
视图文件:
```
<pre class="calibre14">```
$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">'waybillDesign'</span><span class="token1">)</span><span class="token1">;</span>
```
```
提交表单
```
<pre class="calibre14">```
$<span class="token1">(</span><span class="token4">'#submit'</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="token3">post</span><span class="token1">(</span>SITE_URL <span class="token">+</span> <span class="token4">'?ctl=Seller_Trade_Waybill&met=designTpl&typ=json'</span><span class="token1">,</span> $<span class="token1">(</span><span class="token4">'#form'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">serialize</span><span class="token1">(</span><span class="token1">)</span><span class="token1">,</span> <span class="token2">function</span> <span class="token1">(</span>data<span class="token1">)</span><span class="token1">{</span>
<span class="token2">if</span><span class="token1">(</span> data<span class="token1">.</span>status <span class="token">==</span> <span class="token6">200</span> <span class="token1">)</span> <span class="token1">{</span>
Public<span class="token1">.</span><span class="token3">tips</span><span class="token1">(</span><span class="token1">{</span> content<span class="token1">:</span> <span class="token4">"<?=__('修改成功')?>"</span><span class="token1">,</span> type<span class="token1">:</span> <span class="token6">3</span> <span class="token1">}</span><span class="token1">)</span><span class="token1">;</span>
<span class="token3">setTimeout</span><span class="token1">(</span><span class="token2">function</span> <span class="token1">(</span><span class="token1">)</span> <span class="token1">{</span>
window<span class="token1">.</span>location<span class="token1">.</span>href <span class="token">=</span> SITE_URL <span class="token">+</span> <span class="token4">'?ctl=Seller_Trade_Waybill&met=waybillIndex&typ=e'</span><span class="token1">;</span>
<span class="token1">}</span><span class="token1">)</span>
<span class="token1">}</span> <span class="token2">else</span> <span class="token1">{</span>
Public<span class="token1">.</span><span class="token3">tips</span><span class="token1">(</span><span class="token1">{</span> content<span class="token1">:</span> <span class="token4">"<?=__('修改失败')?>"</span><span class="token1">,</span> type<span class="token1">:</span> <span class="token6">1</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="token1">)</span>
$flag <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>logisticsWaybillModel<span class="token">-</span><span class="token">></span><span class="token3">editTpl</span><span class="token1">(</span>$waybill_tpl_id<span class="token1">,</span> $waybill_edit_data<span class="token1">)</span><span class="token1">;</span>
```
```
#### 7、评价管理
文件路径:shop/controllers/Seller/Goods/Evaluation.php
来自买家的评价(evaluation())
```
<pre class="calibre14">```
$data <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>goodsEvaluationModel<span class="token">-</span><span class="token">></span><span class="token3">getEvaluationList</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>
```
```
解释:
视图文件
```
<pre class="calibre14">```
$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">'explain'</span><span class="token1">)</span><span class="token1">;</span>
```
```
表单提交
```
<pre class="calibre14">```
$<span class="token1">(</span><span class="token4">"#add_form"</span><span class="token1">)</span><span class="token1">.</span><span class="token3">ajaxSubmit</span><span class="token1">(</span><span class="token2">function</span><span class="token1">(</span>message<span class="token1">)</span><span class="token1">{</span>
<span class="token2">if</span><span class="token1">(</span>message<span class="token1">.</span>status <span class="token">==</span> <span class="token6">200</span><span class="token1">)</span>
<span class="token1">{</span>
location<span class="token1">.</span>href<span class="token">=</span><span class="token4">"<?=Yf_Registry::get('url')?>?ctl=Seller_Goods_Evaluation&met=evaluation"</span><span class="token1">;</span>
<span class="token1">}</span>
<span class="token2">else</span>
<span class="token1">{</span>
Public<span class="token1">.</span>tips<span class="token1">.</span><span class="token3">error</span><span class="token1">(</span><span class="token4">'<?=__('</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><span class="token1">;</span>
```
```
#### 8、物流工具
文件路径:shop/controllers/Seller/TransportlCtl.php
8.1、运费模板设置(transport())
视图文件:
```
<pre class="calibre14">```
$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">'template'</span><span class="token1">)</span><span class="token1">;</span>
```
```
数据获取:
```
<pre class="calibre14">```
$data <span class="token">=</span> $this<span class="token">-</span><span class="token">></span><span class="token3">template</span><span class="token1">(</span>$shop_id<span class="token1">)</span><span class="token1">;</span>
```
```
8.2、添加/编辑运费模板(transport())
数据获取:
```
<pre class="calibre14">```
$data <span class="token">=</span> $this<span class="token">-</span><span class="token">></span><span class="token3">transport_default</span><span class="token1">(</span>$id<span class="token1">,</span>$shop_id<span class="token1">)</span><span class="token1">;</span>
```
```
添加规则:
```
<pre class="calibre14">```
$<span class="token1">(</span><span class="token4">'.trans-line'</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">'.t_addRule'</span><span class="token1">,</span><span class="token2">function</span><span class="token1">(</span><span class="token1">)</span><span class="token1">{</span>
StartNum <span class="token">+</span><span class="token">=</span><span class="token6">1</span><span class="token1">;</span>
cell <span class="token">=</span> RuleCell<span class="token1">.</span><span class="token3">replace</span><span class="token1">(</span><span class="token">/</span>CurNum<span class="token">/</span>g<span class="token1">,</span>StartNum<span class="token1">)</span><span class="token1">;</span>
$<span class="token1">(</span>this<span class="token1">)</span><span class="token1">.</span><span class="token3">parent</span><span class="token1">(</span><span class="token1">)</span><span class="token1">.</span><span class="token3">parent</span><span class="token1">(</span><span class="token1">)</span><span class="token1">.</span><span class="token3">find</span><span class="token1">(</span><span class="token4">'.tbl-except'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">find</span><span class="token1">(</span><span class="token4">'table'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">append</span><span class="token1">(</span>cell<span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span><span class="token1">)</span><span class="token1">;</span>
```
```
编辑规则:
```
<pre class="calibre14">```
$<span class="token1">(</span><span class="token4">'.trans-line'</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">'a[entype="t_editArea"]'</span><span class="token1">,</span><span class="token2">function</span> <span class="token1">(</span><span class="token1">)</span> <span class="token1">{</span>
curTransType <span class="token">=</span> <span class="token4">'kd'</span><span class="token1">;</span>
<span class="token5">//取消所有已选择的checkbox</span>
$<span class="token1">(</span><span class="token4">'#J_CityList'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">find</span><span class="token1">(</span><span class="token4">'input[type="checkbox"]'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">attr</span><span class="token1">(</span><span class="token4">'checked'</span><span class="token1">,</span><span class="token6">false</span><span class="token1">)</span><span class="token1">.</span><span class="token3">attr</span><span class="token1">(</span><span class="token4">'disabled'</span><span class="token1">,</span><span class="token6">false</span><span class="token1">)</span><span class="token1">;</span>
<span class="token5">//取消显示所有统计数量</span>
$<span class="token1">(</span><span class="token4">'#J_CityList'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">find</span><span class="token1">(</span><span class="token4">'.check_num'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">html</span><span class="token1">(</span><span class="token4">''</span><span class="token1">)</span><span class="token1">;</span>
<span class="token5">//记录当前行的标识n1,n2,n3....</span>
curIndex <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-group'</span><span class="token1">)</span><span class="token1">;</span>
<span class="token5">//记录当前操作的行,选择完地区会向该区域抛出值</span>
objCurlArea <span class="token">=</span> $<span class="token1">(</span><span class="token4">'tr[data-group="'</span><span class="token">+</span>curIndex<span class="token">+</span><span class="token4">'"]'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">children</span><span class="token1">(</span><span class="token6">1</span><span class="token1">)</span><span class="token1">;</span>
<span class="token5">//记录已选择的所有省及市的value,SelectArea下标为value值,值为true,如江苏省SelectArea[320000]=true,南京市SelectArea[320100]=true</span>
SelectArea <span class="token">=</span> <span class="token2">new</span> <span class="token3">Array</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
<span class="token5">//取得当前行隐藏域内的city值,放入SelectArea数组中</span>
var expAreas <span class="token">=</span> $<span class="token1">(</span><span class="token4">'input[name="areas['</span><span class="token">+</span>curTransType<span class="token">+</span><span class="token4">']['</span><span class="token">+</span>curIndex<span class="token1">.</span><span class="token3">substring</span><span class="token1">(</span><span class="token6">1</span><span class="token1">)</span><span class="token">+</span><span class="token4">']"]'</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>
expAreas <span class="token">=</span> expAreas<span class="token1">.</span><span class="token3">split</span><span class="token1">(</span><span class="token4">'|||'</span><span class="token1">)</span><span class="token1">;</span>
expAreas <span class="token">=</span> expAreas<span class="token1">[</span><span class="token6">0</span><span class="token1">]</span><span class="token1">.</span><span class="token3">split</span><span class="token1">(</span><span class="token4">','</span><span class="token1">)</span><span class="token1">;</span>
<span class="token2">try</span><span class="token1">{</span>
<span class="token2">if</span><span class="token1">(</span>expAreas<span class="token1">[</span><span class="token6">0</span><span class="token1">]</span> <span class="token">!=</span> <span class="token4">''</span><span class="token1">)</span><span class="token1">{</span>
<span class="token2">for</span><span class="token1">(</span>var v <span class="token2">in</span> expAreas<span class="token1">)</span><span class="token1">{</span>
SelectArea<span class="token1">[</span>expAreas<span class="token1">[</span>v<span class="token1">]</span><span class="token1">]</span> <span class="token">=</span> <span class="token6">true</span><span class="token1">;</span>
<span class="token1">}</span>
<span class="token1">}</span>
<span class="token5">//初始化已选中的checkbox</span>
$<span class="token1">(</span><span class="token4">'#J_CityList'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">find</span><span class="token1">(</span><span class="token4">'.district-province'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">each</span><span class="token1">(</span><span class="token2">function</span><span class="token1">(</span><span class="token1">)</span><span class="token1">{</span>
var count <span class="token">=</span> <span class="token6">0</span><span class="token1">;</span>
$<span class="token1">(</span>this<span class="token1">)</span><span class="token1">.</span><span class="token3">find</span><span class="token1">(</span><span class="token4">'input[type="checkbox"]'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">each</span><span class="token1">(</span><span class="token2">function</span><span class="token1">(</span><span class="token1">)</span><span class="token1">{</span>
<span class="token2">if</span><span class="token1">(</span>SelectArea<span class="token1">[</span>$<span class="token1">(</span>this<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><span class="token">==</span><span class="token6">true</span><span class="token1">)</span><span class="token1">{</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">'checked'</span><span class="token1">,</span><span class="token6">true</span><span class="token1">)</span><span class="token1">;</span>
<span class="token2">if</span><span class="token1">(</span>$<span class="token1">(</span>this<span class="token1">)</span><span class="token1">[</span><span class="token6">0</span><span class="token1">]</span><span class="token1">.</span>className<span class="token">!=</span><span class="token4">'J_Province'</span><span class="token1">)</span> count<span class="token">++</span><span class="token1">;</span>
<span class="token1">}</span>
<span class="token1">}</span><span class="token1">)</span><span class="token1">;</span>
<span class="token2">if</span> <span class="token1">(</span>count <span class="token">></span> <span class="token6">0</span><span class="token1">)</span><span class="token1">{</span>
$<span class="token1">(</span>this<span class="token1">)</span><span class="token1">.</span><span class="token3">find</span><span class="token1">(</span><span class="token4">'.check_num'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">html</span><span class="token1">(</span><span class="token4">'('</span><span class="token">+</span>count<span class="token">+</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><span class="token1">;</span>
<span class="token5">//循环每一行,如果一行省都选中,则大区载选中</span>
$<span class="token1">(</span><span class="token4">'#J_CityList>li'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">each</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>this<span class="token1">)</span><span class="token1">.</span><span class="token3">find</span><span class="token1">(</span><span class="token4">'.region_group'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">attr</span><span class="token1">(</span><span class="token4">'checked'</span><span class="token1">,</span><span class="token6">true</span><span class="token1">)</span><span class="token1">;</span>
father <span class="token">=</span> this<span class="token1">;</span>
$<span class="token1">(</span>this<span class="token1">)</span><span class="token1">.</span><span class="token3">find</span><span class="token1">(</span><span class="token4">'.J_Province'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">each</span><span class="token1">(</span><span class="token2">function</span><span class="token1">(</span><span class="token1">)</span><span class="token1">{</span>
<span class="token2">if</span> <span class="token1">(</span><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">'checked'</span><span class="token1">)</span><span class="token1">)</span><span class="token1">{</span>
$<span class="token1">(</span>father<span class="token1">)</span><span class="token1">.</span><span class="token3">find</span><span class="token1">(</span><span class="token4">'.region_group'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">attr</span><span class="token1">(</span><span class="token4">'checked'</span><span class="token1">,</span><span class="token6">false</span><span class="token1">)</span><span class="token1">;</span>
<span class="token2">return</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="token1">;</span>
<span class="token1">}</span><span class="token2">catch</span><span class="token1">(</span>ex<span class="token1">)</span><span class="token1">{</span><span class="token1">}</span>
<span class="token5">//其它行已选择的地区,不能再选择了</span>
$<span class="token1">(</span>objCurlArea<span class="token1">)</span><span class="token1">.</span><span class="token3">parent</span><span class="token1">(</span><span class="token1">)</span><span class="token1">.</span><span class="token3">parent</span><span class="token1">(</span><span class="token1">)</span><span class="token1">.</span><span class="token3">find</span><span class="token1">(</span><span class="token4">'.area-group'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">each</span><span class="token1">(</span><span class="token2">function</span><span class="token1">(</span><span class="token1">)</span><span class="token1">{</span>
<span class="token2">if</span> <span class="token1">(</span>$<span class="token1">(</span>this<span class="token1">)</span><span class="token1">.</span><span class="token3">next</span><span class="token1">(</span><span class="token1">)</span><span class="token1">.</span><span class="token3">attr</span><span class="token1">(</span><span class="token4">'name'</span><span class="token1">)</span> <span class="token">!=</span> <span class="token4">'areas['</span><span class="token">+</span>curTransType<span class="token">+</span><span class="token4">']['</span><span class="token">+</span>curIndex<span class="token1">.</span><span class="token3">substring</span><span class="token1">(</span><span class="token6">1</span><span class="token1">)</span><span class="token">+</span><span class="token4">']'</span><span class="token1">)</span><span class="token1">{</span>
expAreas <span class="token">=</span> $<span class="token1">(</span>this<span class="token1">)</span><span class="token1">.</span><span class="token3">next</span><span class="token1">(</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><span class="token3">split</span><span class="token1">(</span><span class="token4">'|||'</span><span class="token1">)</span><span class="token1">;</span>
expAreas <span class="token">=</span> expAreas<span class="token1">[</span><span class="token6">0</span><span class="token1">]</span><span class="token1">.</span><span class="token3">split</span><span class="token1">(</span><span class="token4">','</span><span class="token1">)</span><span class="token1">;</span>
<span class="token5">//重置SelectArea</span>
SelectArea <span class="token">=</span> <span class="token2">new</span> <span class="token3">Array</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
<span class="token2">try</span><span class="token1">{</span>
<span class="token2">if</span><span class="token1">(</span>expAreas<span class="token1">[</span><span class="token6">0</span><span class="token1">]</span> <span class="token">!=</span> <span class="token4">''</span><span class="token1">)</span><span class="token1">{</span>
<span class="token2">for</span><span class="token1">(</span>var v <span class="token2">in</span> expAreas<span class="token1">)</span><span class="token1">{</span>
SelectArea<span class="token1">[</span>expAreas<span class="token1">[</span>v<span class="token1">]</span><span class="token1">]</span> <span class="token">=</span> <span class="token6">true</span><span class="token1">;</span>
<span class="token1">}</span>
<span class="token1">}</span>
<span class="token5">//其它行已选中的在这里都置灰</span>
$<span class="token1">(</span><span class="token4">'#J_CityList'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">find</span><span class="token1">(</span><span class="token4">'input[type="checkbox"]'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">each</span><span class="token1">(</span><span class="token2">function</span><span class="token1">(</span><span class="token1">)</span><span class="token1">{</span>
<span class="token2">if</span><span class="token1">(</span>SelectArea<span class="token1">[</span>$<span class="token1">(</span>this<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><span class="token">==</span><span class="token6">true</span><span class="token1">)</span><span class="token1">{</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">'disabled'</span><span class="token1">,</span><span class="token6">true</span><span class="token1">)</span><span class="token1">.</span><span class="token3">attr</span><span class="token1">(</span><span class="token4">'checked'</span><span class="token1">,</span><span class="token6">false</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="token5">//循环每一行,如果一行的省都被disabled,则大区域也disabled</span>
$<span class="token1">(</span><span class="token4">'#J_CityList>li'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">each</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>this<span class="token1">)</span><span class="token1">.</span><span class="token3">find</span><span class="token1">(</span><span class="token4">'.region_group'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">attr</span><span class="token1">(</span><span class="token4">'disabled'</span><span class="token1">,</span><span class="token6">true</span><span class="token1">)</span><span class="token1">;</span>
father <span class="token">=</span> this<span class="token1">;</span>
$<span class="token1">(</span>this<span class="token1">)</span><span class="token1">.</span><span class="token3">find</span><span class="token1">(</span><span class="token4">'.J_Province'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">each</span><span class="token1">(</span><span class="token2">function</span><span class="token1">(</span><span class="token1">)</span><span class="token1">{</span>
<span class="token2">if</span> <span class="token1">(</span><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">'disabled'</span><span class="token1">)</span><span class="token1">)</span><span class="token1">{</span>
$<span class="token1">(</span>father<span class="token1">)</span><span class="token1">.</span><span class="token3">find</span><span class="token1">(</span><span class="token4">'.region_group'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">attr</span><span class="token1">(</span><span class="token4">'disabled'</span><span class="token1">,</span><span class="token6">false</span><span class="token1">)</span><span class="token1">;</span>
<span class="token2">return</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="token1">;</span>
<span class="token1">}</span><span class="token2">catch</span><span class="token1">(</span>ex<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="token5">//定位弹出层的坐标</span>
$<span class="token1">(</span><span class="token4">"#dialog_areas"</span><span class="token1">)</span><span class="token1">.</span><span class="token3">css</span><span class="token1">(</span><span class="token1">{</span><span class="token4">'position'</span> <span class="token1">:</span> <span class="token4">'absolute'</span><span class="token1">,</span><span class="token4">'display'</span> <span class="token1">:</span> <span class="token4">'block'</span><span class="token1">,</span> <span class="token4">'z-index'</span> <span class="token1">:</span> <span class="token4">'9999'</span><span class="token1">,</span><span class="token4">'top'</span><span class="token1">:</span><span class="token4">'20%'</span><span class="token1">,</span><span class="token4">'border'</span><span class="token1">:</span><span class="token4">'1px solid #E6E6E6'</span><span class="token1">}</span><span class="token1">)</span><span class="token1">;</span>
$<span class="token1">(</span><span class="token4">'.ks-ext-mask'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">css</span><span class="token1">(</span><span class="token4">'display'</span><span class="token1">,</span><span class="token4">'block'</span><span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span><span class="token1">)</span><span class="token1">;</span>
```
```
删除一行规则:
```
<pre class="calibre14">```
$<span class="token1">(</span><span class="token4">'.trans-line'</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">'.t_deleteRule'</span><span class="token1">,</span><span class="token2">function</span> <span class="token1">(</span><span class="token1">)</span><span class="token1">{</span>
curDelNum <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">'ncNum'</span><span class="token1">)</span><span class="token1">;</span>
$<span class="token1">.</span>dialog<span class="token1">.</span><span class="token3">confirm</span><span class="token1">(</span><span class="token4">'<?=__('</span>确认删除吗<span class="token4">')?>?'</span><span class="token1">,</span><span class="token2">function</span><span class="token1">(</span><span class="token1">)</span><span class="token1">{</span>
curTransType <span class="token">=</span> <span class="token4">'kd'</span><span class="token1">;</span>
obj_parent <span class="token">=</span> $<span class="token1">(</span><span class="token4">'tr[data-group="'</span><span class="token">+</span>curDelNum<span class="token">+</span><span class="token4">'"]'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">parent</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
$<span class="token1">(</span><span class="token4">'tr[data-group="'</span><span class="token">+</span>curDelNum<span class="token">+</span><span class="token4">'"]'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">remove</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
<span class="token2">if</span> <span class="token1">(</span>$<span class="token1">(</span>obj_parent<span class="token1">)</span><span class="token1">.</span><span class="token3">find</span><span class="token1">(</span><span class="token4">'tr'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">html</span><span class="token1">(</span><span class="token1">)</span> <span class="token">==</span> <span class="token2">null</span><span class="token1">)</span><span class="token1">{</span>
$<span class="token1">(</span>obj_parent<span class="token1">)</span><span class="token1">.</span><span class="token3">parent</span><span class="token1">(</span><span class="token1">)</span><span class="token1">.</span><span class="token3">parent</span><span class="token1">(</span><span class="token1">)</span><span class="token1">.</span><span class="token3">parent</span><span class="token1">(</span><span class="token1">)</span><span class="token1">.</span><span class="token3">find</span><span class="token1">(</span><span class="token4">'.batch'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">css</span><span class="token1">(</span><span class="token4">'display'</span><span class="token1">,</span><span class="token4">'none'</span><span class="token1">)</span><span class="token1">;</span>
$<span class="token1">(</span>obj_parent<span class="token1">)</span><span class="token1">.</span><span class="token3">parent</span><span class="token1">(</span><span class="token1">)</span><span class="token1">.</span><span class="token3">parent</span><span class="token1">(</span><span class="token1">)</span><span class="token1">.</span><span class="token3">parent</span><span class="token1">(</span><span class="token1">)</span><span class="token1">.</span><span class="token3">find</span><span class="token1">(</span><span class="token4">'.J_ToggleBatch'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">css</span><span class="token1">(</span><span class="token4">'display'</span><span class="token1">,</span><span class="token4">'none'</span><span class="token1">)</span><span class="token1">;</span>
$<span class="token1">(</span>obj_parent<span class="token1">)</span><span class="token1">.</span><span class="token3">parent</span><span class="token1">(</span><span class="token1">)</span><span class="token1">.</span><span class="token3">parent</span><span class="token1">(</span><span class="token1">)</span><span class="token1">.</span><span class="token3">parent</span><span class="token1">(</span><span class="token1">)</span><span class="token1">.</span><span class="token3">find</span><span class="token1">(</span><span class="token4">'.batch'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">next</span><span class="token1">(</span><span class="token1">)</span><span class="token1">.</span><span class="token3">find</span><span class="token1">(</span><span class="token4">'span'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">css</span><span class="token1">(</span><span class="token4">'display'</span><span class="token1">,</span><span class="token4">'none'</span><span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span><span class="token2">else</span><span class="token1">{</span>
<span class="token5">//如果该配送方式,地区都不为空,隐藏地区的提示层</span>
isRemove <span class="token">=</span> <span class="token6">true</span><span class="token1">;</span>
$<span class="token1">(</span><span class="token4">'div[data-delivery="'</span><span class="token">+</span>curTransType<span class="token">+</span><span class="token4">'"]'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">find</span><span class="token1">(</span><span class="token4">'input[type="hidden"]'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">each</span><span class="token1">(</span><span class="token2">function</span><span class="token1">(</span><span class="token1">)</span><span class="token1">{</span>
<span class="token2">if</span> <span class="token1">(</span>$<span class="token1">(</span>this<span class="token1">)</span><span class="token1">.</span><span class="token3">val</span><span class="token1">(</span><span class="token1">)</span><span class="token">==</span><span class="token4">''</span><span class="token1">)</span><span class="token1">{</span>
isRemove <span class="token">=</span> <span class="token6">false</span><span class="token1">;</span><span class="token2">return</span> <span class="token6">false</span><span class="token1">;</span>
<span class="token1">}</span>
<span class="token1">}</span><span class="token1">)</span><span class="token1">;</span>
<span class="token2">if</span> <span class="token1">(</span>isRemove <span class="token">==</span> <span class="token6">true</span><span class="token1">)</span><span class="token1">{</span>
$<span class="token1">(</span><span class="token4">'div[data-delivery="'</span><span class="token">+</span>curTransType<span class="token">+</span><span class="token4">'"]'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">find</span><span class="token1">(</span><span class="token4">'span[error_type="area"]'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">css</span><span class="token1">(</span><span class="token4">'display'</span><span class="token1">,</span><span class="token4">'none'</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="token1">}</span><span class="token1">)</span><span class="token1">;</span>
```
```
表单提交:
```
<pre class="calibre14">```
var form_data <span class="token">=</span> $<span class="token1">(</span><span class="token4">'#transport_form'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">serialize</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
var url <span class="token">=</span> <span class="token4">"<?=Yf_Registry::get('url')?>?ctl=Seller_Transport&met=transportSubmit&typ=json"</span><span class="token1">;</span>
$<span class="token1">.</span><span class="token3">post</span><span class="token1">(</span>url<span class="token1">,</span>form_data<span class="token1">,</span><span class="token2">function</span><span class="token1">(</span>resp<span class="token1">)</span><span class="token1">{</span>
<span class="token2">if</span><span class="token1">(</span>resp<span class="token1">.</span>status <span class="token">==</span> <span class="token6">200</span><span class="token1">)</span><span class="token1">{</span>
window<span class="token1">.</span>location<span class="token1">.</span>href <span class="token">=</span> <span class="token4">"<?=Yf_Registry::get('url')?>?ctl=Seller_Transport&met=transport&typ=e"</span><span class="token1">;</span>
<span class="token1">}</span><span class="token2">else</span><span class="token1">{</span>
Public<span class="token1">.</span><span class="token3">tips</span><span class="token1">(</span><span class="token1">{</span>type<span class="token1">:</span> <span class="token6">1</span><span class="token1">,</span> content<span class="token1">:</span> resp<span class="token1">.</span>msg<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">'json'</span><span class="token1">)</span><span class="token1">;</span>
<span class="token5">//修改模板</span>
$res_info <span class="token">=</span> $Transport_TemplateModel<span class="token">-</span><span class="token">></span><span class="token3">templateAdd</span><span class="token1">(</span>$template_data<span class="token1">)</span><span class="token1">;</span>
<span class="token5">//添加模板</span>
$res_info <span class="token">=</span> $Transport_TemplateModel<span class="token">-</span><span class="token">></span><span class="token3">templateModify</span><span class="token1">(</span>$template_id<span class="token1">,</span>$template_data<span class="token1">)</span><span class="token1">;</span>
<span class="token5">//批量删除规则</span>
$flag2 <span class="token">=</span> $Transport_RuleModel<span class="token">-</span><span class="token">></span><span class="token3">delAllRule</span><span class="token1">(</span>$template_id<span class="token1">)</span><span class="token1">;</span>
<span class="token5">//批量添加规则</span>
foreach <span class="token1">(</span>$transport<span class="token1">[</span>$type<span class="token1">]</span> as $key<span class="token">=</span><span class="token">></span>$value<span class="token1">)</span><span class="token1">{</span>
$flag <span class="token">=</span> $Transport_RuleModel<span class="token">-</span><span class="token">></span><span class="token3">addRule</span><span class="token1">(</span>$rule_data<span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
```
```
8.3、删除模板
```
<pre class="calibre14">```
<span class="token"><</span>span class<span class="token">=</span><span class="token4">"del"</span><span class="token">></span><span class="token"><</span>a data<span class="token">-</span>param<span class="token">=</span><span class="token4">"{'ctl':'Seller_Transport','met':'delTemplate','id':'<?=$value['id']?>'}"</span> href<span class="token">=</span><span class="token4">"javascript:void(0)"</span><span class="token">></span><span class="token"><</span>i class<span class="token">=</span><span class="token4">"iconfont icon-lajitong"</span><span class="token">></span><span class="token"><</span><span class="token">/</span>i<span class="token">></span><span class="token"><</span><span class="token">?</span><span class="token">=</span><span class="token3">__</span><span class="token1">(</span><span class="token4">'删除'</span><span class="token1">)</span><span class="token">?</span><span class="token">></span><span class="token"><</span><span class="token">/</span>a<span class="token">></span><span class="token"><</span><span class="token">/</span>span<span class="token">></span>
$flag <span class="token">=</span> $Transport_TemplateModel<span class="token">-</span><span class="token">></span><span class="token3">templateDel</span><span class="token1">(</span>$transport_template_id<span class="token1">,</span>$shop_id<span class="token1">)</span><span class="token1">;</span>
```
```
#### 9、售卖区域
文件路径:shop/controllers/Seller/TransportlCtl.php
9.1、售卖区域模板设置(tplarea())
视图文件:
```
<pre class="calibre14">```
$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">'transportArea'</span><span class="token1">)</span><span class="token1">;</span>
```
```
数据获取:
```
<pre class="calibre14">```
$data <span class="token">=</span> $this<span class="token">-</span><span class="token">></span><span class="token3">transport_area</span><span class="token1">(</span>$shop_id<span class="token1">)</span><span class="token1">;</span>
```
```
9.2、添加/编辑售卖区域模板(act=area)
视图文件:
```
<pre class="calibre14">```
$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">'area'</span><span class="token1">)</span><span class="token1">;</span>
```
```
自定义中循环生成区域地址:
```
<pre class="calibre14">```
<span class="token"><</span><span class="token">?</span>php <span class="token3">foreach</span><span class="token1">(</span>$val<span class="token1">[</span><span class="token4">'city'</span><span class="token1">]</span> as $citykey <span class="token">=</span><span class="token">></span> $cityval<span class="token1">)</span><span class="token1">{</span><span class="token">?</span><span class="token">></span>
<span class="token"><</span>li<span class="token">></span><span class="token"><</span>label class<span class="token">=</span><span class="token4">"checkbox city"</span><span class="token">></span>
<span class="token"><</span>input <span class="token"><</span><span class="token">?</span>php <span class="token2">if</span><span class="token1">(</span>$data<span class="token1">[</span><span class="token4">'data'</span><span class="token1">]</span><span class="token1">[</span><span class="token4">'area_ids_arr'</span><span class="token1">]</span> <span class="token">&&</span> <span class="token3">in_array</span><span class="token1">(</span>$cityval<span class="token1">[</span><span class="token4">'district_id'</span><span class="token1">]</span><span class="token1">,</span>$data<span class="token1">[</span><span class="token4">'data'</span><span class="token1">]</span><span class="token1">[</span><span class="token4">'area_ids_arr'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">)</span><span class="token1">{</span><span class="token">?</span><span class="token">></span>checked<span class="token">=</span><span class="token4">"checked"</span><span class="token"><</span><span class="token">?</span>php <span class="token1">}</span><span class="token">?</span><span class="token">></span> type<span class="token">=</span><span class="token4">"checkbox"</span> name<span class="token">=</span><span class="token4">"city[]"</span> data<span class="token">-</span>province<span class="token">=</span><span class="token4">"<?=($val['district_id'])?>"</span> value<span class="token">=</span><span class="token4">"<?=($cityval['district_id'])?>"</span> <span class="token">/</span><span class="token">></span><span class="token"><</span><span class="token">?</span><span class="token">=</span><span class="token1">(</span>$cityval<span class="token1">[</span><span class="token4">'district_name'</span><span class="token1">]</span><span class="token1">)</span><span class="token">?</span><span class="token">></span>
<span class="token"><</span><span class="token">/</span>label<span class="token">></span><span class="token"><</span><span class="token">/</span>li<span class="token">></span>
<span class="token"><</span><span class="token">?</span>php <span class="token1">}</span><span class="token">?</span><span class="token">></span>
```
```
表单提交路径:
```
<pre class="calibre14">```
var ajax_url <span class="token">=</span> <span class="token4">'<?= Yf_Registry::get('</span>url<span class="token4">') ?>?ctl=Seller_Transport&met=areaSubmit&typ=json'</span><span class="token1">;</span>
<span class="token5">//全国</span>
$area_ids <span class="token">=</span> <span class="token6">0</span><span class="token1">;</span>
<span class="token5">//非全国</span>
$province_ids <span class="token">=</span> <span class="token3">is_array</span><span class="token1">(</span>$area_province<span class="token1">)</span> <span class="token">&&</span> $area_province <span class="token">?</span> <span class="token3">implode</span><span class="token1">(</span><span class="token4">','</span><span class="token1">,</span> $area_province<span class="token1">)</span> <span class="token1">:</span> <span class="token4">''</span><span class="token1">;</span>
$area_ids <span class="token">=</span> <span class="token3">trim</span><span class="token1">(</span>$city_ids<span class="token1">.</span><span class="token4">','</span><span class="token1">.</span>$province_ids<span class="token1">,</span><span class="token4">','</span><span class="token1">)</span><span class="token1">;</span>
$result <span class="token">=</span> $Transport_AreaModel<span class="token">-</span><span class="token">></span><span class="token3">areaAdd</span><span class="token1">(</span>$data<span class="token1">)</span><span class="token1">;</span>
```
```
11.9.3、删除模板
```
<pre class="calibre15">```
<span class="token"><</span>span class<span class="token">=</span><span class="token4">"del"</span><span class="token">></span><span class="token"><</span>a data<span class="token">-</span>param<span class="token">=</span><span class="token4">"{'ctl':'Seller_Transport','met':'delArea','id':'<?=$value['id']?>'}"</span> <span class="token">></span><span class="token"><</span>i class<span class="token">=</span><span class="token4">"iconfont icon-lajitong"</span><span class="token">></span><span class="token"><</span><span class="token">/</span>i<span class="token">></span><span class="token"><</span><span class="token">?</span><span class="token">=</span><span class="token3">__</span><span class="token1">(</span><span class="token4">'删除'</span><span class="token1">)</span><span class="token">?</span><span class="token">></span><span class="token"><</span><span class="token">/</span>a<span class="token">></span><span class="token"><</span><span class="token">/</span>span<span class="token">></span>
$flag <span class="token">=</span> $Transport_AreaModel<span class="token">-</span><span class="token">></span><span class="token3">typeDel</span><span class="token1">(</span>$type_id<span class="token1">,</span>$shop_id<span class="token1">)</span><span class="token1">;</span>
```
```
- 序言
- 系统要求
- 版本更新日志
- 远丰商城技术对接说明
- 开发指导
- 框架内容
- 基础
- 开发规范
- 目录结构
- 架构
- 架构总览
- 数据库
- 数据库连接
- 基本使用
- 缓存
- 配置
- 路由
- 数据字典
- ucenter
- shop
- paycenter
- ucenter_admin
- shop_admin
- paycenter_admin
- 通讯内容
- 商家中心
- 顶部导航栏
- 店铺信息栏
- 店铺及商品提示栏
- 交易提示栏
- 销售情况统计栏
- 单品销量排行栏
- 店铺运营推广栏
- 平台联系方式栏
- 订单物流
- 商品
- 商品列表
- 商品详情
- 商品发布与编辑
- 分销商品
- 关联版式
- 商品规格
- 图片空间
- 淘宝导入
- 订单流程
- 交易订单
- 订单退款/退货
- 促销
- 团购管理
- 加价购
- 限时折扣
- 满即送
- 代金券管理
- 分销
- 店铺
- 店铺设置
- 自销产品供应商
- 实体店铺
- 品牌申请
- 店铺信息
- 消费者保障服务
- 门店账号
- 分销商--产品供应商
- 分销明细
- 批发市场
- 售后服务
- 咨询管理
- 投诉管理
- 退款管理
- 退货管理
- 云方案架构
- 负载集群
- 云存储
- 接口
- Api接口说明
- 品牌
- 商品规格
- 商品类型
- 商品分类
- 商品
- 订单
- 商品/店铺收藏
- 足迹
- 退款及退货
- 商家店铺
- 会员
- 入驻协议
- 订单接口
- 商品接口
- 订单物流接口
- 商家中心接口
- 促销接口
- 快递鸟物流接口
- 代金券接口
- 首页版块
- 团购
- 平台红包
- 限时折扣接口
- 拼团接口
- wap首页模板
- 杂项
- 远程上传图片
- JS
- 银联支付
- 多语言
- 商品评分
- 图片加载
- 买家申请退款退货
- 商家退款退货
- 平台退款退货
- 添加发票
- 提交订单
- 确认订单
- 运费销售区域
- 获取会员地址
- 充值
- 导出XLS
- 商城系统集成
- 多语言实现
- 三级分销推广链接发展推广员
- app.ini.php
- 去分销
- 版本更新
- 物流支持
- 运营人员建议
- 业务逻辑
- 统计结算
- 客服消息
- 账号
- 三级分销
- IM
- 配置
- 平台帐号
- 活动数据表说明