123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599 |
- <?php
- namespace app\api\controller;
- use think\facade\Lang;
- /**
-
- *
-
- *
- * ----------------------------------------------------------------------------
- *
-
- * 退款控制器
- */
- class Memberrefund extends MobileMember
- {
- public function initialize()
- {
- parent::initialize(); // TODO: Change the autogenerated stub
- Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/memberrefund.lang.php');
- }
- /**
- * @api {POST} api/Memberrefund/refund_all_form 全部退款获取订单信息
- * @apiVersion 1.0.0
- * @apiGroup Memberrefund
- *
- * @apiHeader {String} X-DS-KEY 用户授权token
- *
- * @apiParam {Int} orderId 订单id
- *
- * @apiSuccess {String} code 返回码,10000为成功
- * @apiSuccess {String} message 返回消息
- * @apiSuccess {Object} result 返回数据
- * @apiSuccess {Object} result.order 订单信息
- * @apiSuccess {Int} result.order.order_id 订单ID
- * @apiSuccess {Float} result.order.order_amount 订单金额
- * @apiSuccess {String} result.order.order_sn 订单编号
- * @apiSuccess {String} result.order.store_name 店铺名称
- * @apiSuccess {Int} result.order.store_id 店铺ID
- * @apiSuccess {Float} result.order.allow_refund_amount 允许退款金额
- * @apiSuccess {Float} result.order.book_amount 已退款金额
- * @apiSuccess {Object[]} result.goods_list 订单商品信息
- * @apiSuccess {Int} result.goods_list.goods_id 商品ID
- * @apiSuccess {String} result.goods_list.goods_name 商品名称
- * @apiSuccess {Float} result.goods_list.goods_price 商品价格
- * @apiSuccess {Int} result.goods_list.goods_num 购买数量
- * @apiSuccess {String} result.goods_list.goods_img_480 商品缩略图完整路径
- * @apiSuccess {String} result.goods_list.goods_type 商品类型
- * @apiSuccess {Object[]} result.gift_list 订单信息
- */
- public function refund_all_form()
- {
- $refundreturn_model = model('refundreturn');
- $member_id = $this->member_info['member_id'];
- $order_id = intval(input('param.order_id'));
- $trade_model = model('trade');
- $order_paid = $trade_model->getOrderState('order_paid'); //订单状态20:已付款
- $order_model = model('order');
- $condition = array();
- $condition[] = array('buyer_id', '=', $member_id);
- $condition[] = array('order_id', '=', $order_id);
- $condition[] = array('order_state', '=', $order_paid);
- $order_info = $order_model->getOrderInfo($condition);
- if (!empty($order_info) && is_array($order_info)) {
- $order = $refundreturn_model->getRightOrderList($condition);
- $book_amount = $order_info['refund_amount']; //退款金额
- $order = array();
- $order['order_id'] = $order_info['order_id'];
- //$order['order_type'] = $order_info['order_type'];
- $order['order_amount'] = ds_price_format($order_info['order_amount'] - $order_info['presell_deposit_amount']);
- $order['order_sn'] = $order_info['order_sn'];
- $order['store_name'] = $order_info['store_name'];
- $order['store_id'] = $order_info['store_id'];
- $order['allow_refund_amount'] = ds_price_format($order_info['order_amount'] - $book_amount); //可退款金额
- $order['book_amount'] = ds_price_format($book_amount);
- $goods_list = array();
- $gift_list = array();
- $order_model = model('order');
- $condition = array();
- $condition[] = array('order_id', '=', $order_id);
- $order_goods_list = $order_model->getOrdergoodsList($condition);
- foreach ($order_goods_list as $key => $value) {
- $goods = array();
- $goods['goods_id'] = $value['goods_id'];
- $goods['goods_name'] = $value['goods_name'];
- $goods['goods_price'] = $value['goods_price'];
- $goods['goods_num'] = $value['goods_num'];
- //$goods['goods_spec'] = $value['goods_spec'];
- $goods['goods_img_480'] = goods_thumb($value, 480);
- $goods['goods_type'] = get_order_goodstype($value['goods_type']);
- if ($value['goods_type'] == 5) { //赠品商品
- $gift_list[] = $goods;
- } else {
- $goods_list[] = $goods;
- }
- }
- ds_json_encode(10000, '', array('order' => $order, 'goods_list' => $goods_list, 'gift_list' => $gift_list));
- } else {
- ds_json_encode(10001, lang('param_error'));
- }
- }
- /**
- * @api {POST} api/Memberrefund/refund_all_post 全部退款保存数据
- * @apiVersion 1.0.0
- * @apiGroup Memberrefund
- *
- * @apiHeader {String} X-DS-KEY 用户授权token
- *
- * @apiParam {Int} orderId 订单id
- * @apiParam {String} buyer_message 退款理由
- * @apiParam {Array} refund_pic 退款凭证
- *
- * @apiSuccess {String} code 返回码,10000为成功
- * @apiSuccess {String} message 返回消息
- */
- public function refund_all_post()
- {
- $refundreturn_model = model('refundreturn');
- $member_id = $this->member_info['member_id'];
- $order_id = intval(input('post.order_id'));
- $trade_model = model('trade');
- $order_paid = $trade_model->getOrderState('order_paid'); //订单状态20:已付款
- $order_model = model('order');
- $condition = array();
- $condition[] = array('buyer_id', '=', $member_id);
- $condition[] = array('order_id', '=', $order_id);
- $condition[] = array('order_state', 'in', [ORDER_STATE_PAY, ORDER_STATE_PICKUP]);
- $order_info = $order_model->getOrderInfo($condition);
- $payment_code = $order_info['payment_code']; //支付方式
- $condition = array();
- $condition[] = array('buyer_id', '=', $member_id);
- $condition[] = array('order_id', '=', $order_id);
- $condition[] = array('goods_id', '=', '0');
- $condition[] = array('refund_state', '<', '3');
- $refund = $refundreturn_model->getRefundreturnInfo($condition);
- if (empty($order_info) || $payment_code == 'offline' || $refund['refund_id'] > 0) { //检查数据,防止页面刷新不及时造成数据错误
- ds_json_encode(10001, lang('param_error'));
- } else {
- $book_amount = $order_info['refund_amount']; //退款金额
- $allow_refund_amount = ds_price_format($order_info['order_amount'] - $order_info['presell_deposit_amount'] - $book_amount); //可退款金额
- $refund_array = array();
- $refund_array['refund_type'] = '1'; //类型:1为退款,2为退货
- $refund_array['seller_state'] = '1'; //状态:1为待审核,2为同意,3为不同意
- $refund_array['order_lock'] = '2'; //锁定类型:1为不用锁定,2为需要锁定
- $refund_array['goods_id'] = '0';
- $refund_array['order_goods_id'] = '0';
- $refund_array['reason_id'] = '0';
- $refund_array['reason_info'] = lang('refund_notice4');
- $refund_array['goods_name'] = lang('all_orders_refunded');
- $refund_array['refund_amount'] = ds_price_format($allow_refund_amount);
- $refund_array['buyer_message'] = input('post.buyer_message');
- $refund_array['add_time'] = TIMESTAMP;
- $pic_array = array();
- $pic_array['buyer'] = input('post.refund_pic/a'); //上传凭证 获取数组
- $info = serialize($pic_array);
- $refund_array['pic_info'] = $info;
- $state = $refundreturn_model->addRefundreturn($refund_array, $order_info);
- if ($state) {
- $refundreturn_model->editOrderLock($order_id);
- //自提点订单锁定
- $chain_order_model = model('chain_order');
- $chain_order_model->editChainOrderLock($order_id);
- ds_json_encode(10000, lang('ds_common_op_succ'), 1);
- } else {
- ds_json_encode(10001, lang('ds_common_op_fail'));
- }
- }
- }
- /**
- * @api {POST} api/Memberrefund/refund_form 部分退款获取订单信息
- * @apiVersion 1.0.0
- * @apiGroup Memberrefund
- *
- * @apiHeader {String} X-DS-KEY 用户授权token
- *
- * @apiParam {Int} order_id 订单id
- * @apiParam {Int} order_goods_id 订单商品id
- *
- * @apiSuccess {String} code 返回码,10000为成功
- * @apiSuccess {String} message 返回消息
- * @apiSuccess {Object} result 返回数据
- * @apiSuccess {Object} result.order 订单信息
- * @apiSuccess {Int} result.order.order_id 订单ID
- * @apiSuccess {Float} result.order.order_amount 订单金额
- * @apiSuccess {String} result.order.order_sn 订单编号
- * @apiSuccess {String} result.order.store_name 店铺名称
- * @apiSuccess {Int} result.order.store_id 店铺ID
- * @apiSuccess {Float} result.order.allow_refund_amount 允许退款金额
- * @apiSuccess {Float} result.order.book_amount 已退款金额
- * @apiSuccess {Object[]} result.goods_list 订单商品信息
- * @apiSuccess {Int} result.goods_list.goods_id 商品ID
- * @apiSuccess {Int} result.goods_list.store_id 店铺ID
- * @apiSuccess {Int} result.goods_list.order_goods_id 订单商品ID
- * @apiSuccess {String} result.goods_list.goods_name 商品名称
- * @apiSuccess {Float} result.goods_list.goods_price 商品价格
- * @apiSuccess {Float} result.goods_list.goods_pay_price 实际支付价格
- * @apiSuccess {Int} result.goods_list.goods_num 购买数量
- * @apiSuccess {String} result.goods_list.goods_img_480 商品缩略图完整路径
- * @apiSuccess {String} result.goods_list.goods_type 商品类型
- * @apiSuccess {Object[]} result.reason_list 退款理由列表
- * @apiSuccess {Int} result.reason_list.reason_id 退款理由ID
- * @apiSuccess {String} result.reason_list.reason_info 退款理由
- */
- public function refund_form()
- {
- $refundreturn_model = model('refundreturn');
- $condition = array();
- $reason_list = $refundreturn_model->getReasonList($condition, '', '', 'reason_id,reason_info'); //退款退货原因
- $member_id = $this->member_info['member_id'];
- $order_id = intval(input('param.order_id'));
- $goods_id = intval(input('param.order_goods_id')); //订单商品表编号
- $order_model = model('order');
- $condition = array();
- $condition[] = array('buyer_id', '=', $member_id);
- $condition[] = array('order_id', '=', $order_id);
- $order_info = $refundreturn_model->getRightOrderList($condition, $goods_id);
- //halt($order_info);
- $refund_state = $refundreturn_model->getRefundState($order_info); //根据订单状态判断是否可以退款退货
- if ($refund_state == 1 && $goods_id > 0) {
- $order = array();
- $order['order_id'] = $order_info['order_id'];
- //$order['order_type'] = $order_info['order_type'];
- $order['order_amount'] = ds_price_format($order_info['order_amount']);
- $order['order_sn'] = $order_info['order_sn'];
- $order['store_name'] = $order_info['store_name'];
- $order['store_id'] = $order_info['store_id'];
- $goods = array();
- $goods_list = $order_info['goods_list'];
- $goods_info = $goods_list[0];
- $goods['store_id'] = $goods_info['store_id'];
- $goods['order_goods_id'] = $goods_info['rec_id'];
- $goods['goods_id'] = $goods_info['goods_id'];
- $goods['goods_name'] = $goods_info['goods_name'];
- $goods['goods_type'] = get_order_goodstype($goods_info['goods_type']);
- $goods['goods_img_480'] = goods_thumb($goods_info, 480);
- $goods['goods_price'] = ds_price_format($goods_info['goods_price']);
- //$goods['goods_spec'] = $goods_info['goods_spec'];
- $goods['goods_num'] = $goods_info['goods_num'];
- $goods_pay_price = $goods_info['goods_pay_price']; //商品实际成交价
- $goods_pay_price -= $order_info['presell_deposit_amount'];
- $order_amount = $order_info['order_amount']; //订单金额
- $order_refund_amount = $order_info['refund_amount']; //订单退款金额
- if ($order_amount < ($goods_pay_price + $order_refund_amount)) {
- $goods_pay_price = $order_amount - $order_refund_amount;
- }
- $goods['goods_pay_price'] = ds_price_format($goods_pay_price);
- $reason_list = array_values($reason_list);
- ds_json_encode(10000, '', array('order' => $order, 'goods' => $goods, 'reason_list' => $reason_list));
- } else {
- ds_json_encode(10001, lang('param_error'));
- }
- }
- /**
- * @api {POST} api/Memberrefund/refund_post 部分退款保存数据
- * @apiVersion 1.0.0
- * @apiGroup Memberrefund
- *
- * @apiHeader {String} X-DS-KEY 用户授权token
- *
- * @apiParam {Int} order_id 订单id
- * @apiParam {Int} order_goods_id 订单商品id
- * @apiParam {Float} refund_amount 退款金额
- * @apiParam {Int} goods_num 退货数量
- * @apiParam {Int} reason_id 退款理由id
- * @apiParam {Int} refund_type 类型 1退款 2退货
- * @apiParam {String} buyer_message 退款理由
- * @apiParam {Array} refund_pic 退款凭证
- *
- * @apiSuccess {String} code 返回码,10000为成功
- * @apiSuccess {String} message 返回消息
- */
- public function refund_post()
- {
- $member_id = $this->member_info['member_id'];
- $order_id = intval(input('post.order_id'));
- $goods_id = intval(input('post.order_goods_id')); //订单商品表编号
- $order_model = model('order');
- $refundreturn_model = model('refundreturn');
- $condition = array();
- $condition[] = array('buyer_id', '=', $member_id);
- $condition[] = array('order_id', '=', $order_id);
- $order_info = $refundreturn_model->getRightOrderList($condition, $goods_id);
- $refund_state = $refundreturn_model->getRefundState($order_info); //根据订单状态判断是否可以退款退货
- $condition = array();
- $condition[] = array('buyer_id', '=', $member_id);
- $condition[] = array('order_id', '=', $order_id);
- $condition[] = array('order_goods_id', '=', $goods_id);
- $condition[] = array('refund_state', '<', '3');
- $refund = $refundreturn_model->getRefundreturnInfo($condition);
- if ($refund_state == 1 && $goods_id > 0 && empty($refund)) {
- $goods_list = $order_info['goods_list'];
- $goods_info = $goods_list[0];
- $refund_array = array();
- $goods_pay_price = $goods_info['goods_pay_price']; //商品实际成交价
- $goods_pay_price -= $order_info['presell_deposit_amount'];
- $order_amount = $order_info['order_amount']; //订单金额
- $order_refund_amount = $order_info['refund_amount']; //订单退款金额
- if ($order_amount < ($goods_pay_price + $order_refund_amount)) {
- $goods_pay_price = $order_amount - $order_refund_amount;
- }
- $refund_amount = floatval(input('post.refund_amount')); //退款金额
- if (($refund_amount < 0) || ($refund_amount > $goods_pay_price)) {
- $refund_amount = $goods_pay_price;
- }
- $goods_num = !empty(input('post.goods_num')) ? intval(input('post.goods_num')) : 1; //退货数量
- if (($goods_num < 0) || ($goods_num > $goods_info['goods_num'])) {
- $goods_num = 1;
- }
- $reason_list = $refundreturn_model->getReasonList(array(), '', '', 'reason_id,reason_info'); //退款退货原因
- $refund_array['reason_info'] = '';
- $reason_id = intval(input('post.reason_id')); //退货退款原因
- $refund_array['reason_id'] = $reason_id;
- $reason_array = array();
- $reason_array['reason_info'] = lang('other');
- $reason_list[0] = $reason_array;
- if (!empty($reason_list[$reason_id])) {
- $reason_array = $reason_list[$reason_id];
- $refund_array['reason_info'] = $reason_array['reason_info'];
- }
- $pic_array = array();
- $pic_array['buyer'] = input('post.refund_pic/a'); //上传凭证 获取数组
- $info = serialize($pic_array);
- $refund_array['pic_info'] = $info;
- $trade_model = model('trade');
- $order_shipped = $trade_model->getOrderState('order_shipped'); //订单状态30:已发货
- $refund_array['order_lock'] = '1';
- if ($order_info['order_state'] == $order_shipped) {
- $refund_array['order_lock'] = '2'; //锁定类型:1为不用锁定,2为需要锁定
- }
- $refund_array['refund_type'] = input('post.refund_type'); //类型:1为退款,2为退货
- $refund_array['return_type'] = '2'; //退货类型:1为不用退货,2为需要退货
- if ($refund_array['refund_type'] != '2') {
- $refund_array['refund_type'] = '1';
- $refund_array['return_type'] = '1';
- }
- $refund_array['seller_state'] = '1'; //状态:1为待审核,2为同意,3为不同意
- $refund_array['refund_amount'] = ds_price_format($refund_amount);
- $refund_array['goods_num'] = $goods_num;
- $refund_array['buyer_message'] = input('post.buyer_message');
- $refund_array['add_time'] = TIMESTAMP;
- $state = $refundreturn_model->addRefundreturn($refund_array, $order_info, $goods_info);
- if ($state) {
- if ($order_info['order_state'] == $order_shipped) {
- $refundreturn_model->editOrderLock($order_id);
- }
- //自提点订单锁定
- $chain_order_model = model('chain_order');
- $chain_order_model->editChainOrderLock($order_id);
- ds_json_encode(10000, lang('ds_common_op_succ'), 1);
- } else {
- ds_json_encode(10001, lang('ds_common_op_fail'));
- }
- } else {
- ds_json_encode(10001, lang('param_error'));
- }
- }
- /**
- * @api {POST} api/Memberrefund/refund_all_post 上传凭证
- * @apiVersion 1.0.0
- * @apiGroup Memberrefund
- *
- * @apiHeader {String} X-DS-KEY 用户授权token
- *
- * @apiParam {File} refund_pic 退款凭证
- *
- * @apiSuccess {String} code 返回码,10000为成功
- * @apiSuccess {String} message 返回消息
- * @apiSuccess {Object} result 返回数据
- * @apiSuccess {String} result.file_name 文件名称
- * @apiSuccess {String} result.pic 文件完整路径
- */
- public function upload_pic()
- {
- if (empty($_FILES['refund_pic']['name'])) {
- ds_json_encode(10001, lang('file_empty'));
- }
- $res = ds_upload_pic(ATTACH_PATH . DIRECTORY_SEPARATOR . 'refund', 'refund_pic');
- if ($res['code']) {
- $file_name = $res['data']['file_name'];
- $pic = ds_get_pic(ATTACH_PATH . '/refund', $file_name);
- ds_json_encode(10000, '', array('file_name' => $file_name, 'pic' => $pic));
- } else {
- ds_json_encode(10001, $res['msg']);
- }
- }
- /**
- * @api {POST} api/Memberrefund/get_refund_list 退款记录列表
- * @apiVersion 1.0.0
- * @apiGroup Memberrefund
- *
- * @apiHeader {String} X-DS-KEY 用户授权token
- *
- * @apiParam {Int} page 页码
- * @apiParam {Int} per_page 每页数量
- * @apiParam {String} type 查询字段 order_sn订单号 refund_sn退款单号 goods_name商品名
- * @apiParam {String} k 查询关键词
- * @apiParam {String} add_time_from 时间从 YYYY-MM-DD
- * @apiParam {String} add_time_to 时间到 YYYY-MM-DD
- *
- * @apiSuccess {String} code 返回码,10000为成功
- * @apiSuccess {String} message 返回消息
- * @apiSuccess {Object} result 返回数据
- * @apiSuccess {Object[]} result.refund_list 退款列表
- * @apiSuccess {Int} result.refund_list.add_time 添加时间
- * @apiSuccess {String} result.refund_list.admin_state 管理员状态描述
- * @apiSuccess {Int} result.refund_list.admin_state_v 管理员处理状态 1:待审核 2:同意 3:不同意
- * @apiSuccess {Object[]} result.refund_list.goods_list 商品列表
- * @apiSuccess {Int} result.refund_list.goods_list.goods_id 商品ID
- * @apiSuccess {String} result.refund_list.goods_list.goods_img_480 商品缩略图完整路径
- * @apiSuccess {String} result.refund_list.goods_list.goods_name 商品名称
- * @apiSuccess {Int} result.refund_list.order_id 订单ID
- * @apiSuccess {String} result.refund_list.order_sn 订单编号
- * @apiSuccess {Float} result.refund_list.refund_amount 退款金额
- * @apiSuccess {Int} result.refund_list.refund_id 退款ID
- * @apiSuccess {String} result.refund_list.refund_sn 退款编号
- * @apiSuccess {String} result.refund_list.seller_state 卖家处理状态描述 1:待审核,2:同意,3:不同意
- * @apiSuccess {Int} result.refund_list.seller_state_v 卖家状态
- * @apiSuccess {Int} result.refund_list.store_id 店铺ID
- * @apiSuccess {String} result.refund_list.store_name 店铺描述
- * @apiSuccess {Int} result.page_total 总页数
- * @apiSuccess {Boolean} result.hasmore 是否有更多 true是false否
- */
- public function get_refund_list()
- {
- $order_model = model('order');
- $refundreturn_model = model('refundreturn');
- $member_id = $this->member_info['member_id'];
- $refund_list = array();
- $condition = array();
- $condition[] = array('refund_type', '=', 1);
- $condition[] = array('buyer_id', '=', $member_id);
- $keyword_type = array('order_sn', 'refund_sn', 'goods_name');
- if (trim(input('param.k')) != '' && in_array(input('param.type'), $keyword_type)) {
- $type = input('param.type');
- $condition[] = array($type, 'like', '%' . input('param.k') . '%');
- }
- if (trim(input('param.add_time_from')) != '' || trim(input('param.add_time_to')) != '') {
- $add_time_from = strtotime(trim(input('param.add_time_from')));
- $add_time_to = strtotime(trim(input('param.add_time_to')));
- if ($add_time_from !== false || $add_time_to !== false) {
- $condition[] = array('add_time', 'time', array($add_time_from, $add_time_to));
- }
- }
- $list = $refundreturn_model->getRefundList($condition, $this->pagesize);
- if (!empty($list) && is_array($list)) {
- $seller_state = $this->getRefundStateArray('seller');
- $admin_state = $this->getRefundStateArray('admin');
- foreach ($list as $k => $v) {
- $val = array();
- $val['refund_id'] = $v['refund_id'];
- $val['order_id'] = $v['order_id'];
- $val['refund_amount'] = ds_price_format($v['refund_amount']);
- $val['refund_sn'] = $v['refund_sn'];
- $val['order_sn'] = $v['order_sn'];
- $val['add_time'] = date("Y-m-d H:i:s", $v['add_time']);
- $val['seller_state_v'] = $v['seller_state'];
- $val['seller_state'] = $seller_state[$v['seller_state']];
- $val['admin_state_v'] = $v['refund_state'];
- $val['admin_state'] = $admin_state[$v['refund_state']];
- $val['store_id'] = $v['store_id'];
- $val['store_name'] = $v['store_name'];
- $goods_list = array();
- if ($v['goods_id'] > 0) {
- $goods = array();
- $goods['goods_id'] = $v['goods_id'];
- $goods['goods_name'] = $v['goods_name'];
- $condition = array();
- $condition[] = array('rec_id', '=', $v['order_goods_id']);
- $order_goods_list = $order_model->getOrdergoodsList($condition);
- //$goods['goods_spec'] = $order_goods_list[0]['goods_spec'];
- $goods['goods_img_480'] = goods_thumb($v, 480);
- $goods_list[] = $goods;
- } else {
- $condition = array();
- $condition[] = array('order_id', '=', $v['order_id']);
- $order_goods_list = $order_model->getOrdergoodsList($condition);
- foreach ($order_goods_list as $key => $value) {
- $goods = array();
- $goods['goods_id'] = $value['goods_id'];
- $goods['goods_name'] = $value['goods_name'];
- //$goods['goods_spec'] = $value['goods_spec'];
- $goods['goods_img_480'] = goods_thumb($value, 480);
- $goods_list[] = $goods;
- }
- }
- $val['goods_list'] = $goods_list;
- $refund_list[] = $val;
- }
- }
- $result = array_merge(array('refund_list' => $refund_list), mobile_page($refundreturn_model->page_info));
- ds_json_encode(10000, '', $result);
- }
- /**
- * 查看退款信息
- *
- */
- public function get_refund_info()
- {
- $refundreturn_model = model('refundreturn');
- $member_id = $this->member_info['member_id'];
- $condition = array();
- $condition[] = array('buyer_id', '=', $member_id);
- $condition[] = array('refund_id', '=', intval(input('param.refund_id')));
- $refund_info = $refundreturn_model->getRefundreturnInfo($condition);
- if (!empty($refund_info) && is_array($refund_info)) {
- $seller_state = $this->getRefundStateArray('seller');
- $admin_state = $this->getRefundStateArray('admin');
- $refund = array();
- $refund['refund_id'] = $refund_info['refund_id'];
- $refund['goods_id'] = $refund_info['goods_id'];
- $refund['goods_name'] = $refund_info['goods_name'];
- $refund['order_id'] = $refund_info['order_id'];
- $refund['refund_amount'] = ds_price_format($refund_info['refund_amount']);
- $refund['refund_sn'] = $refund_info['refund_sn'];
- $refund['order_sn'] = $refund_info['order_sn'];
- $refund['add_time'] = date("Y-m-d H:i:s", $refund_info['add_time']);
- $refund['goods_img_480'] = goods_thumb($refund_info, 480);
- $refund['seller_state'] = $seller_state[$refund_info['seller_state']];
- $refund['admin_state'] = $admin_state[$refund_info['refund_state']];
- $refund['store_id'] = $refund_info['store_id'];
- $refund['store_name'] = $refund_info['store_name'];
- $refund['reason_info'] = $refund_info['reason_info'];
- $refund['buyer_message'] = $refund_info['buyer_message'];
- $refund['seller_message'] = $refund_info['seller_message'];
- $refund['admin_message'] = $refund_info['admin_message'];
- $info['buyer'] = array();
- if (!empty($refund_info['pic_info'])) {
- $info = unserialize($refund_info['pic_info']);
- }
- $pic_list = array();
- if (is_array($info['buyer'])) {
- foreach ($info['buyer'] as $k => $v) {
- if (!empty($v)) {
- $pic_list[] = ds_get_pic(ATTACH_PATH . '/refund', $v);
- }
- }
- }
- ds_json_encode(10000, '', array('refund' => $refund, 'pic_list' => $pic_list));
- } else {
- ds_json_encode(10001, lang('param_error'));
- }
- }
- /* 退款审核状态 */
- function getRefundStateArray($type = '')
- {
- if ($type == 'seller') {
- $state_array = array(
- '1' => lang('refund_state_confirm'), '2' => lang('refund_state_yes'), '3' => lang('refund_state_no')
- ); //卖家处理状态:1为待审核,2为同意,3为不同意
- return $state_array;
- };
- if ($type == 'admin') {
- $admin_array = array(
- '1' => lang('in_processing'), '2' => lang('to_be_processed'), '3' => lang('has_been_completed'), '4' => lang('refund_state_no')
- ); //确认状态:1为买家或卖家处理中,2为待平台管理员处理,3为退款退货已完成
- return $admin_array;
- }
- }
- }
|