2019-10-04 20:50:14 +08:00
|
|
|
<?php
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
// | ShopXO 国内领先企业级B2C免费开源电商系统
|
|
|
|
// +----------------------------------------------------------------------
|
2021-03-16 10:34:52 +08:00
|
|
|
// | Copyright (c) 2011~2099 http://shopxo.net All rights reserved.
|
2019-10-04 20:50:14 +08:00
|
|
|
// +----------------------------------------------------------------------
|
2021-03-16 10:34:52 +08:00
|
|
|
// | Licensed ( https://opensource.org/licenses/mit-license.php )
|
2019-10-04 20:50:14 +08:00
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
// | Author: Devil
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\api\controller;
|
|
|
|
|
2021-07-20 23:45:54 +08:00
|
|
|
use app\service\ApiService;
|
2021-04-11 15:51:06 +08:00
|
|
|
use app\service\SystemBaseService;
|
2019-10-04 20:50:14 +08:00
|
|
|
use app\service\OrderAftersaleService;
|
2021-01-27 22:21:04 +08:00
|
|
|
use app\service\ResourcesService;
|
2019-10-04 20:50:14 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 订单售后
|
|
|
|
* @author Devil
|
|
|
|
* @blog http://gong.gg/
|
|
|
|
* @version 0.0.1
|
|
|
|
* @datetime 2019-10-04T21:51:08+0800
|
|
|
|
*/
|
|
|
|
class Orderaftersale extends Common
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* 构造方法
|
|
|
|
* @author Devil
|
|
|
|
* @blog http://gong.gg/
|
|
|
|
* @version 1.0.0
|
|
|
|
* @date 2018-11-30
|
|
|
|
* @desc description
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
|
|
|
|
// 是否登录
|
|
|
|
$this->IsLogin();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 订单列表
|
|
|
|
* @author Devil
|
|
|
|
* @blog http://gong.gg/
|
|
|
|
* @version 1.0.0
|
|
|
|
* @date 2018-09-28
|
|
|
|
* @desc description
|
|
|
|
*/
|
|
|
|
public function Index()
|
|
|
|
{
|
|
|
|
// 参数
|
|
|
|
$params = $this->data_post;
|
|
|
|
$params['user'] = $this->user;
|
|
|
|
$params['user_type'] = 'user';
|
|
|
|
|
|
|
|
// 分页
|
|
|
|
$number = 10;
|
|
|
|
$page = max(1, isset($this->data_post['page']) ? intval($this->data_post['page']) : 1);
|
|
|
|
|
|
|
|
// 条件
|
2019-10-07 17:25:46 +08:00
|
|
|
$where = OrderAftersaleService::OrderAftersaleListWhere($params);
|
2019-10-04 20:50:14 +08:00
|
|
|
|
|
|
|
// 获取总数
|
|
|
|
$total = OrderAftersaleService::OrderAftersaleTotal($where);
|
|
|
|
$page_total = ceil($total/$number);
|
|
|
|
$start = intval(($page-1)*$number);
|
|
|
|
|
|
|
|
// 获取列表
|
|
|
|
$data_params = array(
|
|
|
|
'm' => $start,
|
|
|
|
'n' => $number,
|
|
|
|
'where' => $where,
|
|
|
|
'is_orderaftersale' => 1,
|
|
|
|
);
|
|
|
|
$data = OrderAftersaleService::OrderAftersaleList($data_params);
|
|
|
|
|
|
|
|
// 返回数据
|
|
|
|
$result = [
|
2021-01-06 21:26:19 +08:00
|
|
|
'total' => $total,
|
|
|
|
'page_total' => $page_total,
|
|
|
|
'data' => $data['data'],
|
2019-10-04 20:50:14 +08:00
|
|
|
];
|
2021-07-20 23:45:54 +08:00
|
|
|
return ApiService::ApiDataReturn(SystemBaseService::DataReturn($result));
|
2019-10-04 20:50:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 售后页面
|
|
|
|
* @author Devil
|
|
|
|
* @blog http://gong.gg/
|
|
|
|
* @version 1.0.0
|
|
|
|
* @date 2019-05-21
|
|
|
|
* @desc description
|
|
|
|
*/
|
|
|
|
public function Aftersale()
|
|
|
|
{
|
|
|
|
$order_id = isset($this->data_post['oid']) ? intval($this->data_post['oid']) : 0;
|
|
|
|
$order_detail_id = isset($this->data_post['did']) ? intval($this->data_post['did']) : 0;
|
|
|
|
$ret = OrderAftersaleService::OrdferGoodsRow($order_id, $order_detail_id, $this->user['id']);
|
|
|
|
if($ret['code'] == 0)
|
|
|
|
{
|
|
|
|
// 获取当前订单商品售后最新的一条纪录
|
|
|
|
$data_params = [
|
|
|
|
'm' => 0,
|
|
|
|
'n' => 1,
|
|
|
|
'where' => [
|
|
|
|
['order_detail_id', '=', $order_detail_id],
|
|
|
|
['user_id', '=', $this->user['id']],
|
|
|
|
],
|
|
|
|
];
|
|
|
|
$new_aftersale = OrderAftersaleService::OrderAftersaleList($data_params);
|
|
|
|
if(!empty($new_aftersale['data'][0]))
|
|
|
|
{
|
|
|
|
$new_aftersale_data = $new_aftersale['data'][0];
|
|
|
|
$new_aftersale_data['tips_msg'] = OrderAftersaleService::OrderAftersaleTipsMsg($new_aftersale_data);
|
|
|
|
} else {
|
|
|
|
$new_aftersale_data = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
// 进度
|
|
|
|
$step_data = OrderAftersaleService::OrderAftersaleStep($new_aftersale_data);
|
|
|
|
|
|
|
|
// 可退款退货
|
|
|
|
$returned = OrderAftersaleService::OrderAftersaleCalculation($order_id, $order_detail_id);
|
|
|
|
|
|
|
|
// 仅退款原因
|
|
|
|
$return_only_money_reason = MyC('home_order_aftersale_return_only_money_reason');
|
|
|
|
|
|
|
|
// 退款退货原因
|
|
|
|
$return_money_goods_reason = MyC('home_order_aftersale_return_money_goods_reason');
|
|
|
|
|
2021-07-08 19:10:26 +08:00
|
|
|
// 退货地址
|
2021-07-15 09:56:18 +08:00
|
|
|
$return_goods_address = OrderAftersaleService::OrderAftersaleReturnGoodsAddress($order_id);
|
2021-07-08 19:10:26 +08:00
|
|
|
|
2019-10-04 20:50:14 +08:00
|
|
|
// 返回数据
|
|
|
|
$result = [
|
|
|
|
'order_data' => $ret['data'],
|
|
|
|
'new_aftersale_data' => $new_aftersale_data,
|
|
|
|
'step_data' => $step_data,
|
|
|
|
'returned_data' => $returned['data'],
|
|
|
|
'return_only_money_reason' => empty($return_only_money_reason) ? [] : explode("\n", $return_only_money_reason),
|
|
|
|
'return_money_goods_reason' => empty($return_money_goods_reason) ? [] : explode("\n", $return_money_goods_reason),
|
2021-08-14 17:17:45 +08:00
|
|
|
'aftersale_type_list' => MyConst('common_order_aftersale_type_list'),
|
2021-07-08 19:10:26 +08:00
|
|
|
'return_goods_address' => $return_goods_address,
|
2021-01-27 22:21:04 +08:00
|
|
|
'editor_path_type' => ResourcesService::EditorPathTypeValue(OrderAftersaleService::EditorAttachmentPathType($this->user['id'], $order_id, $order_detail_id)),
|
2019-10-04 20:50:14 +08:00
|
|
|
];
|
2021-07-20 23:45:54 +08:00
|
|
|
$ret = SystemBaseService::DataReturn($result);
|
|
|
|
} else {
|
|
|
|
$ret = DataReturn($ret['msg'], -1);
|
2019-10-04 20:50:14 +08:00
|
|
|
}
|
2021-07-20 23:45:54 +08:00
|
|
|
return ApiService::ApiDataReturn($ret);
|
2019-10-04 20:50:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 申请售后创建
|
|
|
|
* @author Devil
|
|
|
|
* @blog http://gong.gg/
|
|
|
|
* @version 1.0.0
|
|
|
|
* @date 2019-05-23
|
|
|
|
* @desc description
|
|
|
|
*/
|
|
|
|
public function Create()
|
|
|
|
{
|
|
|
|
$params = $this->data_post;
|
|
|
|
$params['user'] = $this->user;
|
2021-07-20 23:45:54 +08:00
|
|
|
return ApiService::ApiDataReturn(OrderAftersaleService::AftersaleCreate($params));
|
2019-10-04 20:50:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 用户退货
|
|
|
|
* @author Devil
|
|
|
|
* @blog http://gong.gg/
|
|
|
|
* @version 1.0.0
|
|
|
|
* @date 2019-05-23
|
|
|
|
* @desc description
|
|
|
|
*/
|
|
|
|
public function Delivery()
|
|
|
|
{
|
|
|
|
$params = $this->data_post;
|
|
|
|
$params['user'] = $this->user;
|
2021-07-20 23:45:54 +08:00
|
|
|
return ApiService::ApiDataReturn(OrderAftersaleService::AftersaleDelivery($params));
|
2019-10-04 20:50:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 订单取消
|
|
|
|
* @author Devil
|
|
|
|
* @blog http://gong.gg/
|
|
|
|
* @version 1.0.0
|
|
|
|
* @date 2018-09-30
|
|
|
|
* @desc description
|
|
|
|
*/
|
|
|
|
public function Cancel()
|
|
|
|
{
|
|
|
|
$params = $this->data_post;
|
|
|
|
$params['user'] = $this->user;
|
2021-07-20 23:45:54 +08:00
|
|
|
return ApiService::ApiDataReturn(OrderAftersaleService::AftersaleCancel($params));
|
2019-10-04 20:50:14 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|