暫無描述
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Level.php 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <?php
  2. /**
  3. * 易优CMS
  4. * ============================================================================
  5. * 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
  6. * 网站地址: http://www.eyoucms.com
  7. * ----------------------------------------------------------------------------
  8. * 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
  9. * ============================================================================
  10. * Author: 陈风任 <491085389@qq.com>
  11. * Date: 2019-6-21
  12. */
  13. namespace app\user\controller;
  14. use think\Db;
  15. use think\Config;
  16. use think\Page;
  17. class Level extends Base
  18. {
  19. // 初始化
  20. public function _initialize() {
  21. parent::_initialize();
  22. // 会员金额明细表
  23. $this->users_money_db = Db::name('users_money');
  24. // 会员等级管理表
  25. $this->users_type_manage_db = Db::name('users_type_manage');
  26. // 商城微信配置信息
  27. $this->pay_wechat_config = '';
  28. $where = [
  29. 'pay_id' => 1,
  30. 'pay_mark' => 'wechat'
  31. ];
  32. $PayInfo = Db::name('pay_api_config')->where($where)->getField('pay_info');
  33. if (!empty($PayInfo)) $this->pay_wechat_config = unserialize($PayInfo);
  34. // 商城支付宝配置信息
  35. $this->pay_alipay_config = '';
  36. $where = [
  37. 'pay_id' => 2,
  38. 'pay_mark' => 'alipay'
  39. ];
  40. $PayInfo = Db::name('pay_api_config')->where($where)->getField('pay_info');
  41. if (!empty($PayInfo)) $this->pay_alipay_config = unserialize($PayInfo);
  42. // 判断PHP版本信息
  43. if (version_compare(PHP_VERSION,'5.5.0','<')) {
  44. $this->php_version = 1; // PHP5.5.0以下版本,可使用旧版支付方式
  45. }else{
  46. $this->php_version = 0; // PHP5.5.0以上版本,可使用新版支付方式,兼容旧版支付方式
  47. }
  48. // 支付功能是否开启
  49. $redirect_url = '';
  50. $pay_open = getUsersConfigData('pay.pay_open');
  51. $web_users_switch = tpCache('web.web_users_switch');
  52. if (empty($pay_open)) {
  53. // 支付功能关闭,立马跳到会员中心
  54. $redirect_url = url('user/Users/index');
  55. $msg = '支付功能尚未开启!';
  56. } else if (empty($web_users_switch)) {
  57. // 前台会员中心已关闭,跳到首页
  58. $redirect_url = ROOT_DIR.'/';
  59. $msg = '会员中心尚未开启!';
  60. }
  61. if (!empty($redirect_url)) {
  62. Db::name('users_menu')->where([
  63. 'mca' => 'user/Shop/shop_centre',
  64. 'lang' => $this->home_lang,
  65. ])->update([
  66. 'status' => 0,
  67. 'update_time' => getTime(),
  68. ]);
  69. $this->error($msg, $redirect_url);
  70. }
  71. // --end
  72. }
  73. // 等级管理列表
  74. public function level_centre()
  75. {
  76. // 查询升级产品分类表
  77. $users_type = $this->users_type_manage_db->order('sort_order asc')->select();
  78. $this->assign('users_type', $users_type);
  79. // 会员期限
  80. $member_limit_arr = Config::get('global.admin_member_limit_arr');
  81. foreach($member_limit_arr as $key => $value) {
  82. // 下标从 1 开始,重组数组,$key初始为 1
  83. $member_limit_arr[$key] = $value['limit_name'];
  84. }
  85. $this->assign('member_limit_arr', $member_limit_arr);
  86. // 查询订单号
  87. $where_1 = [
  88. 'users_id' => $this->users_id,
  89. 'cause_type' => 0, // 消费类型
  90. 'status' => 1, // 未付款状态
  91. 'lang' => $this->home_lang,
  92. ];
  93. $OrderNumber = $this->users_money_db->where($where_1)->getField('order_number');
  94. $this->assign('OrderNumber', $OrderNumber);
  95. // 是否开启微信支付方式
  96. $is_open_wechat = 1;
  97. if (!empty($this->pay_wechat_config)) {
  98. $is_open_wechat = !empty($this->pay_wechat_config['is_open_wechat']) ? $this->pay_wechat_config['is_open_wechat'] : 0;
  99. } else {
  100. $where = [
  101. 'pay_id' => 1,
  102. 'pay_mark' => 'wechat'
  103. ];
  104. $PayInfo = Db::name('pay_api_config')->where($where)->getField('pay_info');
  105. if (!empty($PayInfo)) {
  106. $wechat = unserialize($PayInfo);
  107. $is_open_wechat = !empty($wechat['is_open_wechat']) ? $wechat['is_open_wechat'] : 0;
  108. }
  109. }
  110. $this->assign('is_open_wechat', $is_open_wechat);
  111. // 是否开启支付宝支付方式
  112. $is_open_alipay = 1;
  113. if (!empty($this->pay_alipay_config)) {
  114. $is_open_alipay = !empty($this->pay_alipay_config['is_open_alipay']) ? $this->pay_alipay_config['is_open_alipay'] : 0;
  115. } else {
  116. $where = [
  117. 'pay_id' => 2,
  118. 'pay_mark' => 'alipay'
  119. ];
  120. $PayInfo = Db::name('pay_api_config')->where($where)->getField('pay_info');
  121. if (!empty($PayInfo)) {
  122. $alipay = unserialize($PayInfo);
  123. $is_open_alipay = !empty($alipay['is_open_wechat']) ? $alipay['is_open_wechat'] : 0;
  124. }
  125. }
  126. $this->assign('is_open_alipay', $is_open_alipay);
  127. $result = [];
  128. // 菜单名称
  129. $result['title'] = Db::name('users_menu')->where([
  130. 'mca' => 'user/Level/level_centre',
  131. 'lang' => $this->home_lang,
  132. ])->getField('title');
  133. /*余额开关*/
  134. $pay_balance_open = getUsersConfigData('pay.pay_balance_open');
  135. if (!is_numeric($pay_balance_open) && empty($pay_balance_open)) {
  136. $pay_balance_open = 1;
  137. }
  138. $result['pay_balance_open'] = $pay_balance_open;
  139. /*end*/
  140. $eyou = array(
  141. 'field' => $result,
  142. );
  143. $this->assign('eyou', $eyou);
  144. // 跳转链接
  145. $referurl = input('param.referurl/s', null, 'htmlspecialchars_decode,urldecode');
  146. if (empty($referurl)) {
  147. if (isset($_SERVER['HTTP_REFERER']) && stristr($_SERVER['HTTP_REFERER'], $this->request->host())) {
  148. $referurl = $_SERVER['HTTP_REFERER'];
  149. } else {
  150. $referurl = url("user/Users/centre");
  151. }
  152. }
  153. cookie('referurl', $referurl);
  154. $this->assign('referurl', $referurl);
  155. return $this->fetch('users/level_centre');
  156. }
  157. }