Memberpointorder.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <?php
  2. namespace app\home\controller;
  3. use think\facade\View;
  4. use think\facade\Lang;
  5. /**
  6. * ============================================================================
  7. *
  8. * ============================================================================
  9. *
  10. * ----------------------------------------------------------------------------
  11. *
  12. * ============================================================================
  13. * 控制器
  14. */
  15. class Memberpointorder extends BaseMember
  16. {
  17. public function initialize()
  18. {
  19. parent::initialize(); // TODO: Change the autogenerated stub
  20. Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/memberpoints.lang.php');
  21. }
  22. public function index()
  23. {
  24. //兑换信息列表
  25. $condition = array();
  26. $condition[] = array('point_buyerid', '=', session('member_id'));
  27. $pointorder_model = model('pointorder');
  28. $order_list = $pointorder_model->getPointorderList($condition, '*', 10, 0, 'point_orderid desc');
  29. $order_idarr = array();
  30. $order_listnew = array();
  31. if (is_array($order_list) && count($order_list) > 0) {
  32. foreach ($order_list as $k => $v) {
  33. $order_listnew[$v['point_orderid']] = $v;
  34. $order_idarr[] = $v['point_orderid'];
  35. }
  36. }
  37. //查询兑换商品
  38. if (is_array($order_idarr) && count($order_idarr) > 0) {
  39. $prod_list = $pointorder_model->getPointordergoodsList(array(array('pointog_orderid', 'in', $order_idarr)));
  40. if (is_array($prod_list) && count($prod_list) > 0) {
  41. foreach ($prod_list as $v) {
  42. if (isset($order_listnew[$v['pointog_orderid']])) {
  43. $order_listnew[$v['pointog_orderid']]['prodlist'][] = $v;
  44. }
  45. }
  46. }
  47. }
  48. //信息输出
  49. View::assign('order_list', $order_listnew);
  50. View::assign('show_page', $pointorder_model->page_info->render());
  51. /* 设置买家当前菜单 */
  52. $this->setMemberCurMenu('member_pointorder');
  53. /* 设置买家当前栏目 */
  54. $this->setMemberCurItem('orderlist');
  55. return View::fetch($this->template_dir . 'index');
  56. }
  57. /**
  58. * 取消兑换
  59. */
  60. public function cancel_order()
  61. {
  62. $pointorder_model = model('pointorder');
  63. //取消订单
  64. $data = $pointorder_model->cancelPointorder(input('param.order_id'), session('member_id'));
  65. if ($data['state']) {
  66. ds_json_encode(10000, lang('member_pointorder_cancel_success'));
  67. } else {
  68. ds_json_encode(10001, $data['msg']);
  69. }
  70. }
  71. /**
  72. * 确认收货
  73. */
  74. public function receiving_order()
  75. {
  76. $data = model('pointorder')->receivingPointorder(input('param.order_id'));
  77. if ($data['state']) {
  78. ds_json_encode(10000, lang('member_pointorder_confirmreceiving_success'));
  79. } else {
  80. ds_json_encode(10001, $data['msg']);
  81. }
  82. }
  83. /**
  84. * 兑换信息详细
  85. */
  86. public function order_info()
  87. {
  88. $order_id = intval(input('order_id'));
  89. if ($order_id <= 0) {
  90. $this->error(lang('member_pointorder_parameter_error'));
  91. }
  92. $pointorder_model = model('pointorder');
  93. //查询兑换订单信息
  94. $where = array();
  95. $where[] = array('point_orderid', '=', $order_id);
  96. $where[] = array('point_buyerid', '=', session('member_id'));
  97. $order_info = $pointorder_model->getPointorderInfo($where);
  98. if (!$order_info) {
  99. $this->error(lang('member_pointorder_record_error'));
  100. }
  101. //获取订单状态
  102. $pointorderstate_arr = $pointorder_model->getPointorderStateBySign();
  103. View::assign('pointorderstate_arr', $pointorderstate_arr);
  104. //查询兑换订单收货人地址
  105. $orderaddress_info = $pointorder_model->getPointorderAddressInfo(array('pointoa_orderid' => $order_id));
  106. View::assign('orderaddress_info', $orderaddress_info);
  107. //兑换商品信息
  108. $prod_list = $pointorder_model->getPointordergoodsList(array('pointog_orderid' => $order_id));
  109. View::assign('prod_list', $prod_list);
  110. //物流公司信息
  111. if ($order_info['point_shipping_ecode'] != '') {
  112. $data = model('express')->getExpressInfoByECode($order_info['point_shipping_ecode']);
  113. if ($data['state']) {
  114. $express_info = $data['data']['express_info'];
  115. }
  116. View::assign('express_info', $express_info);
  117. }
  118. View::assign('order_info', $order_info);
  119. View::assign('left_show', 'order_view');
  120. /* 设置买家当前菜单 */
  121. $this->setMemberCurMenu('member_pointorder');
  122. /* 设置买家当前栏目 */
  123. $this->setMemberCurItem('order_info');
  124. return View::fetch($this->template_dir . 'member_pointorder_info');
  125. }
  126. /**
  127. * 用户中心右边,小导航
  128. *
  129. * @param string $menu_type 导航类型
  130. * @param string $menu_key 当前导航的menu_key
  131. * @return
  132. */
  133. public function getMemberItemList()
  134. {
  135. $menu_array = array(
  136. array(
  137. 'name' => 'orderlist',
  138. 'text' => lang('member_pointorder_list_title'),
  139. 'url' => (string)url('Memberpointorder/index')
  140. )
  141. );
  142. if (request()->action() == 'order_info') {
  143. $menu_array = array(
  144. array(
  145. 'name' => 'orderinfo',
  146. 'text' => lang('ds_member_path_pointorder_info'),
  147. 'url' => 'javascript:void(0)'
  148. )
  149. );
  150. }
  151. return $menu_array;
  152. }
  153. }