InvitegiftController.class.php 23 KB

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