VirtualcardController.class.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <?php
  2. /**
  3. * lionfish 商城系统
  4. *
  5. * ==========================================================================
  6. * @link http://www.liofis.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license http://www.liofis.com/license.html License
  9. * ==========================================================================
  10. *
  11. * @author fish
  12. *
  13. */
  14. namespace Home\Controller;
  15. class VirtualcardController extends CommonController {
  16. protected function _initialize()
  17. {
  18. parent::_initialize();
  19. }
  20. public function index(){
  21. $virtualcard_index_info = [];
  22. $virtcard_share_title = D('Home/Front')->get_config_by_name('virtcard_share_title');//分销标题
  23. $virtualcard_index_info['virtcard_share_title'] = !isset($virtcard_share_title) ? '' : $virtcard_share_title;
  24. $virtcard_share_img = D('Home/Front')->get_config_by_name('virtcard_share_img');//分享图片
  25. $virtualcard_index_info['virtcard_share_img'] = empty($virtcard_share_img) ? '' : tomedia($virtcard_share_img );
  26. $virtcard_top_banner = D('Home/Front')->get_config_by_name('virtcard_top_banner');//礼品卡顶部图片
  27. $virtualcard_index_info['virtcard_top_banner'] = empty($virtcard_top_banner) ? '' : tomedia($virtcard_top_banner );
  28. $virtualcard_layout = D('Home/Front')->get_config_by_name('virtualcard_layout');//布局方式 0左右布局,1横向布局
  29. $virtualcard_index_info['virtualcard_layout'] = !isset($virtualcard_layout) ? 0 : $virtualcard_layout;
  30. $virtcard_publish = D('Home/Front')->get_config_by_name('virtcard_publish');//规则说明
  31. $virtualcard_index_info['virtcard_publish'] = htmlspecialchars_decode( $virtcard_publish );
  32. $virtualcard_name_modify = D('Home/Front')->get_config_by_name('virtualcard_name_modify');
  33. $virtualcard_index_info['virtualcard_name_modify'] = empty($virtualcard_name_modify) ? '礼品卡中心' : $virtualcard_name_modify;
  34. echo json_encode( ['code' => 0, 'data' => $virtualcard_index_info ] );
  35. die();
  36. }
  37. /**
  38. * @author yj
  39. * @desc 获取商品列表有分页
  40. */
  41. public function load_goods_list()
  42. {
  43. $result = D('Seller/VirtualCard')->getIndexVirturalCardGoods(0);
  44. echo json_encode( $result );
  45. die();
  46. }
  47. /**
  48. * @author yj
  49. * @desc 获取已兑换列表
  50. */
  51. public function loadUseRecord()
  52. {
  53. $gpc = I('request.');
  54. $token = $gpc['token'];
  55. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  56. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  57. {
  58. //未登录
  59. echo json_encode( array('code' => 1) );
  60. die();
  61. }
  62. $member_id = $weprogram_token['member_id'];
  63. $result = D('Seller/VirtualCard')->getUserUserecord( $member_id );
  64. echo json_encode( $result );
  65. die();
  66. }
  67. public function subOfflineCode()
  68. {
  69. $gpc = I('request.');
  70. $token = $gpc['token'];
  71. $code_sn = $gpc['code_sn'];
  72. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  73. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  74. {
  75. //未登录
  76. echo json_encode( array('code' => 1) );
  77. die();
  78. }
  79. $member_id = $weprogram_token['member_id'];
  80. if($member_id)
  81. {
  82. //检测是否被锁定
  83. $check_lock_res = D('Seller/VirtualCard')->checkUserIsLock( $member_id );
  84. if( $check_lock_res['code'] == 0 )
  85. {
  86. echo json_encode( ['code' => 2, 'message' => '输入次数过多,请在'.$check_lock_res['min'].'分钟后重新尝试' ] );
  87. die();
  88. }
  89. //检验sn
  90. $result = D('Seller/VirtualCard')->subOfflineCodeSn( $code_sn ,$member_id );
  91. if( $result['code'] != 0 )
  92. {
  93. //开启巡查禁用模式
  94. D('Seller/Virtualcard')->insErrorSubCodeSnUserId( $member_id );
  95. D('Seller/Virtualcard')->checkIsNeedLockUser( $member_id );
  96. }
  97. echo json_encode( $result );
  98. die();
  99. }
  100. }
  101. /**
  102. * @author yj
  103. * @desc 提交兑换码兑换余额
  104. */
  105. public function subCodeSn()
  106. {
  107. $gpc = I('request.');
  108. $token = $gpc['token'];
  109. $code_sn = $gpc['code_sn'];
  110. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  111. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  112. {
  113. //未登录
  114. echo json_encode( array('code' => 1) );
  115. die();
  116. }
  117. $member_id = $weprogram_token['member_id'];
  118. if($member_id)
  119. {
  120. //检测是否被锁定
  121. $check_lock_res = D('Seller/VirtualCard')->checkUserIsLock( $member_id );
  122. if( $check_lock_res['code'] == 0 )
  123. {
  124. echo json_encode( ['code' => 2, 'message' => '输入次数过多,请在'.$check_lock_res['min'].'分钟后重新尝试' ] );
  125. die();
  126. }
  127. //检验sn
  128. $result = D('Seller/VirtualCard')->subCodeSn( $code_sn ,$member_id );
  129. if( $result['code'] != 0 )
  130. {
  131. //开启巡查禁用模式
  132. D('Seller/Virtualcard')->insErrorSubCodeSnUserId( $member_id );
  133. D('Seller/Virtualcard')->checkIsNeedLockUser( $member_id );
  134. }
  135. echo json_encode( $result );
  136. die();
  137. }
  138. }
  139. }