refund.php 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <?php
  2. /**
  3. * 退款管理
  4. *
  5. *
  6. *
  7. ***/
  8. defined('InShopNC') or exit('Access Invalid!');
  9. class refundControl extends SystemControl{
  10. public function __construct(){
  11. parent::__construct();
  12. $model_refund = Model('refund_return');
  13. $model_refund->getRefundStateArray();
  14. }
  15. /**
  16. * 待处理列表
  17. */
  18. public function refund_manageOp() {
  19. $model_refund = Model('refund_return');
  20. $condition = array();
  21. $condition['refund_state'] = '2';//状态:1为处理中,2为待管理员处理,3为已完成
  22. $keyword_type = array('order_sn','refund_sn','store_name','buyer_name','goods_name');
  23. if (trim($_GET['key']) != '' && in_array($_GET['type'],$keyword_type)) {
  24. $type = $_GET['type'];
  25. $condition[$type] = array('like','%'.$_GET['key'].'%');
  26. }
  27. if (trim($_GET['add_time_from']) != '' || trim($_GET['add_time_to']) != '') {
  28. $add_time_from = strtotime(trim($_GET['add_time_from']));
  29. $add_time_to = strtotime(trim($_GET['add_time_to']));
  30. if ($add_time_from !== false || $add_time_to !== false) {
  31. $condition['add_time'] = array('time',array($add_time_from,$add_time_to));
  32. }
  33. }
  34. $refund_list = $model_refund->getRefundList($condition,10);
  35. Tpl::output('refund_list',$refund_list);
  36. Tpl::output('show_page',$model_refund->showpage());
  37. Tpl::showpage('refund_manage.list');
  38. }
  39. /**
  40. * 所有记录
  41. */
  42. public function refund_allOp() {
  43. $model_refund = Model('refund_return');
  44. $condition = array();
  45. $keyword_type = array('order_sn','refund_sn','store_name','buyer_name','goods_name');
  46. if (trim($_GET['key']) != '' && in_array($_GET['type'],$keyword_type)) {
  47. $type = $_GET['type'];
  48. $condition[$type] = array('like','%'.$_GET['key'].'%');
  49. }
  50. if (trim($_GET['add_time_from']) != '' || trim($_GET['add_time_to']) != '') {
  51. $add_time_from = strtotime(trim($_GET['add_time_from']));
  52. $add_time_to = strtotime(trim($_GET['add_time_to']));
  53. if ($add_time_from !== false || $add_time_to !== false) {
  54. $condition['add_time'] = array('time',array($add_time_from,$add_time_to));
  55. }
  56. }
  57. $refund_list = $model_refund->getRefundList($condition,10);
  58. Tpl::output('refund_list',$refund_list);
  59. Tpl::output('show_page',$model_refund->showpage());
  60. Tpl::showpage('refund_all.list');
  61. }
  62. /**
  63. * 退款处理页
  64. *
  65. */
  66. public function editOp() {
  67. $model_refund = Model('refund_return');
  68. $condition = array();
  69. $condition['refund_id'] = intval($_GET['refund_id']);
  70. $refund_list = $model_refund->getRefundList($condition);
  71. $refund = $refund_list[0];
  72. if (chksubmit()) {
  73. if ($refund['refund_state'] != '2') {//检查状态,防止页面刷新不及时造成数据错误
  74. showMessage(Language::get('nc_common_save_fail'));
  75. }
  76. $order_id = $refund['order_id'];
  77. $refund_array = array();
  78. $refund_array['admin_time'] = time();
  79. $refund_array['refund_state'] = '3';//状态:1为处理中,2为待管理员处理,3为已完成
  80. $refund_array['admin_message'] = $_POST['admin_message'];
  81. $state = $model_refund->editOrderRefund($refund);
  82. if ($state) {
  83. $model_refund->editRefundReturn($condition, $refund_array);
  84. // 发送买家消息
  85. $param = array();
  86. $param['code'] = 'refund_return_notice';
  87. $param['member_id'] = $refund['buyer_id'];
  88. $param['param'] = array(
  89. 'refund_url' => urlShop('member_refund', 'view', array('refund_id' => $refund['refund_id'])),
  90. 'refund_sn' => $refund['refund_sn']
  91. );
  92. QueueClient::push('sendMemberMsg', $param);
  93. $this->log('退款确认,退款编号'.$refund['refund_sn']);
  94. showMessage(Language::get('nc_common_save_succ'),'index.php?act=refund&op=refund_manage');
  95. } else {
  96. showMessage(Language::get('nc_common_save_fail'));
  97. }
  98. }
  99. Tpl::output('refund',$refund);
  100. $info['buyer'] = array();
  101. if(!empty($refund['pic_info'])) {
  102. $info = unserialize($refund['pic_info']);
  103. }
  104. Tpl::output('pic_list',$info['buyer']);
  105. Tpl::showpage('refund.edit');
  106. }
  107. /**
  108. * 退款记录查看页
  109. *
  110. */
  111. public function viewOp() {
  112. $model_refund = Model('refund_return');
  113. $condition = array();
  114. $condition['refund_id'] = intval($_GET['refund_id']);
  115. $refund_list = $model_refund->getRefundList($condition);
  116. $refund = $refund_list[0];
  117. Tpl::output('refund',$refund);
  118. $info['buyer'] = array();
  119. if(!empty($refund['pic_info'])) {
  120. $info = unserialize($refund['pic_info']);
  121. }
  122. Tpl::output('pic_list',$info['buyer']);
  123. Tpl::showpage('refund.view');
  124. }
  125. /**
  126. * 退款退货原因
  127. */
  128. public function reasonOp() {
  129. $model_refund = Model('refund_return');
  130. $condition = array();
  131. $reason_list = $model_refund->getReasonList($condition,10);
  132. Tpl::output('reason_list',$reason_list);
  133. Tpl::output('show_page',$model_refund->showpage());
  134. Tpl::showpage('refund_reason.list');
  135. }
  136. /**
  137. * 新增退款退货原因
  138. *
  139. */
  140. public function add_reasonOp() {
  141. $model_refund = Model('refund_return');
  142. if (chksubmit()) {
  143. $reason_array = array();
  144. $reason_array['reason_info'] = $_POST['reason_info'];
  145. $reason_array['sort'] = intval($_POST['sort']);
  146. $reason_array['update_time'] = time();
  147. $state = $model_refund->addReason($reason_array);
  148. if ($state) {
  149. $this->log('新增退款退货原因,编号'.$state);
  150. showMessage(Language::get('nc_common_save_succ'),'index.php?act=refund&op=reason');
  151. } else {
  152. showMessage(Language::get('nc_common_save_fail'));
  153. }
  154. }
  155. Tpl::showpage('refund_reason.add');
  156. }
  157. /**
  158. * 编辑退款退货原因
  159. *
  160. */
  161. public function edit_reasonOp() {
  162. $model_refund = Model('refund_return');
  163. $condition = array();
  164. $condition['reason_id'] = intval($_GET['reason_id']);
  165. $reason_list = $model_refund->getReasonList($condition);
  166. $reason = $reason_list[$condition['reason_id']];
  167. if (chksubmit()) {
  168. $reason_array = array();
  169. $reason_array['reason_info'] = $_POST['reason_info'];
  170. $reason_array['sort'] = intval($_POST['sort']);
  171. $reason_array['update_time'] = time();
  172. $state = $model_refund->editReason($condition, $reason_array);
  173. if ($state) {
  174. $this->log('编辑退款退货原因,编号'.$condition['reason_id']);
  175. showMessage(Language::get('nc_common_save_succ'),'index.php?act=refund&op=reason');
  176. } else {
  177. showMessage(Language::get('nc_common_save_fail'));
  178. }
  179. }
  180. Tpl::output('reason',$reason);
  181. Tpl::showpage('refund_reason.edit');
  182. }
  183. /**
  184. * 删除退款退货原因
  185. *
  186. */
  187. public function del_reasonOp() {
  188. $model_refund = Model('refund_return');
  189. $condition = array();
  190. $condition['reason_id'] = intval($_GET['reason_id']);
  191. $state = $model_refund->delReason($condition);
  192. if ($state) {
  193. $this->log('删除退款退货原因,编号'.$condition['reason_id']);
  194. showMessage(Language::get('nc_common_del_succ'),'index.php?act=refund&op=reason');
  195. } else {
  196. showMessage(Language::get('nc_common_del_fail'));
  197. }
  198. }
  199. }