Pointorder.php 6.5 KB

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