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