Memberrefund.php 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  1. <?php
  2. namespace app\api\controller;
  3. use think\facade\Lang;
  4. /**
  5. * ============================================================================
  6. *
  7. * ============================================================================
  8. *
  9. * ----------------------------------------------------------------------------
  10. *
  11. * ============================================================================
  12. * 退款控制器
  13. */
  14. class Memberrefund extends MobileMember
  15. {
  16. public function initialize()
  17. {
  18. parent::initialize(); // TODO: Change the autogenerated stub
  19. Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/memberrefund.lang.php');
  20. }
  21. /**
  22. * @api {POST} api/Memberrefund/refund_all_form 全部退款获取订单信息
  23. * @apiVersion 1.0.0
  24. * @apiGroup Memberrefund
  25. *
  26. * @apiHeader {String} X-DS-KEY 用户授权token
  27. *
  28. * @apiParam {Int} orderId 订单id
  29. *
  30. * @apiSuccess {String} code 返回码,10000为成功
  31. * @apiSuccess {String} message 返回消息
  32. * @apiSuccess {Object} result 返回数据
  33. * @apiSuccess {Object} result.order 订单信息
  34. * @apiSuccess {Int} result.order.order_id 订单ID
  35. * @apiSuccess {Float} result.order.order_amount 订单金额
  36. * @apiSuccess {String} result.order.order_sn 订单编号
  37. * @apiSuccess {String} result.order.store_name 店铺名称
  38. * @apiSuccess {Int} result.order.store_id 店铺ID
  39. * @apiSuccess {Float} result.order.allow_refund_amount 允许退款金额
  40. * @apiSuccess {Float} result.order.book_amount 已退款金额
  41. * @apiSuccess {Object[]} result.goods_list 订单商品信息
  42. * @apiSuccess {Int} result.goods_list.goods_id 商品ID
  43. * @apiSuccess {String} result.goods_list.goods_name 商品名称
  44. * @apiSuccess {Float} result.goods_list.goods_price 商品价格
  45. * @apiSuccess {Int} result.goods_list.goods_num 购买数量
  46. * @apiSuccess {String} result.goods_list.goods_img_480 商品缩略图完整路径
  47. * @apiSuccess {String} result.goods_list.goods_type 商品类型
  48. * @apiSuccess {Object[]} result.gift_list 订单信息
  49. */
  50. public function refund_all_form()
  51. {
  52. $refundreturn_model = model('refundreturn');
  53. $member_id = $this->member_info['member_id'];
  54. $order_id = intval(input('param.order_id'));
  55. $trade_model = model('trade');
  56. $order_paid = $trade_model->getOrderState('order_paid'); //订单状态20:已付款
  57. $order_model = model('order');
  58. $condition = array();
  59. $condition[] = array('buyer_id', '=', $member_id);
  60. $condition[] = array('order_id', '=', $order_id);
  61. $condition[] = array('order_state', '=', $order_paid);
  62. $order_info = $order_model->getOrderInfo($condition);
  63. if (!empty($order_info) && is_array($order_info)) {
  64. $order = $refundreturn_model->getRightOrderList($condition);
  65. $book_amount = $order_info['refund_amount']; //退款金额
  66. $order = array();
  67. $order['order_id'] = $order_info['order_id'];
  68. //$order['order_type'] = $order_info['order_type'];
  69. $order['order_amount'] = ds_price_format($order_info['order_amount'] - $order_info['presell_deposit_amount']);
  70. $order['order_sn'] = $order_info['order_sn'];
  71. $order['store_name'] = $order_info['store_name'];
  72. $order['store_id'] = $order_info['store_id'];
  73. $order['allow_refund_amount'] = ds_price_format($order_info['order_amount'] - $book_amount); //可退款金额
  74. $order['book_amount'] = ds_price_format($book_amount);
  75. $goods_list = array();
  76. $gift_list = array();
  77. $order_model = model('order');
  78. $condition = array();
  79. $condition[] = array('order_id', '=', $order_id);
  80. $order_goods_list = $order_model->getOrdergoodsList($condition);
  81. foreach ($order_goods_list as $key => $value) {
  82. $goods = array();
  83. $goods['goods_id'] = $value['goods_id'];
  84. $goods['goods_name'] = $value['goods_name'];
  85. $goods['goods_price'] = $value['goods_price'];
  86. $goods['goods_num'] = $value['goods_num'];
  87. //$goods['goods_spec'] = $value['goods_spec'];
  88. $goods['goods_img_480'] = goods_thumb($value, 480);
  89. $goods['goods_type'] = get_order_goodstype($value['goods_type']);
  90. if ($value['goods_type'] == 5) { //赠品商品
  91. $gift_list[] = $goods;
  92. } else {
  93. $goods_list[] = $goods;
  94. }
  95. }
  96. ds_json_encode(10000, '', array('order' => $order, 'goods_list' => $goods_list, 'gift_list' => $gift_list));
  97. } else {
  98. ds_json_encode(10001, lang('param_error'));
  99. }
  100. }
  101. /**
  102. * @api {POST} api/Memberrefund/refund_all_post 全部退款保存数据
  103. * @apiVersion 1.0.0
  104. * @apiGroup Memberrefund
  105. *
  106. * @apiHeader {String} X-DS-KEY 用户授权token
  107. *
  108. * @apiParam {Int} orderId 订单id
  109. * @apiParam {String} buyer_message 退款理由
  110. * @apiParam {Array} refund_pic 退款凭证
  111. *
  112. * @apiSuccess {String} code 返回码,10000为成功
  113. * @apiSuccess {String} message 返回消息
  114. */
  115. public function refund_all_post()
  116. {
  117. $refundreturn_model = model('refundreturn');
  118. $member_id = $this->member_info['member_id'];
  119. $order_id = intval(input('post.order_id'));
  120. $trade_model = model('trade');
  121. $order_paid = $trade_model->getOrderState('order_paid'); //订单状态20:已付款
  122. $order_model = model('order');
  123. $condition = array();
  124. $condition[] = array('buyer_id', '=', $member_id);
  125. $condition[] = array('order_id', '=', $order_id);
  126. $condition[] = array('order_state', 'in', [ORDER_STATE_PAY, ORDER_STATE_PICKUP]);
  127. $order_info = $order_model->getOrderInfo($condition);
  128. $payment_code = $order_info['payment_code']; //支付方式
  129. $condition = array();
  130. $condition[] = array('buyer_id', '=', $member_id);
  131. $condition[] = array('order_id', '=', $order_id);
  132. $condition[] = array('goods_id', '=', '0');
  133. $condition[] = array('refund_state', '<', '3');
  134. $refund = $refundreturn_model->getRefundreturnInfo($condition);
  135. if (empty($order_info) || $payment_code == 'offline' || $refund['refund_id'] > 0) { //检查数据,防止页面刷新不及时造成数据错误
  136. ds_json_encode(10001, lang('param_error'));
  137. } else {
  138. $book_amount = $order_info['refund_amount']; //退款金额
  139. $allow_refund_amount = ds_price_format($order_info['order_amount'] - $order_info['presell_deposit_amount'] - $book_amount); //可退款金额
  140. $refund_array = array();
  141. $refund_array['refund_type'] = '1'; //类型:1为退款,2为退货
  142. $refund_array['seller_state'] = '1'; //状态:1为待审核,2为同意,3为不同意
  143. $refund_array['order_lock'] = '2'; //锁定类型:1为不用锁定,2为需要锁定
  144. $refund_array['goods_id'] = '0';
  145. $refund_array['order_goods_id'] = '0';
  146. $refund_array['reason_id'] = '0';
  147. $refund_array['reason_info'] = lang('refund_notice4');
  148. $refund_array['goods_name'] = lang('all_orders_refunded');
  149. $refund_array['refund_amount'] = ds_price_format($allow_refund_amount);
  150. $refund_array['buyer_message'] = input('post.buyer_message');
  151. $refund_array['add_time'] = TIMESTAMP;
  152. $pic_array = array();
  153. $pic_array['buyer'] = input('post.refund_pic/a'); //上传凭证 获取数组
  154. $info = serialize($pic_array);
  155. $refund_array['pic_info'] = $info;
  156. $state = $refundreturn_model->addRefundreturn($refund_array, $order_info);
  157. if ($state) {
  158. $refundreturn_model->editOrderLock($order_id);
  159. //自提点订单锁定
  160. $chain_order_model = model('chain_order');
  161. $chain_order_model->editChainOrderLock($order_id);
  162. ds_json_encode(10000, lang('ds_common_op_succ'), 1);
  163. } else {
  164. ds_json_encode(10001, lang('ds_common_op_fail'));
  165. }
  166. }
  167. }
  168. /**
  169. * @api {POST} api/Memberrefund/refund_form 部分退款获取订单信息
  170. * @apiVersion 1.0.0
  171. * @apiGroup Memberrefund
  172. *
  173. * @apiHeader {String} X-DS-KEY 用户授权token
  174. *
  175. * @apiParam {Int} order_id 订单id
  176. * @apiParam {Int} order_goods_id 订单商品id
  177. *
  178. * @apiSuccess {String} code 返回码,10000为成功
  179. * @apiSuccess {String} message 返回消息
  180. * @apiSuccess {Object} result 返回数据
  181. * @apiSuccess {Object} result.order 订单信息
  182. * @apiSuccess {Int} result.order.order_id 订单ID
  183. * @apiSuccess {Float} result.order.order_amount 订单金额
  184. * @apiSuccess {String} result.order.order_sn 订单编号
  185. * @apiSuccess {String} result.order.store_name 店铺名称
  186. * @apiSuccess {Int} result.order.store_id 店铺ID
  187. * @apiSuccess {Float} result.order.allow_refund_amount 允许退款金额
  188. * @apiSuccess {Float} result.order.book_amount 已退款金额
  189. * @apiSuccess {Object[]} result.goods_list 订单商品信息
  190. * @apiSuccess {Int} result.goods_list.goods_id 商品ID
  191. * @apiSuccess {Int} result.goods_list.store_id 店铺ID
  192. * @apiSuccess {Int} result.goods_list.order_goods_id 订单商品ID
  193. * @apiSuccess {String} result.goods_list.goods_name 商品名称
  194. * @apiSuccess {Float} result.goods_list.goods_price 商品价格
  195. * @apiSuccess {Float} result.goods_list.goods_pay_price 实际支付价格
  196. * @apiSuccess {Int} result.goods_list.goods_num 购买数量
  197. * @apiSuccess {String} result.goods_list.goods_img_480 商品缩略图完整路径
  198. * @apiSuccess {String} result.goods_list.goods_type 商品类型
  199. * @apiSuccess {Object[]} result.reason_list 退款理由列表
  200. * @apiSuccess {Int} result.reason_list.reason_id 退款理由ID
  201. * @apiSuccess {String} result.reason_list.reason_info 退款理由
  202. */
  203. public function refund_form()
  204. {
  205. $refundreturn_model = model('refundreturn');
  206. $condition = array();
  207. $reason_list = $refundreturn_model->getReasonList($condition, '', '', 'reason_id,reason_info'); //退款退货原因
  208. $member_id = $this->member_info['member_id'];
  209. $order_id = intval(input('param.order_id'));
  210. $goods_id = intval(input('param.order_goods_id')); //订单商品表编号
  211. $order_model = model('order');
  212. $condition = array();
  213. $condition[] = array('buyer_id', '=', $member_id);
  214. $condition[] = array('order_id', '=', $order_id);
  215. $order_info = $refundreturn_model->getRightOrderList($condition, $goods_id);
  216. //halt($order_info);
  217. $refund_state = $refundreturn_model->getRefundState($order_info); //根据订单状态判断是否可以退款退货
  218. if ($refund_state == 1 && $goods_id > 0) {
  219. $order = array();
  220. $order['order_id'] = $order_info['order_id'];
  221. //$order['order_type'] = $order_info['order_type'];
  222. $order['order_amount'] = ds_price_format($order_info['order_amount']);
  223. $order['order_sn'] = $order_info['order_sn'];
  224. $order['store_name'] = $order_info['store_name'];
  225. $order['store_id'] = $order_info['store_id'];
  226. $goods = array();
  227. $goods_list = $order_info['goods_list'];
  228. $goods_info = $goods_list[0];
  229. $goods['store_id'] = $goods_info['store_id'];
  230. $goods['order_goods_id'] = $goods_info['rec_id'];
  231. $goods['goods_id'] = $goods_info['goods_id'];
  232. $goods['goods_name'] = $goods_info['goods_name'];
  233. $goods['goods_type'] = get_order_goodstype($goods_info['goods_type']);
  234. $goods['goods_img_480'] = goods_thumb($goods_info, 480);
  235. $goods['goods_price'] = ds_price_format($goods_info['goods_price']);
  236. //$goods['goods_spec'] = $goods_info['goods_spec'];
  237. $goods['goods_num'] = $goods_info['goods_num'];
  238. $goods_pay_price = $goods_info['goods_pay_price']; //商品实际成交价
  239. $goods_pay_price -= $order_info['presell_deposit_amount'];
  240. $order_amount = $order_info['order_amount']; //订单金额
  241. $order_refund_amount = $order_info['refund_amount']; //订单退款金额
  242. if ($order_amount < ($goods_pay_price + $order_refund_amount)) {
  243. $goods_pay_price = $order_amount - $order_refund_amount;
  244. }
  245. $goods['goods_pay_price'] = ds_price_format($goods_pay_price);
  246. $reason_list = array_values($reason_list);
  247. ds_json_encode(10000, '', array('order' => $order, 'goods' => $goods, 'reason_list' => $reason_list));
  248. } else {
  249. ds_json_encode(10001, lang('param_error'));
  250. }
  251. }
  252. /**
  253. * @api {POST} api/Memberrefund/refund_post 部分退款保存数据
  254. * @apiVersion 1.0.0
  255. * @apiGroup Memberrefund
  256. *
  257. * @apiHeader {String} X-DS-KEY 用户授权token
  258. *
  259. * @apiParam {Int} order_id 订单id
  260. * @apiParam {Int} order_goods_id 订单商品id
  261. * @apiParam {Float} refund_amount 退款金额
  262. * @apiParam {Int} goods_num 退货数量
  263. * @apiParam {Int} reason_id 退款理由id
  264. * @apiParam {Int} refund_type 类型 1退款 2退货
  265. * @apiParam {String} buyer_message 退款理由
  266. * @apiParam {Array} refund_pic 退款凭证
  267. *
  268. * @apiSuccess {String} code 返回码,10000为成功
  269. * @apiSuccess {String} message 返回消息
  270. */
  271. public function refund_post()
  272. {
  273. $member_id = $this->member_info['member_id'];
  274. $order_id = intval(input('post.order_id'));
  275. $goods_id = intval(input('post.order_goods_id')); //订单商品表编号
  276. $order_model = model('order');
  277. $refundreturn_model = model('refundreturn');
  278. $condition = array();
  279. $condition[] = array('buyer_id', '=', $member_id);
  280. $condition[] = array('order_id', '=', $order_id);
  281. $order_info = $refundreturn_model->getRightOrderList($condition, $goods_id);
  282. $refund_state = $refundreturn_model->getRefundState($order_info); //根据订单状态判断是否可以退款退货
  283. $condition = array();
  284. $condition[] = array('buyer_id', '=', $member_id);
  285. $condition[] = array('order_id', '=', $order_id);
  286. $condition[] = array('order_goods_id', '=', $goods_id);
  287. $condition[] = array('refund_state', '<', '3');
  288. $refund = $refundreturn_model->getRefundreturnInfo($condition);
  289. if ($refund_state == 1 && $goods_id > 0 && empty($refund)) {
  290. $goods_list = $order_info['goods_list'];
  291. $goods_info = $goods_list[0];
  292. $refund_array = array();
  293. $goods_pay_price = $goods_info['goods_pay_price']; //商品实际成交价
  294. $goods_pay_price -= $order_info['presell_deposit_amount'];
  295. $order_amount = $order_info['order_amount']; //订单金额
  296. $order_refund_amount = $order_info['refund_amount']; //订单退款金额
  297. if ($order_amount < ($goods_pay_price + $order_refund_amount)) {
  298. $goods_pay_price = $order_amount - $order_refund_amount;
  299. }
  300. $refund_amount = floatval(input('post.refund_amount')); //退款金额
  301. if (($refund_amount < 0) || ($refund_amount > $goods_pay_price)) {
  302. $refund_amount = $goods_pay_price;
  303. }
  304. $goods_num = !empty(input('post.goods_num')) ? intval(input('post.goods_num')) : 1; //退货数量
  305. if (($goods_num < 0) || ($goods_num > $goods_info['goods_num'])) {
  306. $goods_num = 1;
  307. }
  308. $reason_list = $refundreturn_model->getReasonList(array(), '', '', 'reason_id,reason_info'); //退款退货原因
  309. $refund_array['reason_info'] = '';
  310. $reason_id = intval(input('post.reason_id')); //退货退款原因
  311. $refund_array['reason_id'] = $reason_id;
  312. $reason_array = array();
  313. $reason_array['reason_info'] = lang('other');
  314. $reason_list[0] = $reason_array;
  315. if (!empty($reason_list[$reason_id])) {
  316. $reason_array = $reason_list[$reason_id];
  317. $refund_array['reason_info'] = $reason_array['reason_info'];
  318. }
  319. $pic_array = array();
  320. $pic_array['buyer'] = input('post.refund_pic/a'); //上传凭证 获取数组
  321. $info = serialize($pic_array);
  322. $refund_array['pic_info'] = $info;
  323. $trade_model = model('trade');
  324. $order_shipped = $trade_model->getOrderState('order_shipped'); //订单状态30:已发货
  325. $refund_array['order_lock'] = '1';
  326. if ($order_info['order_state'] == $order_shipped) {
  327. $refund_array['order_lock'] = '2'; //锁定类型:1为不用锁定,2为需要锁定
  328. }
  329. $refund_array['refund_type'] = input('post.refund_type'); //类型:1为退款,2为退货
  330. $refund_array['return_type'] = '2'; //退货类型:1为不用退货,2为需要退货
  331. if ($refund_array['refund_type'] != '2') {
  332. $refund_array['refund_type'] = '1';
  333. $refund_array['return_type'] = '1';
  334. }
  335. $refund_array['seller_state'] = '1'; //状态:1为待审核,2为同意,3为不同意
  336. $refund_array['refund_amount'] = ds_price_format($refund_amount);
  337. $refund_array['goods_num'] = $goods_num;
  338. $refund_array['buyer_message'] = input('post.buyer_message');
  339. $refund_array['add_time'] = TIMESTAMP;
  340. $state = $refundreturn_model->addRefundreturn($refund_array, $order_info, $goods_info);
  341. if ($state) {
  342. if ($order_info['order_state'] == $order_shipped) {
  343. $refundreturn_model->editOrderLock($order_id);
  344. }
  345. //自提点订单锁定
  346. $chain_order_model = model('chain_order');
  347. $chain_order_model->editChainOrderLock($order_id);
  348. ds_json_encode(10000, lang('ds_common_op_succ'), 1);
  349. } else {
  350. ds_json_encode(10001, lang('ds_common_op_fail'));
  351. }
  352. } else {
  353. ds_json_encode(10001, lang('param_error'));
  354. }
  355. }
  356. /**
  357. * @api {POST} api/Memberrefund/refund_all_post 上传凭证
  358. * @apiVersion 1.0.0
  359. * @apiGroup Memberrefund
  360. *
  361. * @apiHeader {String} X-DS-KEY 用户授权token
  362. *
  363. * @apiParam {File} refund_pic 退款凭证
  364. *
  365. * @apiSuccess {String} code 返回码,10000为成功
  366. * @apiSuccess {String} message 返回消息
  367. * @apiSuccess {Object} result 返回数据
  368. * @apiSuccess {String} result.file_name 文件名称
  369. * @apiSuccess {String} result.pic 文件完整路径
  370. */
  371. public function upload_pic()
  372. {
  373. if (empty($_FILES['refund_pic']['name'])) {
  374. ds_json_encode(10001, lang('file_empty'));
  375. }
  376. $res = ds_upload_pic(ATTACH_PATH . DIRECTORY_SEPARATOR . 'refund', 'refund_pic');
  377. if ($res['code']) {
  378. $file_name = $res['data']['file_name'];
  379. $pic = ds_get_pic(ATTACH_PATH . '/refund', $file_name);
  380. ds_json_encode(10000, '', array('file_name' => $file_name, 'pic' => $pic));
  381. } else {
  382. ds_json_encode(10001, $res['msg']);
  383. }
  384. }
  385. /**
  386. * @api {POST} api/Memberrefund/get_refund_list 退款记录列表
  387. * @apiVersion 1.0.0
  388. * @apiGroup Memberrefund
  389. *
  390. * @apiHeader {String} X-DS-KEY 用户授权token
  391. *
  392. * @apiParam {Int} page 页码
  393. * @apiParam {Int} per_page 每页数量
  394. * @apiParam {String} type 查询字段 order_sn订单号 refund_sn退款单号 goods_name商品名
  395. * @apiParam {String} k 查询关键词
  396. * @apiParam {String} add_time_from 时间从 YYYY-MM-DD
  397. * @apiParam {String} add_time_to 时间到 YYYY-MM-DD
  398. *
  399. * @apiSuccess {String} code 返回码,10000为成功
  400. * @apiSuccess {String} message 返回消息
  401. * @apiSuccess {Object} result 返回数据
  402. * @apiSuccess {Object[]} result.refund_list 退款列表
  403. * @apiSuccess {Int} result.refund_list.add_time 添加时间
  404. * @apiSuccess {String} result.refund_list.admin_state 管理员状态描述
  405. * @apiSuccess {Int} result.refund_list.admin_state_v 管理员处理状态 1:待审核 2:同意 3:不同意
  406. * @apiSuccess {Object[]} result.refund_list.goods_list 商品列表
  407. * @apiSuccess {Int} result.refund_list.goods_list.goods_id 商品ID
  408. * @apiSuccess {String} result.refund_list.goods_list.goods_img_480 商品缩略图完整路径
  409. * @apiSuccess {String} result.refund_list.goods_list.goods_name 商品名称
  410. * @apiSuccess {Int} result.refund_list.order_id 订单ID
  411. * @apiSuccess {String} result.refund_list.order_sn 订单编号
  412. * @apiSuccess {Float} result.refund_list.refund_amount 退款金额
  413. * @apiSuccess {Int} result.refund_list.refund_id 退款ID
  414. * @apiSuccess {String} result.refund_list.refund_sn 退款编号
  415. * @apiSuccess {String} result.refund_list.seller_state 卖家处理状态描述 1:待审核,2:同意,3:不同意
  416. * @apiSuccess {Int} result.refund_list.seller_state_v 卖家状态
  417. * @apiSuccess {Int} result.refund_list.store_id 店铺ID
  418. * @apiSuccess {String} result.refund_list.store_name 店铺描述
  419. * @apiSuccess {Int} result.page_total 总页数
  420. * @apiSuccess {Boolean} result.hasmore 是否有更多 true是false否
  421. */
  422. public function get_refund_list()
  423. {
  424. $order_model = model('order');
  425. $refundreturn_model = model('refundreturn');
  426. $member_id = $this->member_info['member_id'];
  427. $refund_list = array();
  428. $condition = array();
  429. $condition[] = array('refund_type', '=', 1);
  430. $condition[] = array('buyer_id', '=', $member_id);
  431. $keyword_type = array('order_sn', 'refund_sn', 'goods_name');
  432. if (trim(input('param.k')) != '' && in_array(input('param.type'), $keyword_type)) {
  433. $type = input('param.type');
  434. $condition[] = array($type, 'like', '%' . input('param.k') . '%');
  435. }
  436. if (trim(input('param.add_time_from')) != '' || trim(input('param.add_time_to')) != '') {
  437. $add_time_from = strtotime(trim(input('param.add_time_from')));
  438. $add_time_to = strtotime(trim(input('param.add_time_to')));
  439. if ($add_time_from !== false || $add_time_to !== false) {
  440. $condition[] = array('add_time', 'time', array($add_time_from, $add_time_to));
  441. }
  442. }
  443. $list = $refundreturn_model->getRefundList($condition, $this->pagesize);
  444. if (!empty($list) && is_array($list)) {
  445. $seller_state = $this->getRefundStateArray('seller');
  446. $admin_state = $this->getRefundStateArray('admin');
  447. foreach ($list as $k => $v) {
  448. $val = array();
  449. $val['refund_id'] = $v['refund_id'];
  450. $val['order_id'] = $v['order_id'];
  451. $val['refund_amount'] = ds_price_format($v['refund_amount']);
  452. $val['refund_sn'] = $v['refund_sn'];
  453. $val['order_sn'] = $v['order_sn'];
  454. $val['add_time'] = date("Y-m-d H:i:s", $v['add_time']);
  455. $val['seller_state_v'] = $v['seller_state'];
  456. $val['seller_state'] = $seller_state[$v['seller_state']];
  457. $val['admin_state_v'] = $v['refund_state'];
  458. $val['admin_state'] = $admin_state[$v['refund_state']];
  459. $val['store_id'] = $v['store_id'];
  460. $val['store_name'] = $v['store_name'];
  461. $goods_list = array();
  462. if ($v['goods_id'] > 0) {
  463. $goods = array();
  464. $goods['goods_id'] = $v['goods_id'];
  465. $goods['goods_name'] = $v['goods_name'];
  466. $condition = array();
  467. $condition[] = array('rec_id', '=', $v['order_goods_id']);
  468. $order_goods_list = $order_model->getOrdergoodsList($condition);
  469. //$goods['goods_spec'] = $order_goods_list[0]['goods_spec'];
  470. $goods['goods_img_480'] = goods_thumb($v, 480);
  471. $goods_list[] = $goods;
  472. } else {
  473. $condition = array();
  474. $condition[] = array('order_id', '=', $v['order_id']);
  475. $order_goods_list = $order_model->getOrdergoodsList($condition);
  476. foreach ($order_goods_list as $key => $value) {
  477. $goods = array();
  478. $goods['goods_id'] = $value['goods_id'];
  479. $goods['goods_name'] = $value['goods_name'];
  480. //$goods['goods_spec'] = $value['goods_spec'];
  481. $goods['goods_img_480'] = goods_thumb($value, 480);
  482. $goods_list[] = $goods;
  483. }
  484. }
  485. $val['goods_list'] = $goods_list;
  486. $refund_list[] = $val;
  487. }
  488. }
  489. $result = array_merge(array('refund_list' => $refund_list), mobile_page($refundreturn_model->page_info));
  490. ds_json_encode(10000, '', $result);
  491. }
  492. /**
  493. * 查看退款信息
  494. *
  495. */
  496. public function get_refund_info()
  497. {
  498. $refundreturn_model = model('refundreturn');
  499. $member_id = $this->member_info['member_id'];
  500. $condition = array();
  501. $condition[] = array('buyer_id', '=', $member_id);
  502. $condition[] = array('refund_id', '=', intval(input('param.refund_id')));
  503. $refund_info = $refundreturn_model->getRefundreturnInfo($condition);
  504. if (!empty($refund_info) && is_array($refund_info)) {
  505. $seller_state = $this->getRefundStateArray('seller');
  506. $admin_state = $this->getRefundStateArray('admin');
  507. $refund = array();
  508. $refund['refund_id'] = $refund_info['refund_id'];
  509. $refund['goods_id'] = $refund_info['goods_id'];
  510. $refund['goods_name'] = $refund_info['goods_name'];
  511. $refund['order_id'] = $refund_info['order_id'];
  512. $refund['refund_amount'] = ds_price_format($refund_info['refund_amount']);
  513. $refund['refund_sn'] = $refund_info['refund_sn'];
  514. $refund['order_sn'] = $refund_info['order_sn'];
  515. $refund['add_time'] = date("Y-m-d H:i:s", $refund_info['add_time']);
  516. $refund['goods_img_480'] = goods_thumb($refund_info, 480);
  517. $refund['seller_state'] = $seller_state[$refund_info['seller_state']];
  518. $refund['admin_state'] = $admin_state[$refund_info['refund_state']];
  519. $refund['store_id'] = $refund_info['store_id'];
  520. $refund['store_name'] = $refund_info['store_name'];
  521. $refund['reason_info'] = $refund_info['reason_info'];
  522. $refund['buyer_message'] = $refund_info['buyer_message'];
  523. $refund['seller_message'] = $refund_info['seller_message'];
  524. $refund['admin_message'] = $refund_info['admin_message'];
  525. $info['buyer'] = array();
  526. if (!empty($refund_info['pic_info'])) {
  527. $info = unserialize($refund_info['pic_info']);
  528. }
  529. $pic_list = array();
  530. if (is_array($info['buyer'])) {
  531. foreach ($info['buyer'] as $k => $v) {
  532. if (!empty($v)) {
  533. $pic_list[] = ds_get_pic(ATTACH_PATH . '/refund', $v);
  534. }
  535. }
  536. }
  537. ds_json_encode(10000, '', array('refund' => $refund, 'pic_list' => $pic_list));
  538. } else {
  539. ds_json_encode(10001, lang('param_error'));
  540. }
  541. }
  542. /* 退款审核状态 */
  543. function getRefundStateArray($type = '')
  544. {
  545. if ($type == 'seller') {
  546. $state_array = array(
  547. '1' => lang('refund_state_confirm'), '2' => lang('refund_state_yes'), '3' => lang('refund_state_no')
  548. ); //卖家处理状态:1为待审核,2为同意,3为不同意
  549. return $state_array;
  550. };
  551. if ($type == 'admin') {
  552. $admin_array = array(
  553. '1' => lang('in_processing'), '2' => lang('to_be_processed'), '3' => lang('has_been_completed'), '4' => lang('refund_state_no')
  554. ); //确认状态:1为买家或卖家处理中,2为待平台管理员处理,3为退款退货已完成
  555. return $admin_array;
  556. }
  557. }
  558. }