文件路径:
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);
}
}
- IM api调试接口
- 群主踢人
- 群成员退群
- 用户创建群
- 群主修改群信息
- 群主转换
- 群成员拉好友入群
- 翻译
- 客户端获取手机验证码
- SHOP
- 团队限购
- 常用
- 银联支付
- 多语言
- API配置都对,但接口还是报错,解决方法
- 商品评分
- 图片延时加载
- 买家申请“退款/退货”
- 商家处理“退款/退货”申请
- 平台“退款/退货”审核
- 添加发票
- 提交订单
- 确认订单
- 运费和售卖区域查询
- 购物车商品删除
- 领取代金券
- APP打包H5通用功能
- 首页扫一扫
- 分享事件监听
- 支付事件监听
- SHOP_ADMIN
- 导出xls
- 弹出窗口
- 计划任务
- SOHP_WAP
- 首页聊天消息
- Ucenter
- 弹出窗口
- 微博登录
- 获取会员地址
- 商城配置数据库权限
- 商城后台供应商SQL
- 去分销
- paycenter_ucenter_shop通信说明
- AES
- 红包
- goods_common
- 红包退回
- 微信小程序
- 手机验证码API
- APP充值
- 摄像头cronjob
- WEBPOS自动加载权限
- 商城子帐号
- 云版升级注意事项
- 集群服务