RefundAction.class.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Fanwe 方维直播系统
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2011 http://www.fanwe.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: 云淡风轻(1956838968@qq.com)
  8. // +----------------------------------------------------------------------
  9. class RefundAction extends CommonAction
  10. {
  11. public function index()
  12. {
  13. //列表过滤器,生成查询Map对象
  14. $map = $this->_search();
  15. if (!isset($_REQUEST['order_status'])) {
  16. $_REQUEST['order_status'] = -1;
  17. }
  18. $order_sn = $param['order_sn'] = strim($_REQUEST['order_sn']);
  19. $refund_platform = $param['refund_platform'] = intval($_REQUEST['refund_platform']);
  20. $begin_time = $param['begin_time'] = strim($_REQUEST['begin_time']);
  21. $end_time = $param['end_time'] = strim($_REQUEST['end_time']);
  22. $this->assign('param', $param);
  23. //追加默认参数
  24. if ($this->get("default_map")) {
  25. $map = array_merge($map, $this->get("default_map"));
  26. }
  27. if ($order_sn != '') {
  28. $map['order_sn'] = $order_sn;
  29. }
  30. if (isset($_REQUEST['refund_platform']) && $refund_platform >= 0) {
  31. $map['refund_platform'] = $refund_platform;
  32. } else {
  33. $map['refund_platform'] = array('gt', 0);
  34. }
  35. $begin_time_span = to_timespan($begin_time);
  36. $end_time_span = to_timespan($end_time);
  37. if ($begin_time != '' && $end_time == '') {
  38. $map['_string'] = "create_time >=" . $begin_time_span . "";
  39. } elseif ($begin_time != '' && $end_time != '') {
  40. $map['_string'] = "create_time >=" . $begin_time_span . " and create_time <=" . $end_time_span . "";
  41. } elseif ($begin_time == '' && $end_time != '') {
  42. $map['_string'] = "create_time <=" . $end_time_span . "";
  43. }
  44. if (method_exists($this, '_filter')) {
  45. $this->_filter($map);
  46. }
  47. $model = D("goods_order");
  48. if (!empty($model)) {
  49. $this->_list($model, $map);
  50. }
  51. $list = $this->get("list");
  52. $result = array();
  53. $row = 0;
  54. foreach ($list as $k => $v) {
  55. $list[$k]['order_source'] = $v['order_source'] == 'local' ? "本地" : "远程";
  56. $list[$k]['order_type'] = $v['order_type'] == 'shop' ? "购物单" : "竞拍单";
  57. $list[$k]['no_refund_format'] = $v['no_refund'] ? "否" : "是";
  58. switch ($v['order_status']) {
  59. case '1':
  60. $list[$k]['order_status_format'] = "待付款";
  61. break;
  62. case '2':
  63. $list[$k]['order_status_format'] = "待发货";
  64. break;
  65. case '3':
  66. $list[$k]['order_status_format'] = "待收货";
  67. break;
  68. case '4':
  69. $list[$k]['order_status_format'] = "已收货";
  70. break;
  71. case '5':
  72. $list[$k]['order_status_format'] = "已退货";
  73. break;
  74. case '6':
  75. $list[$k]['order_status_format'] = "超时关闭";
  76. break;
  77. case '7':
  78. $list[$k]['order_status_format'] = "结单";
  79. break;
  80. }
  81. if($v['order_type'] == 'shop'){
  82. $list[$k]['podcast_name'] = emoji_decode(M("user")->where("id=" . $v['podcast_id'] . " ")->getField("nick_name"));
  83. }else{
  84. $list[$k]['podcast_name'] = emoji_decode(M("pai_goods")->where("id=" . $v['pai_id'] . " ")->getField("podcast_name"));
  85. }
  86. $list[$k]['pai_name'] = emoji_decode(M("user")->where("id=" . $v['viewer_id'] . " ")->getField("nick_name"));
  87. }
  88. $this->assign("list", $list);
  89. $this->display();
  90. return;
  91. }
  92. /**
  93. *
  94. * 订单详情
  95. */
  96. public function edit()
  97. {
  98. $this->assign("type_list", $this->type_list);
  99. $id = intval($_REQUEST['id']);
  100. if (!isset($id) || empty($id)) {
  101. $this->error('系统繁忙,参数不存在!');
  102. }
  103. $vo = M('goods_order')->where(array('id' => $id))->find();
  104. if ($vo['order_source'] == 'local') {
  105. $vo['order_source'] = '本地';
  106. } else {
  107. $vo['order_source'] = '远程';
  108. }
  109. if ($vo['order_type'] == 'shop') {
  110. $vo['order_type'] = '购物单';
  111. } else {
  112. $vo['order_type'] = '竞拍单';
  113. }
  114. $vo['no_refund_format'] = $vo['no_refund'] ? '否' : '是';
  115. if ($vo['order_status'] == 1) {
  116. $vo['order_status_format'] = "待付款";
  117. } elseif ($vo['order_status'] == 2) {
  118. $vo['order_status_format'] = "待发货";
  119. } elseif ($vo['order_status'] == 3) {
  120. $vo['order_status_format'] = "待收货";
  121. } elseif ($vo['order_status'] == 4) {
  122. $vo['order_status_format'] = "已收货";
  123. } elseif ($vo['order_status'] == 5) {
  124. $vo['order_status_format'] = "已退货";
  125. }
  126. if ($vo['refund_buyer_delivery'] == 0) {
  127. $vo['delivery_status_format'] = "无";
  128. } elseif ($vo['refund_buyer_delivery'] == 1) {
  129. $vo['delivery_status_format'] = "未发货";
  130. } else {
  131. $vo['delivery_status_format'] = "已发货";
  132. }
  133. if ($vo['refund_buyer_status'] == 0) {
  134. $vo['refund_buyer_status'] = "无";
  135. } elseif ($vo['refund_buyer_status'] == 1) {
  136. $vo['refund_buyer_status'] = "退款中";
  137. } elseif ($vo['refund_buyer_status'] == 2) {
  138. $vo['refund_buyer_status'] = "退货中";
  139. } elseif ($vo['refund_buyer_status'] == 3) {
  140. $vo['refund_buyer_status'] = "退款成功";
  141. } elseif ($vo['refund_buyer_status'] == 4) {
  142. $vo['refund_buyer_status'] = "主动撤销退款";
  143. } else {
  144. $vo['refund_buyer_status'] = "被动关闭";
  145. }
  146. if ($vo['refund_seller_status'] == 0) {
  147. $vo['refund_seller_status'] = "无";
  148. } else {
  149. $vo['refund_seller_status'] = "退款成功";
  150. }
  151. switch ($vo['refund_platform']) {
  152. case '0':
  153. $vo['refund_platform'] = "无";
  154. break;
  155. case '1':
  156. $vo['refund_platform'] = "申诉中(卖方)";
  157. break;
  158. case '2':
  159. $vo['refund_platform'] = "申诉完成(卖方)";
  160. break;
  161. case '3':
  162. $vo['refund_platform'] = "申诉中(买方)";
  163. break;
  164. case '4':
  165. $vo['refund_platform'] = "申诉完成(买方)";
  166. break;
  167. }
  168. if($vo['order_type'] == '购物单'){
  169. $vo['podcast_name'] = emoji_decode(M("user")->where("id=" . $vo['podcast_id'] . " ")->getField("nick_name"));
  170. $vo['goods_name'] = emoji_decode(M("goods")->where("id=" . $vo['goods_id'] . " ")->getField("name"));
  171. }else{
  172. $vo['podcast_name'] = emoji_decode(M("pai_goods")->where("id=" . $vo['pai_id'] . " ")->getField("podcast_name"));
  173. $vo['goods_name'] = emoji_decode(M("pai_goods")->where("id=" . $vo['pai_id'] . " ")->getField("name"));
  174. }
  175. $vo['pai_name'] = emoji_decode(M("user")->where("id=" . $vo['viewer_id'] . " ")->getField("nick_name"));
  176. if (!empty($vo['consignee_district'])) {
  177. $arr = json_decode(htmlspecialchars_decode($vo['consignee_district']), true);
  178. //按数组方式调用里面的数据
  179. $vo['consignee_district'] = $arr['province'].$arr['city'].$arr['area'];
  180. }
  181. $vo['pay_time'] = $vo['pay_time'] == '0000-00-00 00:00:00' ? '未付款' : $vo['pay_time'];
  182. switch ($vo['order_status']) {
  183. case '1':
  184. $vo['order_status_format'] = '待付款';
  185. break;
  186. case '2':
  187. $vo['order_status_format'] = '待发货';
  188. break;
  189. case '3':
  190. $vo['order_status_format'] = '待收货';
  191. break;
  192. case '4':
  193. $vo['order_status_format'] = '已收货';
  194. break;
  195. case '5':
  196. $vo['order_status_format'] = '退款成功';
  197. break;
  198. case '6':
  199. $vo['order_status_format'] = '未付款';
  200. break;
  201. case '7':
  202. $vo['order_status_format'] = '结单';
  203. break;
  204. }
  205. $this->assign('vo', $vo);
  206. $this->display();
  207. }
  208. public function update()
  209. {
  210. $id = intval($_REQUEST['id']);
  211. $reason = trim($_REQUEST['reason']);
  212. $this->assign("jumpUrl", u(MODULE_NAME . "/edit", array("id" => $id)));
  213. if (!$id) {
  214. $this->error("参数错误");
  215. }
  216. $mod = M('goods_order');
  217. $order = $mod->field('order_sn,refund_platform,pai_id')->find($id);
  218. $log_info = $order['order_sn'];
  219. $refund_platform = $order['refund_platform'];
  220. switch ($order['refund_platform']) {
  221. case '1':
  222. $refund_platform = 2;
  223. break;
  224. case '3':
  225. $refund_platform = 4;
  226. break;
  227. }
  228. $time = NOW_TIME+28800;
  229. $refund_over_time = date("Y-m-d H:i:s",$time);
  230. $res = $mod->save(array('id' => $id, 'refund_platform' => $refund_platform,'refund_over_time'=>$refund_over_time, 'refund_reason' => $reason, 'order_status' => 7));
  231. if(intval($order['pai_id']) !=0){
  232. $pai_goods = M('pai_goods')->save(array('id'=>$order['pai_id'],'order_status' => 7));
  233. $pai_join = M('pai_join')->where('order_id='.$id)->save(array('order_status' => 7));
  234. }
  235. if (false === $res) {
  236. //错误提示
  237. save_log($log_info . L("UPDATE_FAILED"), 0);
  238. $this->error(L("UPDATE_FAILED"), 0, $log_info . L("UPDATE_FAILED"));
  239. } else {
  240. //成功提示
  241. clear_auto_cache("banner_list");
  242. load_auto_cache("banner_list");
  243. save_log($log_info . L("UPDATE_SUCCESS"), 1);
  244. $this->success(L("UPDATE_SUCCESS"));
  245. }
  246. }
  247. }