Memberpointorder.php 6.0 KB

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