MarketController.php 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: 小夏 < 449134904@qq.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\admin\controller;
  12. use cmf\controller\AdminBaseController;
  13. use think\Db;
  14. use think\db\Query;
  15. use app\admin\model\BooksModel;
  16. use app\weixin\service\Activity;
  17. use app\weixin\service\PRedis;
  18. /**
  19. * Class UserController
  20. * @package app\admin\controller
  21. * @adminMenuRoot(
  22. * 'name' => '管理组',
  23. * 'action' => 'default',
  24. * 'parent' => 'user/AdminIndex/default',
  25. * 'display'=> true,
  26. * 'order' => 10000,
  27. * 'icon' => '',
  28. * 'remark' => '管理组'
  29. * )
  30. */
  31. class MarketController extends AdminBaseController
  32. {
  33. /**
  34. * 分销设置界面
  35. */
  36. public function marketset(){
  37. //查询得到分销表
  38. $market=Db::name('market')->where('id',1)->find();
  39. // var_dump($market);die();
  40. $this->assign('market', $market);
  41. return $this->fetch();
  42. }
  43. /**
  44. * 分销设置界面提交
  45. */
  46. public function marketsetpost(){
  47. //提交 param('level_1'),也可以相当于param['level_1'];
  48. $data=$this->request->param();
  49. $data['updated_at'] = date('Y-m-d H:i:s',time());
  50. if(Db::name('market')->where('id',1)->update($data)){
  51. $this->success('保存成功!');
  52. }else{
  53. $this->error('保存失败!');
  54. }
  55. }
  56. //分销用户显示
  57. public function marketuser(){
  58. $data = $this->request->param();
  59. session('search',[
  60. 'uid' => isset($data['uid'])? intval($data['uid']) : 0,
  61. 'keyword' => isset($data['keyword'])? trim($data['keyword']) : '',
  62. ]);
  63. // 添加返回历史修改 by wesmiler 2020-02-16
  64. $history = isset($data['history'])? intval($data['history']) : 0;
  65. if($history){
  66. $data = session('user_search');
  67. }else{
  68. session('user_search', $data);
  69. }
  70. // 修改 end
  71. //var_dump($data);die;
  72. $list = Db::name('user')->field('u.id,u.user_login,u.user_nickname,u.real_name,u.redheart,u.is_tuijian,u.create_time,u.is_heart,u.user_status,u.mobile,u.freezing,u.updated_at,last_login_time,up.idcard,
  73. up.idcard_check,up.position_check,up.education_check')
  74. ->alias('u')
  75. ->join('user_profile up','u.id=up.userid','left')
  76. ->where(function (Query $query) use($data){
  77. $query->where('u.user_type', 2);
  78. $query->where('u.openid', 'not in','');
  79. $query->where('u.agent_type',1);
  80. //代表是否付费定制
  81. ($this->request->action()=='custom' || $this->request->param('u')==2)?$query->where('u.is_vip', 1):$query->where('u.is_vip', 0);
  82. //代表是否冻结
  83. if($this->request->action()!='userlogout' && $this->request->param('u')!=5){
  84. ($this->request->action()=='userban' || $this->request->param('u')==3)?$query->where('u.user_status', 0):$query->where('u.user_status', 1);
  85. }
  86. //代表是否筛选
  87. ($this->request->action()=='screen' || $this->request->param('u')==4)?$query->where('u.is_screen', 1):$query->where('u.is_screen', 0);
  88. //代表是否注销
  89. if($this->request->action()!='userban' && $this->request->param('u')!=3){
  90. ($this->request->action()=='userlogout' || $this->request->param('u')==5)?$query->where('u.user_status', -1):$query->where('u.user_status', 1);
  91. }
  92. //$data = $this->request->param();
  93. if (!empty($data['uid'])) {
  94. $query->where('u.id', intval($data['uid']));
  95. }
  96. if (!empty($data['keyword'])) {
  97. $keyword = $data['keyword'];
  98. $query->where('u.user_nickname|u.real_name|u.mobile', 'like', "%$keyword%");
  99. }
  100. //年龄区间查询
  101. if((!empty($data['age1']) && $data['age1']!='none') && (!empty($data['age2']) && $data['age2']!='none')){
  102. $query->where('u.birthday',['>',strtotime($data['age1'])],['<',strtotime($data['age2'])],'and');
  103. $query->whereNotNull('u.birthday');
  104. }
  105. // //只有第一个年龄的情况下
  106. if((!empty($data['age1']) && $data['age1']!='none') && (empty($data['age2']) || $data['age2']=='none')){
  107. $birthday = $data['age1'];
  108. $query->whereRaw("YEAR(from_unixtime(u.`birthday`))=$birthday and u.birthday is not null ");
  109. }
  110. // //只有第二个年龄的情况下
  111. if((empty($data['age1']) || $data['age1']=='none') && (!empty($data['age2']) && $data['age2']!='none')){
  112. $birthday = $data['age2'];
  113. $query->whereRaw("YEAR(from_unixtime(u.`birthday`))=$birthday and u.birthday is not null ");
  114. }
  115. //身高区间查询
  116. if((!empty(input('height')) && input('height')!='none') && (!empty(input('heightt')) && input('heightt')!='none')){
  117. $query->where('up.height',['>',input('height')],['<',input('heightt')],'and');
  118. }
  119. //身高第一个查找
  120. if((!empty(input('height')) && input('height')!='none') && (empty(input('heightt')) || input('heightt')=='none')){
  121. $query->where('up.height',input('height'));
  122. }
  123. //身高第二个查找
  124. if((empty(input('height')) ||input('height')=='none') && (!empty(input('heightt')) && input('heightt')!='none')){
  125. $query->where('up.height',input('heightt'));
  126. }
  127. //学历
  128. if((!empty(input('education')) && input('education')!='none') ){
  129. $query->where('up.education',input('education'));
  130. }
  131. //职位
  132. if((!empty(input('occupation')) && input('occupation')!='none') ){
  133. $query->where('up.occupation',input('occupation'));
  134. }
  135. //收入
  136. if((!empty(input('salary')) && input('salary')!='none') ){
  137. $query->where('up.salary',input('salary'));
  138. }
  139. //资产
  140. if((!empty(input('property')) && input('property')!='none') ){
  141. $query->where('up.property',input('property'));
  142. }
  143. //家乡
  144. if((!empty(input('home_city')) && input('home_city')!='none') ){
  145. $query->where('up.home_province|up.home_city','like','%'.input('home_city').'%','or');
  146. }
  147. //居住地(市)
  148. if((!empty(input('city')) && input('city')!='none') ){
  149. $query->where('up.city','like','%'.input('city').'%');
  150. }
  151. //婚姻状况
  152. if((!empty(input('married')) && input('married')!='none') ){
  153. $query->where('up.married',input('married'));
  154. }
  155. //性别
  156. if((!empty(input('sex')) && input('sex')!='none') ){
  157. $query->where('u.sex',input('sex'));
  158. }
  159. })
  160. //待审核
  161. ->order("u.create_time DESC")
  162. ->paginate(10,false,['query'=>request()->param()]);
  163. // echo Db::name('user')->getLastSql();die;
  164. // 获取分页显示
  165. $page = $list->render();
  166. $this->assign('list', $list);
  167. $this->assign('page', $page);
  168. return $this->fetch();
  169. }
  170. //分销员审核
  171. public function marketexamine(){
  172. $data = $this->request->param();
  173. session('search',[
  174. 'uid' => isset($data['uid'])? intval($data['uid']) : 0,
  175. 'keyword' => isset($data['keyword'])? trim($data['keyword']) : '',
  176. ]);
  177. // 添加返回历史修改 by wesmiler 2020-02-16
  178. $history = isset($data['history'])? intval($data['history']) : 0;
  179. if($history){
  180. $data = session('user_search');
  181. }else{
  182. session('user_search', $data);
  183. }
  184. // 修改 end
  185. //var_dump($data);die;
  186. $list = Db::name('user')->field('u.id,u.user_login,u.user_nickname,u.real_name,u.redheart,u.is_tuijian,u.create_time,u.is_heart,u.user_status,u.mobile,u.freezing,u.updated_at,u.agent_create_time,last_login_time,up.idcard,
  187. up.idcard_check,up.position_check,up.education_check')
  188. ->alias('u')
  189. ->join('user_profile up','u.id=up.userid','left')
  190. ->where(function (Query $query) use($data){
  191. $query->where('u.user_type', 2);
  192. $query->where('u.openid', 'not in','');
  193. $query->where('u.agent_status',2); //待审核
  194. //代表是否付费定制
  195. ($this->request->action()=='custom' || $this->request->param('u')==2)?$query->where('u.is_vip', 1):$query->where('u.is_vip', 0);
  196. //代表是否冻结
  197. if($this->request->action()!='userlogout' && $this->request->param('u')!=5){
  198. ($this->request->action()=='userban' || $this->request->param('u')==3)?$query->where('u.user_status', 0):$query->where('u.user_status', 1);
  199. }
  200. //代表是否筛选
  201. ($this->request->action()=='screen' || $this->request->param('u')==4)?$query->where('u.is_screen', 1):$query->where('u.is_screen', 0);
  202. //代表是否注销
  203. if($this->request->action()!='userban' && $this->request->param('u')!=3){
  204. ($this->request->action()=='userlogout' || $this->request->param('u')==5)?$query->where('u.user_status', -1):$query->where('u.user_status', 1);
  205. }
  206. //$data = $this->request->param();
  207. if (!empty($data['uid'])) {
  208. $query->where('u.id', intval($data['uid']));
  209. }
  210. if (!empty($data['keyword'])) {
  211. $keyword = $data['keyword'];
  212. $query->where('u.user_nickname|u.real_name|u.mobile', 'like', "%$keyword%");
  213. }
  214. //年龄区间查询
  215. if((!empty($data['age1']) && $data['age1']!='none') && (!empty($data['age2']) && $data['age2']!='none')){
  216. $query->where('u.birthday',['>',strtotime($data['age1'])],['<',strtotime($data['age2'])],'and');
  217. $query->whereNotNull('u.birthday');
  218. }
  219. // //只有第一个年龄的情况下
  220. if((!empty($data['age1']) && $data['age1']!='none') && (empty($data['age2']) || $data['age2']=='none')){
  221. $birthday = $data['age1'];
  222. $query->whereRaw("YEAR(from_unixtime(u.`birthday`))=$birthday and u.birthday is not null ");
  223. }
  224. // //只有第二个年龄的情况下
  225. if((empty($data['age1']) || $data['age1']=='none') && (!empty($data['age2']) && $data['age2']!='none')){
  226. $birthday = $data['age2'];
  227. $query->whereRaw("YEAR(from_unixtime(u.`birthday`))=$birthday and u.birthday is not null ");
  228. }
  229. //身高区间查询
  230. if((!empty(input('height')) && input('height')!='none') && (!empty(input('heightt')) && input('heightt')!='none')){
  231. $query->where('up.height',['>',input('height')],['<',input('heightt')],'and');
  232. }
  233. //身高第一个查找
  234. if((!empty(input('height')) && input('height')!='none') && (empty(input('heightt')) || input('heightt')=='none')){
  235. $query->where('up.height',input('height'));
  236. }
  237. //身高第二个查找
  238. if((empty(input('height')) ||input('height')=='none') && (!empty(input('heightt')) && input('heightt')!='none')){
  239. $query->where('up.height',input('heightt'));
  240. }
  241. //学历
  242. if((!empty(input('education')) && input('education')!='none') ){
  243. $query->where('up.education',input('education'));
  244. }
  245. //职位
  246. if((!empty(input('occupation')) && input('occupation')!='none') ){
  247. $query->where('up.occupation',input('occupation'));
  248. }
  249. //收入
  250. if((!empty(input('salary')) && input('salary')!='none') ){
  251. $query->where('up.salary',input('salary'));
  252. }
  253. //资产
  254. if((!empty(input('property')) && input('property')!='none') ){
  255. $query->where('up.property',input('property'));
  256. }
  257. //家乡
  258. if((!empty(input('home_city')) && input('home_city')!='none') ){
  259. $query->where('up.home_province|up.home_city','like','%'.input('home_city').'%','or');
  260. }
  261. //居住地(市)
  262. if((!empty(input('city')) && input('city')!='none') ){
  263. $query->where('up.city','like','%'.input('city').'%');
  264. }
  265. //婚姻状况
  266. if((!empty(input('married')) && input('married')!='none') ){
  267. $query->where('up.married',input('married'));
  268. }
  269. //性别
  270. if((!empty(input('sex')) && input('sex')!='none') ){
  271. $query->where('u.sex',input('sex'));
  272. }
  273. })
  274. //待审核
  275. ->order("u.agent_create_time DESC")
  276. ->paginate(10,false,['query'=>request()->param()]);
  277. //echo Db::name('user')->getLastSql();die;
  278. // 获取分页显示
  279. $page = $list->render();
  280. $this->assign('list', $list);
  281. $this->assign('page', $page);
  282. return $this->fetch();
  283. }
  284. //分销一级用户显示
  285. public function Marketoneuser(){
  286. $data = $this->request->param();
  287. session('search',[
  288. 'uid' => isset($data['uid'])? intval($data['uid']) : 0,
  289. 'keyword' => isset($data['keyword'])? trim($data['keyword']) : '',
  290. ]);
  291. // 添加返回历史修改 by wesmiler 2020-02-16
  292. $history = isset($data['history'])? intval($data['history']) : 0;
  293. if($history){
  294. $data = session('user_search');
  295. }else{
  296. session('user_search', $data);
  297. }
  298. // 修改 end
  299. //var_dump($data);die;
  300. $list = Db::name('user')->field('u.id,u.user_login,u.user_nickname,u.real_name,u.redheart,u.is_tuijian,u.create_time,u.is_heart,u.user_status,u.mobile,u.freezing,u.updated_at,last_login_time,up.idcard,
  301. up.idcard_check,up.position_check,up.education_check')
  302. ->alias('u')
  303. ->join('user_profile up','u.id=up.userid','left')
  304. ->where(function (Query $query) use($data){
  305. $query->where('u.user_type', 2);
  306. $query->where('u.openid', 'not in','');
  307. $query->where('u.agent_type',1);
  308. //代表是否付费定制
  309. ($this->request->action()=='custom' || $this->request->param('u')==2)?$query->where('u.is_vip', 1):$query->where('u.is_vip', 0);
  310. //代表是否冻结
  311. if($this->request->action()!='userlogout' && $this->request->param('u')!=5){
  312. ($this->request->action()=='userban' || $this->request->param('u')==3)?$query->where('u.user_status', 0):$query->where('u.user_status', 1);
  313. }
  314. //代表是否筛选
  315. ($this->request->action()=='screen' || $this->request->param('u')==4)?$query->where('u.is_screen', 1):$query->where('u.is_screen', 0);
  316. //代表是否注销
  317. if($this->request->action()!='userban' && $this->request->param('u')!=3){
  318. ($this->request->action()=='userlogout' || $this->request->param('u')==5)?$query->where('u.user_status', -1):$query->where('u.user_status', 1);
  319. }
  320. //$data = $this->request->param();
  321. if (!empty($data['uid'])) {
  322. $query->where('u.id', intval($data['uid']));
  323. }
  324. if (!empty($data['keyword'])) {
  325. $keyword = $data['keyword'];
  326. $query->where('u.user_nickname|u.real_name|u.mobile', 'like', "%$keyword%");
  327. }
  328. //年龄区间查询
  329. if((!empty($data['age1']) && $data['age1']!='none') && (!empty($data['age2']) && $data['age2']!='none')){
  330. $query->where('u.birthday',['>',strtotime($data['age1'])],['<',strtotime($data['age2'])],'and');
  331. $query->whereNotNull('u.birthday');
  332. }
  333. // //只有第一个年龄的情况下
  334. if((!empty($data['age1']) && $data['age1']!='none') && (empty($data['age2']) || $data['age2']=='none')){
  335. $birthday = $data['age1'];
  336. $query->whereRaw("YEAR(from_unixtime(u.`birthday`))=$birthday and u.birthday is not null ");
  337. }
  338. // //只有第二个年龄的情况下
  339. if((empty($data['age1']) || $data['age1']=='none') && (!empty($data['age2']) && $data['age2']!='none')){
  340. $birthday = $data['age2'];
  341. $query->whereRaw("YEAR(from_unixtime(u.`birthday`))=$birthday and u.birthday is not null ");
  342. }
  343. //身高区间查询
  344. if((!empty(input('height')) && input('height')!='none') && (!empty(input('heightt')) && input('heightt')!='none')){
  345. $query->where('up.height',['>',input('height')],['<',input('heightt')],'and');
  346. }
  347. //身高第一个查找
  348. if((!empty(input('height')) && input('height')!='none') && (empty(input('heightt')) || input('heightt')=='none')){
  349. $query->where('up.height',input('height'));
  350. }
  351. //身高第二个查找
  352. if((empty(input('height')) ||input('height')=='none') && (!empty(input('heightt')) && input('heightt')!='none')){
  353. $query->where('up.height',input('heightt'));
  354. }
  355. //学历
  356. if((!empty(input('education')) && input('education')!='none') ){
  357. $query->where('up.education',input('education'));
  358. }
  359. //职位
  360. if((!empty(input('occupation')) && input('occupation')!='none') ){
  361. $query->where('up.occupation',input('occupation'));
  362. }
  363. //收入
  364. if((!empty(input('salary')) && input('salary')!='none') ){
  365. $query->where('up.salary',input('salary'));
  366. }
  367. //资产
  368. if((!empty(input('property')) && input('property')!='none') ){
  369. $query->where('up.property',input('property'));
  370. }
  371. //家乡
  372. if((!empty(input('home_city')) && input('home_city')!='none') ){
  373. $query->where('up.home_province|up.home_city','like','%'.input('home_city').'%','or');
  374. }
  375. //居住地(市)
  376. if((!empty(input('city')) && input('city')!='none') ){
  377. $query->where('up.city','like','%'.input('city').'%');
  378. }
  379. //婚姻状况
  380. if((!empty(input('married')) && input('married')!='none') ){
  381. $query->where('up.married',input('married'));
  382. }
  383. //性别
  384. if((!empty(input('sex')) && input('sex')!='none') ){
  385. $query->where('u.sex',input('sex'));
  386. }
  387. })
  388. //待审核
  389. ->order("u.create_time DESC")
  390. ->paginate(10,false,['query'=>request()->param()]);
  391. // echo Db::name('user')->getLastSql();die;
  392. // 获取分页显示
  393. $page = $list->render();
  394. $this->assign('list', $list);
  395. $this->assign('page', $page);
  396. return $this->fetch();
  397. }
  398. //分二级用户显示
  399. public function Markettwouser(){
  400. $data = $this->request->param();
  401. session('search',[
  402. 'uid' => isset($data['uid'])? intval($data['uid']) : 0,
  403. 'keyword' => isset($data['keyword'])? trim($data['keyword']) : '',
  404. ]);
  405. // 添加返回历史修改 by wesmiler 2020-02-16
  406. $history = isset($data['history'])? intval($data['history']) : 0;
  407. if($history){
  408. $data = session('user_search');
  409. }else{
  410. session('user_search', $data);
  411. }
  412. // 修改 end
  413. //var_dump($data);die;
  414. $list = Db::name('user')->field('u.id,u.user_login,u.user_nickname,u.real_name,u.redheart,u.is_tuijian,u.create_time,u.is_heart,u.user_status,u.mobile,u.freezing,u.updated_at,last_login_time,up.idcard,
  415. up.idcard_check,up.position_check,up.education_check')
  416. ->alias('u')
  417. ->join('user_profile up','u.id=up.userid','left')
  418. ->where(function (Query $query) use($data){
  419. $query->where('u.user_type', 2);
  420. $query->where('u.openid', 'not in','');
  421. $query->where('u.agent_type',1);
  422. //代表是否付费定制
  423. ($this->request->action()=='custom' || $this->request->param('u')==2)?$query->where('u.is_vip', 1):$query->where('u.is_vip', 0);
  424. //代表是否冻结
  425. if($this->request->action()!='userlogout' && $this->request->param('u')!=5){
  426. ($this->request->action()=='userban' || $this->request->param('u')==3)?$query->where('u.user_status', 0):$query->where('u.user_status', 1);
  427. }
  428. //代表是否筛选
  429. ($this->request->action()=='screen' || $this->request->param('u')==4)?$query->where('u.is_screen', 1):$query->where('u.is_screen', 0);
  430. //代表是否注销
  431. if($this->request->action()!='userban' && $this->request->param('u')!=3){
  432. ($this->request->action()=='userlogout' || $this->request->param('u')==5)?$query->where('u.user_status', -1):$query->where('u.user_status', 1);
  433. }
  434. //$data = $this->request->param();
  435. if (!empty($data['uid'])) {
  436. $query->where('u.id', intval($data['uid']));
  437. }
  438. if (!empty($data['keyword'])) {
  439. $keyword = $data['keyword'];
  440. $query->where('u.user_nickname|u.real_name|u.mobile', 'like', "%$keyword%");
  441. }
  442. //年龄区间查询
  443. if((!empty($data['age1']) && $data['age1']!='none') && (!empty($data['age2']) && $data['age2']!='none')){
  444. $query->where('u.birthday',['>',strtotime($data['age1'])],['<',strtotime($data['age2'])],'and');
  445. $query->whereNotNull('u.birthday');
  446. }
  447. // //只有第一个年龄的情况下
  448. if((!empty($data['age1']) && $data['age1']!='none') && (empty($data['age2']) || $data['age2']=='none')){
  449. $birthday = $data['age1'];
  450. $query->whereRaw("YEAR(from_unixtime(u.`birthday`))=$birthday and u.birthday is not null ");
  451. }
  452. // //只有第二个年龄的情况下
  453. if((empty($data['age1']) || $data['age1']=='none') && (!empty($data['age2']) && $data['age2']!='none')){
  454. $birthday = $data['age2'];
  455. $query->whereRaw("YEAR(from_unixtime(u.`birthday`))=$birthday and u.birthday is not null ");
  456. }
  457. //身高区间查询
  458. if((!empty(input('height')) && input('height')!='none') && (!empty(input('heightt')) && input('heightt')!='none')){
  459. $query->where('up.height',['>',input('height')],['<',input('heightt')],'and');
  460. }
  461. //身高第一个查找
  462. if((!empty(input('height')) && input('height')!='none') && (empty(input('heightt')) || input('heightt')=='none')){
  463. $query->where('up.height',input('height'));
  464. }
  465. //身高第二个查找
  466. if((empty(input('height')) ||input('height')=='none') && (!empty(input('heightt')) && input('heightt')!='none')){
  467. $query->where('up.height',input('heightt'));
  468. }
  469. //学历
  470. if((!empty(input('education')) && input('education')!='none') ){
  471. $query->where('up.education',input('education'));
  472. }
  473. //职位
  474. if((!empty(input('occupation')) && input('occupation')!='none') ){
  475. $query->where('up.occupation',input('occupation'));
  476. }
  477. //收入
  478. if((!empty(input('salary')) && input('salary')!='none') ){
  479. $query->where('up.salary',input('salary'));
  480. }
  481. //资产
  482. if((!empty(input('property')) && input('property')!='none') ){
  483. $query->where('up.property',input('property'));
  484. }
  485. //家乡
  486. if((!empty(input('home_city')) && input('home_city')!='none') ){
  487. $query->where('up.home_province|up.home_city','like','%'.input('home_city').'%','or');
  488. }
  489. //居住地(市)
  490. if((!empty(input('city')) && input('city')!='none') ){
  491. $query->where('up.city','like','%'.input('city').'%');
  492. }
  493. //婚姻状况
  494. if((!empty(input('married')) && input('married')!='none') ){
  495. $query->where('up.married',input('married'));
  496. }
  497. //性别
  498. if((!empty(input('sex')) && input('sex')!='none') ){
  499. $query->where('u.sex',input('sex'));
  500. }
  501. })
  502. //待审核
  503. ->order("u.create_time DESC")
  504. ->paginate(10,false,['query'=>request()->param()]);
  505. // echo Db::name('user')->getLastSql();die;
  506. // 获取分页显示
  507. $page = $list->render();
  508. $this->assign('list', $list);
  509. $this->assign('page', $page);
  510. return $this->fetch();
  511. }
  512. /**
  513. * 审核通过和审核不通过的弹框
  514. */
  515. public function goconfrom(){
  516. $this->assign("id",input('id'));
  517. return $this->fetch('marketconfrom');
  518. }
  519. /**
  520. * 审核通过和审核不通过的弹框操作
  521. */
  522. public function doconfrom(){
  523. $param= $this->request->param();
  524. if(isset($param['yes']) && isset($param['id'])){
  525. //开始进行调用成功发送
  526. $data['agent_status'] = 1;
  527. $result=Db::name('user')->where('id',$param['id'])->update($data);
  528. // echo Db::name('user')->getLastSql();die();
  529. //$result=Activity::bookConfirm($param['id'],3);
  530. // if(is_array($result)){
  531. if($result){
  532. echo 1;die;
  533. }else{
  534. echo 0;die;
  535. }
  536. }
  537. if(isset($param['no']) && isset($param['id'])){
  538. //开始进行调用审核失败发送
  539. // $result=Activity::bookConfirm($param['id'],5,$param['noremark']);
  540. if(is_array($result)){
  541. echo 1;die;
  542. }else{
  543. echo 0;die;
  544. }
  545. }
  546. }
  547. /**
  548. * 分销员奖励交易记录表
  549. */
  550. public function markettrans(){
  551. //
  552. /**搜索条件**/
  553. $trans_name = $this->request->param('user_nickname');
  554. $money = $this->request->param('money');
  555. //$userEmail = trim($this->request->param('user_email'));
  556. //账户明细表(包含用户名称,爱心,余额)
  557. $account_logs = Db::name('user_balance_log')
  558. ->alias('blog')
  559. ->join('user u','blog.user_id=u.id','left')
  560. ->whereIn('blog.type',[31,32])
  561. ->where(function (Query $query) use ($trans_name,$money) {
  562. if ($trans_name) {
  563. $query->where('u.user_nickname', 'like', "%$trans_name%");
  564. }
  565. if ($money) {
  566. $query->where('blog.balance', $money);
  567. }
  568. })
  569. ->field('blog.*,u.user_nickname')
  570. ->order("blog.id DESC")
  571. ->paginate(10,false,['query'=>request()->param()])
  572. ->each(function($item,$key){
  573. $item['source_username'] = Db::name('user')->where(['id'=> $item['source_uid'], 'user_type'=> 2])->field('user_nickname')->find();
  574. return $item;
  575. })
  576. ;
  577. //echo Db::name('user_balance_log')->getLastSql();die();
  578. $account_logs->appends(['title' => $trans_name]);
  579. // 获取分页显示
  580. $page = $account_logs->render();
  581. $this->assign("page", $page);
  582. $this->assign("account_logs", $account_logs);
  583. return $this->fetch();
  584. }
  585. /**
  586. * 分销奖励和扣除查看详情
  587. */
  588. public function transinfo(){
  589. $id=input('id');
  590. $balance_log = Db::name('user_balance_log')
  591. ->alias('blog')
  592. ->join('user u','blog.user_id=u.id','left')
  593. ->where(function (Query $query) use ($id) {
  594. if ($id) {
  595. $query->where('blog.id', $id);
  596. }
  597. })
  598. ->field('blog.*,u.user_nickname')
  599. ->find();
  600. $this->assign($balance_log);
  601. return $this->fetch();
  602. }
  603. /**
  604. * 分销记录
  605. */
  606. public function marketrecord(){
  607. // echo Db::name('user')->getLastSql().var_dump( $result);die();
  608. /**搜索条件**/
  609. $trans_name = $this->request->param('user_nickname');
  610. $money = $this->request->param('money');
  611. //$userEmail = trim($this->request->param('user_email'));
  612. //账户明细表(包含用户名称,爱心,余额)
  613. $balance_logs = Db::name('user_balance_log')
  614. ->alias('blog')
  615. ->join('user u','blog.user_id=u.id','left')
  616. ->whereIn('blog.type',[31,32])
  617. ->where(function (Query $query) use ($trans_name,$money) {
  618. if ($trans_name) {
  619. $query->where('u.user_nickname', 'like', "%$trans_name%");
  620. }
  621. if ($money) {
  622. $query->where('blog.balance', $money);
  623. }
  624. })
  625. ->field('blog.*,u.user_nickname')
  626. ->order("blog.id DESC")
  627. ->paginate(10,false,['query'=>request()->param()])
  628. ->each(function($item,$key){
  629. $item['source_username'] = Db::name('user')->where(['id'=> $item['source_uid'], 'user_type'=> 2])->field('user_nickname')->find();
  630. return $item;
  631. })
  632. ;
  633. //echo Db::name('user_balance_log')->getLastSql();die();
  634. $balance_logs->appends(['title' => $trans_name]);
  635. // 获取分页显示
  636. $page = $balance_logs->render();
  637. // var_dump($balance_logs);die();
  638. $this->assign("page", $page);
  639. $this->assign("balance_logs", $balance_logs);
  640. return $this->fetch();
  641. }
  642. //假删除用户
  643. public function todelete(){
  644. $param = $this->request->param();
  645. if (isset($param['ids']) && isset($param["yes"])) {
  646. $ids = $this->request->param('ids/a');
  647. Db::name('user')->where('id', 'in', $ids)->update(['agent_type' => 0]);
  648. $this->success("删除成功!");
  649. }
  650. if (isset($_POST['ids']) && isset($param["no"])) {
  651. $ids = $this->request->param('ids/a');
  652. Db::name('user')->where('id', 'in', $ids)->update(['agent_type' => 1]);
  653. $this->success("取消删除成功!", '/market/marketexamine');
  654. }
  655. }
  656. /**
  657. * 显示奖励充值
  658. */
  659. public function marketshowreward(){
  660. $this->assign("id",input('id'));
  661. return $this->fetch();
  662. }
  663. /**
  664. * 进行奖励充值
  665. */
  666. public function markettoreward(){
  667. $this->assign("id",input('id'));
  668. return $this->fetch();
  669. }
  670. }