多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
# 退款管理 一、买家申请退款 文件路径:shop/controllers/Buyer/Service/ReturnCtl.php ``` <pre class="calibre14">``` <span class="token5">//根据URL参数act,判断视图</span> <span class="token2">if</span> <span class="token1">(</span>$act <span class="token">==</span> <span class="token4">"detail"</span><span class="token1">)</span> <span class="token1">{</span> $data <span class="token">=</span> $this<span class="token">-</span><span class="token">></span><span class="token3">detail</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span> $this<span class="token">-</span><span class="token">></span>view<span class="token">-</span><span class="token">></span><span class="token3">setMet</span><span class="token1">(</span><span class="token4">'detail'</span><span class="token1">)</span><span class="token1">;</span> $d <span class="token">=</span> $data<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> $data <span class="token">=</span> $this<span class="token">-</span><span class="token">></span><span class="token3">add</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span> <span class="token2">if</span> <span class="token1">(</span>$data <span class="token">==</span> <span class="token">-</span><span class="token6">3</span><span class="token1">)</span> <span class="token1">{</span> $this<span class="token">-</span><span class="token">></span>view<span class="token">-</span><span class="token">></span><span class="token3">setMet</span><span class="token1">(</span><span class="token4">'error3'</span><span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span><span class="token3">elseif</span><span class="token1">(</span>$data <span class="token">==</span> <span class="token">-</span><span class="token6">4</span><span class="token1">)</span><span class="token1">{</span> $this<span class="token">-</span><span class="token">></span>view<span class="token">-</span><span class="token">></span><span class="token3">setMet</span><span class="token1">(</span><span class="token4">'error4'</span><span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> elseif <span class="token1">(</span>$data <span class="token">==</span> <span class="token">-</span><span class="token6">1</span><span class="token1">)</span> <span class="token1">{</span> $this<span class="token">-</span><span class="token">></span>view<span class="token">-</span><span class="token">></span><span class="token3">setMet</span><span class="token1">(</span><span class="token4">'error2'</span><span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> elseif <span class="token1">(</span>$data <span class="token">==</span> <span class="token6">0</span><span class="token1">)</span> <span class="token1">{</span> $this<span class="token">-</span><span class="token">></span>view<span class="token">-</span><span class="token">></span><span class="token3">setMet</span><span class="token1">(</span><span class="token4">'error'</span><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">'add'</span><span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> <span class="token1">}</span> ``` ``` 视图:shop/views/default/Buyer/Service/ReturnCtl/add.php 退款表单提交: ``` <pre class="calibre14">``` $<span class="token1">(</span><span class="token4">'#form'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">validator</span><span class="token1">(</span><span class="token1">{</span> <span class="token1">.</span><span class="token1">.</span><span class="token1">.</span><span class="token1">.</span><span class="token1">.</span><span class="token1">.</span> <span class="token1">}</span><span class="token1">)</span><span class="token1">.</span><span class="token3">on</span><span class="token1">(</span><span class="token4">"click"</span><span class="token1">,</span> <span class="token4">"#handle_submit"</span><span class="token1">,</span> <span class="token2">function</span> <span class="token1">(</span>e<span class="token1">)</span> <span class="token1">{</span> submit_trigger <span class="token">?</span> $<span class="token1">(</span>e<span class="token1">.</span>delegateTarget<span class="token1">)</span><span class="token1">.</span><span class="token3">trigger</span><span class="token1">(</span><span class="token4">"validate"</span><span class="token1">)</span> <span class="token1">:</span> submit_trigger <span class="token">=</span> <span class="token6">false</span><span class="token1">;</span> <span class="token1">}</span><span class="token1">)</span><span class="token1">;</span> ``` ``` 方法:addReturn() ``` <pre class="calibre14">``` <span class="token5">//如果是货到付款,确认收货(付款)后才能退款</span> <span class="token2">if</span><span class="token1">(</span>$order<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> <span class="token2">if</span><span class="token1">(</span>$order<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> $flag2 <span class="token">=</span> <span class="token6">false</span><span class="token1">;</span> <span class="token1">}</span> <span class="token3">fb</span><span class="token1">(</span>$flag2<span class="token1">)</span><span class="token1">;</span> <span class="token3">fb</span><span class="token1">(</span><span class="token4">'flag22'</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>$goods<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_PAYED <span class="token">&&</span> $order<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> <span class="token5">//白条支付不支持退款和退货</span> <span class="token2">if</span><span class="token1">(</span><span class="token3">strstr</span><span class="token1">(</span>$order<span class="token1">[</span><span class="token4">'payment_name'</span><span class="token1">]</span><span class="token1">,</span><span class="token4">'白条支付'</span><span class="token1">)</span><span class="token1">)</span><span class="token1">{</span> $flag2 <span class="token">=</span> <span class="token6">false</span><span class="token1">;</span> <span class="token1">}</span> <span class="token3">fb</span><span class="token1">(</span>$flag2<span class="token1">)</span><span class="token1">;</span> <span class="token3">fb</span><span class="token1">(</span><span class="token4">'flag23'</span><span class="token1">)</span><span class="token1">;</span> $field<span class="token1">[</span><span class="token4">'return_goods_return'</span><span class="token1">]</span> <span class="token">=</span> <span class="token6">0</span><span class="token1">;</span> <span class="token5">//是否需要退货 0-不需要 1-需要</span> $<span class="token2">return</span> <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>orderReturnModel<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_goods_id'</span> <span class="token">=</span><span class="token">></span> $goods_id<span class="token1">,</span> <span class="token4">'return_type'</span> <span class="token">=</span><span class="token">></span> Order_ReturnModel<span class="token1">:</span><span class="token1">:</span>RETURN_TYPE_ORDER<span class="token1">,</span> <span class="token4">'return_state:!='</span> <span class="token">=</span><span class="token">></span> Order_ReturnModel<span class="token1">:</span><span class="token1">:</span>RETURN_SELLER_UNPASS <span class="token1">)</span><span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> ``` ``` 二、买家审核退款 文件路径:shop/controllers/Seller/Service/ReturnCtl.php 视图:shop/views/default/Seller/Service/ReturnCtl/detail.php 处理结果表单提交: ``` <pre class="calibre14">``` $<span class="token1">(</span><span class="token4">'#form'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">validator</span><span class="token1">(</span><span class="token1">{</span> ignore<span class="token1">:</span> <span class="token4">':hidden'</span><span class="token1">,</span> theme<span class="token1">:</span> <span class="token4">'yellow_right'</span><span class="token1">,</span> timely<span class="token1">:</span> <span class="token6">1</span><span class="token1">,</span> stopOnError<span class="token1">:</span> <span class="token6">false</span><span class="token1">,</span> fields<span class="token1">:</span> <span class="token1">{</span>return_shop_message<span class="token1">:</span> <span class="token4">"required"</span><span class="token1">}</span><span class="token1">,</span> valid<span class="token1">:</span> <span class="token2">function</span> <span class="token1">(</span>form<span class="token1">)</span> <span class="token1">{</span> <span class="token5">//表单验证通过,提交表单</span> <span class="token1">.</span><span class="token1">.</span><span class="token1">.</span><span class="token1">.</span><span class="token1">.</span><span class="token1">.</span> <span class="token1">}</span><span class="token1">)</span><span class="token1">.</span><span class="token3">on</span><span class="token1">(</span><span class="token4">"click"</span><span class="token1">,</span> <span class="token4">"#handle_submit"</span><span class="token1">,</span> <span class="token2">function</span> <span class="token1">(</span>e<span class="token1">)</span> <span class="token1">{</span> <span class="token5">//同意</span> ajax_url <span class="token">=</span> SITE_URL <span class="token">+</span> <span class="token4">'?ctl=Seller_Service_Return&met=agreeReturn&typ=json'</span><span class="token1">;</span> $<span class="token1">(</span>e<span class="token1">.</span>delegateTarget<span class="token1">)</span><span class="token1">.</span><span class="token3">trigger</span><span class="token1">(</span><span class="token4">"validate"</span><span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span><span class="token1">)</span><span class="token1">.</span><span class="token3">on</span><span class="token1">(</span><span class="token4">"click"</span><span class="token1">,</span> <span class="token4">"#handle_close"</span><span class="token1">,</span> <span class="token2">function</span> <span class="token1">(</span>e<span class="token1">)</span> <span class="token1">{</span> <span class="token5">//不同意</span> ajax_url <span class="token">=</span> SITE_URL <span class="token">+</span> <span class="token4">'?ctl=Seller_Service_Return&met=closeReturn&typ=json'</span><span class="token1">;</span> $<span class="token1">(</span>e<span class="token1">.</span>delegateTarget<span class="token1">)</span><span class="token1">.</span><span class="token3">trigger</span><span class="token1">(</span><span class="token4">"validate"</span><span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span><span class="token1">)</span><span class="token1">;</span> ``` ``` 三、平台审核,退款完成 文件路径:shop/controllers/Api/Trade/ReturnCtl.php 视图:shop\_admin/view/default/Trade/ReturnCtl/detail.php JS:shop\_admin/static/default/js/controllers/trade/return/detail.js 四、买家退款管理 文件路径:shop/controllers/Seller/Service/ReturnCtl.php - 退款流程:申请退款->卖家同意->平台同意->退款成功 - 退款状态: ``` <pre class="calibre14">``` <span class="token5">//模型:shop/models/Order/ReturnModel.php</span> public <span class="token2">function</span> <span class="token3">__construct</span><span class="token1">(</span><span class="token1">)</span> <span class="token1">{</span> parent<span class="token1">:</span><span class="token1">:</span><span class="token3">__construct</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span> $this<span class="token">-</span><span class="token">></span>return_state <span class="token">=</span> <span class="token3">array</span><span class="token1">(</span> <span class="token4">'1'</span> <span class="token">=</span><span class="token">></span> <span class="token3">__</span><span class="token1">(</span><span class="token4">"等待卖家审核"</span><span class="token1">)</span><span class="token1">,</span> <span class="token4">'2'</span> <span class="token">=</span><span class="token">></span> <span class="token3">__</span><span class="token1">(</span><span class="token4">"卖家审核通过"</span><span class="token1">)</span><span class="token1">,</span> <span class="token4">'3'</span> <span class="token">=</span><span class="token">></span> <span class="token3">__</span><span class="token1">(</span><span class="token4">"卖家审核未通过"</span><span class="token1">)</span><span class="token1">,</span> <span class="token4">'4'</span> <span class="token">=</span><span class="token">></span> <span class="token3">__</span><span class="token1">(</span><span class="token4">"等待平台审核"</span><span class="token1">)</span><span class="token1">,</span> <span class="token4">'5'</span> <span class="token">=</span><span class="token">></span> <span class="token3">__</span><span class="token1">(</span><span class="token4">"退款/货完成"</span><span class="token1">)</span><span class="token1">,</span> <span class="token1">)</span><span class="token1">;</span> $this<span class="token">-</span><span class="token">></span>return_type <span class="token">=</span> <span class="token3">array</span><span class="token1">(</span> <span class="token4">'1'</span> <span class="token">=</span><span class="token">></span> <span class="token3">__</span><span class="token1">(</span><span class="token4">"退款"</span><span class="token1">)</span><span class="token1">,</span> <span class="token4">'2'</span> <span class="token">=</span><span class="token">></span> <span class="token3">__</span><span class="token1">(</span><span class="token4">"退货"</span><span class="token1">)</span><span class="token1">,</span> <span class="token4">'3'</span> <span class="token">=</span><span class="token">></span> <span class="token3">__</span><span class="token1">(</span><span class="token4">"虚拟订单退款"</span><span class="token1">)</span> <span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> ``` ``` - 视图:根据URL获得参数act的值,判断视图 ``` <pre class="calibre14">``` <span class="token2">if</span> <span class="token1">(</span>$act <span class="token">==</span> <span class="token4">"detail"</span><span class="token1">)</span> <span class="token1">{</span> $data <span class="token">=</span> $this<span class="token">-</span><span class="token">></span><span class="token3">detail</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span> $this<span class="token">-</span><span class="token">></span>view<span class="token">-</span><span class="token">></span><span class="token3">setMet</span><span class="token1">(</span><span class="token4">'detail'</span><span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> <span class="token2">else</span> <span class="token1">{</span> <span class="token5">//orderReturn.php</span> <span class="token1">}</span> ``` ``` 1.退款管理列表 方法:orderReturn()、listReturn() ``` <pre class="calibre14">``` $data <span class="token">=</span> $this<span class="token">-</span><span class="token">></span><span class="token3">listReturn</span><span class="token1">(</span>Order_ReturnModel<span class="token1">:</span><span class="token1">:</span>RETURN_TYPE_ORDER<span class="token1">)</span><span class="token1">;</span> public <span class="token2">function</span> <span class="token3">listReturn</span><span class="token1">(</span>$type<span class="token1">)</span> <span class="token1">{</span> $data <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>orderReturnModel<span class="token">-</span><span class="token">></span><span class="token3">getReturnList</span><span class="token1">(</span>$cond_row<span class="token1">,</span> <span class="token3">array</span><span class="token1">(</span><span class="token4">'return_add_time'</span> <span class="token">=</span><span class="token">></span> <span class="token4">'DESC'</span><span class="token1">)</span><span class="token1">,</span> $page<span class="token1">,</span> $rows<span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> ``` ``` 2.查看退款详情 视图:shop/views/default/Seller/Service/ReturnCtl/detail.php - 卖家同意退款方法:agreeReturn() ``` <pre class="calibre14">``` <span class="token5">//判断该笔退款金额的订单是否已经结算</span> $Order_BaseModel <span class="token">=</span> <span class="token2">new</span> <span class="token3">Order_BaseModel</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span> $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>$<span class="token2">return</span><span class="token1">[</span><span class="token4">'order_number'</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>$order_base<span class="token1">[</span><span class="token4">'order_status'</span><span class="token1">]</span> <span class="token">==</span> $Order_StateModel<span class="token1">:</span><span class="token1">:</span>ORDER_FINISH <span class="token1">)</span> <span class="token1">{</span> $order_finish <span class="token">=</span> <span class="token6">false</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> $formvars <span class="token">=</span> <span class="token3">array</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span> $user_id <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">'user_id'</span><span class="token1">]</span> <span class="token">=</span> $user_id<span class="token1">;</span> $formvars<span class="token1">[</span><span class="token4">'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> $money_row <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=getUserResourceInfo&typ=json'</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">'paycenter_api_url'</span><span class="token1">)</span><span class="token1">)</span><span class="token1">,</span> $formvars<span class="token1">)</span><span class="token1">;</span> $user_money <span class="token">=</span> <span class="token6">0</span><span class="token1">;</span> $user_money_frozen <span class="token">=</span> <span class="token6">0</span><span class="token1">;</span> <span class="token2">if</span> <span class="token1">(</span>$money_row<span class="token1">[</span><span class="token4">'status'</span><span class="token1">]</span> <span class="token">==</span> <span class="token4">'200'</span><span class="token1">)</span> <span class="token1">{</span> $money <span class="token">=</span> $money_row<span class="token1">[</span><span class="token4">'data'</span><span class="token1">]</span><span class="token1">;</span> $user_money <span class="token">=</span> $money<span class="token1">[</span><span class="token4">'user_money'</span><span class="token1">]</span><span class="token1">;</span> $user_money_frozen <span class="token">=</span> $money<span class="token1">[</span><span class="token4">'user_money_frozen'</span><span class="token1">]</span><span class="token1">;</span> <span class="token1">}</span> $shop_return_amount <span class="token">=</span> $<span class="token2">return</span><span class="token1">[</span><span class="token4">'return_cash'</span><span class="token1">]</span> <span class="token">-</span> $<span class="token2">return</span><span class="token1">[</span><span class="token4">'return_commision_fee'</span><span class="token1">]</span><span class="token1">;</span> <span class="token5">//获取该店铺最新的结算结束日期</span> $Order_SettlementModel <span class="token">=</span> <span class="token2">new</span> <span class="token3">Order_SettlementModel</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span> $settlement_last_info <span class="token">=</span> $Order_SettlementModel<span class="token">-</span><span class="token">></span><span class="token3">getLastSettlementByShopid</span><span class="token1">(</span>Perm<span class="token1">:</span><span class="token1">:</span>$shopId<span class="token1">,</span> $<span class="token2">return</span><span class="token1">[</span><span class="token4">'order_is_virtual'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">;</span> <span class="token2">if</span><span class="token1">(</span>$settlement_last_info<span class="token1">)</span> <span class="token1">{</span> $settlement_unixtime <span class="token">=</span> $settlement_last_info<span class="token1">[</span><span class="token4">'os_end_date'</span><span class="token1">]</span> <span class="token1">;</span> <span class="token1">}</span> <span class="token2">else</span> <span class="token1">{</span> $settlement_unixtime <span class="token">=</span> <span class="token4">''</span><span class="token1">;</span> <span class="token1">}</span> $settlement_unixtime <span class="token">=</span> <span class="token3">strtotime</span><span class="token1">(</span>$settlement_unixtime<span class="token1">)</span><span class="token1">;</span> $order_finish_time <span class="token">=</span> $order_base<span class="token1">[</span><span class="token4">'order_finished_time'</span><span class="token1">]</span><span class="token1">;</span> $order_finish_unixtime <span class="token">=</span> <span class="token3">strtotime</span><span class="token1">(</span>$order_finish_time<span class="token1">)</span><span class="token1">;</span> <span class="token3">fb</span><span class="token1">(</span>$settlement_unixtime<span class="token1">)</span><span class="token1">;</span> <span class="token2">if</span><span class="token1">(</span>$settlement_unixtime <span class="token">>=</span> $order_finish_unixtime <span class="token1">)</span> <span class="token1">{</span> <span class="token5">//结算时间大于订单完成时间。需要扣除卖家的现金账户</span> $money <span class="token">=</span> $user_money<span class="token1">;</span> $pay_type <span class="token">=</span> <span class="token4">'cash'</span><span class="token1">;</span> <span class="token1">}</span> <span class="token2">else</span> <span class="token1">{</span> <span class="token5">//结算时间小于订单完成时间。需要扣除卖家的冻结资金,如果冻结资金不足就扣除账户余额</span> $money <span class="token">=</span> $user_money_frozen <span class="token">+</span> $user_money<span class="token1">;</span> $pay_type <span class="token">=</span> <span class="token4">'frozen_cash'</span><span class="token1">;</span> <span class="token1">}</span> <span class="token1">}</span> <span class="token2">else</span> <span class="token1">{</span> $order_finish <span class="token">=</span> <span class="token6">true</span><span class="token1">;</span> <span class="token1">}</span> ``` ``` - 卖家不同意退款方法:closeReturn() `$edit_flag = $this->orderReturnModel->editReturn($order_return_id, $data);` 五、买家退款管理 1.退款申请列表 文件路径:shop/controllers/Buyer/Service/ReturnCtl.php 视图:shop/views/default/Buyer/Service/ReturnCtl/index.php `$data = $this->orderReturnModel->getReturnList($cond_row, array('return_add_time' => 'DESC'), $page, $rows);` 2.退款详情 文件路径:shop/controllers/Buyer/Service/ReturnCtl.php 视图:shop/views/default/Buyer/Service/ReturnCtl/detail.php ``` <pre class="calibre15">``` <span class="token5">//查找退货单信息</span> $data <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>orderReturnModel<span class="token">-</span><span class="token">></span><span class="token3">getReturn</span><span class="token1">(</span>$cond_row<span class="token1">)</span><span class="token1">;</span> <span class="token5">//查找订单信息</span> $order_base <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>orderBaseModel<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_number'</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>$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> <span class="token1">(</span>$order_base<span class="token1">[</span><span class="token4">'order_sub_pay'</span><span class="token1">]</span> <span class="token">==</span> Order_StateModel<span class="token1">:</span><span class="token1">:</span>SUB_USER_PAY <span class="token">&&</span> $order_base<span class="token1">[</span><span class="token4">'order_sub_user'</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> <span class="token2">if</span> <span class="token1">(</span>$data<span class="token1">[</span><span class="token4">'return_type'</span><span class="token1">]</span> <span class="token">==</span> Order_ReturnModel<span class="token1">:</span><span class="token1">:</span>RETURN_TYPE_GOODS<span class="token1">)</span> <span class="token1">{</span> $data<span class="token1">[</span><span class="token4">'text'</span><span class="token1">]</span> <span class="token">=</span> <span class="token3">__</span><span class="token1">(</span><span class="token4">"退货"</span><span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> <span class="token2">else</span> <span class="token1">{</span> $data<span class="token1">[</span><span class="token4">'text'</span><span class="token1">]</span> <span class="token">=</span> <span class="token3">__</span><span class="token1">(</span><span class="token4">"退款"</span><span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> <span class="token2">if</span><span class="token1">(</span>$data<span class="token1">[</span><span class="token4">'order_goods_id'</span><span class="token1">]</span><span class="token1">)</span> <span class="token1">{</span> $data<span class="token1">[</span><span class="token4">'refund_goods'</span><span class="token1">]</span> <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>orderGoodsModel<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_goods_id'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">;</span> <span class="token1">}</span> $data<span class="token1">[</span><span class="token4">'order'</span><span class="token1">]</span> <span class="token">=</span> $order_base<span class="token1">;</span> $return_limit <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>orderReturnModel<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_number'</span> <span class="token">=</span><span class="token">></span> $data<span class="token1">[</span><span class="token4">'order'</span><span class="token1">]</span><span class="token1">[</span><span class="token4">'order_id'</span><span class="token1">]</span><span class="token1">,</span> <span class="token4">'return_state:!='</span> <span class="token">=</span><span class="token">></span> Order_ReturnModel<span class="token1">:</span><span class="token1">:</span>RETURN_SELLER_UNPASS <span class="token1">)</span><span class="token1">)</span><span class="token1">;</span> $cash <span class="token">=</span> <span class="token6">0</span><span class="token1">;</span> foreach <span class="token1">(</span>$return_limit as $v<span class="token1">)</span> <span class="token1">{</span> $cash <span class="token">+</span><span class="token">=</span> $v<span class="token1">[</span><span class="token4">'return_cash'</span><span class="token1">]</span><span class="token1">;</span> <span class="token1">}</span> $data<span class="token1">[</span><span class="token4">'return_limit'</span><span class="token1">]</span> <span class="token">=</span> $cash<span class="token1">;</span> ``` ```