💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
一、买家申请退货 文件路径:shop/controllers/Buyer/Service/ReturnCtl.php ~~~ //根据URL参数act,判断视图 if ($act == "detail") { $data = $this->detail(); $this->view->setMet('detail'); $d = $data; } elseif ($act == "add") { $data = $this->add(); if ($data == -3) { $this->view->setMet('error3'); }elseif($data == -4){ $this->view->setMet('error4'); } elseif ($data == -1) { $this->view->setMet('error2'); } elseif ($data == 0) { $this->view->setMet('error'); } else { $this->view->setMet('add'); } } ~~~ 视图:shop/views/default/Buyer/Service/ReturnCtl/add.php 退货表单提交: ~~~ $('#form').validator({ ...... }).on("click", "#handle_submit", function (e) { submit_trigger ? $(e.delegateTarget).trigger("validate") : submit_trigger = false; }); ~~~ 方法:addReturn() ~~~ //退货 if ($goods['order_goods_status'] == Order_StateModel::ORDER_FINISH) { if(strstr($order['payment_name'],'白条支付')){ $flag2 = false; } $field['return_goods_return'] = 1; //需要退货 //查询是否存在该订单商品的退货申请信息,且该申请未被卖家拒绝,以此判断是否重新提交退货申请 //只有以前没有提交过该商品的退货申请,且未被卖家拒绝的情况下,才可以提交退货申请 $return = $this->orderReturnModel->getByWhere(array( 'order_goods_id' => $goods_id, 'return_type' => Order_ReturnModel::RETURN_TYPE_GOODS, 'return_state:!=' => Order_ReturnModel::RETURN_SELLER_UNPASS )); } ~~~ 二、卖家审核退货申请Seller_Service_Return&met=goodsReturn&act=detail 文件路径:shop/controllers/Seller/Service/ReturnCtl.php ~~~ //根据URL参数act,判断视图 if ($act == "detail") { $data = $this->detail(); $this->view->setMet('detail'); } ~~~ 视图:shop/views/default/Seller/Service/ReturnCtl/detail.php 卖家审核表单提交: ~~~ $('#form').validator({ //审核 ...... }).on("click", "#handle_submit", function (e) { ajax_url = SITE_URL + '?ctl=Seller_Service_Return&met=agreeReturn&typ=json'; $(e.delegateTarget).trigger("validate"); }).on("click", "#handle_close", function (e) { ajax_url = SITE_URL + '?ctl=Seller_Service_Return&met=closeReturn&typ=json'; $(e.delegateTarget).trigger("validate"); }); ~~~ 审核同意方法:agreeReturn() ~~~ $data['return_shop_message'] = $return_shop_message; if ($return['return_goods_return'] == Order_ReturnModel::RETURN_GOODS_RETURN) { $data['return_state'] = Order_ReturnModel::RETURN_SELLER_PASS; } else { $data['return_state'] = Order_ReturnModel::RETURN_SELLER_GOODS; } $data['return_shop_handle'] = Order_ReturnModel::RETURN_SELLER_PASS; $data['return_shop_time'] = get_date_time(); $flag = $this->orderReturnModel->editReturn($order_return_id, $data); ~~~ 审核不同意方法:closeReturn() ~~~ $data['return_shop_message'] = $return_shop_message; $data['return_state'] = Order_ReturnModel::RETURN_SELLER_UNPASS; $data['return_shop_handle'] = Order_ReturnModel::RETURN_SELLER_UNPASS; $data['return_shop_time'] = get_date_time(); $rs_row = array(); $this->orderReturnModel->sql->startTransactionDb(); $edit_flag = $this->orderReturnModel->editReturn($order_return_id, $data); ~~~ 三、卖家确认收获 文件路径:shop/controllers/Seller/Service/ReturnCtl.php 视图:shop/views/default/Seller/Service/ReturnCtl/detail.php ~~~ $('#form2').validator({ ignore: ':hidden', theme: 'yellow_right', timely: 1, stopOnError: false, fields: {}, valid: function (form) { //表单验证通过,提交表单 $.ajax({ url: SITE_URL + '?ctl=Seller_Service_Return&met=agreeGoods&typ=json', data: $("#form2").serialize(), success: function (a) { if (a.status == 200) { location.href = "./index.php?ctl=Seller_Service_Return&met=<?php if ($data['order_goods_id']) { echo "goodsReturn"; } else { echo "orderReturn"; }?>&act=detail&id=" + order_return_id; } else { Public.tips.error('<?=__('操作失败!')?>'); } } }); } }).on("click", "#handle_goods", function (e) { $(e.delegateTarget).trigger("validate"); }); ~~~ 方法:agreeGoods() ~~~ $data['return_state'] = Order_ReturnModel::RETURN_SELLER_GOODS; $flag = $this->orderReturnModel->editReturn($order_return_id, $data); check_rs($flag,$rs_row); //如果订单为分销商采购单,扣除分销商的钱 if($order_base['order_source_id']) { $dist_order = $Order_BaseModel -> getOneByWhere(array('order_id'=>$order_base['order_source_id'])); if(!empty($dist_order)){ $dist_return_order = $this->orderReturnModel->getOneByWhere(array('order_number'=>$dist_order['order_id'],'return_type'=>$return['return_type'])); $flag = $this->orderReturnModel->editReturn($dist_return_order['order_return_id'], $data); check_rs($flag,$rs_row); } ~~~ 四、平台审核 文件路径: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 * 退货流程:申请退货->卖家同意->买家退货->退货成功 * 退货状态: ~~~ //模型:shop/models/Order/ReturnModel.php public function __construct() { parent::__construct(); $this->return_state = array( '1' => __("等待卖家审核"), '2' => __("卖家审核通过"), '3' => __("卖家审核未通过"), '4' => __("等待平台审核"), '5' => __("退款/货完成"), ); $this->return_type = array( '1' => __("退款"), '2' => __("退货"), '3' => __("虚拟订单退款") ); } ~~~ * 视图:根据URL获得参数act的值,判断视图 ~~~ if ($act == "detail") { $data = $this->detail(); $this->view->setMet('detail'); } else { //goodsReturn.php } ~~~ 1.退货管理列表 方法:goodsReturn()、listReturn() ~~~ $data = $this->listReturn(Order_ReturnModel::RETURN_TYPE_ORDER); public function listReturn($type) { $data = $this->orderReturnModel->getReturnList($cond_row, array('return_add_time' => 'DESC'), $page, $rows); } ~~~ 2.查看退货详情 视图:shop/views/default/Seller/Service/ReturnCtl/detail.php * 卖家同意退货方法:agreeReturn() ~~~ //判断该笔退款金额的订单是否已经结算 $Order_BaseModel = new Order_BaseModel(); $order_base = $Order_BaseModel->getOne($return['order_number']); //判断该笔订单是否已经收货,如果没有收货的话,不扣除卖家资金。已确认收货则扣除卖家资金 if($order_base['order_status'] == $Order_StateModel::ORDER_FINISH ) { $order_finish = false; //获取用户的账户资金资源 $key = Yf_Registry::get('shop_api_key'); $formvars = array(); $user_id = Perm::$userId; $formvars['user_id'] = $user_id; $formvars['app_id'] = Yf_Registry::get('shop_app_id'); $money_row = get_url_with_encrypt($key, sprintf('%s?ctl=Api_User_Info&met=getUserResourceInfo&typ=json', Yf_Registry::get('paycenter_api_url')), $formvars); $user_money = 0; $user_money_frozen = 0; if ($money_row['status'] == '200') { $money = $money_row['data']; $user_money = $money['user_money']; $user_money_frozen = $money['user_money_frozen']; } $shop_return_amount = $return['return_cash'] - $return['return_commision_fee']; //获取该店铺最新的结算结束日期 $Order_SettlementModel = new Order_SettlementModel(); $settlement_last_info = $Order_SettlementModel->getLastSettlementByShopid(Perm::$shopId, $return['order_is_virtual']); if($settlement_last_info) { $settlement_unixtime = $settlement_last_info['os_end_date'] ; } else { $settlement_unixtime = ''; } $settlement_unixtime = strtotime($settlement_unixtime); $order_finish_time = $order_base['order_finished_time']; $order_finish_unixtime = strtotime($order_finish_time); fb($settlement_unixtime); if($settlement_unixtime >= $order_finish_unixtime ) { //结算时间大于订单完成时间。需要扣除卖家的现金账户 $money = $user_money; $pay_type = 'cash'; } else { //结算时间小于订单完成时间。需要扣除卖家的冻结资金,如果冻结资金不足就扣除账户余额 $money = $user_money_frozen + $user_money; $pay_type = 'frozen_cash'; } } else { $order_finish = true; } ~~~ * 卖家确认收货:agreeGoods() ~~~ $data['return_state'] = Order_ReturnModel::RETURN_SELLER_GOODS; $flag = $this->orderReturnModel->editReturn($order_return_id, $data); check_rs($flag,$rs_row); //如果订单为分销商采购单,扣除分销商的钱 if($order_base['order_source_id']) { $dist_order = $Order_BaseModel -> getOneByWhere(array('order_id'=>$order_base['order_source_id'])); if(!empty($dist_order)){ $dist_return_order = $this->orderReturnModel->getOneByWhere(array('order_number'=>$dist_order['order_id'],'return_type'=>$return['return_type'])); $flag = $this->orderReturnModel->editReturn($dist_return_order['order_return_id'], $data); check_rs($flag,$rs_row); } ~~~ * 卖家不同意退货方法: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 ~~~ //查找退货单信息 $data = $this->orderReturnModel->getReturn($cond_row); //查找订单信息 $order_base = $this->orderBaseModel->getOne($data['order_number']); //如果下单这为当前用户 或者此订单是主管账号支付订单并且当前用户是主管账号,则当前用户可以查看该笔订单的退款退货状态 if($order_base['buyer_user_id'] == Perm::$userId || ($order_base['order_sub_pay'] == Order_StateModel::SUB_USER_PAY && $order_base['order_sub_user'] == Perm::$userId)) { if ($data['return_type'] == Order_ReturnModel::RETURN_TYPE_GOODS) { $data['text'] = __("退货"); } else { $data['text'] = __("退款"); } if($data['order_goods_id']) { $data['refund_goods'] = $this->orderGoodsModel->getOne($data['order_goods_id']); } $data['order'] = $order_base; $return_limit = $this->orderReturnModel->getByWhere(array( 'order_number' => $data['order']['order_id'], 'return_state:!=' => Order_ReturnModel::RETURN_SELLER_UNPASS )); $cash = 0; foreach ($return_limit as $v) { $cash += $v['return_cash']; } $data['return_limit'] = $cash; ~~~