AfterorderController.class.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758
  1. <?php
  2. /**
  3. * lionfish 商城系统
  4. *
  5. * ==========================================================================
  6. * @link http://www.liofis.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license http://www.liofis.com/license.html License
  9. * ==========================================================================
  10. *
  11. * @author fish
  12. *
  13. */
  14. namespace Home\Controller;
  15. class AfterorderController extends CommonController {
  16. public function get_order_money()
  17. {
  18. $_GPC = I('request.');
  19. $token = $_GPC['token'];
  20. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  21. $member_id = $weprogram_token['member_id'];
  22. $member_info = M('lionfish_comshop_member')->where( array('member_id' => $member_id) )->find();
  23. if( empty($member_id) )
  24. {
  25. $result['code'] = 0;
  26. $result['msg'] = '登录失效';
  27. echo json_encode($result);
  28. die();
  29. }
  30. $order_id = $_GPC['order_id'];
  31. $order_goods_id = $_GPC['order_goods_id'];
  32. $ref_id = isset($_GPC['ref_id']) && $_GPC['ref_id'] > 0 ? intval($_GPC['ref_id']) : '';
  33. //total lionfish_comshop_order
  34. //shipping_name shipping_tel
  35. $total = 0;
  36. $order_info = M('lionfish_comshop_order')->where( array('order_id' => $order_id , 'member_id' => $member_id ) )->find();
  37. $order_goods = M('lionfish_comshop_order_goods')->where( array('order_id' =>$order_id,'order_goods_id' =>$order_goods_id ) )->find();
  38. $order_goods['total_score'] = intval($order_goods['total']);
  39. $is_has_refund_deliveryfree = D('Home/Front')->get_config_by_name('is_has_refund_deliveryfree');
  40. $is_has_refund_deliveryfree = !isset($is_has_refund_deliveryfree) || $is_has_refund_deliveryfree == 1 ? 1:0;
  41. if( $is_has_refund_deliveryfree == 1 )
  42. {
  43. $ref_shipping_fare_old = M('lionfish_comshop_order_refund')->where( array('order_goods_id' => $order_goods_id,'state' => 3 ) )->sum('ref_shipping_fare');
  44. $ref_shipping_fare_new = $order_goods['shipping_fare'] - $ref_shipping_fare_old ;
  45. $order_goods['total'] = $order_goods['total'] + $ref_shipping_fare_new - $order_goods['voucher_credit']- $order_goods['fullreduction_money'] - $order_goods['score_for_money'];
  46. }else{
  47. $order_goods['total'] = $order_goods['total'] - $order_goods['voucher_credit']- $order_goods['fullreduction_money'] - $order_goods['score_for_money'];
  48. }
  49. $total = $order_goods['total'];
  50. //判断是否预售 begin
  51. $presale_result = D('Home/PresaleGoods')->getOrderPresaleInfo( $order_id );
  52. if($presale_result['code'] == 0 )
  53. {
  54. $total = $total - $presale_result['data']['presale_for_ordermoney'];
  55. }
  56. //end
  57. $order_option_info = M('lionfish_comshop_order_option')->field('value')->where( array('order_id' =>$order_id,'order_goods_id' => $order_goods_id ) )->select();
  58. foreach($order_option_info as $option)
  59. {
  60. $order_goods['option_str'][] = $option['value'];
  61. }
  62. if(empty($order_goods['option_str']))
  63. {
  64. //option_str
  65. $order_goods['option_str'] = '';
  66. }else{
  67. $order_goods['option_str'] = implode(',', $order_goods['option_str']);
  68. }
  69. //$goods_images = resize($order_goods['goods_images'],400);
  70. $goods_images = $order_goods['goods_images'];
  71. if( !is_array($goods_images) )
  72. {
  73. $order_goods['image']= tomedia( $goods_images );
  74. $order_goods['goods_images']= tomedia( $goods_images );
  75. }else{
  76. $order_goods['image']= $order_goods['goods_images'];
  77. }
  78. $integral_flow = M('lionfish_comshop_member_integral_flow')->where( array('type' => 'orderbuy', 'order_goods_id' => $order_goods_id ) )->find();
  79. $use_score = 0;
  80. if( !empty($integral_flow) )
  81. {
  82. $use_score = $integral_flow['score'];
  83. }
  84. $one_goods_score = intval($use_score / $order_goods['quantity'] );
  85. $refund_integral_flow = M('lionfish_comshop_member_integral_flow')->where( array('type' => 'refundorder', 'order_goods_id' => $order_goods_id ) )->sum('score');
  86. if( $refund_integral_flow > 0 )
  87. {
  88. $use_score = $use_score - $refund_integral_flow;
  89. }
  90. $order_goods['use_score'] = $use_score;
  91. $order_goods['one_goods_score'] = $one_goods_score;
  92. $order_goods['type'] = $order_info['type'];
  93. $shipping_name = $order_info['shipping_name'];
  94. $shipping_tel = $order_info['shipping_tel'];
  95. //商品图片 ref_id
  96. $refund_info = array();
  97. $refund_image = array();
  98. if( !empty($ref_id) && $ref_id > 0 )
  99. {
  100. $refund_info = M('lionfish_comshop_order_refund')->where( array('ref_id' => $ref_id ) )->find();
  101. $order_refund_image = M('lionfish_comshop_order_refund_image')->where( array('ref_id' =>$order_refund['ref_id'] ) )->select();
  102. if(!empty($order_refund_image))
  103. {
  104. foreach($order_refund_image as $key => $refund_image)
  105. {
  106. $refund_image['thumb_image'] = tomedia( resize($refund_image['image'], 200) );
  107. $order_refund_image[$key] = $refund_image;
  108. }
  109. }
  110. }
  111. echo json_encode( array('code' =>1, 'total' => $total,'is_has_refund_deliveryfree' => $is_has_refund_deliveryfree,'refund_info' => $refund_info,'refund_image' => $refund_image,'order_goods' => $order_goods ,'shipping_name' => $shipping_name,'shipping_tel' => $shipping_tel, 'order_status_id'=>$order_info['order_status_id']) );
  112. die();
  113. }
  114. public function refund_sub()
  115. {
  116. $_GPC = I('request.');
  117. $token = $_GPC['token'];
  118. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  119. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  120. {
  121. $result['code'] = 0;
  122. $result['msg'] = '登录失效';
  123. echo json_encode($result);
  124. die();
  125. }
  126. $member_id = $weprogram_token['member_id'];
  127. $member_info = M('lionfish_comshop_member')->where( array('member_id' => $member_id) )->find();
  128. $member_id = $weprogram_token['member_id'];
  129. if( empty($member_id) )
  130. {
  131. $result['code'] = 0;
  132. $result['msg'] = '登录失效';
  133. echo json_encode($result);
  134. die();
  135. }
  136. $data = array();
  137. $data['order_id'] = $_GPC['order_id'];//订单号
  138. if(isset($_GPC['ref_id']) && $_GPC['ref_id'] > 0)
  139. {
  140. $data['ref_id'] = isset($_GPC['ref_id']) ? $_GPC['ref_id'] : 0 ;//如果是退款申请修改,那么有此字段,这个是退款的编号
  141. }
  142. $data['complaint_type'] = $_GPC['complaint_type'];//1 退款,2退货
  143. $data['complaint_images'] = $_GPC['complaint_images'];//退款的图片
  144. $data['complaint_desc'] = $_GPC['complaint_desc'];//商品问题描述
  145. $data['complaint_mobile'] = $_GPC['complaint_mobile'];//联系人手机号
  146. $data['complaint_name'] = $_GPC['complaint_name'];//退款的联系人
  147. $data['complaint_reason'] = $_GPC['complaint_reason'];//问题类型
  148. $data['complaint_money'] = $_GPC['complaint_money'];//退款金额
  149. $is_has_refund_deliveryfree = D('Home/Front')->get_config_by_name('is_has_refund_deliveryfree');
  150. $is_has_refund_deliveryfree = !isset($is_has_refund_deliveryfree) || $is_has_refund_deliveryfree == 1 ? 1:0;
  151. $data['complaint_shipping_fare'] = $_GPC['complaint_shipping_fare'];//退款金额
  152. if( $is_has_refund_deliveryfree == 0 )
  153. {
  154. $data['complaint_shipping_fare'] = 0;
  155. }
  156. if( !empty($data['complaint_images']) )
  157. {
  158. $data['complaint_images'] = explode(',', $data['complaint_images']);
  159. }
  160. $order_id = $data['order_id'];
  161. $order_goods_id = $_GPC['order_goods_id'];//子订单号
  162. $real_refund_quantity = isset($_GPC['real_refund_quantity']) ? $_GPC['real_refund_quantity'] : 1;
  163. $order_info = M('lionfish_comshop_order')->where( array('member_id' => $member_id, 'order_id' => $order_id ) )->find();
  164. if(empty($order_info) )
  165. {
  166. $result['code'] = 0;
  167. $result['msg'] = '没有此订单';
  168. echo json_encode($result);
  169. die();
  170. }
  171. //确认收货后才能退款
  172. if($order_info['order_status_id'] < 6)
  173. {
  174. $result['code'] = 0;
  175. $result['msg'] = '收货后才能售后';
  176. echo json_encode($result);
  177. die();
  178. }
  179. $result = array('code' => 0);
  180. $refdata = array();
  181. $refdata['order_id'] = intval($data['order_id']);
  182. $refdata['ref_type'] = intval($data['complaint_type']);
  183. $refdata['ref_money'] = floatval($data['complaint_money']);
  184. //子订单商品数
  185. $order_goods = M('lionfish_comshop_order_goods')->where( array('order_id' =>$order_id,'order_goods_id' =>$order_goods_id ) )->find();
  186. //子订单最后一个商品
  187. if( $real_refund_quantity + $order_goods['has_refund_quantity'] == $order_goods['quantity'] ){
  188. $ref_shipping_fare_old = M('lionfish_comshop_order_goods_refund')->where( array('order_goods_id' => $order_goods_id ) )->sum('refund_shipping_fare');
  189. $refdata['ref_shipping_fare'] = floatval( $order_goods['fenbi_li']*$order_goods['shipping_fare'] - $ref_shipping_fare_old );
  190. }else{
  191. $refdata['ref_shipping_fare'] = floatval( $real_refund_quantity/$order_goods['quantity'] * $data['complaint_shipping_fare'] * $order_goods['fenbi_li'] );
  192. }
  193. $refdata['ref_member_id'] = $member_id;
  194. $refdata['ref_name'] = htmlspecialchars($data['complaint_reason']);
  195. $refdata['ref_mobile'] = htmlspecialchars($data['complaint_mobile']);
  196. $refdata['ref_description'] = htmlspecialchars($data['complaint_desc']);
  197. $refdata['complaint_name'] = htmlspecialchars($data['complaint_name']);
  198. $refdata['state'] = 0;
  199. $refdata['real_refund_quantity'] = $real_refund_quantity;
  200. $refdata['addtime'] = time();
  201. //complaint_name
  202. $order_info['total'] = round($order_info['total'],2)< 0.01 ? '0.00':round($order_info['total']+$order_info['shipping_fare']-$order_info['voucher_credit']-$order_info['fullreduction_money'],2) ;
  203. if( !empty($order_goods_id) && $order_goods_id > 0 )
  204. {
  205. $order_goods_info = M('lionfish_comshop_order_goods')->where( array('order_goods_id' => $order_goods_id ) )->find();
  206. $tp_total = round($order_goods_info['total'],2)< 0.01 ? '0.00':round($order_goods_info['total']+$order_goods_info['shipping_fare']-$order_goods_info['voucher_credit']-$order_goods_info['score_for_money']-$order_goods_info['fullreduction_money'],2) ;
  207. $order_info['total'] = $tp_total;
  208. }
  209. if( $refdata['ref_money'] <=0 )
  210. {
  211. //$result['msg'] = '退款金额不能为0';
  212. //echo json_encode($result);
  213. //die();
  214. }
  215. if($order_info['total'] < 0)
  216. {
  217. $order_info['total'] = '0.00';
  218. }
  219. if($refdata['ref_money'] > $order_info['total'])
  220. {
  221. $result['msg'] = '退款金额不能大于订单总额';
  222. echo json_encode($result);
  223. die();
  224. }
  225. if(!empty($data['ref_id']))
  226. {
  227. $ref_id = intval($data['ref_id']);
  228. unset($refdata['order_id']);
  229. unset($refdata['ref_member_id']);
  230. unset($refdata['addtime']);
  231. M('lionfish_comshop_order_refund')->where( array('ref_id' => $ref_id) )->save( $refdata );
  232. $order_history = array();
  233. //$order_history['ref_id'] = $ref_id;
  234. $order_history['order_id'] = $order_id;
  235. $order_history['order_status_id'] = $order_info['order_status_id'];
  236. $order_history['notify'] = 0;
  237. $order_history['comment'] = '用户修改退款资料';
  238. $order_history['date_added']=time();
  239. //pdo_insert('lionfish_comshop_order_history', $order_history);
  240. //记录日志
  241. $order_refund_history = array();
  242. $order_refund_history['ref_id'] = $ref_id;
  243. $order_refund_history['order_id'] = $order_id;
  244. $order_refund_history['order_goods_id'] = $order_goods_id;
  245. $order_refund_history['message'] = '用户修改退款资料';
  246. $order_refund_history['type'] = 1;
  247. $order_refund_history['addtime'] = time();
  248. $orh_id = M('lionfish_comshop_order_refund_history')->add( $order_refund_history );
  249. if(!empty($data['complaint_images']))
  250. {
  251. foreach($data['complaint_images'] as $complaint_images)
  252. {
  253. $img_data = array();
  254. $img_data['orh_id'] = $orh_id;
  255. $img_data['image'] = htmlspecialchars($complaint_images);
  256. $img_data['addtime'] = time();
  257. M('lionfish_comshop_order_refund_history_image')->add( $img_data );
  258. }
  259. }
  260. }else {
  261. //real_refund_quantity
  262. //$refdata['real_refund_quantity'] = $real_refund_quantity;
  263. //申请中的退款数量
  264. $has_refund_quantity = $order_goods_info['has_refund_quantity'];
  265. $del_can_refund_quantity = $order_goods_info['quantity'] - $has_refund_quantity;
  266. if( $real_refund_quantity <= 0 )
  267. {
  268. $real_refund_quantity = $del_can_refund_quantity;
  269. $refdata['real_refund_quantity'] = $real_refund_quantity;
  270. }
  271. $refdata['order_goods_id'] = $order_goods_id;
  272. //store_id
  273. $refdata['store_id'] = $order_info['store_id'];
  274. $refdata['head_id'] = $order_info['head_id'];
  275. $ref_id = M('lionfish_comshop_order_refund')->add($refdata);
  276. $order_refund_history = array();
  277. $order_refund_history['ref_id'] = $ref_id;
  278. $order_refund_history['order_id'] = $order_id;
  279. $order_refund_history['order_goods_id'] = $order_goods_id;
  280. $order_refund_history['message'] = '已经提交退款申请,待平台审核';
  281. $order_refund_history['type'] = 1;
  282. $order_refund_history['addtime'] = time();
  283. $orh_id = M('lionfish_comshop_order_refund_history')->add($order_refund_history);
  284. $can_refund_order = true;
  285. if( !empty($order_goods_id) && $order_goods_id > 0 )
  286. {
  287. M('lionfish_comshop_order_goods')->where( array('order_goods_id' => $order_goods_id ) )->save( array('is_refund_state' => 1) );
  288. //判断是否全部都退款了
  289. $gdall = M('lionfish_comshop_order_goods')->field('is_refund_state')->where( array('order_id' => $order_id ) )->select();
  290. foreach( $gdall as $vv )
  291. {
  292. if( $vv['is_refund_state'] == 0 )
  293. {
  294. $can_refund_order = false;
  295. break;
  296. }
  297. }
  298. if( $real_refund_quantity != $del_can_refund_quantity )
  299. {
  300. $can_refund_order = false;
  301. }
  302. }
  303. /**
  304. 判断是否所有订单都在退款中
  305. **/
  306. if($can_refund_order)
  307. {
  308. $up_order = array();
  309. $up_order['order_status_id'] = 12;
  310. $up_order['last_refund_order_status_id'] = $order_info['order_status_id'];
  311. M('lionfish_comshop_order')->where( array('order_id' => $order_id ) )->save( $up_order );
  312. }
  313. $order_history = array();
  314. $order_history['order_id'] = $order_id;
  315. $order_history['order_goods_id'] = $order_goods_id;
  316. $order_history['order_status_id'] = 12;
  317. $order_history['notify'] = 0;
  318. $order_history['comment'] = '用户申请退款中,申请退款'.$real_refund_quantity.'个';
  319. $order_history['date_added']=time();
  320. M('lionfish_comshop_order_history')->add( $order_history );
  321. if(!empty($data['complaint_images']))
  322. {
  323. //complaint_images
  324. foreach($data['complaint_images'] as $complaint_images)
  325. {
  326. $img_data = array();
  327. $img_data['ref_id'] = $ref_id;
  328. $img_data['uniacid'] = $_W['uniacid'];
  329. $img_data['image'] = htmlspecialchars($complaint_images);
  330. $img_data['addtime'] = time();
  331. M('lionfish_comshop_order_refund_image')->add( $img_data );
  332. }
  333. }
  334. //发送消息给管理员,有人申请退款了
  335. $platform_send_info_member_id = D('Home/Front')->get_config_by_name('platform_send_info_member');
  336. $weixin_template_apply_refund = D('Home/Front')->get_config_by_name('weixin_template_apply_refund');
  337. if( !empty($weixin_template_apply_refund) && !empty($platform_send_info_member_id) )
  338. {
  339. $weixin_template_order =array();
  340. $weixin_appid = D('Home/Front')->get_config_by_name('weixin_appid' );
  341. if( !empty($weixin_appid) && !empty($weixin_template_apply_refund) )
  342. {
  343. $head_pathinfo = "lionfish_comshop/pages/index/index";
  344. //$weopenid = M('lionfish_comshop_member')->where( array('member_id' => $platform_send_info_member_id ) )->find();
  345. //dump($weopenid);die;
  346. $sql = "select * from oscshop_lionfish_comshop_member where member_id in ( ".$platform_send_info_member_id.")";
  347. $we_openid = M()->query($sql);
  348. foreach($we_openid as $k=>$v){
  349. $weixin_template_order = array(
  350. 'appid' => $weixin_appid,
  351. 'template_id' => $weixin_template_apply_refund,
  352. 'pagepath' => $head_pathinfo,
  353. 'data' => array(
  354. 'first' => array('value' => '您好,您收到了一个顾客退款申请订单,请尽快处理','color' => '#030303'),
  355. 'keyword1' => array('value' =>$member_info['username'] ,'color' => '#030303'),//顾客信息
  356. 'keyword2' => array('value' => $order_info['shipping_tel'],'color' => '#030303'),//联系方式
  357. 'keyword3' => array('value' => $order_info['order_num_alias'],'color' => '#030303'),
  358. 'keyword4' => array('value' => sprintf("%01.2f", $order_info['total']),'color' => '#030303'),
  359. 'keyword5' => array('value' => htmlspecialchars($data['complaint_reason']),'color' => '#030303'),
  360. 'remark' => array('value' => '请在48小时内响应顾客的售后申请,请尽快处理','color' => '#030303'),
  361. )
  362. );
  363. D('Seller/User')->just_send_wxtemplate($v['we_openid'], 0, $weixin_template_order );
  364. }
  365. }
  366. }
  367. }
  368. $result['code'] = 1;
  369. echo json_encode($result);
  370. die();
  371. }
  372. public function test(){
  373. $platform_send_info_member_id = D('Home/Front')->get_config_by_name('platform_send_info_member');
  374. $sql = "select * from oscshop_lionfish_comshop_member where member_id in (".$platform_send_info_member_id.")";
  375. $we_openid = M()->query($sql);
  376. dump($we_openid);
  377. }
  378. public function refunddetail()
  379. {
  380. $_GPC = I('request.');
  381. $token = $_GPC['token'];
  382. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  383. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  384. {
  385. echo json_encode( array('code' => 1) );
  386. die();
  387. }
  388. $member_id = $weprogram_token['member_id'];
  389. $member_info = M('lionfish_comshop_member')->where( array('member_id' => $member_id) )->find();
  390. if( empty($member_id) )
  391. {
  392. $result['code'] = 0;
  393. $result['msg'] = '登录失效';
  394. echo json_encode($result);
  395. die();
  396. }
  397. $ref_id = $_GPC['ref_id'];
  398. $order_refund = M('lionfish_comshop_order_refund')->where( array('ref_id' => $ref_id ) )->find();
  399. $order_id = $order_refund['order_id'];
  400. $order_info = M('lionfish_comshop_order')->where( array('member_id' => $member_id, 'order_id' =>$order_id ) )->find();
  401. if(empty($order_info) )
  402. {
  403. $result['code'] = 0;
  404. $result['msg'] = '无此订单';
  405. echo json_encode($result);
  406. die();
  407. }
  408. if($order_refund['order_goods_id'] > 0)
  409. {
  410. $order_goods = M('lionfish_comshop_order_goods')->where( array('order_goods_id' =>$order_refund['order_goods_id'],'order_id' => $order_id ) )->find();
  411. }else{
  412. $order_goods = M('lionfish_comshop_order_goods')->where( array('order_id' => $order_id ) )->find();
  413. }
  414. $total = 0;
  415. $total = $order_goods['total'] + $order_goods['shipping_fare']- $order_goods['voucher_credit']- $order_goods['fullreduction_money'] - $order_goods['score_for_money'];
  416. $order_goods['total'] = $total;
  417. $order_option_info = M('lionfish_comshop_order_option')->field('value')->where( array('order_id' => $order_id ,'order_goods_id' => $order_refund['order_goods_id'] ) )->select();
  418. foreach($order_option_info as $option)
  419. {
  420. $order_goods['option_str'][] = $option['value'];
  421. }
  422. if(empty($order_goods['option_str']))
  423. {
  424. //option_str
  425. $order_goods['option_str'] = '';
  426. }else{
  427. $order_goods['option_str'] = implode(',', $order_goods['option_str']);
  428. }
  429. $goods_images = $order_goods['goods_images'];
  430. if( !is_array($goods_images) )
  431. {
  432. $order_goods['image']= tomedia( $goods_images );
  433. $order_goods['goods_images']= tomedia( $goods_images );
  434. }else{
  435. $order_goods['image']= $order_goods['goods_images'];
  436. }
  437. $order_refund['ref_type'] = $order_refund['ref_type'] ==1 ? '退款': '退款退货';
  438. $refund_state = array(
  439. 0 => '申请中',
  440. 1 => '商家拒绝',
  441. 2 => '平台介入',
  442. 3 => '退款成功',
  443. 4 => '退款失败',
  444. 5 => '撤销申请',
  445. );
  446. $order_refund['state_str'] = $refund_state[$order_refund['state']];
  447. $order_refund['addtime'] = date('Y-m-d H:i:s', $order_refund['addtime']);
  448. $order_refund_image = M('lionfish_comshop_order_refund_image')->where( array('ref_id' => $order_refund['ref_id'] ) )->select();
  449. $refund_images = array();
  450. if(!empty($order_refund_image))
  451. {
  452. foreach($order_refund_image as $refund_image)
  453. {
  454. $refund_image['thumb_image'] = $refund_image['image'];
  455. $refund_images[] = $refund_image;
  456. }
  457. }
  458. if($order_refund['order_goods_id'] > 0)
  459. {
  460. $order_refund_historylist = M('lionfish_comshop_order_refund_history')->where( array('order_id' => $order_id,'order_goods_id' => $order_refund['order_goods_id'] ) )->order('addtime asc')->select();
  461. }else{
  462. $order_refund_historylist = M('lionfish_comshop_order_refund_history')->where( array('order_id' => $order_id) )->order('addtime asc')->select();
  463. }
  464. foreach($order_refund_historylist as $key => $val)
  465. {
  466. $val['addtime'] = date('Y-m-d H:i:s', $val['addtime']);
  467. $order_refund_historylist[$key] = $val;
  468. }
  469. echo json_encode( array('code' => 1,'order_refund' =>$order_refund, 'order_id' => $order_id ,'order_refund_historylist' => $order_refund_historylist, 'refund_images' => $refund_images,'order_goods' => $order_goods ,'order_info' => $order_info) );
  470. die();
  471. }
  472. }