VirtualcardController.class.php 5.4 KB

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