InvitegiftController.class.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  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 cy(694418550@qq.com) 2021-03-09
  12. *
  13. */
  14. namespace Seller\Controller;
  15. class InvitegiftController extends CommonController{
  16. protected function _initialize(){
  17. parent::_initialize();
  18. }
  19. /**
  20. * @author cy 2021-03-09
  21. * @desc 邀新有礼配置
  22. */
  23. public function config()
  24. {
  25. $_GPC = I('request.');
  26. if (IS_POST) {
  27. //邀新有礼开启/关闭状态
  28. $is_invite_open_status = isset($_GPC['is_invite_open_status']) ? $_GPC['is_invite_open_status'] : 0;
  29. //邀请者奖励类型
  30. $inviter_reward_type = isset($_GPC['inviter_reward_type']) ? $_GPC['inviter_reward_type'] : 0;
  31. $inviter_reward_couponid = isset($_GPC['inviter_reward_couponid']) ? $_GPC['inviter_reward_couponid'] : 0;
  32. $inviter_reward_point = isset($_GPC['inviter_reward_point']) ? $_GPC['inviter_reward_point'] : 0;
  33. //被邀请者奖励类型
  34. $invitees_reward_type = isset($_GPC['invitees_reward_type']) ? $_GPC['invitees_reward_type'] : 0;
  35. $invitees_register_reward_type = isset($_GPC['invitees_register_reward_type']) ? $_GPC['invitees_register_reward_type'] : 0;
  36. $invitees_register_reward_couponid = isset($_GPC['invitees_register_reward_couponid']) ? $_GPC['invitees_register_reward_couponid'] : 0;
  37. $invitees_register_reward_point = isset($_GPC['invitees_register_reward_point']) ? $_GPC['invitees_register_reward_point'] : 0;
  38. $invitees_order_reward_type = isset($_GPC['invitees_order_reward_type']) ? $_GPC['invitees_order_reward_type'] : 0;
  39. $invitees_order_reward_couponid = isset($_GPC['invitees_order_reward_couponid']) ? $_GPC['invitees_order_reward_couponid'] : 0;
  40. $invitees_order_reward_point = isset($_GPC['invitees_order_reward_point']) ? $_GPC['invitees_order_reward_point'] : 0;
  41. //活动奖励类型
  42. $invite_activity_reward_type = isset($_GPC['invite_activity_reward_type']) ? $_GPC['invite_activity_reward_type'] : 0;
  43. //邀请人数限制
  44. $is_open_invitation_limit = isset($_GPC['is_open_invitation_limit']) ? $_GPC['is_open_invitation_limit'] : 0;
  45. //邀请人数限制
  46. $invitation_limit_person = isset($_GPC['invitation_limit_person']) ? $_GPC['invitation_limit_person'] : 0;
  47. //邀新有礼活动顶部背景图
  48. $invite_activity_topback_img = isset($_GPC['invite_activity_topback_img']) ? $_GPC['invite_activity_topback_img'] : '';
  49. //活动打开页面顶部背景图
  50. $invite_activity_open_topback_img = isset($_GPC['invite_activity_open_topback_img']) ? $_GPC['invite_activity_open_topback_img'] : '';
  51. //活动积分/优惠卷使用规则
  52. $invite_activity_use_rules = isset($_GPC['invite_activity_use_rules']) ? $_GPC['invite_activity_use_rules'] : '';
  53. //分享标题
  54. $invite_share_title = isset($_GPC['invite_share_title']) ? $_GPC['invite_share_title'] : '';
  55. //分享图片
  56. $invite_share_img = isset($_GPC['invite_share_img']) ? $_GPC['invite_share_img'] : '';
  57. //邀请下单分享标题
  58. $invite_order_share_title = isset($_GPC['invite_order_share_title']) ? $_GPC['invite_order_share_title'] : '';
  59. //邀请下单分享图片
  60. $invite_order_share_img = isset($_GPC['invite_order_share_img']) ? $_GPC['invite_order_share_img'] : '';
  61. //活动规则
  62. $invite_activity_rules = isset($_GPC['invite_activity_rules']) ? $_GPC['invite_activity_rules'] : '';
  63. if($is_invite_open_status == 1){
  64. if($inviter_reward_type == 1){
  65. if(empty($inviter_reward_couponid)){
  66. show_json(0, array('message' => '请选择邀请者奖励赠送的优惠券'));
  67. }
  68. }else if($inviter_reward_type == 2){
  69. if(empty($inviter_reward_point) || !is_numeric($inviter_reward_point) || $inviter_reward_point < 0){
  70. show_json(0, array('message' => '邀请者奖励赠送的积分必填且为大于0'));
  71. }
  72. }else if($inviter_reward_type == 0){
  73. if(empty($inviter_reward_couponid)){
  74. show_json(0, array('message' => '请选择邀请者奖励赠送的优惠券'));
  75. }
  76. if(empty($inviter_reward_point) || !is_numeric($inviter_reward_point) || $inviter_reward_point < 0){
  77. show_json(0, array('message' => '邀请者奖励赠送的积分必填且为大于0'));
  78. }
  79. }
  80. if($invitees_reward_type == 1){//新人注册(授权登陆)
  81. if($invitees_register_reward_type == 1){
  82. if(empty($invitees_register_reward_couponid)){
  83. show_json(0, array('message' => '请选择被邀请者奖励新人注册赠送的优惠券'));
  84. }
  85. }else if($invitees_register_reward_type == 2){
  86. if(empty($invitees_register_reward_point) || !is_numeric($invitees_register_reward_point) || $invitees_register_reward_point < 0){
  87. show_json(0, array('message' => '被邀请者奖励新人注册赠送的积分必填且为大于0'));
  88. }
  89. }else{
  90. if(empty($invitees_register_reward_couponid)){
  91. show_json(0, array('message' => '请选择被邀请者奖励新人注册赠送的优惠券'));
  92. }
  93. if(empty($invitees_register_reward_point) || !is_numeric($invitees_register_reward_point) || $invitees_register_reward_point < 0){
  94. show_json(0, array('message' => '被邀请者奖励新人注册赠送的积分必填且为大于0'));
  95. }
  96. }
  97. }else if($invitees_reward_type == 2){//下单完成
  98. if($invitees_order_reward_type == 1){
  99. if(empty($invitees_order_reward_couponid)){
  100. show_json(0, array('message' => '请选择被邀请者奖励下单完成赠送的优惠券'));
  101. }
  102. }else if($invitees_order_reward_type == 2){
  103. if(empty($invitees_order_reward_point) || !is_numeric($invitees_order_reward_point) || $invitees_order_reward_point < 0){
  104. show_json(0, array('message' => '被邀请者奖励下单完成赠送的积分必填且为大于0'));
  105. }
  106. }else{
  107. if(empty($invitees_order_reward_couponid)){
  108. show_json(0, array('message' => '请选择被邀请者奖励下单完成赠送的优惠券'));
  109. }
  110. if(empty($invitees_order_reward_point) || !is_numeric($invitees_order_reward_point) || $invitees_order_reward_point < 0){
  111. show_json(0, array('message' => '被邀请者奖励下单完成赠送的积分必填且为大于0'));
  112. }
  113. }
  114. }else if($invitees_reward_type == 0){//新人注册和下单完成
  115. if($invitees_register_reward_type == 1){
  116. if(empty($invitees_register_reward_couponid)){
  117. show_json(0, array('message' => '请选择被邀请者奖励新人注册赠送的优惠券'));
  118. }
  119. }else if($invitees_register_reward_type == 2){
  120. if(empty($invitees_register_reward_point) || !is_numeric($invitees_register_reward_point) || $invitees_register_reward_point < 0){
  121. show_json(0, array('message' => '被邀请者奖励新人注册赠送的积分必填且为大于0'));
  122. }
  123. }else{
  124. if(empty($invitees_register_reward_couponid)){
  125. show_json(0, array('message' => '请选择被邀请者奖励新人注册赠送的优惠券'));
  126. }
  127. if(empty($invitees_register_reward_point) || !is_numeric($invitees_register_reward_point) || $invitees_register_reward_point < 0){
  128. show_json(0, array('message' => '被邀请者奖励新人注册赠送的积分必填且为大于0'));
  129. }
  130. }
  131. if($invitees_order_reward_type == 1){
  132. if(empty($invitees_order_reward_couponid)){
  133. show_json(0, array('message' => '请选择被邀请者奖励下单完成赠送的优惠券'));
  134. }
  135. }else if($invitees_order_reward_type == 2){
  136. if(empty($invitees_order_reward_point) || !is_numeric($invitees_order_reward_point) || $invitees_order_reward_point < 0){
  137. show_json(0, array('message' => '被邀请者奖励下单完成赠送的积分必填且为大于0'));
  138. }
  139. }else{
  140. if(empty($invitees_order_reward_couponid)){
  141. show_json(0, array('message' => '请选择被邀请者奖励下单完成赠送的优惠券'));
  142. }
  143. if(empty($invitees_order_reward_point) || !is_numeric($invitees_order_reward_point) || $invitees_order_reward_point < 0){
  144. show_json(0, array('message' => '被邀请者奖励下单完成赠送的积分必填且为大于0'));
  145. }
  146. }
  147. }
  148. if($is_open_invitation_limit == 1){
  149. if(empty($invitation_limit_person) || floor($invitation_limit_person) != $invitation_limit_person || $invitation_limit_person <= 0){
  150. show_json(0, array('message' => '请填写邀请人数且为大于0整数'));
  151. }
  152. }
  153. }
  154. $parameter = array();
  155. $parameter['is_invite_open_status'] = $is_invite_open_status;
  156. $parameter['inviter_reward_type'] = $inviter_reward_type;
  157. $parameter['inviter_reward_couponid'] = $inviter_reward_couponid;
  158. $parameter['inviter_reward_point'] = $inviter_reward_point;
  159. $parameter['invitees_reward_type'] = $invitees_reward_type;
  160. $parameter['invitees_register_reward_type'] = $invitees_register_reward_type;
  161. $parameter['invitees_register_reward_couponid'] = $invitees_register_reward_couponid;
  162. $parameter['invitees_register_reward_point'] = $invitees_register_reward_point;
  163. $parameter['invitees_order_reward_type'] = $invitees_order_reward_type;
  164. $parameter['invitees_order_reward_couponid'] = $invitees_order_reward_couponid;
  165. $parameter['invitees_order_reward_point'] = $invitees_order_reward_point;
  166. $parameter['invite_activity_reward_type'] = $invite_activity_reward_type;
  167. $parameter['is_open_invitation_limit'] = $is_open_invitation_limit;
  168. $parameter['invitation_limit_person'] = $invitation_limit_person;
  169. $parameter['invite_activity_topback_img'] = $invite_activity_topback_img;
  170. $parameter['invite_activity_open_topback_img'] = $invite_activity_open_topback_img;
  171. $parameter['invite_activity_use_rules'] = $invite_activity_use_rules;
  172. $parameter['invite_share_title'] = $invite_share_title;
  173. $parameter['invite_share_img'] = $invite_share_img;
  174. $parameter['invite_order_share_title'] = $invite_order_share_title;
  175. $parameter['invite_order_share_img'] = $invite_order_share_img;
  176. $parameter['invite_activity_rules'] = $invite_activity_rules;
  177. D('Seller/Config')->update($parameter);
  178. show_json(1, array('url' => $_SERVER['HTTP_REFERER']) );
  179. die();
  180. }else{
  181. $data = D('Seller/Config')->get_all_config();
  182. $this->data = $data;
  183. $coupon_list = M('lionfish_comshop_coupon')->field('id,voucher_title,person_limit_count,total_count,send_count')->order('displayorder desc')->select();
  184. if( !empty($coupon_list) )
  185. {
  186. foreach($coupon_list as $k=> $v )
  187. {
  188. if($v['total_count'] != -1){
  189. //已发送张数
  190. $send_count = M('lionfish_comshop_coupon_list')->where( array('voucher_id' => $v['id'] ) )->count();
  191. $v['remain_count'] = $v['total_count'] - $send_count;
  192. $v['remain_count'] = '剩余'.$v['remain_count'].'张';
  193. }else{
  194. $v['remain_count'] = '无限制';
  195. }
  196. $coupon_list[$k] = $v;
  197. }
  198. }
  199. $this->coupon_list = $coupon_list;
  200. $this->display();
  201. }
  202. }
  203. /**
  204. * @author cy 2021-03-09
  205. * @desc 邀新海报背景配置
  206. */
  207. public function poster_background(){
  208. if (IS_POST) {
  209. $_GPC = I('request.');
  210. $invite_poster_back_type = isset($_GPC['invite_poster_back_type']) ? $_GPC['invite_poster_back_type'] : 0;
  211. $invite_poster_back_color = isset($_GPC['invite_poster_back_color']) ? $_GPC['invite_poster_back_color'] : '#ffffff';
  212. $invite_poster_back_img = isset($_GPC['invite_poster_back_img']) ? $_GPC['invite_poster_back_img'] : '';
  213. $parameter = array();
  214. $parameter['invite_poster_back_type'] = $invite_poster_back_type;
  215. $parameter['invite_poster_back_color'] = $invite_poster_back_color;
  216. $parameter['invite_poster_back_img'] = $invite_poster_back_img;
  217. D('Seller/Config')->update($parameter);
  218. show_json(1, array('url' => $_SERVER['HTTP_REFERER']) );
  219. die();
  220. }else{
  221. $data = D('Seller/Config')->get_all_config();
  222. $need_data = array();
  223. $need_data['invite_poster_back_type'] = isset( $data['invite_poster_back_type'] ) ? $data['invite_poster_back_type']: 0;
  224. $need_data['invite_poster_back_color'] = isset( $data['invite_poster_back_color'] ) ? $data['invite_poster_back_color']: '#ffffff';
  225. $need_data['invite_poster_back_img'] = isset( $data['invite_poster_back_img'] ) ? $data['invite_poster_back_img']: '';
  226. $this->data = $need_data;
  227. $this->display();
  228. }
  229. }
  230. /**
  231. * @author cy 2021-03-10
  232. * @desc 邀新海报二维码配置
  233. */
  234. public function poster_qrcode(){
  235. if (IS_POST) {
  236. $_GPC = I('request.');
  237. $invite_poster_qrcode_backcolor = isset($_GPC['invite_poster_qrcode_backcolor']) ? $_GPC['invite_poster_qrcode_backcolor'] : 0;
  238. $invite_poster_qrcode_linecolor = isset($_GPC['invite_poster_qrcode_linecolor']) ? $_GPC['invite_poster_qrcode_linecolor'] : '';
  239. $invite_poster_qrcode_corner_type = isset($_GPC['invite_poster_qrcode_corner_type']) ? $_GPC['invite_poster_qrcode_corner_type'] : '';
  240. $invite_poster_qrcode_size = isset($_GPC['invite_poster_qrcode_size']) ? $_GPC['invite_poster_qrcode_size'] : 0;
  241. $invite_poster_qrcode_border_status = isset($_GPC['invite_poster_qrcode_border_status']) ? $_GPC['invite_poster_qrcode_border_status'] : '';
  242. $invite_poster_qrcode_bordercolor = isset($_GPC['invite_poster_qrcode_bordercolor']) ? $_GPC['invite_poster_qrcode_bordercolor'] : '';
  243. $invite_poster_qrcode_img = isset($_GPC['invite_poster_qrcode_img']) ? $_GPC['invite_poster_qrcode_img'] : '';
  244. $invite_poster_qrcode_top = isset($_GPC['invite_poster_qrcode_top']) ? $_GPC['invite_poster_qrcode_top'] : '';
  245. $invite_poster_qrcode_left = isset($_GPC['invite_poster_qrcode_left']) ? $_GPC['invite_poster_qrcode_left'] : '';
  246. $parameter = array();
  247. $parameter['invite_poster_qrcode_img'] = empty($invite_poster_qrcode_img) ? '' : $invite_poster_qrcode_img;
  248. $parameter['invite_poster_qrcode_backcolor'] = empty($invite_poster_qrcode_backcolor) ? '#323233' : $invite_poster_qrcode_backcolor;
  249. $parameter['invite_poster_qrcode_linecolor'] = empty($invite_poster_qrcode_linecolor) ? '#323233' : $invite_poster_qrcode_linecolor;
  250. $parameter['invite_poster_qrcode_corner_type'] = empty($invite_poster_qrcode_corner_type) ? '0' : $invite_poster_qrcode_corner_type;
  251. $parameter['invite_poster_qrcode_size'] = empty($invite_poster_qrcode_size) ? '100' : $invite_poster_qrcode_size;
  252. $parameter['invite_poster_qrcode_border_status'] = empty($invite_poster_qrcode_border_status) ? '0' : $invite_poster_qrcode_border_status;
  253. $parameter['invite_poster_qrcode_bordercolor'] = empty($invite_poster_qrcode_bordercolor) ? '#323233' : $invite_poster_qrcode_bordercolor;;
  254. $parameter['invite_poster_qrcode_top'] = empty($invite_poster_qrcode_top) ? '0' : $invite_poster_qrcode_top;
  255. $parameter['invite_poster_qrcode_left'] = empty($invite_poster_qrcode_left) ? '0' : $invite_poster_qrcode_left;
  256. $parameter['invite_poster_update_time'] = time();
  257. D('Seller/Config')->update($parameter);
  258. show_json(1, array('url' => $_SERVER['HTTP_REFERER']) );
  259. die();
  260. }else{
  261. $config_data = D('Seller/Config')->get_all_config();
  262. $need_data = [];
  263. $need_data['invite_poster_qrcode_backcolor'] = isset( $config_data['invite_poster_qrcode_backcolor'] ) ? $config_data['invite_poster_qrcode_backcolor'] : '#ffffff';
  264. $need_data['invite_poster_qrcode_linecolor'] = isset( $config_data['invite_poster_qrcode_linecolor'] ) ? $config_data['invite_poster_qrcode_linecolor'] : '#000000';
  265. $need_data['invite_poster_qrcode_corner_type'] = isset( $config_data['invite_poster_qrcode_corner_type'] ) ? $config_data['invite_poster_qrcode_corner_type']: 0;
  266. $need_data['invite_poster_qrcode_size'] = isset( $config_data['invite_poster_qrcode_size'] ) ? $config_data['invite_poster_qrcode_size'] : '300';
  267. $need_data['invite_poster_qrcode_border_status'] = isset( $config_data['invite_poster_qrcode_border_status'] ) ? $config_data['invite_poster_qrcode_border_status'] : 0;
  268. $need_data['invite_poster_qrcode_bordercolor'] = isset( $config_data['invite_poster_qrcode_bordercolor'] ) ? $config_data['invite_poster_qrcode_bordercolor'] : '#000000';
  269. $need_data['invite_poster_qrcode_top'] = isset( $config_data['invite_poster_qrcode_top'] ) ? $config_data['invite_poster_qrcode_top'] : '0';
  270. $need_data['invite_poster_qrcode_left'] = isset( $config_data['invite_poster_qrcode_left'] ) ? $config_data['invite_poster_qrcode_left'] : '0';
  271. if(empty($config_data['invite_poster_qrcode_img'])){
  272. $invite_qrcode = D('Home/Pingoods')->_get_invite_wxqrcode("lionfish_comshop/moduleB/invite/share", 0 ,$need_data['invite_poster_qrcode_backcolor'],$need_data['invite_poster_qrcode_linecolor']);
  273. $need_data['invite_poster_qrcode_img_yuan'] = $invite_qrcode;
  274. $need_data['invite_poster_qrcode_img'] = tomedia($invite_qrcode);
  275. $parameter['invite_poster_qrcode_img'] = empty($invite_qrcode) ? '' : $invite_qrcode;
  276. $parameter['invite_poster_qrcode_backcolor'] = empty($need_data['invite_poster_qrcode_backcolor']) ? '' : $need_data['invite_poster_qrcode_backcolor'];
  277. $parameter['invite_poster_qrcode_linecolor'] = empty($need_data['invite_poster_qrcode_linecolor']) ? '' : $need_data['invite_poster_qrcode_linecolor'];
  278. $parameter['invite_poster_update_time'] = time();
  279. D('Seller/Config')->update($parameter);
  280. }else{
  281. $need_data['invite_poster_qrcode_img_yuan'] = $config_data['invite_poster_qrcode_img'];
  282. $need_data['invite_poster_qrcode_img'] = tomedia($config_data['invite_poster_qrcode_img']);
  283. }
  284. $need_data['invite_poster_back_type'] = isset( $config_data['invite_poster_back_type'] ) ? $config_data['invite_poster_back_type']: 0;
  285. $need_data['invite_poster_back_color'] = isset( $config_data['invite_poster_back_color'] ) ? $config_data['invite_poster_back_color']: '#ffffff';
  286. $need_data['invite_poster_back_img'] = isset( $config_data['invite_poster_back_img'] ) ? $config_data['invite_poster_back_img']: '';
  287. $need_data['qrcode_width'] = round($need_data['invite_poster_qrcode_size'] / 2);
  288. $need_data['qrcode_top'] = $need_data['invite_poster_qrcode_top'] / 2;
  289. $need_data['qrcode_left'] = $need_data['invite_poster_qrcode_left'] / 2;
  290. $this->data = $need_data;
  291. $this->display();
  292. }
  293. }
  294. /**
  295. * @author cy 2021-03-10
  296. * @desc 修改二维码背景色
  297. */
  298. public function changeQrcodeBackground(){
  299. $_GPC = I('request.');
  300. $config_data = D('Seller/Config')->get_all_config();
  301. $back_color = !empty($_GPC['back_color']) ? $_GPC['back_color'] : '#ffffff';
  302. $line_color = !empty($_GPC['line_color']) ? $_GPC['line_color'] : '#000000';
  303. $need_data = [];
  304. //生成二维码
  305. $invite_qrcode = D('Home/Pingoods')->_get_invite_wxqrcode("lionfish_comshop/moduleB/invite/share", 0 , $back_color, $line_color);
  306. $need_data['invite_poster_qrcode_img_yuan'] = $invite_qrcode;
  307. $need_data['invite_poster_qrcode_img'] = tomedia($invite_qrcode);
  308. $parameter['invite_poster_qrcode_img'] = empty($invite_qrcode) ? '' : $invite_qrcode;
  309. $parameter['invite_poster_qrcode_backcolor'] = empty($back_color) ? '' : $back_color;
  310. $parameter['invite_poster_qrcode_linecolor'] = empty($line_color) ? '' : $line_color;
  311. $parameter['invite_poster_update_time'] = time();
  312. D('Seller/Config')->update($parameter);
  313. //删除二维码图片
  314. $upload_path = ROOT_PATH.'Uploads/image/';
  315. if(file_exists($upload_path.$config_data['invite_poster_qrcode_img'])){
  316. unlink($upload_path.$config_data['invite_poster_qrcode_img']);
  317. }
  318. show_json(1, $need_data);
  319. }
  320. /**
  321. * @author cy 2021-03-10
  322. * @desc 邀新记录
  323. * @return mixed
  324. */
  325. public function record(){
  326. $_GPC = I('request.');
  327. $pindex = max(1, intval($_GPC['page']));
  328. $psize = 20;
  329. $condition = " 1 ";
  330. if (!empty($_GPC['keyword'])) {
  331. $_GPC['keyword'] = trim($_GPC['keyword']);
  332. $condition .= " and m.username like '%".$_GPC['keyword']."%' ";
  333. }
  334. $sql = 'SELECT distinct(r.user_id) as user_id,m.username,count(r.invitee_userid) as invite_count,m.share_status FROM '. C('DB_PREFIX'). "lionfish_comshop_invitegift_record r "
  335. . " left join ".C('DB_PREFIX')."lionfish_comshop_member m on r.user_id = m.member_id "
  336. . " where ". $condition . ' group by r.user_id ';
  337. $query_sql = " select * from (".$sql.") as t order by invite_count desc limit ".(($pindex - 1) * $psize).",".$psize;
  338. $list = M()->query($query_sql);
  339. $total_sql = "select count(1) as count from (".$sql.") t";
  340. $total_arr = M()->query($total_sql);
  341. $total = $total_arr[0]['count'];
  342. $pager = pagination2($total, $pindex, $psize);
  343. $invitegift_model = D('Seller/Invitegift');
  344. if( $total > 0 )
  345. {
  346. foreach( $list as $k=>&$v )
  347. {
  348. $v['invite_succ_count'] = $invitegift_model->getInviteSuccCount($v['user_id']);
  349. $v['coupon_count'] = $invitegift_model->getInviteSuccSendCouponCount($v['user_id']);
  350. $v['point_count'] = $invitegift_model->getInviteSuccSendPointTotal($v['user_id']);
  351. $v['get_coupon_count'] = $invitegift_model->getInviteSuccCouponCount($v['user_id']);
  352. $v['get_point_count'] = $invitegift_model->getInviteSuccPointTotal($v['user_id']);
  353. }
  354. }
  355. $this->list = $list;
  356. $this->pager = $pager;
  357. $this->coupon_total_count = $invitegift_model->getInviteSendCouponCount();
  358. $this->point_total_count = $invitegift_model->getInviteSendPointTotal();
  359. $this->get_coupon_total_count = $invitegift_model->getInviteCouponCount();
  360. $this->get_point_total_count = $invitegift_model->getInvitePointTotal();
  361. $this->_GPC = $_GPC;
  362. $this->display();
  363. }
  364. /**
  365. * @author cy 2021-03-10
  366. * @desc 更新会员邀新状态
  367. * @return mixed
  368. */
  369. public function changestatus(){
  370. $_GPC = I('request.');
  371. $user_id = $_GPC['user_id'];
  372. $type = $_GPC['type'];
  373. $status = $_GPC['value'];
  374. M('lionfish_comshop_member')->where( array('member_id' => $user_id) )->save( array($type => $status) );
  375. show_json(1, array('url' => U('invitegift/record')));
  376. }
  377. /**
  378. * @author cy 2021-03-10
  379. * @desc 被邀请者列表
  380. */
  381. public function invite_list(){
  382. $_GPC = I('request.');
  383. $pindex = max(1, intval($_GPC['page']));
  384. $psize = 20;
  385. $keyword = $_GPC['keyword'];
  386. $user_id = $_GPC['user_id'];
  387. $condition = " 1 ";
  388. $condition .= " and r.user_id = ". $user_id;
  389. if (!empty($_GPC['keyword'])) {
  390. $_GPC['keyword'] = trim($_GPC['keyword']);
  391. $condition .= " and m.username like '%".$keyword."%' ";
  392. }
  393. $sql = "select r.invitee_userid,m.username,r.addtime,r.invitee_status from ".C('DB_PREFIX')."lionfish_comshop_invitegift_record r "
  394. . " left join ".C('DB_PREFIX')."lionfish_comshop_member m on r.invitee_userid=m.member_id "
  395. . " where ".$condition;
  396. $query_sql = $sql." order by r.addtime desc limit ".(($pindex - 1) * $psize).",".$psize;
  397. $list = M()->query($query_sql);
  398. $total_sql = "select count(1) as count from (".$sql.") t";
  399. $total_arr = M()->query($total_sql);
  400. $total = $total_arr[0]['count'];
  401. $pager = pagination2($total, $pindex, $psize);
  402. if( $total > 0 )
  403. {
  404. foreach( $list as $k=>&$v )
  405. {
  406. $v['addtime'] = date('Y-m-d H:i:s',$v['addtime']);
  407. }
  408. }
  409. $this->list = $list;
  410. $this->pager = $pager;
  411. $member_info = M('lionfish_comshop_member')->where(array('member_id'=>$user_id))->field('username')->find();
  412. $this->member = $member_info;
  413. $this->_GPC = $_GPC;
  414. $this->display();
  415. }
  416. }
  417. ?>