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