Sellerrefund.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <?php
  2. namespace app\home\controller;
  3. use think\facade\View;
  4. use think\facade\Lang;
  5. /**
  6. * ============================================================================
  7. *
  8. * ============================================================================
  9. * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
  10. * 网站地址: https://www.valimart.net/
  11. * ----------------------------------------------------------------------------
  12. *
  13. * ============================================================================
  14. * 控制器
  15. */
  16. class Sellerrefund extends BaseSeller {
  17. public function initialize() {
  18. parent::initialize();
  19. Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/sellerrefund.lang.php');
  20. $this->getRefundStateArray();
  21. }
  22. /**
  23. * 退款记录列表页
  24. *
  25. */
  26. public function index() {
  27. $refundreturn_model = model('refundreturn');
  28. $condition = array();
  29. $condition[] = array('store_id', '=', session('store_id'));
  30. $condition[] = array('refund_type', '=', '1'); //类型:1为退款,2为退货
  31. $keyword_type = array('order_sn', 'refund_sn', 'buyer_name');
  32. $key = input('key');
  33. $type = input('type');
  34. if (trim($key) != '' && in_array($type, $keyword_type)) {
  35. $condition[] = array($type, 'like', '%' . $key . '%');
  36. }
  37. $add_time_from = input('add_time_from');
  38. $add_time_to = input('add_time_to');
  39. if (trim($add_time_from) != '') {
  40. $add_time_from=strtotime($add_time_from);
  41. if ($add_time_from !== false) {
  42. $condition[] = array('add_time', '>=', $add_time_from);
  43. }
  44. }
  45. if (trim($add_time_to) != '') {
  46. $add_time_to=strtotime($add_time_to)+86399;
  47. if ($add_time_to !== false) {
  48. $condition[] = array('add_time', '<=', $add_time_to);
  49. }
  50. }
  51. $seller_state = intval(input('state'));
  52. if ($seller_state > 0) {
  53. $condition[] = array('seller_state', '=', $seller_state);
  54. }
  55. $order_lock = intval(input('lock'));
  56. if ($order_lock != 1) {
  57. $order_lock = 2;
  58. }
  59. $condition[] = array('order_lock', '=', $order_lock);
  60. $refund_list = $refundreturn_model->getRefundList($condition, 10);
  61. $page = $refundreturn_model->page_info->render();
  62. View::assign('refund_list', $refund_list);
  63. View::assign('show_page', $page);
  64. /* 设置卖家当前菜单 */
  65. $this->setSellerCurMenu('seller_refund');
  66. /* 设置卖家当前栏目 */
  67. $this->setSellerCurItem($order_lock);
  68. return View::fetch($this->template_dir . 'index');
  69. }
  70. /**
  71. * 退款审核页
  72. *
  73. */
  74. public function edit() {
  75. $refundreturn_model = model('refundreturn');
  76. $condition = array();
  77. $condition[]=array('store_id','=',session('store_id'));
  78. $condition[]=array('refund_id','=',intval(input('param.refund_id')));
  79. $condition[] =array('refund_type','=',1);
  80. $refund_list = $refundreturn_model->getRefundList($condition);
  81. $refund = $refund_list[0];
  82. if (!request()->isPost()) {
  83. View::assign('refund', $refund);
  84. $info['buyer'] = array();
  85. if (!empty($refund['pic_info'])) {
  86. $info = unserialize($refund['pic_info']);
  87. }
  88. View::assign('pic_list', $info['buyer']);
  89. $member_model = model('member');
  90. $member = $member_model->getMemberInfoByID($refund['buyer_id']);
  91. View::assign('member', $member);
  92. $condition = array();
  93. $condition[] = array('order_id','=',$refund['order_id']);
  94. $order = $refundreturn_model->getRightOrderList($condition, $refund['order_goods_id']);
  95. View::assign('order', $order);
  96. View::assign('store', $order['extend_store']);
  97. View::assign('order_common', $order['extend_order_common']);
  98. View::assign('goods_list', $order['goods_list']);
  99. /* 设置卖家当前菜单 */
  100. $this->setSellerCurMenu('seller_refund');
  101. /* 设置卖家当前栏目 */
  102. $this->setSellerCurItem('');
  103. return View::fetch($this->template_dir . 'edit');
  104. } else {
  105. if ($refund['seller_state'] != '1') {//检查状态,防止页面刷新不及时造成数据错误
  106. ds_json_encode(10001, lang('param_error'));
  107. }
  108. $order_id = $refund['order_id'];
  109. $refund_array = array();
  110. $refund_array['seller_time'] = TIMESTAMP;
  111. $refund_array['seller_state'] = input('post.seller_state'); //卖家处理状态:1为待审核,2为同意,3为不同意
  112. $refund_array['seller_message'] = input('post.seller_message');
  113. if ($refund_array['seller_state'] == '3') {
  114. $refund_array['refund_state'] = '3'; //状态:1为处理中,2为待管理员处理,3为已完成
  115. } else {
  116. $refund_array['seller_state'] = '2';
  117. $refund_array['refund_state'] = '2';
  118. }
  119. $state = $refundreturn_model->editRefundreturn($condition, $refund_array);
  120. if ($state) {
  121. if ($refund_array['seller_state'] == '3') {
  122. if($refund['order_lock'] == '2'){
  123. $refundreturn_model->editOrderUnlock($order_id); //订单解锁
  124. }
  125. //自提点订单解锁
  126. $chain_order_model=model('chain_order');
  127. $chain_order_model->editChainOrderUnlock($order_id);
  128. }
  129. $this->recordSellerlog(lang('refund_processing') . $refund['refund_sn']);
  130. // 发送买家消息
  131. $param = array();
  132. $param['code'] = 'refund_return_notice';
  133. $param['member_id'] = $refund['buyer_id'];
  134. $param['ali_param'] = array(
  135. 'refund_sn' => $refund['refund_sn']
  136. );
  137. $param['ten_param'] = array(
  138. $refund['refund_sn']
  139. );
  140. $param['param'] = array_merge($param['ali_param'], array(
  141. 'refund_url' => HOME_SITE_URL .'/Memberrefund/view?refund_id='.$refund['refund_id'],
  142. ));
  143. //微信模板消息
  144. $param['weixin_param'] = array(
  145. 'url' => config('ds_config.h5_site_url') . '/pages/member/' . ($refund['refund_type'] == 1 ? 'refund/RefundView' : 'return/ReturnView').'?refund_id=' . $refund['refund_id'],
  146. 'data' => array(
  147. "keyword1" => array(
  148. "value" => $refund['order_sn'],
  149. "color" => "#333"
  150. ),
  151. "keyword2" => array(
  152. "value" => $refund['refund_amount'],
  153. "color" => "#333"
  154. )
  155. ),
  156. );
  157. model('cron')->addCron(array('cron_exetime'=>TIMESTAMP,'cron_type'=>'sendMemberMsg','cron_value'=>serialize($param)));
  158. ds_json_encode(10000, lang('ds_common_save_succ'));
  159. } else {
  160. ds_json_encode(10001, lang('ds_common_save_fail'));
  161. }
  162. }
  163. }
  164. /**
  165. * 退款记录查看页
  166. *
  167. */
  168. public function view() {
  169. $refundreturn_model = model('refundreturn');
  170. $condition = array();
  171. $condition[] =array('refund_type','=',1);
  172. $condition[]=array('store_id','=',session('store_id'));
  173. $condition[]=array('refund_id','=',intval(input('param.refund_id')));
  174. $refund_list = $refundreturn_model->getRefundList($condition);
  175. $refund = $refund_list[0];
  176. View::assign('refund', $refund);
  177. $info['buyer'] = array();
  178. if (!empty($refund['pic_info'])) {
  179. $info = unserialize($refund['pic_info']);
  180. }
  181. View::assign('pic_list', $info['buyer']);
  182. $member_model = model('member');
  183. $member = $member_model->getMemberInfoByID($refund['buyer_id']);
  184. View::assign('member', $member);
  185. $condition = array();
  186. $condition[] = array('order_id','=',$refund['order_id']);
  187. $order = $refundreturn_model->getRightOrderList($condition, $refund['order_goods_id']);
  188. View::assign('order', $order);
  189. View::assign('store', $order['extend_store']);
  190. View::assign('order_common', $order['extend_order_common']);
  191. View::assign('goods_list', $order['goods_list']);
  192. /* 设置卖家当前菜单 */
  193. $this->setSellerCurMenu('seller_refund');
  194. /* 设置卖家当前栏目 */
  195. $this->setSellerCurItem('');
  196. return View::fetch($this->template_dir . 'view');
  197. }
  198. function getRefundStateArray($type = 'all') {
  199. $state_array = array(
  200. '1' => lang('refund_state_confirm'),
  201. '2' => lang('refund_state_yes'),
  202. '3' => lang('refund_state_no')
  203. ); //卖家处理状态:1为待审核,2为同意,3为不同意
  204. View::assign('state_array', $state_array);
  205. $admin_array = array(
  206. '1' => lang('in_processing'),
  207. '2' => lang('to_processed'),
  208. '3' => lang('has_been_completed'),
  209. '4' => lang('refund_state_no')
  210. ); //确认状态:1为买家或卖家处理中,2为待平台管理员处理,3为退款退货已完成
  211. View::assign('admin_array', $admin_array);
  212. $state_data = array(
  213. 'seller' => $state_array,
  214. 'admin' => $admin_array
  215. );
  216. if ($type == 'all') {
  217. return $state_data; //返回所有
  218. }
  219. return $state_data[$type];
  220. }
  221. /**
  222. * 用户中心右边,小导航
  223. *
  224. * @param string $menu_type 导航类型
  225. * @param string $menu_key 当前导航的menu_key
  226. * @return
  227. */
  228. function getSellerItemList() {
  229. $menu_array = array(
  230. array(
  231. 'name' => '2',
  232. 'text' => lang('before_refund'),
  233. 'url' => (string) url('Sellerrefund/index', ['lock' => 2])
  234. ),
  235. array(
  236. 'name' => '1',
  237. 'text' => lang('after_refund'),
  238. 'url' => (string) url('Sellerrefund/index', ['lock' => 1])
  239. ),
  240. );
  241. return $menu_array;
  242. }
  243. }