💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
文件路径: shop\controllers\Api\Trade\ReturnCtl.php 方法: agree() 参数: order_return_id:退单id return_platform_message:处理备注 # 1.判断商家是否同意此退单,如果不同意则只修改订单状态,不修改商家金额。如果商家同意,则修改订单状态并修改商家金额。 if($return['return_state'] == Order_ReturnModel::RETURN_SELLER_UNPASS) { //不同意 $data['return_platform_message'] = $return_platform_message; $data['return_state'] = Order_ReturnModel::RETURN_PLAT_PASS; $data['return_finish_time'] = get_date_time(); $rs_row = array(); $this->Order_ReturnModel->sql->startTransactionDb(); $edit_flag = $this->Order_ReturnModel->editReturn($order_return_id, $data); check_rs($edit_flag, $rs_row); if ($return['return_goods_return']) { //商品退换情况为完成2 $goods_data['goods_refund_status'] = Order_GoodsModel::REFUND_COM; $edit_flag = $this->Order_GoodsModel->editGoods($return['order_goods_id'], $goods_data); check_rs($edit_flag, $rs_row); } else { $goods_data['goods_return_status'] = Order_GoodsModel::REFUND_COM; $edit_flag = $this->Order_GoodsModel->editGoods($return['order_goods_id'], $goods_data); check_rs($edit_flag, $rs_row); } } # 2.商家同意退款的情况 (1)修改退单的状态 $data['return_platform_message'] = $return_platform_message; $data['return_state'] = Order_ReturnModel::RETURN_PLAT_PASS; $data['return_finish_time'] = get_date_time(); $rs_row = array(); $this->Order_ReturnModel->sql->startTransactionDb(); $edit_flag = $this->Order_ReturnModel->editReturn($order_return_id, $data); (2)根据退款/退货情况,修改订单商品的状态 if ($return['return_goods_return']) { //商品退换情况为完成2 $goods_data['goods_refund_status'] = Order_GoodsModel::REFUND_COM; $edit_flag = $this->Order_GoodsModel->editGoods($return['order_goods_id'], $goods_data); check_rs($edit_flag, $rs_row); } else { $goods_data['goods_return_status'] = Order_GoodsModel::REFUND_COM; $edit_flag = $this->Order_GoodsModel->editGoods($return['order_goods_id'], $goods_data); check_rs($edit_flag, $rs_row); } (3)将退款金额,退还佣金,退还红包,退货数量等写入订单表 $order_edit['order_refund_amount'] = $return['return_cash']; $order_edit['order_return_num'] = $return['order_goods_num']; $order_edit['order_commission_return_fee'] = $return['return_commision_fee']; $order_edit['order_rpt_return'] = $return['return_rpt_cash']; $edit_flag = $this->Order_BaseModel->editBase($return['order_number'], $order_edit,true); (4)如果此订单为退款订单,并且将所有商品退还,则就订单状态修改为完成状态 if($order_all_goods_num == $order_return_num && $order_base['order_status'] !== $Order_StateModel::ORDER_FINISH) { $order_edit_row = array(); $order_edit_row['order_status'] = $Order_StateModel::ORDER_FINISH; $edit_flag2 = $this->Order_BaseModel->editBase($return['order_number'], $order_edit_row); check_rs($edit_flag2, $rs_row); } (5)在paycenter中增加退款流水 判断该笔订单是否是主账号支付,如果是主账号支付,则将退款金额退还主账号 if($order_base['order_sub_pay'] == Order_StateModel::SUB_SELF_PAY) { $return_user_id = $return['buyer_user_id']; $return_user_name = $return['buyer_user_account']; } if($order_base['order_sub_pay'] == Order_StateModel::SUB_USER_PAY) { //查找主管账户用户名 $User_BaseModel = new User_BaseModel(); $sub_user_base = $User_BaseModel->getOne($order_base['order_sub_user']); $return_user_id = $order_base['order_sub_user']; $return_user_name = $sub_user_base['user_account']; } $key = Yf_Registry::get('shop_api_key'); $url = Yf_Registry::get('paycenter_api_url'); $shop_app_id = Yf_Registry::get('shop_app_id'); $formvars = array(); $formvars['app_id'] = $shop_app_id; $formvars['user_id'] = $return_user_id; $formvars['user_account'] = $return_user_name; $formvars['seller_id'] = $return['seller_user_id']; $formvars['seller_account'] = $return['seller_user_account']; $formvars['amount'] = $return['return_cash']; $formvars['return_commision_fee'] = $return['return_commision_fee']; $formvars['order_id'] = $return['order_number']; $formvars['goods_id'] = $return['order_goods_id']; $formvars['uorder_id'] = $order_base['payment_other_number']; $formvars['payment_id'] = $order_base['payment_id']; //平台同意退款(只增加买家的流水) $rs = get_url_with_encrypt($key, sprintf('%s?ctl=Api_Pay_Pay&met=refundBuyerTransfer&typ=json', $url), $formvars); (6)如果订单金额全数退还需要将订单商品,支付中心的订单状态修改为订单完成(未发货) if($order_all_goods_num == $order_return_num && $order_base['order_status'] == Order_StateModel::ORDER_PAYED) { $goods_data['order_goods_status'] = $Order_StateModel::ORDER_FINISH; $order_goods_ids = $this->Order_GoodsModel->getByWhere(array('order_id'=>$return['order_number'])); $ed_flag = $this->Order_GoodsModel->editGoods($order_goods_ids, $goods_data); check_rs($ed_flag, $rs_row); //将需要确认的订单号远程发送给Paycenter修改订单状态 //远程修改paycenter中的订单状态 $key = Yf_Registry::get('shop_api_key'); $url = Yf_Registry::get('paycenter_api_url'); $shop_app_id = Yf_Registry::get('shop_app_id'); $formvars = array(); $formvars['order_id'] = $return['order_number']; $formvars['app_id'] = $shop_app_id; $formvars['from_app_id'] = Yf_Registry::get('shop_app_id'); $rs = get_url_with_encrypt($key, sprintf('%s?ctl=Api_Pay_Pay&met=confirmOrder&typ=json', $url), $formvars); if($rs['status'] == 250) { $rs_flag = false; check_rs($rs_flag,$rs_row); } }