# 交易订单
购物流程:
生成订单 --> 支付订单 --> 商家发货 --> 确认收货 --> 评价订单
1.买家在生成订单之后,支付订单之前可以取消订单
2.买家在支付订单之后,商家发货之前可以申请退款
3.买家在确认收货之后可以申请退货
#### 1.生成订单
文件路径:\\shop\\controllers\\Buyer\\OrderCtl.php
控制器:Buyer\_OrderCtl
方法:addOrder()
判断选项的支付方式是否合法
```
<pre class="calibre14">```
<span class="token5">/**
* 如果不是选 在线支付 或 货到付款 ,则提示错误
*/</span>
<span class="token2">if</span><span class="token1">(</span><span class="token">!</span><span class="token3">in_array</span><span class="token1">(</span>$pay_way_id<span class="token1">,</span> <span class="token1">[</span><span class="token6">1</span><span class="token1">,</span><span class="token6">2</span><span class="token1">]</span><span class="token1">)</span><span class="token1">)</span><span class="token1">{</span>
$data <span class="token">=</span> <span class="token1">[</span><span class="token1">]</span><span class="token1">;</span>
$status <span class="token">=</span> <span class="token6">250</span><span class="token1">;</span>
$msg <span class="token">=</span> <span class="token4">"操作错误,请刷新当前页面!"</span><span class="token1">;</span>
<span class="token2">return</span> $this<span class="token">-</span><span class="token">></span>data<span class="token">-</span><span class="token">></span><span class="token3">addBody</span><span class="token1">(</span><span class="token">-</span><span class="token6">140</span><span class="token1">,</span> $data<span class="token1">,</span> $msg<span class="token1">,</span> $status<span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
```
```
检测是否存在加价购商品,若存在则检测加价购商品信息是否正确。检测加价购商品正确性后重组加价购商品的活动规则,查找出活动中所有规则下的加价购商品信息
```
<pre class="calibre14">```
<span class="token2">if</span><span class="token1">(</span>$increase_arr<span class="token1">)</span>
<span class="token1">{</span>
<span class="token5">//检验加价购商品信息是否正确</span>
$increase_price_info <span class="token">=</span> $this<span class="token">-</span><span class="token">></span><span class="token3">checkIncreaseGoods</span><span class="token1">(</span>$increase_arr<span class="token1">,</span> $cart_id<span class="token1">)</span><span class="token1">;</span>
<span class="token2">if</span><span class="token1">(</span><span class="token">!</span>$increase_price_info<span class="token1">)</span>
<span class="token1">{</span>
<span class="token2">return</span> $this<span class="token">-</span><span class="token">></span>data<span class="token">-</span><span class="token">></span><span class="token3">addBody</span><span class="token1">(</span><span class="token">-</span><span class="token6">140</span><span class="token1">,</span> <span class="token3">array</span><span class="token1">(</span><span class="token4">'code'</span><span class="token">=</span><span class="token">></span><span class="token6">1</span><span class="token1">)</span><span class="token1">,</span> <span class="token4">'failure1'</span><span class="token1">,</span> <span class="token6">250</span><span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
$increase_goods_id <span class="token">=</span> <span class="token3">array_column</span><span class="token1">(</span>$increase_arr<span class="token1">,</span> <span class="token4">'increase_goods_id'</span><span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
```
```
判断订单来源
```
<pre class="calibre14">```
<span class="token5">//wap端下单</span>
$order_from <span class="token">=</span> Order_StateModel<span class="token1">:</span><span class="token1">:</span>FROM_WAP<span class="token1">;</span>
<span class="token5">//pc端下单</span>
$order_from <span class="token">=</span> Order_StateModel<span class="token1">:</span><span class="token1">:</span>FROM_PC<span class="token1">;</span>
```
```
判断支付方式为在线支付还是货到付款,如果是货到付款则订单状态直接为待发货状态,如果是在线支付则订单状态为待付款
```
<pre class="calibre14">```
<span class="token2">if</span><span class="token1">(</span>$pay_way_id <span class="token">==</span> PaymentChannlModel<span class="token1">:</span><span class="token1">:</span>PAY_ONLINE<span class="token1">)</span>
<span class="token1">{</span>
$order_status <span class="token">=</span> Order_StateModel<span class="token1">:</span><span class="token1">:</span>ORDER_WAIT_PAY<span class="token1">;</span>
<span class="token1">}</span>
<span class="token2">if</span><span class="token1">(</span>$pay_way_id <span class="token">==</span> PaymentChannlModel<span class="token1">:</span><span class="token1">:</span>PAY_CONFIRM<span class="token1">)</span>
<span class="token1">{</span>
$order_status <span class="token">=</span> Order_StateModel<span class="token1">:</span><span class="token1">:</span>ORDER_WAIT_PREPARE_GOODS<span class="token1">;</span>
<span class="token1">}</span>
```
```
获取用户的平台折扣信息
```
<pre class="calibre14">```
$user_info <span class="token">=</span> $User_InfoModel<span class="token">-</span><span class="token">></span><span class="token3">getOne</span><span class="token1">(</span>$user_id<span class="token1">)</span><span class="token1">;</span>
```
```
判断是否使用了代金券,如果使用了代金券,则处理代金券的信息
```
<pre class="calibre14">```
<span class="token2">if</span> <span class="token1">(</span>$voucher_id<span class="token1">)</span>
<span class="token1">{</span>
<span class="token5">//查找代金券的信息</span>
$Voucher_BaseModel <span class="token">=</span> <span class="token2">new</span> <span class="token3">Voucher_BaseModel</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
$voucher_cond_row<span class="token1">[</span><span class="token4">'voucher_id:IN'</span><span class="token1">]</span> <span class="token">=</span> $voucher_id<span class="token1">;</span>
$voucher_row <span class="token">=</span> $Voucher_BaseModel<span class="token">-</span><span class="token">></span><span class="token3">getByWhere</span><span class="token1">(</span>$voucher_cond_row<span class="token1">)</span><span class="token1">;</span>
$shop_voucher_row <span class="token">=</span> <span class="token3">array</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
foreach <span class="token1">(</span>$voucher_row as $voukey <span class="token">=</span><span class="token">></span> $vouval<span class="token1">)</span>
<span class="token1">{</span>
$shop_voucher_row<span class="token1">[</span>$vouval<span class="token1">[</span><span class="token4">'voucher_shop_id'</span><span class="token1">]</span><span class="token1">]</span> <span class="token">=</span> $vouval<span class="token1">;</span>
<span class="token1">}</span>
<span class="token1">}</span>
```
```
根据cart\_id查找出购物车中的商品信息
```
<pre class="calibre14">```
$data <span class="token">=</span> $CartModel<span class="token">-</span><span class="token">></span><span class="token3">getCardList</span><span class="token1">(</span>$cond_row<span class="token1">,</span> $order_row<span class="token1">)</span><span class="token1">;</span>
```
```
计算购物车中每件商品的最后优惠的实际价格
1.店铺商品总价 = 加价购商品总价 + 购物车商品总价(按照限时折扣和团购价计算)
2.判断平台是否开启会员折扣只限自营店铺使用。如果是平台自营店铺需要计算会员折扣,非平台自营不需要计算折扣
3.计算每个商品订单实际支付的金额,以及每件商品的实际支付单价为多少
4.平台红包的使用情况
查找收货地址,计算运费
```
<pre class="calibre14">```
$User_AddressModel <span class="token">=</span> <span class="token2">new</span> <span class="token3">User_AddressModel</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
$city_id <span class="token">=</span> <span class="token6">0</span><span class="token1">;</span>
<span class="token2">if</span><span class="token1">(</span>$address_id<span class="token1">)</span>
<span class="token1">{</span>
$user_address <span class="token">=</span> $User_AddressModel<span class="token">-</span><span class="token">></span><span class="token3">getOne</span><span class="token1">(</span>$address_id<span class="token1">)</span><span class="token1">;</span>
$city_id <span class="token">=</span> $user_address<span class="token1">[</span><span class="token4">'user_address_city_id'</span><span class="token1">]</span><span class="token1">;</span>
<span class="token1">}</span>
$Transport_TemplateModel <span class="token">=</span> <span class="token2">new</span> <span class="token3">Transport_TemplateModel</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
$transport_cost <span class="token">=</span> $Transport_TemplateModel<span class="token">-</span><span class="token">></span><span class="token3">cartTransportCost</span><span class="token1">(</span>$city_id<span class="token1">,</span> $cart_id<span class="token1">)</span><span class="token1">;</span>
```
```
生成订单(order\_base)
```
<pre class="calibre14">```
<span class="token5">//生成订单号</span>
$prefix <span class="token">=</span> <span class="token3">sprintf</span><span class="token1">(</span><span class="token4">'%s-%s-'</span><span class="token1">,</span> Yf_Registry<span class="token1">:</span><span class="token1">:</span><span class="token3">get</span><span class="token1">(</span><span class="token4">'shop_app_id'</span><span class="token1">)</span><span class="token1">,</span> <span class="token3">date</span><span class="token1">(</span><span class="token4">'YmdHis'</span><span class="token1">)</span><span class="token1">)</span><span class="token1">;</span>
$order_number <span class="token">=</span> $Number_SeqModel<span class="token">-</span><span class="token">></span><span class="token3">createSeq</span><span class="token1">(</span>$prefix<span class="token1">)</span><span class="token1">;</span>
$order_id <span class="token">=</span> <span class="token3">sprintf</span><span class="token1">(</span><span class="token4">'%s-%s-%s-%s'</span><span class="token1">,</span> <span class="token4">'DD'</span><span class="token1">,</span> $val<span class="token1">[</span><span class="token4">'shop_user_id'</span><span class="token1">]</span><span class="token1">,</span> $key<span class="token1">,</span> $order_number<span class="token1">)</span><span class="token1">;</span>
<span class="token5">//生成订单发票信息</span>
$Order_InvoiceModel <span class="token">=</span> <span class="token2">new</span> <span class="token3">Order_InvoiceModel</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
$order_invoice_id <span class="token">=</span> $Order_InvoiceModel<span class="token">-</span><span class="token">></span><span class="token3">getOrderInvoiceId</span><span class="token1">(</span>$invoice_id<span class="token1">,</span>$invoice_title<span class="token1">,</span>$invoice_content<span class="token1">,</span>$order_id<span class="token1">)</span><span class="token1">;</span>
<span class="token5">//生成订单</span>
$flag1 <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>tradeOrderModel<span class="token">-</span><span class="token">></span><span class="token3">addBase</span><span class="token1">(</span>$order_row<span class="token1">)</span><span class="token1">;</span>
<span class="token5">//修改用户使用的红包信息</span>
<span class="token2">if</span><span class="token1">(</span>$rpacket_id<span class="token1">)</span>
<span class="token1">{</span>
<span class="token2">if</span><span class="token1">(</span><span class="token3">isset</span><span class="token1">(</span>$rpacket_id<span class="token1">[</span>$key<span class="token1">]</span><span class="token1">)</span><span class="token1">)</span>
<span class="token1">{</span>
$redPacket_BaseModel <span class="token">=</span> <span class="token2">new</span> <span class="token3">RedPacket_BaseModel</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
$field_row <span class="token">=</span> <span class="token3">array</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
$field_row<span class="token1">[</span><span class="token4">'redpacket_state'</span><span class="token1">]</span> <span class="token">=</span> RedPacket_BaseModel<span class="token1">:</span><span class="token1">:</span>USED<span class="token1">;</span>
$field_row<span class="token1">[</span><span class="token4">'redpacket_order_id'</span><span class="token1">]</span> <span class="token">=</span> $order_id<span class="token1">;</span>
$flag5 <span class="token">=</span> $redPacket_BaseModel<span class="token">-</span><span class="token">></span><span class="token3">editRedPacket</span><span class="token1">(</span>$rpacket_id<span class="token1">[</span>$key<span class="token1">]</span><span class="token1">,</span> $field_row<span class="token1">)</span><span class="token1">;</span>
$flag <span class="token">=</span> $flag <span class="token">&&</span> $flag5<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>$val<span class="token1">[</span><span class="token4">'voucher_id'</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">isset</span><span class="token1">(</span>$shop_voucher_row<span class="token1">[</span>$key<span class="token1">]</span><span class="token1">)</span><span class="token1">)</span>
<span class="token1">{</span>
$Voucher_BaseModel <span class="token">=</span> <span class="token2">new</span> <span class="token3">Voucher_BaseModel</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
$flag6 <span class="token">=</span> $Voucher_BaseModel<span class="token">-</span><span class="token">></span><span class="token3">changeVoucherState</span><span class="token1">(</span>$val<span class="token1">[</span><span class="token4">'voucher_id'</span><span class="token1">]</span><span class="token1">,</span> $order_id<span class="token1">)</span><span class="token1">;</span>
<span class="token5">//代金券使用提醒</span>
$message <span class="token">=</span> <span class="token2">new</span> <span class="token3">MessageModel</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
$message<span class="token">-</span><span class="token">></span><span class="token3">sendMessage</span><span class="token1">(</span><span class="token4">'The use of vouchers to remind'</span><span class="token1">,</span> Perm<span class="token1">:</span><span class="token1">:</span>$userId<span class="token1">,</span> Perm<span class="token1">:</span><span class="token1">:</span>$row<span class="token1">[</span><span class="token4">'user_account'</span><span class="token1">]</span><span class="token1">,</span> NULL<span class="token1">,</span> $shop_name <span class="token">=</span> NULL<span class="token1">,</span> <span class="token6">0</span><span class="token1">,</span> MessageModel<span class="token1">:</span><span class="token1">:</span>USER_MESSAGE<span class="token1">)</span><span class="token1">;</span>
$flag <span class="token">=</span> $flag <span class="token">&&</span> $flag6<span class="token1">;</span>
<span class="token1">}</span>
<span class="token1">}</span>
<span class="token5">//生成订单商品信息(order_goods)</span>
$flag2 <span class="token">=</span> $Order_GoodsModel<span class="token">-</span><span class="token">></span><span class="token3">addGoods</span><span class="token1">(</span>$order_goods_row<span class="token1">)</span><span class="token1">;</span>
<span class="token5">//生成交易快照</span>
$Order_GoodsSnapshot<span class="token">-</span><span class="token">></span><span class="token3">addSnapshot</span><span class="token1">(</span>$order_goods_snapshot_add_row<span class="token1">)</span><span class="token1">;</span>
<span class="token5">//删除商品库存</span>
$Goods_BaseModel<span class="token">-</span><span class="token">></span><span class="token3">delStock</span><span class="token1">(</span>$v<span class="token1">[</span><span class="token4">'goods_id'</span><span class="token1">]</span><span class="token1">,</span> $v<span class="token1">[</span><span class="token4">'goods_num'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">;</span>
<span class="token5">//从购物车中删除已生成订单的商品</span>
$CartModel<span class="token">-</span><span class="token">></span><span class="token3">removeCart</span><span class="token1">(</span>$v<span class="token1">[</span><span class="token4">'cart_id'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">;</span>
```
```
加价购、满即送等活动商品信息插入订单商品表
将单个店铺订单信息同步到paycenter中,并将paycenter中生成的支付单号写入订单表中
```
<pre class="calibre14">```
<span class="token5">//支付中心生成订单</span>
$key <span class="token">=</span> Yf_Registry<span class="token1">:</span><span class="token1">:</span><span class="token3">get</span><span class="token1">(</span><span class="token4">'shop_api_key'</span><span class="token1">)</span><span class="token1">;</span>
$url <span class="token">=</span> Yf_Registry<span class="token1">:</span><span class="token1">:</span><span class="token3">get</span><span class="token1">(</span><span class="token4">'paycenter_api_url'</span><span class="token1">)</span><span class="token1">;</span>
$shop_app_id <span class="token">=</span> Yf_Registry<span class="token1">:</span><span class="token1">:</span><span class="token3">get</span><span class="token1">(</span><span class="token4">'shop_app_id'</span><span class="token1">)</span><span class="token1">;</span>
$formvars <span class="token">=</span> <span class="token3">array</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
$formvars<span class="token1">[</span><span class="token4">'app_id'</span><span class="token1">]</span> <span class="token">=</span> $shop_app_id<span class="token1">;</span>
$formvars<span class="token1">[</span><span class="token4">'from_app_id'</span><span class="token1">]</span> <span class="token">=</span> Yf_Registry<span class="token1">:</span><span class="token1">:</span><span class="token3">get</span><span class="token1">(</span><span class="token4">'shop_app_id'</span><span class="token1">)</span><span class="token1">;</span>
$formvars<span class="token1">[</span><span class="token4">'consume_trade_id'</span><span class="token1">]</span> <span class="token">=</span> $order_row<span class="token1">[</span><span class="token4">'order_id'</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> $order_row<span class="token1">[</span><span class="token4">'order_id'</span><span class="token1">]</span><span class="token1">;</span>
$formvars<span class="token1">[</span><span class="token4">'buy_id'</span><span class="token1">]</span> <span class="token">=</span> Perm<span class="token1">:</span><span class="token1">:</span>$userId<span class="token1">;</span>
$formvars<span class="token1">[</span><span class="token4">'buyer_name'</span><span class="token1">]</span> <span class="token">=</span> Perm<span class="token1">:</span><span class="token1">:</span>$row<span class="token1">[</span><span class="token4">'user_account'</span><span class="token1">]</span><span class="token1">;</span>
$formvars<span class="token1">[</span><span class="token4">'seller_id'</span><span class="token1">]</span> <span class="token">=</span> $order_row<span class="token1">[</span><span class="token4">'seller_user_id'</span><span class="token1">]</span><span class="token1">;</span>
$formvars<span class="token1">[</span><span class="token4">'seller_name'</span><span class="token1">]</span> <span class="token">=</span> $order_row<span class="token1">[</span><span class="token4">'seller_user_name'</span><span class="token1">]</span><span class="token1">;</span>
$formvars<span class="token1">[</span><span class="token4">'order_state_id'</span><span class="token1">]</span> <span class="token">=</span> $order_row<span class="token1">[</span><span class="token4">'order_status'</span><span class="token1">]</span><span class="token1">;</span>
$formvars<span class="token1">[</span><span class="token4">'order_payment_amount'</span><span class="token1">]</span> <span class="token">=</span> $order_row<span class="token1">[</span><span class="token4">'order_payment_amount'</span><span class="token1">]</span><span class="token1">;</span>
$formvars<span class="token1">[</span><span class="token4">'order_commission_fee'</span><span class="token1">]</span> <span class="token">=</span> $order_row<span class="token1">[</span><span class="token4">'order_commission_fee'</span><span class="token1">]</span><span class="token1">;</span>
$formvars<span class="token1">[</span><span class="token4">'trade_remark'</span><span class="token1">]</span> <span class="token">=</span> $order_row<span class="token1">[</span><span class="token4">'order_message'</span><span class="token1">]</span><span class="token1">;</span>
$formvars<span class="token1">[</span><span class="token4">'trade_create_time'</span><span class="token1">]</span> <span class="token">=</span> $order_row<span class="token1">[</span><span class="token4">'order_create_time'</span><span class="token1">]</span><span class="token1">;</span>
$formvars<span class="token1">[</span><span class="token4">'trade_title'</span><span class="token1">]</span> <span class="token">=</span> $trade_title<span class="token1">;</span> <span class="token5">//商品名称 - 标题</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=addConsumeTrade&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>
```
```
生成合并支付订单
```
<pre class="calibre14">```
<span class="token5">//生成合并支付订单</span>
$key <span class="token">=</span> Yf_Registry<span class="token1">:</span><span class="token1">:</span><span class="token3">get</span><span class="token1">(</span><span class="token4">'shop_api_key'</span><span class="token1">)</span><span class="token1">;</span>
$url <span class="token">=</span> Yf_Registry<span class="token1">:</span><span class="token1">:</span><span class="token3">get</span><span class="token1">(</span><span class="token4">'paycenter_api_url'</span><span class="token1">)</span><span class="token1">;</span>
$shop_app_id <span class="token">=</span> Yf_Registry<span class="token1">:</span><span class="token1">:</span><span class="token3">get</span><span class="token1">(</span><span class="token4">'shop_app_id'</span><span class="token1">)</span><span class="token1">;</span>
$formvars <span class="token">=</span> <span class="token3">array</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
$formvars<span class="token1">[</span><span class="token4">'inorder'</span><span class="token1">]</span> <span class="token">=</span> $inorder<span class="token1">;</span>
$formvars<span class="token1">[</span><span class="token4">'uprice'</span><span class="token1">]</span> <span class="token">=</span> $uprice<span class="token1">;</span>
$formvars<span class="token1">[</span><span class="token4">'buyer'</span><span class="token1">]</span> <span class="token">=</span> Perm<span class="token1">:</span><span class="token1">:</span>$userId<span class="token1">;</span>
$formvars<span class="token1">[</span><span class="token4">'trade_title'</span><span class="token1">]</span> <span class="token">=</span> $utrade_title<span class="token1">;</span>
$formvars<span class="token1">[</span><span class="token4">'buyer_name'</span><span class="token1">]</span> <span class="token">=</span> Perm<span class="token1">:</span><span class="token1">:</span>$row<span class="token1">[</span><span class="token4">'user_account'</span><span class="token1">]</span><span class="token1">;</span>
$formvars<span class="token1">[</span><span class="token4">'app_id'</span><span class="token1">]</span> <span class="token">=</span> $shop_app_id<span class="token1">;</span>
$formvars<span class="token1">[</span><span class="token4">'from_app_id'</span><span class="token1">]</span> <span class="token">=</span> Yf_Registry<span class="token1">:</span><span class="token1">:</span><span class="token3">get</span><span class="token1">(</span><span class="token4">'shop_app_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=addUnionOrder&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>
```
```
判断订单生成是否成功,如果成功则将信息推送到统计中心添加订单统计,将下单成功信息通过IM推送给商家。订单提交失败,将paycenter中生成的订单删除。
#### 2.支付订单
支付单与订单说明:
用户在店铺A和店铺B中购买了100元的商品a和50元的商品b。这两件商品在结算时同时结算,生成订单Oa和订单Ob。Paycenter中生成150元的合并支付单Uab,100元的合并支付订单Ua,50元的合并支付订单Ub。
用户在店铺C中购买10元的商品c。结算生成订单Oc。Paycenter中生成10元的合并支付订单Uc1(相当于上个例子中的Uab),生成10元的合并支付订单Uc2(相当于上个例子中的Ua或者Ub)。
页面显示
文件路径:\\paycenter\\controllers\\InfoCtl.php
控制器:InfoCtl
方法:pay()
视图文件:\\paycenter\\views\\default\\InfoCtl\\pay.php
```
<pre class="calibre14">```
<span class="token5">//判断用户选择哪种支付方式,如果选择在线支付则调用相应的方法,如果选择账户余额支付则调用money方法</span>
<span class="token2">if</span><span class="token1">(</span>online_payway<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=Pay&met="</span> <span class="token">+</span> online_payway <span class="token">+</span> <span class="token4">"&trade_id="</span> <span class="token">+</span> uorder_id<span class="token1">;</span>
<span class="token1">}</span>
<span class="token2">else</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=Pay&met=money&typ=json"</span> <span class="token1">,</span><span class="token1">{</span>trade_id<span class="token1">:</span>uorder_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="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>
window<span class="token1">.</span>location<span class="token1">.</span>href <span class="token">=</span> data<span class="token1">.</span>data<span class="token1">.</span>return_app_url <span class="token">+</span> <span class="token4">'?ctl=Buyer_Order&met=<?=$order_g_type?>'</span><span class="token1">;</span>
<span class="token1">}</span>
<span class="token2">else</span>
<span class="token1">{</span>
$<span class="token1">(</span><span class="token4">".loading-msg"</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>
window<span class="token1">.</span>location<span class="token1">.</span><span class="token3">reload</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>
```
```
文件路径:\\paycenter\\controllers\\PayCtl.php
控制器:PayCtl.php
方法:money()
```
<pre class="calibre14">```
<span class="token5">//获取合并订单号的信息</span>
$uorder <span class="token">=</span> $Union_OrderModel<span class="token">-</span><span class="token">></span><span class="token3">getOne</span><span class="token1">(</span>$trade_id<span class="token1">)</span><span class="token1">;</span>
<span class="token5">//判断订单状态是否为等待付款状态</span>
<span class="token2">if</span><span class="token1">(</span>$uorder<span class="token1">[</span><span class="token4">'order_state_id'</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>
<span class="token1">{</span>
$pay_flag <span class="token">=</span> <span class="token6">false</span><span class="token1">;</span>
$pay_user_id <span class="token">=</span> <span class="token6">0</span><span class="token1">;</span>
<span class="token5">//判断当前用户是否是下单者,并且订单状态是否是待付款状态</span>
<span class="token2">if</span><span class="token1">(</span>$uorder<span class="token1">[</span><span class="token4">'buyer_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>
$pay_flag <span class="token">=</span> <span class="token6">true</span><span class="token1">;</span>
$pay_user_id <span class="token">=</span> $uorder<span class="token1">[</span><span class="token4">'buyer_id'</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>
$key <span class="token">=</span> Yf_Registry<span class="token1">:</span><span class="token1">:</span><span class="token3">get</span><span class="token1">(</span><span class="token4">'shop_api_key'</span><span class="token1">)</span><span class="token1">;</span>
$url <span class="token">=</span> Yf_Registry<span class="token1">:</span><span class="token1">:</span><span class="token3">get</span><span class="token1">(</span><span class="token4">'shop_api_url'</span><span class="token1">)</span><span class="token1">;</span>
$shop_app_id <span class="token">=</span> Yf_Registry<span class="token1">:</span><span class="token1">:</span><span class="token3">get</span><span class="token1">(</span><span class="token4">'shop_app_id'</span><span class="token1">)</span><span class="token1">;</span>
$formvars <span class="token">=</span> <span class="token3">array</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
$formvars<span class="token1">[</span><span class="token4">'app_id'</span><span class="token1">]</span> <span class="token">=</span> $shop_app_id<span class="token1">;</span>
$formvars<span class="token1">[</span><span class="token4">'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>
$formvars<span class="token1">[</span><span class="token4">'sub_user_id'</span><span class="token1">]</span> <span class="token">=</span> $uorder<span class="token1">[</span><span class="token4">'buyer_id'</span><span class="token1">]</span><span class="token1">;</span>
$sub_user <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_User_Info&met=checkSubUser&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="token2">if</span><span class="token1">(</span><span class="token">!</span><span class="token3">empty</span><span class="token1">(</span>$sub_user<span class="token1">[</span><span class="token4">'data'</span><span class="token1">]</span><span class="token1">)</span> <span class="token">&&</span> $sub_user<span class="token1">[</span><span class="token4">'status'</span><span class="token1">]</span> <span class="token">==</span> <span class="token6">200</span><span class="token1">)</span>
<span class="token1">{</span>
$pay_flag <span class="token">=</span> <span class="token6">true</span><span class="token1">;</span>
$pay_user_id <span class="token">=</span> Perm<span class="token1">:</span><span class="token1">:</span>$userId<span class="token1">;</span>
<span class="token1">}</span>
<span class="token1">}</span>
<span class="token2">if</span><span class="token1">(</span>$pay_flag<span class="token1">)</span>
<span class="token1">{</span>
<span class="token5">//修改订单表中的各种状态</span>
$flag <span class="token">=</span> $Consume_DepositModel<span class="token">-</span><span class="token">></span><span class="token3">notifyShop</span><span class="token1">(</span>$trade_id<span class="token1">,</span>$pay_user_id<span class="token1">)</span><span class="token1">;</span>
<span class="token2">if</span> <span class="token1">(</span>$flag<span class="token1">[</span><span class="token4">'status'</span><span class="token1">]</span> <span class="token">==</span> <span class="token6">200</span><span class="token1">)</span>
<span class="token1">{</span>
<span class="token5">//查找回调地址</span>
$User_AppModel <span class="token">=</span> <span class="token2">new</span> <span class="token3">User_AppModel</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
$user_app <span class="token">=</span> $User_AppModel<span class="token">-</span><span class="token">></span><span class="token3">getOne</span><span class="token1">(</span>$uorder<span class="token1">[</span><span class="token4">'app_id'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">;</span>
$return_app_url <span class="token">=</span> $user_app<span class="token1">[</span><span class="token4">'app_url'</span><span class="token1">]</span><span class="token1">;</span>
$data<span class="token1">[</span><span class="token4">'return_app_url'</span><span class="token1">]</span> <span class="token">=</span> $return_app_url<span class="token1">;</span>
$msg <span class="token">=</span> <span class="token4">'success'</span><span class="token1">;</span>
$status <span class="token">=</span> <span class="token6">200</span><span class="token1">;</span>
<span class="token1">}</span>
<span class="token2">else</span>
<span class="token1">{</span>
$msg <span class="token">=</span> <span class="token3">_</span><span class="token1">(</span><span class="token4">'failure'</span><span class="token1">)</span><span class="token1">;</span>
$status <span class="token">=</span> <span class="token6">250</span><span class="token1">;</span>
<span class="token1">}</span>
<span class="token1">}</span>
<span class="token2">else</span>
<span class="token1">{</span>
$msg <span class="token">=</span> <span class="token3">_</span><span class="token1">(</span><span class="token4">'failure'</span><span class="token1">)</span><span class="token1">;</span>
$status <span class="token">=</span> <span class="token6">250</span><span class="token1">;</span>
<span class="token1">}</span>
<span class="token1">}</span>
```
```
文件路径:\\paycenter\\controllers\\PayCtl.php
控制器:PayCtl.php
方法:alipay()
```
<pre class="calibre14">```
<span class="token5">//判断订单状态是否为等待付款状态</span>
<span class="token2">if</span><span class="token1">(</span>$trade_row<span class="token1">[</span><span class="token4">'order_state_id'</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>
<span class="token1">{</span>
$pay_flag <span class="token">=</span> <span class="token6">false</span><span class="token1">;</span>
$pay_user_id <span class="token">=</span> <span class="token6">0</span><span class="token1">;</span>
<span class="token5">//判断当前用户是否是下单者,并且订单状态是否是待付款状态</span>
<span class="token2">if</span><span class="token1">(</span>$trade_row<span class="token1">[</span><span class="token4">'buyer_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>
$pay_flag <span class="token">=</span> <span class="token6">true</span><span class="token1">;</span>
$pay_user_id <span class="token">=</span> $trade_row<span class="token1">[</span><span class="token4">'buyer_id'</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>
$key <span class="token">=</span> Yf_Registry<span class="token1">:</span><span class="token1">:</span><span class="token3">get</span><span class="token1">(</span><span class="token4">'shop_api_key'</span><span class="token1">)</span><span class="token1">;</span>
$url <span class="token">=</span> Yf_Registry<span class="token1">:</span><span class="token1">:</span><span class="token3">get</span><span class="token1">(</span><span class="token4">'shop_api_url'</span><span class="token1">)</span><span class="token1">;</span>
$shop_app_id <span class="token">=</span> Yf_Registry<span class="token1">:</span><span class="token1">:</span><span class="token3">get</span><span class="token1">(</span><span class="token4">'shop_app_id'</span><span class="token1">)</span><span class="token1">;</span>
$formvars <span class="token">=</span> <span class="token3">array</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
$formvars<span class="token1">[</span><span class="token4">'app_id'</span><span class="token1">]</span> <span class="token">=</span> $shop_app_id<span class="token1">;</span>
$formvars<span class="token1">[</span><span class="token4">'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>
$formvars<span class="token1">[</span><span class="token4">'sub_user_id'</span><span class="token1">]</span> <span class="token">=</span> $trade_row<span class="token1">[</span><span class="token4">'buyer_id'</span><span class="token1">]</span><span class="token1">;</span>
$sub_user <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_User_Info&met=checkSubUser&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="token2">if</span><span class="token1">(</span><span class="token">!</span><span class="token3">empty</span><span class="token1">(</span>$sub_user<span class="token1">[</span><span class="token4">'data'</span><span class="token1">]</span><span class="token1">)</span> <span class="token">&&</span> $sub_user<span class="token1">[</span><span class="token4">'status'</span><span class="token1">]</span> <span class="token">==</span> <span class="token6">200</span><span class="token1">)</span>
<span class="token1">{</span>
$pay_flag <span class="token">=</span> <span class="token6">true</span><span class="token1">;</span>
$pay_user_id <span class="token">=</span> Perm<span class="token1">:</span><span class="token1">:</span>$userId<span class="token1">;</span>
<span class="token1">}</span>
<span class="token1">}</span>
<span class="token5">//ignore 给webpos使用</span>
<span class="token2">if</span><span class="token1">(</span>$pay_flag <span class="token">||</span> $_GET<span class="token1">[</span><span class="token4">'ignore'</span><span class="token1">]</span><span class="token">==</span><span class="token4">'abc'</span> <span class="token1">)</span>
<span class="token1">{</span>
<span class="token2">if</span> <span class="token1">(</span>$trade_row<span class="token1">)</span>
<span class="token1">{</span>
$Payment <span class="token">=</span> PaymentModel<span class="token1">:</span><span class="token1">:</span><span class="token3">create</span><span class="token1">(</span><span class="token4">'alipay'</span><span class="token1">)</span><span class="token1">;</span>
$Payment<span class="token">-</span><span class="token">></span><span class="token3">pay</span><span class="token1">(</span>$trade_row<span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
<span class="token2">else</span>
<span class="token1">{</span>
echo<span class="token4">"<script>alert('支付失败,请重新支付');history.go(-1);</script>"</span><span class="token1">;</span>
<span class="token1">}</span>
<span class="token1">}</span>
<span class="token2">else</span>
<span class="token1">{</span>
echo<span class="token4">"<script>alert('支付失败,请重新支付');history.go(-1);</script>"</span><span class="token1">;</span>
<span class="token1">}</span>
<span class="token1">}</span>
```
```
文件路径:F:\\www\\paycenter\\paycenter\\models\\Consume\\DepositModel.php
方法:notifyShop($order\_id = null,$user\_id = null)
1.修改paycenter中订单的信息
```
<pre class="calibre14">```
<span class="token5">//修改合并订单中的订单支付状态</span>
<span class="token5">//获取合并支付订单信息</span>
$union_order <span class="token">=</span> $Union_OrderModel<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>
$bt_flag <span class="token">=</span> $this<span class="token">-</span><span class="token">></span><span class="token3">checkBt</span><span class="token1">(</span><span class="token3">array</span><span class="token1">(</span><span class="token4">'trade_payment_amount'</span><span class="token">=</span><span class="token">></span>$union_order<span class="token1">[</span><span class="token4">'trade_payment_amount'</span><span class="token1">]</span><span class="token1">,</span><span class="token4">'payment_channel_id'</span><span class="token">=</span><span class="token">></span>$union_order<span class="token1">[</span><span class="token4">'payment_channel_id'</span><span class="token1">]</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="token1">(</span>$union_order<span class="token1">[</span><span class="token4">'trade_payment_amount'</span><span class="token1">]</span> <span class="token">==</span> $union_order<span class="token1">[</span><span class="token4">'union_online_pay_amount'</span><span class="token1">]</span> <span class="token">+</span> $union_order<span class="token1">[</span><span class="token4">'union_money_pay_amount'</span><span class="token1">]</span> <span class="token">+</span> $union_order<span class="token1">[</span><span class="token4">'union_cards_pay_amount'</span><span class="token1">]</span><span class="token1">)</span> <span class="token">||</span> $bt_flag<span class="token1">)</span>
<span class="token1">{</span>
略
<span class="token1">}</span>
```
```
如果是合并支付的订单,则需要将属于它的单个合并支付单修改状态
```
<pre class="calibre14">```
<span class="token2">if</span><span class="token1">(</span><span class="token3">count</span><span class="token1">(</span>$order_id<span class="token1">)</span> <span class="token">></span> <span class="token6">1</span><span class="token1">)</span>
<span class="token1">{</span>
<span class="token5">//修改单个合并订单状态</span>
$uorder_row <span class="token">=</span> $Union_OrderModel<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">'inorder:IN'</span> <span class="token">=</span><span class="token">></span> $order_id<span class="token1">)</span><span class="token1">)</span><span class="token1">;</span>
$uorder_id_row <span class="token">=</span> <span class="token3">array_column</span><span class="token1">(</span>$uorder_row<span class="token1">,</span><span class="token4">'union_order_id'</span><span class="token1">)</span><span class="token1">;</span>
$edit_uorder_row <span class="token">=</span> <span class="token3">array</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
$edit_uorder_row<span class="token1">[</span><span class="token4">'order_state_id'</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>
$edit_uorder_row<span class="token1">[</span><span class="token4">'pay_time'</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="token1">;</span>
<span class="token3">check_rs</span><span class="token1">(</span>$Union_OrderModel<span class="token">-</span><span class="token">></span><span class="token3">editUnionOrder</span><span class="token1">(</span>$uorder_id_row<span class="token1">,</span>$edit_uorder_row<span class="token1">)</span><span class="token1">,</span> $rs_row<span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
```
```
修改订单表中的交易状态
修改交易明细中的订单状态
根据支付情况修改用户资金信息
```
<pre class="calibre14">```
<span class="token2">if</span><span class="token1">(</span>$union_order<span class="token1">[</span><span class="token4">'union_money_pay_amount'</span><span class="token1">]</span> <span class="token">></span> <span class="token6">0</span><span class="token1">)</span>
<span class="token1">{</span>
<span class="token5">//修改用户的资源状态</span>
$User_ResourceModel <span class="token">=</span> <span class="token2">new</span> <span class="token3">User_ResourceModel</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
<span class="token5">//1.用户资源中订单金额冻结(现金)</span>
$flag <span class="token">=</span> $User_ResourceModel<span class="token">-</span><span class="token">></span><span class="token3">frozenUserMoney</span><span class="token1">(</span>$user_id<span class="token1">,</span>$union_order<span class="token1">[</span><span class="token4">'union_money_pay_amount'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">;</span>
<span class="token3">check_rs</span><span class="token1">(</span>$flag<span class="token1">,</span> $rs_row<span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
<span class="token2">if</span><span class="token1">(</span>$union_order<span class="token1">[</span><span class="token4">'union_cards_pay_amount'</span><span class="token1">]</span> <span class="token">></span> <span class="token6">0</span><span class="token1">)</span>
<span class="token1">{</span>
$User_ResourceModel <span class="token">=</span> <span class="token2">new</span> <span class="token3">User_ResourceModel</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
<span class="token5">//2.用户资源中订单金额冻结(卡)</span>
$flag <span class="token">=</span> $User_ResourceModel<span class="token">-</span><span class="token">></span><span class="token3">frozenUserCards</span><span class="token1">(</span>$user_id<span class="token1">,</span>$union_order<span class="token1">[</span><span class="token4">'union_cards_pay_amount'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">;</span>
<span class="token3">check_rs</span><span class="token1">(</span>$flag<span class="token1">,</span> $rs_row<span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
<span class="token5">//修改白条余额</span>
<span class="token2">if</span><span class="token1">(</span>$bt_flag<span class="token1">)</span>
<span class="token1">{</span>
$User_ResourceModel <span class="token">=</span> <span class="token2">new</span> <span class="token3">User_ResourceModel</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
$user_credit_availability <span class="token">=</span> $union_order<span class="token1">[</span><span class="token4">'trade_payment_amount'</span><span class="token1">]</span><span class="token">*</span><span class="token1">(</span><span class="token">-</span><span class="token6">1</span><span class="token1">)</span><span class="token1">;</span>
$flag <span class="token">=</span> $User_ResourceModel<span class="token">-</span><span class="token">></span><span class="token3">editResource</span><span class="token1">(</span>$user_id<span class="token1">,</span><span class="token3">array</span><span class="token1">(</span><span class="token4">'user_credit_availability'</span><span class="token">=</span><span class="token">></span>$user_credit_availability<span class="token1">)</span><span class="token1">,</span><span class="token6">true</span><span class="token1">)</span><span class="token1">;</span>
<span class="token3">check_rs</span><span class="token1">(</span>$flag<span class="token1">,</span> $rs_row<span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
```
```
2.paycenter中订单修改完成后,修改shop中的订单信息
付款成功后对买家极光推送
订单付款成功后对卖家进行极光推送
```
<pre class="calibre14">```
<span class="token5">//根据订单来源,修改shop订单状态</span>
$consume_record <span class="token">=</span> $Consume_TradeModel<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>
$app_id <span class="token">=</span> $consume_record<span class="token1">[</span><span class="token4">'app_id'</span><span class="token1">]</span><span class="token1">;</span>
$User_AppModel <span class="token">=</span> <span class="token2">new</span> <span class="token3">User_AppModel</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
$app_row <span class="token">=</span> $User_AppModel<span class="token">-</span><span class="token">></span><span class="token3">getOne</span><span class="token1">(</span>$app_id<span class="token1">)</span><span class="token1">;</span>
$key <span class="token">=</span> $app_row<span class="token1">[</span><span class="token4">'app_key'</span><span class="token1">]</span><span class="token1">;</span>
$url <span class="token">=</span> $app_row<span class="token1">[</span><span class="token4">'app_url'</span><span class="token1">]</span><span class="token1">;</span>
$shop_app_id <span class="token">=</span> $app_id<span class="token1">;</span>
$formvars <span class="token">=</span> <span class="token3">array</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
$formvars <span class="token">=</span> $_POST<span class="token1">;</span>
$formvars<span class="token1">[</span><span class="token4">'app_id'</span><span class="token1">]</span> <span class="token">=</span> $shop_app_id<span class="token1">;</span>
$formvars<span class="token1">[</span><span class="token4">'order_id'</span><span class="token1">]</span> <span class="token">=</span> $order_id<span class="token1">;</span>
$formvars<span class="token1">[</span><span class="token4">'uorder_id'</span><span class="token1">]</span> <span class="token">=</span> $uorder_id<span class="token1">;</span>
<span class="token2">if</span><span class="token1">(</span>$consume_record<span class="token1">[</span><span class="token4">'payment_channel_id'</span><span class="token1">]</span> <span class="token">==</span> Payment_ChannelModel<span class="token1">:</span><span class="token1">:</span>BAITIAO<span class="token1">)</span><span class="token1">{</span>
$formvars<span class="token1">[</span><span class="token4">'payment_channel_code'</span><span class="token1">]</span> <span class="token">=</span> <span class="token4">'baitiao'</span><span class="token1">;</span>
<span class="token1">}</span><span class="token2">else</span><span class="token1">{</span>
$formvars<span class="token1">[</span><span class="token4">'payment_channel_code'</span><span class="token1">]</span> <span class="token">=</span> <span class="token4">''</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_Trade_Order&met=editOrderRowSatus&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="token2">return</span> $rs<span class="token1">;</span>
```
```
#### 3.商家发货
地址链接:/index.php?ctl=Seller\_Trade\_Order&met=send&typ=e&order\_id=订单编号
文件路径:\\shop\\controllers\\Seller\\Trade\\OrderCtl.php
控制器:OrderCtl
方法:send()
视图文件:\\shop\\views\\default\\Seller\\Trade\\OrderCtl\\send.php
根据typ判断该方法是用来显示页面,还是修改订单状态。
```
<pre class="calibre14">```
<span class="token2">if</span> <span class="token1">(</span>$typ <span class="token">==</span> <span class="token4">'e'</span><span class="token1">)</span>
<span class="token1">{</span>
显示页面
<span class="token1">}</span>
<span class="token2">else</span>
<span class="token1">{</span>
修改订单状态
<span class="token1">}</span>
```
```
显示页面部分
```
<pre class="calibre14">```
$condi<span class="token1">[</span><span class="token4">'order_id'</span><span class="token1">]</span> <span class="token">=</span> $order_id<span class="token1">;</span>
$data <span class="token">=</span> $Order_BaseModel<span class="token">-</span><span class="token">></span><span class="token3">getOrderList</span><span class="token1">(</span>$condi<span class="token1">)</span><span class="token1">;</span>
$data <span class="token">=</span> <span class="token3">pos</span><span class="token1">(</span>$data<span class="token1">[</span><span class="token4">'items'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">;</span>
<span class="token5">//默认物流公司 url</span>
$default_express_url <span class="token">=</span> Yf_Registry<span class="token1">:</span><span class="token1">:</span><span class="token3">get</span><span class="token1">(</span><span class="token4">'url'</span><span class="token1">)</span> <span class="token1">.</span> <span class="token4">'?ctl=Seller_Trade_Deliver&met=express&typ=e'</span><span class="token1">;</span>
<span class="token5">//打印运单URL</span>
$print_tpl_url <span class="token">=</span> Yf_Registry<span class="token1">:</span><span class="token1">:</span><span class="token3">get</span><span class="token1">(</span><span class="token4">'url'</span><span class="token1">)</span> <span class="token1">.</span> <span class="token4">'?ctl=Seller_Trade_Waybill&met=printTpl&typ=e&order_id='</span> <span class="token1">.</span> $order_id<span class="token1">;</span>
<span class="token5">//默认物流公司</span>
$express_list <span class="token">=</span> $Shop_ExpressModel<span class="token">-</span><span class="token">></span><span class="token3">getDefaultShopExpress</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">is_array</span><span class="token1">(</span>$express_list<span class="token1">)</span> <span class="token">&&</span> $express_list<span class="token1">)</span><span class="token1">{</span>
$express_list <span class="token">=</span> <span class="token3">array_values</span><span class="token1">(</span>$express_list<span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
include $this<span class="token">-</span><span class="token">></span>view<span class="token">-</span><span class="token">></span><span class="token3">getView</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
```
```
修改订单状态部分
```
<pre class="calibre14">```
<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="token2">if</span><span class="token1">(</span>$check_send <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_RECEIVED<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> $update_data<span class="token1">)</span><span class="token1">;</span>
<span class="token5">//修改订单商品信息</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="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">//远程修改paycenter中的订单信息</span>
$key <span class="token">=</span> Yf_Registry<span class="token1">:</span><span class="token1">:</span><span class="token3">get</span><span class="token1">(</span><span class="token4">'shop_api_key'</span><span class="token1">)</span><span class="token1">;</span>
$url <span class="token">=</span> Yf_Registry<span class="token1">:</span><span class="token1">:</span><span class="token3">get</span><span class="token1">(</span><span class="token4">'paycenter_api_url'</span><span class="token1">)</span><span class="token1">;</span>
$shop_app_id <span class="token">=</span> Yf_Registry<span class="token1">:</span><span class="token1">:</span><span class="token3">get</span><span class="token1">(</span><span class="token4">'shop_app_id'</span><span class="token1">)</span><span class="token1">;</span>
$formvars <span class="token">=</span> <span class="token3">array</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> $order_id<span class="token1">;</span>
$formvars<span class="token1">[</span><span class="token4">'app_id'</span><span class="token1">]</span> <span class="token">=</span> $shop_app_id<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=sendOrderGoods&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>
```
```
如果订单信息修改正确,发送站内信。
#### 4.确认收货
地址路径:index.php?ctl=Buyer\_Order&met=confirmOrder&user=buyer
控制器文件路径:\\shop\\controllers\\Buyer\\OrderCtl.php
控制器:Buyer\_OrderCtl
方法:confirmOrder()
判断下单者是否是当前用户,订单状态是否为已发货状态
```
<pre class="calibre14">```
$order_base<span class="token1">[</span><span class="token4">'buyer_user_id'</span><span class="token1">]</span> <span class="token">==</span> Perm<span class="token1">:</span><span class="token1">:</span>$userId <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_CONFIRM_GOODS
```
```
判断是否是货到付款订单,如果是货到付款订单,则将支付时间改为确认收货时间
```
<pre class="calibre14">```
<span class="token2">if</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="token1">)</span>
<span class="token1">{</span>
$condition<span class="token1">[</span><span class="token4">'payment_time'</span><span class="token1">]</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>
```
```
修改订单商品表中的订单状态
```
<pre class="calibre14">```
$edit_row<span class="token1">[</span><span class="token4">'order_goods_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>
$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_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_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>
```
```
货到付款修改商品销量
修改paycenter中的订单状态
```
<pre class="calibre14">```
$key <span class="token">=</span> Yf_Registry<span class="token1">:</span><span class="token1">:</span><span class="token3">get</span><span class="token1">(</span><span class="token4">'shop_api_key'</span><span class="token1">)</span><span class="token1">;</span>
$url <span class="token">=</span> Yf_Registry<span class="token1">:</span><span class="token1">:</span><span class="token3">get</span><span class="token1">(</span><span class="token4">'paycenter_api_url'</span><span class="token1">)</span><span class="token1">;</span>
$shop_app_id <span class="token">=</span> Yf_Registry<span class="token1">:</span><span class="token1">:</span><span class="token3">get</span><span class="token1">(</span><span class="token4">'shop_app_id'</span><span class="token1">)</span><span class="token1">;</span>
$formvars <span class="token">=</span> <span class="token3">array</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> $order_id<span class="token1">;</span>
$formvars<span class="token1">[</span><span class="token4">'app_id'</span><span class="token1">]</span> <span class="token">=</span> $shop_app_id<span class="token1">;</span>
$formvars<span class="token1">[</span><span class="token4">'from_app_id'</span><span class="token1">]</span> <span class="token">=</span> Yf_Registry<span class="token1">:</span><span class="token1">:</span><span class="token3">get</span><span class="token1">(</span><span class="token4">'shop_app_id'</span><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">'payment_id'</span><span class="token1">]</span> <span class="token">==</span> PaymentChannlModel<span class="token1">:</span><span class="token1">:</span>PAY_CONFIRM<span class="token1">)</span>
<span class="token1">{</span>
$formvars<span class="token1">[</span><span class="token4">'payment'</span><span class="token1">]</span> <span class="token">=</span> <span class="token6">0</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=confirmOrder&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>
```
```
判断用户该笔订单是否存在退款,如果有的话添加商家的退款流水
```
<pre class="calibre14">```
$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=refundShopTransfer&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>
```
```
计算本次确认收货,用户将获取的积分与成长值
判断用户是否需要升级
```
<pre class="calibre14">```
$res_flag <span class="token">=</span> $User_GradeModel<span class="token">-</span><span class="token">></span><span class="token3">upGrade</span><span class="token1">(</span>Perm<span class="token1">:</span><span class="token1">:</span>$userId<span class="token1">,</span> $resource_row<span class="token1">[</span><span class="token4">'user_growth'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">;</span>
```
```
修改用户积分与成长值之后添加记录
```
<pre class="calibre14">```
<span class="token5">//积分</span>
$points_row<span class="token1">[</span><span class="token4">'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>
$points_row<span class="token1">[</span><span class="token4">'user_name'</span><span class="token1">]</span> <span class="token">=</span> Perm<span class="token1">:</span><span class="token1">:</span>$row<span class="token1">[</span><span class="token4">'user_account'</span><span class="token1">]</span><span class="token1">;</span>
$points_row<span class="token1">[</span><span class="token4">'class_id'</span><span class="token1">]</span> <span class="token">=</span> Points_LogModel<span class="token1">:</span><span class="token1">:</span>ONBUY<span class="token1">;</span>
$points_row<span class="token1">[</span><span class="token4">'points_log_points'</span><span class="token1">]</span> <span class="token">=</span> $user_points<span class="token1">;</span>
$points_row<span class="token1">[</span><span class="token4">'points_log_time'</span><span class="token1">]</span> <span class="token">=</span> <span class="token3">get_date_time</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
$points_row<span class="token1">[</span><span class="token4">'points_log_desc'</span><span class="token1">]</span> <span class="token">=</span> <span class="token4">'确认收货'</span><span class="token1">;</span>
$points_row<span class="token1">[</span><span class="token4">'points_log_flag'</span><span class="token1">]</span> <span class="token">=</span> <span class="token4">'confirmorder'</span><span class="token1">;</span>
$Points_LogModel <span class="token">=</span> <span class="token2">new</span> <span class="token3">Points_LogModel</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
$Points_LogModel<span class="token">-</span><span class="token">></span><span class="token3">addLog</span><span class="token1">(</span>$points_row<span class="token1">)</span><span class="token1">;</span>
<span class="token5">//成长值</span>
$grade_row<span class="token1">[</span><span class="token4">'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>
$grade_row<span class="token1">[</span><span class="token4">'user_name'</span><span class="token1">]</span> <span class="token">=</span> Perm<span class="token1">:</span><span class="token1">:</span>$row<span class="token1">[</span><span class="token4">'user_account'</span><span class="token1">]</span><span class="token1">;</span>
$grade_row<span class="token1">[</span><span class="token4">'class_id'</span><span class="token1">]</span> <span class="token">=</span> Grade_LogModel<span class="token1">:</span><span class="token1">:</span>ONBUY<span class="token1">;</span>
$grade_row<span class="token1">[</span><span class="token4">'grade_log_grade'</span><span class="token1">]</span> <span class="token">=</span> $user_grade<span class="token1">;</span>
$grade_row<span class="token1">[</span><span class="token4">'grade_log_time'</span><span class="token1">]</span> <span class="token">=</span> <span class="token3">get_date_time</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
$grade_row<span class="token1">[</span><span class="token4">'grade_log_desc'</span><span class="token1">]</span> <span class="token">=</span> <span class="token4">'确认收货'</span><span class="token1">;</span>
$grade_row<span class="token1">[</span><span class="token4">'grade_log_flag'</span><span class="token1">]</span> <span class="token">=</span> <span class="token4">'confirmorder'</span><span class="token1">;</span>
$Grade_LogModel <span class="token">=</span> <span class="token2">new</span> <span class="token3">Grade_LogModel</span><span class="token1">;</span>
$Grade_LogModel<span class="token">-</span><span class="token">></span><span class="token3">addLog</span><span class="token1">(</span>$grade_row<span class="token1">)</span><span class="token1">;</span>
```
```
确认收货成功之后,将信息添加到统计中心。
#### 5.评价订单
页面链接:/index.php?ctl=Buyer\_Order&met=evaluation&act=add&order\_id=订单编号
控制器文件路径:\\shop\\controllers\\Buyer\\OrderCtl.php
控制器:Buyer\_OrderCtl
方法:evaluation()
根据传递的参数act,判断是追加评价,初次评价还是显示评价列表页
```
<pre class="calibre14">```
<span class="token2">if</span> <span class="token1">(</span>$act <span class="token">==</span> <span class="token4">'again'</span><span class="token1">)</span>
<span class="token1">{</span>
<span class="token5">//追加评价</span>
<span class="token5">//获取已评价信息</span>
$data <span class="token">=</span> $Goods_EvaluationModel<span class="token">-</span><span class="token">></span><span class="token3">getOne</span><span class="token1">(</span>$evaluation_goods_id<span class="token1">)</span><span class="token1">;</span>
<span class="token5">//商品信息</span>
$data<span class="token1">[</span><span class="token4">'goods_base'</span><span class="token1">]</span> <span class="token">=</span> <span class="token3">current</span><span class="token1">(</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">'goods_id'</span><span class="token">=</span><span class="token">></span>$data<span class="token1">[</span><span class="token4">'goods_id'</span><span class="token1">]</span><span class="token1">,</span><span class="token4">'order_id'</span><span class="token">=</span><span class="token">></span>$data<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="token1">;</span>
<span class="token5">//订单信息</span>
$data<span class="token1">[</span><span class="token4">'order_base'</span><span class="token1">]</span> <span class="token">=</span> $Order_BaseModel<span class="token">-</span><span class="token">></span><span class="token3">getOne</span><span class="token1">(</span>$data<span class="token1">[</span><span class="token4">'order_id'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">;</span>
<span class="token5">//评价用户的信息</span>
$data<span class="token1">[</span><span class="token4">'user_info'</span><span class="token1">]</span> <span class="token">=</span> $User_InfoModel<span class="token">-</span><span class="token">></span><span class="token3">getOne</span><span class="token1">(</span>$data<span class="token1">[</span><span class="token4">'order_base'</span><span class="token1">]</span><span class="token1">[</span><span class="token4">'buyer_user_id'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">;</span>
<span class="token2">if</span> <span class="token1">(</span><span class="token4">'json'</span> <span class="token">==</span> $this<span class="token">-</span><span class="token">></span>typ<span class="token1">)</span>
<span class="token1">{</span>
<span class="token2">return</span> $this<span class="token">-</span><span class="token">></span>data<span class="token">-</span><span class="token">></span><span class="token3">addBody</span><span class="token1">(</span><span class="token">-</span><span class="token6">140</span><span class="token1">,</span> $data<span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
<span class="token2">else</span>
<span class="token1">{</span>
$this<span class="token">-</span><span class="token">></span>view<span class="token">-</span><span class="token">></span><span class="token3">setMet</span><span class="token1">(</span><span class="token4">'evalagain'</span><span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
<span class="token1">}</span>
elseif <span class="token1">(</span>$act <span class="token">==</span> <span class="token4">'add'</span><span class="token1">)</span>
<span class="token1">{</span>
<span class="token5">//初次评价</span>
<span class="token5">//订单信息</span>
$data<span class="token1">[</span><span class="token4">'order_base'</span><span class="token1">]</span> <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>
$data<span class="token1">[</span><span class="token4">'user_info'</span><span class="token1">]</span> <span class="token">=</span> $User_InfoModel<span class="token">-</span><span class="token">></span><span class="token3">getOne</span><span class="token1">(</span>$data<span class="token1">[</span><span class="token4">'order_base'</span><span class="token1">]</span><span class="token1">[</span><span class="token4">'buyer_user_id'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">;</span>
<span class="token5">//店铺信息</span>
$data<span class="token1">[</span><span class="token4">'shop_base'</span><span class="token1">]</span> <span class="token">=</span> $Shop_BaseModel<span class="token">-</span><span class="token">></span><span class="token3">getOne</span><span class="token1">(</span>$data<span class="token1">[</span><span class="token4">'order_base'</span><span class="token1">]</span><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>
$order_goods_id_row <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_id'</span> <span class="token">=</span><span class="token">></span> $order_id<span class="token1">)</span><span class="token1">)</span><span class="token1">;</span>
<span class="token5">//商品信息</span>
foreach <span class="token1">(</span>$order_goods_id_row as $ogkey <span class="token">=</span><span class="token">></span> $order_good_id<span class="token1">)</span>
<span class="token1">{</span>
$data<span class="token1">[</span><span class="token4">'order_goods'</span><span class="token1">]</span><span class="token1">[</span><span class="token1">]</span> <span class="token">=</span> $Order_GoodsModel<span class="token">-</span><span class="token">></span><span class="token3">getOne</span><span class="token1">(</span>$order_good_id<span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
<span class="token2">if</span> <span class="token1">(</span><span class="token4">'json'</span> <span class="token">==</span> $this<span class="token">-</span><span class="token">></span>typ<span class="token1">)</span>
<span class="token1">{</span>
<span class="token2">return</span> $this<span class="token">-</span><span class="token">></span>data<span class="token">-</span><span class="token">></span><span class="token3">addBody</span><span class="token1">(</span><span class="token">-</span><span class="token6">140</span><span class="token1">,</span> $data<span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
<span class="token2">else</span>
<span class="token1">{</span>
$this<span class="token">-</span><span class="token">></span>view<span class="token">-</span><span class="token">></span><span class="token3">setMet</span><span class="token1">(</span><span class="token4">'evaladd'</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>
<span class="token5">//显示评价列表页面</span>
<span class="token5">//获取买家的所有评论</span>
$user_id <span class="token">=</span> Perm<span class="token1">:</span><span class="token1">:</span>$userId<span class="token1">;</span>
$goods_evaluation_row <span class="token">=</span> <span class="token3">array</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
$goods_evaluation_row<span class="token1">[</span><span class="token4">'user_id'</span><span class="token1">]</span> <span class="token">=</span> $user_id<span class="token1">;</span>
$data <span class="token">=</span> $Goods_EvaluationModel<span class="token">-</span><span class="token">></span><span class="token3">getEvaluationByUser</span><span class="token1">(</span>$goods_evaluation_row<span class="token1">,</span> <span class="token3">array</span><span class="token1">(</span><span class="token1">)</span><span class="token1">,</span> $page<span class="token1">,</span> $rows<span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
```
```
1.初次评价
方法链接:index.php?ctl=Goods\_Evaluation&met=addGoodsEvaluation&typ=json
控制器文件:\\shop\\controllers\\Goods\\EvaluationCtl.php
控制器:Goods\_EvaluationCtl
方法:addGoodsEvaluation()
循环商品评价
```
<pre class="calibre14">```
<span class="token3">foreach</span><span class="token1">(</span>$evaluation as $key <span class="token">=</span><span class="token">></span> $val<span class="token1">)</span>
<span class="token1">{</span>
<span class="token5">//订单商品信息</span>
$order_goods <span class="token">=</span> $Order_GoodsModel<span class="token">-</span><span class="token">></span><span class="token3">getOne</span><span class="token1">(</span>$val<span class="token1">[</span><span class="token6">0</span><span class="token1">]</span><span class="token1">)</span><span class="token1">;</span>
<span class="token5">//商品信息</span>
$goods_base <span class="token">=</span> $Goods_BaseModel<span class="token">-</span><span class="token">></span><span class="token3">getOne</span><span class="token1">(</span>$order_goods<span class="token1">[</span><span class="token4">'goods_id'</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_goods<span class="token1">[</span><span class="token4">'order_id'</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>Text_Filter<span class="token1">:</span><span class="token1">:</span><span class="token3">checkBanned</span><span class="token1">(</span>$val<span class="token1">[</span><span class="token6">3</span><span class="token1">]</span><span class="token1">,</span> $matche_row<span class="token1">)</span><span class="token1">)</span>
<span class="token1">{</span>
$data <span class="token">=</span> <span class="token3">array</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
$msg <span class="token">=</span> <span class="token3">__</span><span class="token1">(</span><span class="token4">'含有违禁词'</span><span class="token1">)</span><span class="token1">;</span>
$status <span class="token">=</span> <span class="token6">250</span><span class="token1">;</span>
$this<span class="token">-</span><span class="token">></span>data<span class="token">-</span><span class="token">></span><span class="token3">addBody</span><span class="token1">(</span><span class="token">-</span><span class="token6">140</span><span class="token1">,</span> <span class="token3">array</span><span class="token1">(</span><span class="token1">)</span><span class="token1">,</span> $msg<span class="token1">,</span> $status<span class="token1">)</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="token5">//修改商品的评价</span>
$evaluation_num <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">countGoodsEvaluation</span><span class="token1">(</span>$order_goods<span class="token1">[</span><span class="token4">'goods_id'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">;</span>
<span class="token5">//星级好评数</span>
$goods_evaluation_good_star <span class="token">=</span> <span class="token3">ceil</span><span class="token1">(</span><span class="token1">(</span>$evaluation_num <span class="token">*</span> $goods_base<span class="token1">[</span><span class="token4">'goods_evaluation_good_star'</span><span class="token1">]</span> <span class="token">+</span> $val<span class="token1">[</span><span class="token6">1</span><span class="token1">]</span><span class="token1">)</span> <span class="token">/</span> <span class="token1">(</span>$evaluation_num <span class="token">*</span> <span class="token6">1</span> <span class="token">+</span> <span class="token6">1</span><span class="token1">)</span><span class="token1">)</span><span class="token1">;</span>
$goods_evaluation_count <span class="token">=</span> $evaluation_num <span class="token">*</span> <span class="token6">1</span> <span class="token">+</span> <span class="token6">1</span><span class="token1">;</span>
$edit_row <span class="token">=</span> <span class="token3">array</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
$edit_row<span class="token1">[</span><span class="token4">'goods_evaluation_good_star'</span><span class="token1">]</span> <span class="token">=</span> $goods_evaluation_good_star<span class="token1">;</span>
$edit_row<span class="token1">[</span><span class="token4">'goods_evaluation_count'</span><span class="token1">]</span> <span class="token">=</span> $goods_evaluation_count<span class="token1">;</span>
$Goods_BaseModel<span class="token">-</span><span class="token">></span><span class="token3">editBaseFalse</span><span class="token1">(</span>$order_goods<span class="token1">[</span><span class="token4">'goods_id'</span><span class="token1">]</span><span class="token1">,</span> $edit_row<span class="token1">)</span><span class="token1">;</span>
<span class="token5">//修改商品common表中的评论数量</span>
$edit_common_row<span class="token1">[</span><span class="token4">'common_evaluate'</span><span class="token1">]</span> <span class="token">=</span> <span class="token6">1</span><span class="token1">;</span>
$Goods_CommonModel<span class="token">-</span><span class="token">></span><span class="token3">editCommonTrue</span><span class="token1">(</span>$order_goods<span class="token1">[</span><span class="token4">'common_id'</span><span class="token1">]</span><span class="token1">,</span>$edit_common_row<span class="token1">)</span><span class="token1">;</span>
<span class="token5">//插入商品评价表</span>
$flag <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">addEvalution</span><span class="token1">(</span>$add_row<span class="token1">)</span><span class="token1">;</span>
<span class="token2">if</span><span class="token1">(</span>$flag<span class="token1">)</span>
<span class="token1">{</span>
<span class="token5">/********************************************************/</span>
<span class="token5">//评价成功添加数据到统计中心 商品评分</span>
$analytics_data <span class="token">=</span> <span class="token3">array</span><span class="token1">(</span>
<span class="token4">'product_id'</span><span class="token">=</span><span class="token">></span>$goods_base<span class="token1">[</span><span class="token4">'goods_id'</span><span class="token1">]</span><span class="token1">,</span>
<span class="token4">'shop_id'</span><span class="token">=</span><span class="token">></span>$goods_base<span class="token1">[</span><span class="token4">'shop_id'</span><span class="token1">]</span><span class="token1">,</span>
<span class="token4">'score'</span><span class="token">=</span><span class="token">></span>$goods_evaluation_good_star<span class="token1">,</span>
<span class="token1">)</span><span class="token1">;</span>
Yf_Plugin_Manager<span class="token1">:</span><span class="token1">:</span><span class="token3">getInstance</span><span class="token1">(</span><span class="token1">)</span><span class="token">-</span><span class="token">></span><span class="token3">trigger</span><span class="token1">(</span><span class="token4">'analyticsScore'</span><span class="token1">,</span>$analytics_data<span class="token1">)</span><span class="token1">;</span>
<span class="token5">/********************************************************/</span>
<span class="token1">}</span>
<span class="token5">//修改订单商品表</span>
$edit_order_goods<span class="token1">[</span><span class="token4">'order_goods_evaluation_status'</span><span class="token1">]</span> <span class="token">=</span> Order_GoodsModel<span class="token1">:</span><span class="token1">:</span>EVALUATION_YES<span class="token1">;</span>
$Order_GoodsModel<span class="token">-</span><span class="token">></span><span class="token3">editGoods</span><span class="token1">(</span>$val<span class="token1">[</span><span class="token6">0</span><span class="token1">]</span><span class="token1">,</span> $edit_order_goods<span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
```
```
添加店铺评价
```
<pre class="calibre14">```
$Shop_EvaluationModel<span class="token">-</span><span class="token">></span><span class="token3">addEvaluation</span><span class="token1">(</span>$add_shop_row<span class="token1">)</span><span class="token1">;</span>
<span class="token5">/********************************************************/</span>
<span class="token5">//评价成功添加数据到统计中心 店铺评分</span>
$analytics_data <span class="token">=</span> <span class="token3">array</span><span class="token1">(</span>
<span class="token4">'shop_id'</span><span class="token">=</span><span class="token">></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>
Yf_Plugin_Manager<span class="token1">:</span><span class="token1">:</span><span class="token3">getInstance</span><span class="token1">(</span><span class="token1">)</span><span class="token">-</span><span class="token">></span><span class="token3">trigger</span><span class="token1">(</span><span class="token4">'analyticsShopCredit'</span><span class="token1">,</span>$analytics_data<span class="token1">)</span><span class="token1">;</span>
<span class="token5">/********************************************************/</span>
<span class="token5">//修改订单中的评价信息</span>
$edit_order<span class="token1">[</span><span class="token4">'order_buyer_evaluation_status'</span><span class="token1">]</span> <span class="token">=</span> Order_BaseModel<span class="token1">:</span><span class="token1">:</span>BUYER_EVALUATE_YES<span class="token1">;</span>
$edit_order<span class="token1">[</span><span class="token4">'order_buyer_evaluation_time'</span><span class="token1">]</span> <span class="token">=</span> <span class="token3">get_date_time</span><span class="token1">(</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>$order_base<span class="token1">[</span><span class="token4">'order_id'</span><span class="token1">]</span><span class="token1">,</span> $edit_order<span class="token1">)</span><span class="token1">;</span>
```
```
评价成功后,修改用户的积分及成长值。
2.追加评价
方法链接:index.php?ctl=Goods\_Evaluation&met=againGoodsEvaluation&typ=json
控制器文件:\\shop\\controllers\\Goods\\EvaluationCtl.php
控制器:Goods\_EvaluationCtl
方法:againGoodsEvaluation()
获取追加评价的商品的初次评价信息
```
<pre class="calibre14">```
$evaluation_base <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">getOne</span><span class="token1">(</span>$evaluation_goods_id<span class="token1">)</span><span class="token1">;</span>
```
```
判断是否存在违禁词
```
<pre class="calibre14">```
<span class="token2">if</span> <span class="token1">(</span>Text_Filter<span class="token1">:</span><span class="token1">:</span><span class="token3">checkBanned</span><span class="token1">(</span>$content<span class="token1">,</span> $matche_row<span class="token1">)</span><span class="token1">)</span>
<span class="token1">{</span>
$data <span class="token">=</span> <span class="token3">array</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
$msg <span class="token">=</span> <span class="token3">__</span><span class="token1">(</span><span class="token4">'含有违禁词'</span><span class="token1">)</span><span class="token1">;</span>
$status <span class="token">=</span> <span class="token6">250</span><span class="token1">;</span>
$this<span class="token">-</span><span class="token">></span>data<span class="token">-</span><span class="token">></span><span class="token3">addBody</span><span class="token1">(</span><span class="token">-</span><span class="token6">140</span><span class="token1">,</span> <span class="token3">array</span><span class="token1">(</span><span class="token1">)</span><span class="token1">,</span> $msg<span class="token1">,</span> $status<span class="token1">)</span><span class="token1">;</span>
<span class="token2">return</span> <span class="token6">false</span><span class="token1">;</span>
<span class="token1">}</span>
```
```
修改商品评价数
```
<pre class="calibre14">```
$edit_row<span class="token1">[</span><span class="token4">'goods_evaluation_count'</span><span class="token1">]</span> <span class="token">=</span> $goods_evaluation_count<span class="token1">;</span>
$Goods_BaseModel <span class="token">=</span> <span class="token2">new</span> <span class="token3">Goods_BaseModel</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
$edit_flag <span class="token">=</span> $Goods_BaseModel<span class="token">-</span><span class="token">></span><span class="token3">editBase</span><span class="token1">(</span>$goods_id<span class="token1">,</span> $edit_row<span class="token1">)</span><span class="token1">;</span>
```
```
插入商品评价表
```
<pre class="calibre14">```
$add_flag <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">addEvalution</span><span class="token1">(</span>$add_row<span class="token1">)</span><span class="token1">;</span>
```
```
修改订单商品表中商品的评价状态
```
<pre class="calibre14">```
$og_update_flag <span class="token">=</span> $order_goods_model<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="token1">[</span><span class="token4">'order_goods_evaluation_status'</span><span class="token">=</span><span class="token">></span> Order_GoodsModel<span class="token1">:</span><span class="token1">:</span>EVALUATION_AGAIN<span class="token1">]</span><span class="token1">)</span><span class="token1">;</span>
```
```
追加评价成功后,修改用户的积分及成长值。
#### 5.买家取消订单
方法路径:index.php?ctl=Buyer\_Order&met=orderCancel&user=buyer
文件路径:\\shop\\controllers\\Buyer\\OrderCtl.php
控制器:Buyer\_OrderCtl
方法:orderCancel()
根据typ判断是显示页面,还是操作
```
<pre class="calibre14">```
<span class="token2">if</span> <span class="token1">(</span>$typ <span class="token">==</span> <span class="token4">'e'</span><span class="token1">)</span>
<span class="token1">{</span>
<span class="token5">//显示页面</span>
$cancel_row<span class="token1">[</span><span class="token4">'cancel_identity'</span><span class="token1">]</span> <span class="token">=</span> Order_CancelReasonModel<span class="token1">:</span><span class="token1">:</span>CANCEL_BUYER<span class="token1">;</span>
<span class="token5">//获取取消原因</span>
$Order_CancelReasonModel <span class="token">=</span> <span class="token2">new</span> <span class="token3">Order_CancelReasonModel</span><span class="token1">;</span>
$reason <span class="token">=</span> <span class="token3">array_values</span><span class="token1">(</span>$Order_CancelReasonModel<span class="token">-</span><span class="token">></span><span class="token3">getByWhere</span><span class="token1">(</span>$cancel_row<span class="token1">)</span><span class="token1">)</span><span class="token1">;</span>
include $this<span class="token">-</span><span class="token">></span>view<span class="token">-</span><span class="token">></span><span class="token3">getView</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
<span class="token2">else</span>
<span class="token1">{</span>
处理取消订单
<span class="token1">}</span>
```
```
处理取消订单
获取订单详情,判断订单的状态与下单者是否是当前用户
```
<pre class="calibre14">```
$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>
<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>
<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_PAY
<span class="token">&&</span> $order_base<span class="token1">[</span><span class="token4">'buyer_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="token1">}</span>
```
```
修改订单信息
```
<pre class="calibre14">```
<span class="token5">//订单状态</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>
<span class="token5">//订单取消原因</span>
$condition<span class="token1">[</span><span class="token4">'order_cancel_reason'</span><span class="token1">]</span> <span class="token">=</span> <span class="token3">addslashes</span><span class="token1">(</span>$state_info<span class="token1">)</span><span class="token1">;</span>
<span class="token5">//订单取消者身份</span>
$condition<span class="token1">[</span><span class="token4">'order_cancel_identity'</span><span class="token1">]</span> <span class="token">=</span> Order_BaseModel<span class="token1">:</span><span class="token1">:</span>IS_BUYER_CANCEL<span class="token1">;</span>
<span class="token5">//订单取消时间</span>
$condition<span class="token1">[</span><span class="token4">'order_cancel_date'</span><span class="token1">]</span> <span class="token">=</span> <span class="token3">get_date_time</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</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>
```
```
修改订单商品信息
```
<pre class="calibre14">```
<span class="token5">//订单商品状态</span>
$edit_row<span class="token1">[</span><span class="token4">'order_goods_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>
$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_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_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>
```
```
修改商品库存
修改paycenter中的订单状态
```
<pre class="calibre14">```
$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>
```
```
判断订单是否使用平台红包,如果使用,将平台红包状态改为未使用
```
<pre class="calibre14">```
<span class="token5">//判断订单是否使用平台红包,如果使用,将平台红包状态改为未使用</span>
$RedPacket_BaseModel <span class="token">=</span> <span class="token2">new</span> <span class="token3">RedPacket_BaseModel</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
$red_data <span class="token">=</span> $RedPacket_BaseModel<span class="token">-</span><span class="token">></span><span class="token3">getOneByWhere</span><span class="token1">(</span><span class="token1">[</span><span class="token4">'redpacket_order_id'</span><span class="token">=</span><span class="token">></span>$order_base<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>$red_data<span class="token1">)</span>
<span class="token1">{</span>
$red_flag <span class="token">=</span> $RedPacket_BaseModel<span class="token">-</span><span class="token">></span><span class="token3">editRedPacket</span><span class="token1">(</span>$red_data<span class="token1">[</span><span class="token4">'redpacket_id'</span><span class="token1">]</span><span class="token1">,</span> <span class="token1">[</span><span class="token4">'redpacket_state'</span><span class="token">=</span><span class="token">></span>RedPacket_BaseModel<span class="token1">:</span><span class="token1">:</span>UNUSED<span class="token1">]</span><span class="token1">)</span><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
- 配置
- 平台帐号
- 活动数据表说明