|
@@ -13,10 +13,10 @@
|
|
|
defined('InShopNC') or exit('Access Invalid!');
|
|
|
|
|
|
|
|
|
-
|
|
|
class member_refundControl extends mbMemberControl
|
|
|
{
|
|
|
- static private $refund_type = array('1','2');
|
|
|
+ static private $refund_type = array('1', '2');
|
|
|
+
|
|
|
public function __construct()
|
|
|
{
|
|
|
parent::__construct();
|
|
@@ -37,11 +37,12 @@ class member_refundControl extends mbMemberControl
|
|
|
$order = $model_refund->getRightOrderList(array('buyer_id' => $_SESSION['member_id'], 'order_id' => $order_id));
|
|
|
|
|
|
$order_amount = $order['order_amount'];//订单金额
|
|
|
- $condition = array(); {
|
|
|
+ $condition = array();
|
|
|
+ {
|
|
|
$condition['buyer_id'] = $order['buyer_id'];
|
|
|
$condition['order_id'] = $order['order_id'];
|
|
|
$condition['goods_id'] = '0';
|
|
|
- $condition['seller_state'] = array('lt','3'); //状态:1为待审核,2为同意,3为不同意
|
|
|
+ $condition['seller_state'] = array('lt', '3'); //状态:1为待审核,2为同意,3为不同意
|
|
|
}
|
|
|
|
|
|
$refund_list = $model_refund->getRefundReturnList($condition);
|
|
@@ -53,7 +54,7 @@ class member_refundControl extends mbMemberControl
|
|
|
$order_paid = $model_trade->getOrderState('order_paid');//订单状态20:已付款
|
|
|
$payment_code = $order['payment_code'];//支付方式
|
|
|
if ($refund['refund_id'] > 0 || $order['order_state'] != $order_paid || $payment_code == 'offline') {//检查订单状态,防止页面刷新不及时造成数据错误
|
|
|
- return self::outerr(errcode::ErrOrderState,"只有付完款尚未发货的时才能退款。");
|
|
|
+ return self::outerr(errcode::ErrOrderState, "只有付完款尚未发货的时才能退款。");
|
|
|
}
|
|
|
|
|
|
$refund_array = array();
|
|
@@ -72,13 +73,13 @@ class member_refundControl extends mbMemberControl
|
|
|
$pic_array = array();
|
|
|
$pic_array['buyer'] = array();
|
|
|
$refund_array['pic_info'] = serialize($pic_array);
|
|
|
- $state = $model_refund->addRefundReturn($refund_array,$order);
|
|
|
+ $state = $model_refund->addRefundReturn($refund_array, $order);
|
|
|
|
|
|
if ($state) {
|
|
|
$model_refund->editOrderLock($order_id);
|
|
|
return self::outsuccess(array("ret" => 1));
|
|
|
} else {
|
|
|
- return self::outerr(errcode::ErrOrderRefundError,"退款失败.");
|
|
|
+ return self::outerr(errcode::ErrOrderRefundError, "退款失败.");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -92,12 +93,16 @@ class member_refundControl extends mbMemberControl
|
|
|
$order_id = intval($order_info['order_id']);
|
|
|
$order_goods_id = intval($_GET['order_goods_id']);//订单商品表编号
|
|
|
if ($order_id < 1 || $order_goods_id < 1) { //参数验证
|
|
|
- return self::outerr(errcode::ErrParamter,"商品参数错误.");
|
|
|
+ return self::outerr(errcode::ErrParamter, "商品参数错误.");
|
|
|
}
|
|
|
|
|
|
$model_refund = Model('refund_return');
|
|
|
$condition = array();
|
|
|
- $reason_list = $model_refund->getReasonList($condition);//退款退货原因
|
|
|
+ $reason_data = $model_refund->getReasonList($condition, '', '', 'reason_id,reason_info');//退款退货原因
|
|
|
+ foreach ($reason_data as $data) {
|
|
|
+ $reason_list[] = $data;
|
|
|
+ }
|
|
|
+ array_push($reason_list, array('reason_id' => 0, 'reason_info' => '其他'));
|
|
|
|
|
|
$condition = array();
|
|
|
$condition['buyer_id'] = $_SESSION['member_id'];
|
|
@@ -118,7 +123,7 @@ class member_refundControl extends mbMemberControl
|
|
|
$condition['buyer_id'] = $order['buyer_id'];
|
|
|
$condition['order_id'] = $order['order_id'];
|
|
|
$condition['order_goods_id'] = $goods_id;
|
|
|
- $condition['seller_state'] = array('lt','3');
|
|
|
+ $condition['seller_state'] = array('lt', '3');
|
|
|
$refund_list = $model_refund->getRefundReturnList($condition);
|
|
|
$refund = array();
|
|
|
if (!empty($refund_list) && is_array($refund_list)) {
|
|
@@ -127,27 +132,27 @@ class member_refundControl extends mbMemberControl
|
|
|
$refund_state = $model_refund->getRefundState($order);//根据订单状态判断是否可以退款退货
|
|
|
|
|
|
if ($refund['refund_id'] > 0) {
|
|
|
- return self::outerr(errcode::ErrOrderRefundError,"不能重复退货.");
|
|
|
+ return self::outerr(errcode::ErrOrderRefundError, "不能重复退货.");
|
|
|
}
|
|
|
- if($refund_state != 1) {
|
|
|
- return self::outerr(errcode::ErrOrderState,'请确认订单状态,在已经付款后才能退款,已经发货后才能退货.');
|
|
|
+ if ($refund_state != 1) {
|
|
|
+ return self::outerr(errcode::ErrOrderState, '请确认订单状态,在已经付款后才能退款,已经发货后才能退货.');
|
|
|
}
|
|
|
|
|
|
$goods['goods_image'] = cthumb($goods['goods_image'], 360, $order_info['store_id']);
|
|
|
$goods['order_goods_id'] = $order_goods_id;
|
|
|
|
|
|
- return self::outsuccess(array('ret' => 1, 'reason_list' => $reason_list,'goods' => $goods));
|
|
|
+ return self::outsuccess(array('ret' => 1, 'reason_list' => (array)$reason_list, 'goods' => $goods));
|
|
|
}
|
|
|
|
|
|
//已经付款,未发货时退款,退货。只能单品退款
|
|
|
public function add_refund_oneOp()
|
|
|
{
|
|
|
- if(!isset($_GET['refund_type']) || empty($_GET['refund_type'])
|
|
|
- || !in_array($_GET['refund_type'],self::$refund_type))
|
|
|
- {
|
|
|
- return self::outerr(errcode::ErrParamter,"请使用正确的退款类型,1:退款,2:退货.");
|
|
|
- }
|
|
|
- $refund_type = $_GET['refund_type'];
|
|
|
+ // if(!isset($_GET['refund_type']) || empty($_GET['refund_type'])
|
|
|
+ // || !in_array($_GET['refund_type'],self::$refund_type))
|
|
|
+ // {
|
|
|
+ // return self::outerr(errcode::ErrParamter,"请使用正确的退款类型,1:退款,2:退货.");
|
|
|
+ //}
|
|
|
+ //$refund_type = $_GET['refund_type'];
|
|
|
|
|
|
$order_info = Model('order')->getOrderInfo(array('order_sn' => $_GET['order_sn']));
|
|
|
if (empty($order_info)) {
|
|
@@ -156,7 +161,7 @@ class member_refundControl extends mbMemberControl
|
|
|
$order_id = $order_info['order_id'];
|
|
|
$order_goods_id = intval($_GET['order_goods_id']);//订单商品表编号
|
|
|
if ($order_id < 1 || $order_goods_id < 1) { //参数验证
|
|
|
- return self::outerr(errcode::ErrParamter,"商品参数错误.");
|
|
|
+ return self::outerr(errcode::ErrParamter, "商品参数错误.");
|
|
|
}
|
|
|
$buyer_msg = isset($_GET['buyer_msg']) ? $_GET['buyer_msg'] : '';
|
|
|
|
|
@@ -193,7 +198,7 @@ class member_refundControl extends mbMemberControl
|
|
|
$condition['buyer_id'] = $order['buyer_id'];
|
|
|
$condition['order_id'] = $order['order_id'];
|
|
|
$condition['order_goods_id'] = $goods_id;
|
|
|
- $condition['seller_state'] = array('lt','3');
|
|
|
+ $condition['seller_state'] = array('lt', '3');
|
|
|
$refund_list = $model_refund->getRefundReturnList($condition);
|
|
|
$refund = array();
|
|
|
if (!empty($refund_list) && is_array($refund_list)) {
|
|
@@ -222,7 +227,7 @@ class member_refundControl extends mbMemberControl
|
|
|
if ($order['order_state'] == $order_shipped) {
|
|
|
$refund_array['order_lock'] = '2';//锁定类型:1为不用锁定,2为需要锁定
|
|
|
}
|
|
|
- $refund_array['refund_type'] = $refund_type;//类型:1为退款,2为退货
|
|
|
+ $refund_array['refund_type'] = 2;//类型:1为退款,2为退货
|
|
|
$refund_array['return_type'] = '2';//退货类型:1为不用退货,2为需要退货
|
|
|
if ($refund_array['refund_type'] != '2') {
|
|
|
$refund_array['refund_type'] = '1';
|
|
@@ -233,16 +238,44 @@ class member_refundControl extends mbMemberControl
|
|
|
$refund_array['goods_num'] = $goods_num;
|
|
|
$refund_array['buyer_message'] = $buyer_msg;
|
|
|
$refund_array['add_time'] = time();
|
|
|
- $state = $model_refund->addRefundReturn($refund_array,$order,$goods);
|
|
|
+ $state = $model_refund->addRefundReturn($refund_array, $order, $goods);
|
|
|
|
|
|
- if ($state)
|
|
|
- {
|
|
|
+ if ($state) {
|
|
|
if ($order['order_state'] == $order_shipped) {
|
|
|
$model_refund->editOrderLock($order_id);
|
|
|
}
|
|
|
return self::outsuccess(array('ret' => 1));
|
|
|
} else {
|
|
|
- return self::outerr(errcode::ErrOrderRefundError,"退货失败.");
|
|
|
+ return self::outerr(errcode::ErrOrderRefundError, "退货失败.");
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 退款或退货退款记录详情
|
|
|
+ */
|
|
|
+ public function refund_viewOp()
|
|
|
+ {
|
|
|
+ if (!isset($_GET['refund_id']) || empty($_GET['refund_id'])) {
|
|
|
+ return self::outerr(errcode::ErrParamter, "记录参数有误");
|
|
|
+ }
|
|
|
+ $model_refund = Model('refund_return');
|
|
|
+ $condition = array();
|
|
|
+ $condition['buyer_id'] = $_SESSION['member_id'];
|
|
|
+ $condition['refund_id'] = intval($_GET['refund_id']);
|
|
|
+ $refund_fields = 'refund_id,order_id,order_sn,order_goods_id,add_time,refund_type,return_type,seller_time,ship_time,admin_time';
|
|
|
+ $refund_list = $model_refund->getRefundReturnList($condition, '', $refund_fields);
|
|
|
+ $refund = $refund_list[0];
|
|
|
+ $refund['refund_state'] = $model_refund->getRefundStatueApp($refund);
|
|
|
+ unset($refund['return_type']);
|
|
|
+ unset($refund['seller_time']);
|
|
|
+ unset($refund['ship_time']);
|
|
|
+ unset($refund['admin_time']);
|
|
|
+ $model_order = Model('order');
|
|
|
+ $condition = array();
|
|
|
+ $condition['order_id'] = $refund['order_id'];
|
|
|
+ $condition['rec_id'] = $refund['order_goods_id'];
|
|
|
+ $good_fields = 'goods_id,goods_name,goods_price,goods_num,goods_image,goods_pay_price,goods_type,commis_rate,gc_id,goods_spec';
|
|
|
+ $refund['good_list'] = $model_order->getOrderGoodsList($condition, $good_fields);
|
|
|
+ return self::outsuccess(array('refund' => $refund));
|
|
|
+ }
|
|
|
}
|