AfterorderController.class.php 21 KB

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