Sellerrefund.php 11 KB

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