model('orders'); $orderData = $orderModel->getList('order_bn', array('order_id'=>$refund['order_id']), 0, 1); $order = $orderData[0]; if($refund['shop_type'] == 'luban'){ $api_method = $this->_updateRefundApplyStatusApi($status, $refund); }else{ $api_method = $this->_updateRefundApplyStatusApi($status); } if ($api_method == '' || $mod != 'sync') { return false; } $params = $this->_updateRefundApplyStatusParam($refund, $status); $params['tid'] = $order['order_bn']; $title = '店铺('.$this->__channelObj->channel['name'].')更新[交易退款状态],(订单号:'.$order['order_bn'].'退款单号:'.$refund['refund_apply_bn'].')'; $callback = array(); $result = $this->__caller->call($api_method, $params, $callback, $title, 10, $order['order_bn']); $rs = array(); if(isset($result['msg']) && $result['msg']){ $rs['msg'] = $result['msg']; }elseif(isset($result['err_msg']) && $result['err_msg']){ $rs['msg'] = $result['err_msg']; }elseif(isset($result['res']) && $result['res']){ $rs['msg'] = $result['res']; } $rs['rsp'] = $result['rsp']; //[抖音平台]格式化退款单状态 if($rs['rsp'] == 'succ' && $refund['shop_type'] == 'luban'){ $rs = $this->_formatResultStatus($result); } return $rs; } /** * * @param [type] $sdf [description] * @return [type] [description] */ public function searchRefund($sdf) { $title = sprintf('%s退款单查询[%s]', $this->__channelObj->channel['name'], $sdf['refund_apply_bn']); $params = [ 'aftersale_id' => $sdf['refund_apply_bn'], ]; $result = $this->__caller->call(SHOP_REFUND_LIST_SEARCH, $params, [], $title, 10, $sdf['order_bn']); if ($result['rsp'] == 'succ') { $data = @json_decode($result['data'],true); $result['data'] = $data; } return $result; } public function getRefundStatus($sdf) {return $this->succ('没有接口');} /** * 获取协商退货退款渲染数据 * * @param array $params 参数数组,包含refund_id等 * @return array */ public function getNegotiateReturnRenderData($params) { $title = '获取协商退货退款渲染数据'; // 确保refund_id存在 if (!isset($params['refund_id'])) { return array('rsp' => 'fail', 'msg' => '缺少refund_id参数'); } // 获取API方法名 $api_method = $this->_getNegotiateReturnRenderDataApiMethod(); if (empty($api_method)) { return array('rsp' => 'fail', 'msg' => '未定义API方法'); } // 组装参数 $api_params = $this->_getNegotiateReturnRenderDataApiParams($params); $res = $this->__caller->call($api_method, $api_params, array(), $title, 10, $params['refund_id']); if ($res['rsp'] == 'succ') { // 如果 data 是字符串,则解析为数组 if (is_string($res['data'])) { $data = @json_decode($res['data'], true); if ($data) { $res['data'] = $data; } } } return $res; } /** * 查询是否可发起协商 * * @param array $params 参数数组,包含refund_id等 * @return array */ public function getNegotiateCanApply($params) { $title = '查询是否可发起协商'; // 确保refund_id存在 if (!isset($params['refund_id'])) { return array('rsp' => 'fail', 'msg' => '缺少refund_id参数'); } // 获取API方法名 $api_method = $this->_getNegotiateCanApplyApiMethod(); if (empty($api_method)) { return array('rsp' => 'fail', 'msg' => '未定义API方法'); } // 组装参数 $api_params = $this->_getNegotiateCanApplyApiParams($params); $res = $this->__caller->call($api_method, $api_params, array(), $title, 10, $params['refund_id']); if ($res['rsp'] == 'succ') { // 如果 data 是字符串,则解析为数组 if (is_string($res['data'])) { $data = @json_decode($res['data'], true); if ($data) { $res['data'] = $data; } } // 如果 data 已经是数组,直接使用 } return $res; } /** * 协商退货退款 * * @param array $params 参数数组 * @return array */ public function createRefundNegotiation($params) { $title = '协商退货退款'; // 验证必需参数 if (!isset($params['negotiate_data']) || !isset($params['detail'])) { return array('rsp' => 'fail', 'msg' => '协商请求缺少必要参数'); } // 确保refund_id存在 if (!isset($params['refund_id'])) { return array('rsp' => 'fail', 'msg' => '缺少refund_id参数'); } if (!isset($params['source'])) { return array('rsp' => 'fail', 'msg' => '缺少来源source参数'); } // 获取API方法名 $api_method = $this->_getRefundNegotiationApiMethod(); if (empty($api_method)) { return array('rsp' => 'fail', 'msg' => '未定义API方法'); } // 组装参数 $api_params = $this->_getRefundNegotiationApiParams($params); // 调用接口 $refund_id = $params['refund_id']; $res = $this->__caller->call($api_method, $api_params, array(), $title, 10, $refund_id); if ($res['rsp'] == 'succ') { // 如果 data 是字符串,则解析为数组 if (is_string($res['data'])) { $data = @json_decode($res['data'], true); if ($data) { $res['data'] = $data; } } } return $res; } /** * 获取协商退货退款API方法名 * * @return string */ protected function _getRefundNegotiationApiMethod() { return ''; } /** * 获取协商退货退款API参数 * * @param array $params 包含negotiate_data, return_detail, return_id的完整参数 * @return array */ protected function _getRefundNegotiationApiParams($params) { return $params; } /** * 获取协商退货退款渲染数据API方法名 * * @return string */ protected function _getNegotiateReturnRenderDataApiMethod() { return ''; } /** * 获取协商退货退款渲染数据API参数 * * @param array $params 包含refund_id等参数 * @return array */ protected function _getNegotiateReturnRenderDataApiParams($params) { return $params; } /** * 获取协商是否可发起API方法名 * * @return string */ protected function _getNegotiateCanApplyApiMethod() { return ''; } /** * 获取协商是否可发起API参数 * * @param array $params 包含refund_id等参数 * @return array */ protected function _getNegotiateCanApplyApiParams($params) { return $params; } }