ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
文件路径: shop\controllers\Seller\Service\ReturnCtl.php 方法: agreeReturn() 参数: order_return_id:退单id return_shop_message:商家处理备注 # 1.判断此退单是否已经被处理。 if($return['return_state'] == Order_ReturnModel::RETURN_SELLER_PASS) { $msg = __('已经退款,请刷新页面。'); $status = 200; $this->data->addBody(-140, array(), $msg, $status); return false; } # 2.判断商家处理备注是都存在违禁词 if (Text_Filter::checkBanned($return_shop_message, $matche_row)) { $msg = __('含有违禁词'); $status = 250; $this->data->addBody(-140, array(), $msg, $status); return false; } # 3.判读订单是否已经收获,如果没有收货,不扣除卖家资金。已确认收货则扣除卖家资金。 $order_finish:订单是否已经完成确认收货 false :已收货 true:未收货 # 4.获取用户的账户资金信息 $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 = $money['user_money']; //账户余额 $user_money_frozen = $money['user_money_frozen']; //账户冻结资金 //判断订单是否已经结算 if($settlement_unixtime >= $order_finish_unixtime ) { //结算时间大于订单完成时间。需要扣除卖家的现金账户 $money = $user_money; $pay_type = 'cash'; } else { //结算时间小于订单完成时间。需要扣除卖家的冻结资金,如果冻结资金不足就扣除账户余额 $money = $user_money_frozen + $user_money; $pay_type = 'frozen_cash'; } # 5.判断该退单是否是当前商家的订单 # 6.当退款金额小于用户资金时,或者订单为未收货订单时流程继续,否则报错。 $shop_return_amount = $return['return_cash'] - $return['return_commision_fee']; $shop_return_amount:退款金额 $money:用户资金 修改退货单状态 $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_time'] = get_date_time(); $flag = $this->orderReturnModel->editReturn($order_return_id, $data); 修改退货单成功后,如果订单为已收货订单,则修改商家金额。 if($flag && !$order_finish) { //扣除卖家的金额 $key = Yf_Registry::get('shop_api_key'); $formvars = array(); $user_id = Perm::$userId; $formvars['user_id'] = $user_id; $formvars['user_name'] = Perm::$row['user_name']; $formvars['app_id'] = Yf_Registry::get('shop_app_id'); $formvars['money'] = $shop_return_amount * (-1); $formvars['pay_type'] = $pay_type; $formvars['reason'] = '退款'; $formvars['order_id'] = $order_base['order_id']; $formvars['goods_id'] = $return['order_goods_id']; $rs = get_url_with_encrypt($key, sprintf('%s?ctl=Api_User_Info&met=editReturnUserResourceInfo&typ=json', Yf_Registry::get('paycenter_api_url')), $formvars); $dist_rs['status'] = 200; //分销 if(isset($dist_return_order) && !empty($dist_return_order)){ $key = Yf_Registry::get('shop_api_key'); $formvars = array(); $user_id = Perm::$userId; $formvars['user_id'] = $dist_order['seller_user_id']; $formvars['user_name'] = $dist_order['seller_user_name']; $formvars['money'] = ($dist_return_order['return_cash']-$dist_return_order['return_commision_fee'])*(-1); $formvars['order_id'] = $dist_order['order_id']; $formvars['goods_id'] =0; $formvars['app_id'] = Yf_Registry::get('shop_app_id'); $formvars['pay_type'] = $pay_type; $formvars['reason'] = '退款'; $dist_rs = get_url_with_encrypt($key, sprintf('%s?ctl=Api_User_Info&met=editReturnUserResourceInfo&typ=json', Yf_Registry::get('paycenter_api_url')), $formvars); } if($rs['status'] == 200 && $dist_rs['status']==200) { $flag = true; } else { $flag = false; } }