Pointorder.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <?php
  2. namespace app\admin\controller;
  3. use think\facade\View;
  4. use think\facade\Lang;
  5. /**
  6. *
  7. *
  8. * ----------------------------------------------------------------------------
  9. *
  10. * 控制器
  11. */
  12. class Pointorder extends AdminControl
  13. {
  14. public function initialize()
  15. {
  16. parent::initialize(); // TODO: Change the autogenerated stub
  17. Lang::load(base_path() . 'admin/lang/' . config('lang.default_lang') . '/pointorder.lang.php');
  18. }
  19. /**
  20. * 积分兑换列表
  21. */
  22. public function pointorder_list()
  23. {
  24. $pointorder_model = model('pointorder');
  25. //获取兑换订单状态
  26. $pointorderstate_arr = $pointorder_model->getPointorderStateBySign();
  27. $where = array();
  28. //兑换单号
  29. $pordersn = trim(input('param.pordersn'));
  30. if ($pordersn) {
  31. $where[] = array('point_ordersn', 'like', "%{$pordersn}%");
  32. }
  33. //兑换会员名称
  34. $pbuyname = trim(input('param.pbuyname'));
  35. if (trim(input('param.pbuyname'))) {
  36. $where[] = array('point_buyername', 'like', "%{$pbuyname}%");
  37. }
  38. //订单状态
  39. if (trim(input('param.porderstate'))) {
  40. $where[] = array('point_orderstate', '=', $pointorderstate_arr[input('param.porderstate')][0]);
  41. }
  42. //查询兑换订单列表
  43. $order_list = $pointorder_model->getPointorderList($where, '*', 10, 0, 'point_orderid desc');
  44. //信息输出
  45. View::assign('pointorderstate_arr', $pointorderstate_arr);
  46. View::assign('order_list', $order_list);
  47. View::assign('show_page', $pointorder_model->page_info->render());
  48. $this->setAdminCurItem('pointorder_list');
  49. return View::fetch();
  50. }
  51. /**
  52. * 删除兑换订单信息
  53. */
  54. public function order_drop()
  55. {
  56. $data = model('pointorder')->delPointorderByOrderID(input('param.order_id'));
  57. if ($data['state']) {
  58. ds_json_encode(10000, lang('admin_pointorder_del_success'));
  59. } else {
  60. ds_json_encode(10001, $data['msg']);
  61. }
  62. }
  63. /**
  64. * 取消兑换
  65. */
  66. public function order_cancel()
  67. {
  68. $pointorder_model = model('pointorder');
  69. //取消订单
  70. $data = $pointorder_model->cancelPointorder(input('param.id'));
  71. if ($data['state']) {
  72. ds_json_encode(10000, lang('admin_pointorder_cancel_success'));
  73. } else {
  74. ds_json_encode(10001, $data['msg']);
  75. }
  76. }
  77. /**
  78. * 发货
  79. */
  80. public function order_ship()
  81. {
  82. $order_id = intval(input('param.id'));
  83. if ($order_id <= 0) {
  84. $this->error(lang('admin_pointorder_parameter_error'), (string)url('Pointorder/pointorder_list'));
  85. }
  86. $pointorder_model = model('pointorder');
  87. //获取订单状态
  88. $pointorderstate_arr = $pointorder_model->getPointorderStateBySign();
  89. //查询订单信息
  90. $where = array();
  91. $where[] = array('point_orderid', '=', $order_id);
  92. $where[] = array('point_orderstate', 'in', array($pointorderstate_arr['waitship'][0], $pointorderstate_arr['waitreceiving'][0])); //待发货和已经发货状态
  93. $order_info = $pointorder_model->getPointorderInfo($where);
  94. if (!$order_info) {
  95. $this->error(lang('admin_pointorderd_record_error'), (string)url('Pointorder/pointorder_list'));
  96. }
  97. if (request()->isPost()) {
  98. $data = [
  99. 'shippingcode' => input('post.shippingcode')
  100. ];
  101. $point_validate = ds_validate('point');
  102. if (!$point_validate->scene('order_ship')->check($data)) {
  103. $this->error($point_validate->getError());
  104. }
  105. //发货
  106. $data = $pointorder_model->shippingPointorder($order_id, input('post.'), $order_info);
  107. if ($data['state']) {
  108. dsLayerOpenSuccess(lang('ds_common_op_succ'));
  109. } else {
  110. $this->error($data['msg'], (string)url('Pointorder/pointorder_list'));
  111. }
  112. } else {
  113. $express_list = model('express')->getExpressList();
  114. View::assign('express_list', $express_list);
  115. View::assign('order_info', $order_info);
  116. return View::fetch();
  117. }
  118. }
  119. /**
  120. * 兑换信息详细
  121. */
  122. public function order_info()
  123. {
  124. $order_id = intval(input('param.order_id'));
  125. if ($order_id <= 0) {
  126. $this->error(lang('admin_pointorder_parameter_error'));
  127. }
  128. //查询订单信息
  129. $pointorder_model = model('pointorder');
  130. $order_info = $pointorder_model->getPointorderInfo(array('point_orderid' => $order_id));
  131. if (!$order_info) {
  132. $this->error(lang('admin_pointorderd_record_error'));
  133. }
  134. $orderstate_arr = $pointorder_model->getPointorderState($order_info['point_orderstate']);
  135. $order_info['point_orderstatetext'] = $orderstate_arr[1];
  136. //查询兑换订单收货人地址
  137. $orderaddress_info = $pointorder_model->getPointorderAddressInfo(array('pointoa_orderid' => $order_id));
  138. View::assign('orderaddress_info', $orderaddress_info);
  139. //兑换商品信息
  140. $prod_list = $pointorder_model->getPointordergoodsList(array('pointog_orderid' => $order_id));
  141. View::assign('prod_list', $prod_list);
  142. //物流公司信息
  143. if ($order_info['point_shipping_ecode'] != '') {
  144. $data = model('express')->getExpressInfoByECode($order_info['point_shipping_ecode']);
  145. if ($data['state']) {
  146. $express_info = $data['data']['express_info'];
  147. }
  148. View::assign('express_info', $express_info);
  149. }
  150. View::assign('order_info', $order_info);
  151. return View::fetch();
  152. }
  153. protected function getAdminItemList()
  154. {
  155. $menu_array = array(
  156. array(
  157. 'name' => 'pointorder_list', 'text' => lang('admin_pointorder_list_title'), 'url' => (string)url('Pointorder/pointorder_list')
  158. ),
  159. );
  160. return $menu_array;
  161. }
  162. }