| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402 |
- <?php
- // +----------------------------------------------------------------------
- // | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
- // +----------------------------------------------------------------------
- // | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
- // +----------------------------------------------------------------------
- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
- // +----------------------------------------------------------------------
- // | Author: 小夏 < 449134904@qq.com>
- // +----------------------------------------------------------------------
- namespace app\admin\controller;
- use cmf\controller\AdminBaseController;
- use think\Db;
- use think\db\Query;
- use app\admin\model\BooksModel;
- use app\weixin\model\Wechat;
- use app\weixin\model\AccountLog;
- use app\weixin\model\Member;
- use app\weixin\model\UserBalanceLog;
- use app\weixin\service\PRedis;
- /**
- * Class UserController
- * @package app\admin\controller
- * @adminMenuRoot(
- * 'name' => '管理组',
- * 'action' => 'default',
- * 'parent' => 'user/AdminIndex/default',
- * 'display'=> true,
- * 'order' => 10000,
- * 'icon' => '',
- * 'remark' => '管理组'
- * )
- */
- class MarketController extends AdminBaseController
- {
- /**
- * 分销设置界面
- */
- public function marketset(){
- //查询得到分销表
- $market=Db::name('market')->where('id',input('id'))->find();
- // $market=Db::name('market')->find();
-
- // var_dump($market);die();
- $this->assign('market', $market);
- return $this->fetch();
- }
- /**
- * 分销设置界面提交
- */
- public function marketsetpost(){
- //提交 param('level_1'),也可以相当于param['level_1'];
- $data=$this->request->param();
- $data['updated_at'] = date('Y-m-d H:i:s',time());
-
- if(Db::name('market')->where('id',$data['id'])->update($data)){
- $this->success('保存成功!',url('market/marketsetlist'));
- }else{
- $this->error('保存失败!');
- }
- }
- public function marketsetedit(){
- //提交 param('level_1'),也可以相当于param['level_1'];
- $data=$this->request->param();
- $data['updated_at'] = date('Y-m-d H:i:s',time());
-
- if(Db::name('market')->where('id',$data['id'])->update($data)){
- $this->success('保存成功!',url('market/marketsetlist'));
- }else{
- $this->error('保存失败!');
- }
- }
- //分销用户显示
- public function marketuser(){
- $data = $this->request->param();
- session('search',[
- 'uid' => isset($data['uid'])? intval($data['uid']) : 0,
- 'keyword' => isset($data['keyword'])? trim($data['keyword']) : '',
- ]);
- // 添加返回历史修改 by wesmiler 2020-02-16
- $history = isset($data['history'])? intval($data['history']) : 0;
- if($history){
- $data = session('user_search');
- }else{
- session('user_search', $data);
- }
- // 修改 end
- //var_dump($data);die;
- $list = Db::name('user')->field('u.id,u.user_login,u.user_nickname,u.real_name,u.redheart,u.is_tuijian,u.parent_id,u.create_time,u.is_heart,u.user_status,u.balance,u.mobile,u.level,u.freezing,u.updated_at,last_login_time,up.idcard,
- up.idcard_check,up.position_check,up.education_check')
- ->alias('u')
- ->join('user_profile up','u.id=up.userid','left')
-
- ->where(function (Query $query) use($data){
- $query->where('u.user_type', 2);
- $query->where('u.openid', 'not in','');
- $query->where('u.agent_type',1);
- //代表是否付费定制
- ($this->request->action()=='custom' || $this->request->param('u')==2)?$query->where('u.is_vip', 1):$query->where('u.is_vip', 0);
- //代表是否冻结
- if($this->request->action()!='userlogout' && $this->request->param('u')!=5){
- ($this->request->action()=='userban' || $this->request->param('u')==3)?$query->where('u.user_status', 0):$query->where('u.user_status', 1);
- }
- //代表是否筛选
- ($this->request->action()=='screen' || $this->request->param('u')==4)?$query->where('u.is_screen', 1):$query->where('u.is_screen', 0);
- //代表是否注销
- if($this->request->action()!='userban' && $this->request->param('u')!=3){
- ($this->request->action()=='userlogout' || $this->request->param('u')==5)?$query->where('u.user_status', -1):$query->where('u.user_status', 1);
- }
- //$data = $this->request->param();
- if (!empty($data['uid'])) {
- $query->where('u.id', intval($data['uid']));
- }
- if (!empty($data['keyword'])) {
- $keyword = $data['keyword'];
- $query->where('u.user_nickname|u.real_name|u.mobile', 'like', "%$keyword%");
- }
- //年龄区间查询
- if((!empty($data['age1']) && $data['age1']!='none') && (!empty($data['age2']) && $data['age2']!='none')){
- $query->where('u.birthday',['>',strtotime($data['age1'])],['<',strtotime($data['age2'])],'and');
- $query->whereNotNull('u.birthday');
- }
- // //只有第一个年龄的情况下
- if((!empty($data['age1']) && $data['age1']!='none') && (empty($data['age2']) || $data['age2']=='none')){
- $birthday = $data['age1'];
- $query->whereRaw("YEAR(from_unixtime(u.`birthday`))=$birthday and u.birthday is not null ");
- }
- // //只有第二个年龄的情况下
- if((empty($data['age1']) || $data['age1']=='none') && (!empty($data['age2']) && $data['age2']!='none')){
- $birthday = $data['age2'];
- $query->whereRaw("YEAR(from_unixtime(u.`birthday`))=$birthday and u.birthday is not null ");
- }
- //身高区间查询
- if((!empty(input('height')) && input('height')!='none') && (!empty(input('heightt')) && input('heightt')!='none')){
- $query->where('up.height',['>',input('height')],['<',input('heightt')],'and');
- }
- //身高第一个查找
- if((!empty(input('height')) && input('height')!='none') && (empty(input('heightt')) || input('heightt')=='none')){
- $query->where('up.height',input('height'));
- }
- //身高第二个查找
- if((empty(input('height')) ||input('height')=='none') && (!empty(input('heightt')) && input('heightt')!='none')){
- $query->where('up.height',input('heightt'));
- }
- //学历
- if((!empty(input('education')) && input('education')!='none') ){
- $query->where('up.education',input('education'));
- }
- //职位
- if((!empty(input('occupation')) && input('occupation')!='none') ){
- $query->where('up.occupation',input('occupation'));
- }
- //收入
- if((!empty(input('salary')) && input('salary')!='none') ){
- $query->where('up.salary',input('salary'));
- }
- //资产
- if((!empty(input('property')) && input('property')!='none') ){
- $query->where('up.property',input('property'));
- }
- //家乡
- if((!empty(input('home_city')) && input('home_city')!='none') ){
- $query->where('up.home_province|up.home_city','like','%'.input('home_city').'%','or');
- }
- //居住地(市)
- if((!empty(input('city')) && input('city')!='none') ){
- $query->where('up.city','like','%'.input('city').'%');
- }
- //婚姻状况
- if((!empty(input('married')) && input('married')!='none') ){
- $query->where('up.married',input('married'));
- }
- //性别
- if((!empty(input('sex')) && input('sex')!='none') ){
- $query->where('u.sex',input('sex'));
- }
- })
- //待审核
- ->order("u.create_time DESC")
- ->paginate(10,false,['query'=>request()->param()])
- ->each(function($item,$key){
- $item['marketusername'] = Db::name('user')->where('id',$item['parent_id'])->field('real_name,user_nickname')->find();
- $item['marketcount'] = Db::name('user')->where(array('parent_id'=>$item['id'],'agent_type'=>1))->count('id');
- $item['marketusercount'] = Db::name('user')->where(array('parent_id' =>$item['id'],'agent_type'=>0))->count('id');
- return $item;
- })
- ;
- // echo Db::name('user')->getLastSql();die;
- // 获取分页显示
- $page = $list->render();
- $this->assign('list', $list);
- $this->assign('page', $page);
-
- return $this->fetch();
- }
- //分销员审核
- public function marketexamine(){
- $data = $this->request->param();
- session('search',[
- 'uid' => isset($data['uid'])? intval($data['uid']) : 0,
- 'keyword' => isset($data['keyword'])? trim($data['keyword']) : '',
- ]);
- // 添加返回历史修改 by wesmiler 2020-02-16
- $history = isset($data['history'])? intval($data['history']) : 0;
- if($history){
- $data = session('user_search');
- }else{
- session('user_search', $data);
- }
- // 修改 end
- //var_dump($data);die;
- $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,
- up.idcard_check,up.position_check,up.education_check')
- ->alias('u')
- ->join('user_profile up','u.id=up.userid','left')
-
- ->where(function (Query $query) use($data){
- $query->where('u.user_type', 2);
- $query->where('u.openid', 'not in','');
- $query->where('u.agent_type',1);
- $query->where('u.agent_status',2); //待审核
- //代表是否付费定制
- ($this->request->action()=='custom' || $this->request->param('u')==2)?$query->where('u.is_vip', 1):$query->where('u.is_vip', 0);
- //代表是否冻结
- if($this->request->action()!='userlogout' && $this->request->param('u')!=5){
- ($this->request->action()=='userban' || $this->request->param('u')==3)?$query->where('u.user_status', 0):$query->where('u.user_status', 1);
- }
- //代表是否筛选
- ($this->request->action()=='screen' || $this->request->param('u')==4)?$query->where('u.is_screen', 1):$query->where('u.is_screen', 0);
- //代表是否注销
- if($this->request->action()!='userban' && $this->request->param('u')!=3){
- ($this->request->action()=='userlogout' || $this->request->param('u')==5)?$query->where('u.user_status', -1):$query->where('u.user_status', 1);
- }
- //$data = $this->request->param();
- if (!empty($data['uid'])) {
- $query->where('u.id', intval($data['uid']));
- }
- if (!empty($data['keyword'])) {
- $keyword = $data['keyword'];
- $query->where('u.user_nickname|u.real_name|u.mobile', 'like', "%$keyword%");
- }
- //年龄区间查询
- if((!empty($data['age1']) && $data['age1']!='none') && (!empty($data['age2']) && $data['age2']!='none')){
- $query->where('u.birthday',['>',strtotime($data['age1'])],['<',strtotime($data['age2'])],'and');
- $query->whereNotNull('u.birthday');
- }
- // //只有第一个年龄的情况下
- if((!empty($data['age1']) && $data['age1']!='none') && (empty($data['age2']) || $data['age2']=='none')){
- $birthday = $data['age1'];
- $query->whereRaw("YEAR(from_unixtime(u.`birthday`))=$birthday and u.birthday is not null ");
- }
- // //只有第二个年龄的情况下
- if((empty($data['age1']) || $data['age1']=='none') && (!empty($data['age2']) && $data['age2']!='none')){
- $birthday = $data['age2'];
- $query->whereRaw("YEAR(from_unixtime(u.`birthday`))=$birthday and u.birthday is not null ");
- }
- //身高区间查询
- if((!empty(input('height')) && input('height')!='none') && (!empty(input('heightt')) && input('heightt')!='none')){
- $query->where('up.height',['>',input('height')],['<',input('heightt')],'and');
- }
- //身高第一个查找
- if((!empty(input('height')) && input('height')!='none') && (empty(input('heightt')) || input('heightt')=='none')){
- $query->where('up.height',input('height'));
- }
- //身高第二个查找
- if((empty(input('height')) ||input('height')=='none') && (!empty(input('heightt')) && input('heightt')!='none')){
- $query->where('up.height',input('heightt'));
- }
- //学历
- if((!empty(input('education')) && input('education')!='none') ){
- $query->where('up.education',input('education'));
- }
- //职位
- if((!empty(input('occupation')) && input('occupation')!='none') ){
- $query->where('up.occupation',input('occupation'));
- }
- //收入
- if((!empty(input('salary')) && input('salary')!='none') ){
- $query->where('up.salary',input('salary'));
- }
- //资产
- if((!empty(input('property')) && input('property')!='none') ){
- $query->where('up.property',input('property'));
- }
- //家乡
- if((!empty(input('home_city')) && input('home_city')!='none') ){
- $query->where('up.home_province|up.home_city','like','%'.input('home_city').'%','or');
- }
- //居住地(市)
- if((!empty(input('city')) && input('city')!='none') ){
- $query->where('up.city','like','%'.input('city').'%');
- }
- //婚姻状况
- if((!empty(input('married')) && input('married')!='none') ){
- $query->where('up.married',input('married'));
- }
- //性别
- if((!empty(input('sex')) && input('sex')!='none') ){
- $query->where('u.sex',input('sex'));
- }
- })
- //待审核
- ->order("u.agent_create_time DESC")
- ->paginate(10,false,['query'=>request()->param()]);
- //echo Db::name('user')->getLastSql();die;
- // 获取分页显示
- $page = $list->render();
- $this->assign('list', $list);
- $this->assign('page', $page);
-
- return $this->fetch();
- }
- //分销一级用户显示
- public function Marketoneuser(){
- $data = $this->request->param();
- session('search',[
- 'uid' => isset($data['uid'])? intval($data['uid']) : 0,
- 'keyword' => isset($data['keyword'])? trim($data['keyword']) : '',
- ]);
- // 添加返回历史修改 by wesmiler 2020-02-16
- $history = isset($data['history'])? intval($data['history']) : 0;
- if($history){
- $data = session('user_search');
- }else{
- session('user_search', $data);
- }
- // 修改 end
- //var_dump($data);die;
- $list = Db::name('user')->field('u.id,u.user_login,u.user_nickname,u.real_name,u.redheart,u.is_tuijian,u.parent_id,u.create_time,u.is_heart,u.user_status,u.balance,u.mobile,u.level,u.freezing,u.updated_at,last_login_time,up.idcard,
- up.idcard_check,up.position_check,up.education_check')
- ->alias('u')
- ->join('user_profile up','u.id=up.userid','left')
-
- ->where(function (Query $query) use($data){
- $query->where('u.user_type', 2);
- // $query->where('u.agent_type', 1); //分销用户
-
- $query->where('u.openid', 'not in','');
- if($data['agent_type']==0){
- $query->where(array('u.parent_id' =>$data['id'],'u.agent_type'=>0));
- }
- if($data['agent_type']==1){
- $query->where(array('u.parent_id' =>$data['id'],'u.agent_type'=>1));
- }
-
- //代表是否付费定制
- ($this->request->action()=='custom' || $this->request->param('u')==2)?$query->where('u.is_vip', 1):$query->where('u.is_vip', 0);
- //代表是否冻结
- if($this->request->action()!='userlogout' && $this->request->param('u')!=5){
- ($this->request->action()=='userban' || $this->request->param('u')==3)?$query->where('u.user_status', 0):$query->where('u.user_status', 1);
- }
- //代表是否筛选
- ($this->request->action()=='screen' || $this->request->param('u')==4)?$query->where('u.is_screen', 1):$query->where('u.is_screen', 0);
- //代表是否注销
- if($this->request->action()!='userban' && $this->request->param('u')!=3){
- ($this->request->action()=='userlogout' || $this->request->param('u')==5)?$query->where('u.user_status', -1):$query->where('u.user_status', 1);
- }
- //$data = $this->request->param();
- if (!empty($data['uid'])) {
- $query->where('u.id', intval($data['uid']));
- }
- if (!empty($data['keyword'])) {
- $keyword = $data['keyword'];
- $query->where('u.user_nickname|u.real_name|u.mobile', 'like', "%$keyword%");
- }
- //年龄区间查询
- if((!empty($data['age1']) && $data['age1']!='none') && (!empty($data['age2']) && $data['age2']!='none')){
- $query->where('u.birthday',['>',strtotime($data['age1'])],['<',strtotime($data['age2'])],'and');
- $query->whereNotNull('u.birthday');
- }
- // //只有第一个年龄的情况下
- if((!empty($data['age1']) && $data['age1']!='none') && (empty($data['age2']) || $data['age2']=='none')){
- $birthday = $data['age1'];
- $query->whereRaw("YEAR(from_unixtime(u.`birthday`))=$birthday and u.birthday is not null ");
- }
- // //只有第二个年龄的情况下
- if((empty($data['age1']) || $data['age1']=='none') && (!empty($data['age2']) && $data['age2']!='none')){
- $birthday = $data['age2'];
- $query->whereRaw("YEAR(from_unixtime(u.`birthday`))=$birthday and u.birthday is not null ");
- }
- //身高区间查询
- if((!empty(input('height')) && input('height')!='none') && (!empty(input('heightt')) && input('heightt')!='none')){
- $query->where('up.height',['>',input('height')],['<',input('heightt')],'and');
- }
- //身高第一个查找
- if((!empty(input('height')) && input('height')!='none') && (empty(input('heightt')) || input('heightt')=='none')){
- $query->where('up.height',input('height'));
- }
- //身高第二个查找
- if((empty(input('height')) ||input('height')=='none') && (!empty(input('heightt')) && input('heightt')!='none')){
- $query->where('up.height',input('heightt'));
- }
- //学历
- if((!empty(input('education')) && input('education')!='none') ){
- $query->where('up.education',input('education'));
- }
- //职位
- if((!empty(input('occupation')) && input('occupation')!='none') ){
- $query->where('up.occupation',input('occupation'));
- }
- //收入
- if((!empty(input('salary')) && input('salary')!='none') ){
- $query->where('up.salary',input('salary'));
- }
- //资产
- if((!empty(input('property')) && input('property')!='none') ){
- $query->where('up.property',input('property'));
- }
- //家乡
- if((!empty(input('home_city')) && input('home_city')!='none') ){
- $query->where('up.home_province|up.home_city','like','%'.input('home_city').'%','or');
- }
- //居住地(市)
- if((!empty(input('city')) && input('city')!='none') ){
- $query->where('up.city','like','%'.input('city').'%');
- }
- //婚姻状况
- if((!empty(input('married')) && input('married')!='none') ){
- $query->where('up.married',input('married'));
- }
- //性别
- if((!empty(input('sex')) && input('sex')!='none') ){
- $query->where('u.sex',input('sex'));
- }
- })
- //待审核
- ->order("u.create_time DESC")
- ->paginate(10,false,['query'=>request()->param()])
- ->each(function($item,$key){
- $item['marketusername'] = Db::name('user')->where('id',$item['parent_id'])->field('real_name,user_nickname')->find();
- $item['marketcount'] = Db::name('user')->where('parent_id',$item['id'])->count('id');
- $item['marketusercount'] = Db::name('user')->where(array('parent_id'=>$item['id'],'agent_type'=>0))->count('id');//普通用户会员,不是分销员
- return $item;
- })
- ;
- //echo Db::name('user')->getLastSql();die;
- // 获取分页显示
- $page = $list->render();
-
- $this->assign('list', $list);
- $this->assign('page', $page);
-
- return $this->fetch();
- }
- //显示子级用户显示
- public function Markettwouser(){
- $data = $this->request->param();
- session('search',[
- 'uid' => isset($data['uid'])? intval($data['uid']) : 0,
- 'keyword' => isset($data['keyword'])? trim($data['keyword']) : '',
- ]);
- // 添加返回历史修改 by wesmiler 2020-02-16
- $history = isset($data['history'])? intval($data['history']) : 0;
- if($history){
- $data = session('user_search');
- }else{
- session('user_search', $data);
- }
- // 修改 end
- //var_dump($data);die;
- $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,
- up.idcard_check,up.position_check,up.education_check')
- ->alias('u')
- ->join('user_profile up','u.id=up.userid','left')
-
- ->where(function (Query $query) use($data){
- $query->where('u.user_type', 2);
- $query->where('u.openid', 'not in','');
- $query->where('u.agent_type',1);
- //代表是否付费定制
- ($this->request->action()=='custom' || $this->request->param('u')==2)?$query->where('u.is_vip', 1):$query->where('u.is_vip', 0);
- //代表是否冻结
- if($this->request->action()!='userlogout' && $this->request->param('u')!=5){
- ($this->request->action()=='userban' || $this->request->param('u')==3)?$query->where('u.user_status', 0):$query->where('u.user_status', 1);
- }
- //代表是否筛选
- ($this->request->action()=='screen' || $this->request->param('u')==4)?$query->where('u.is_screen', 1):$query->where('u.is_screen', 0);
- //代表是否注销
- if($this->request->action()!='userban' && $this->request->param('u')!=3){
- ($this->request->action()=='userlogout' || $this->request->param('u')==5)?$query->where('u.user_status', -1):$query->where('u.user_status', 1);
- }
- //$data = $this->request->param();
- if (!empty($data['uid'])) {
- $query->where('u.id', intval($data['uid']));
- }
- if (!empty($data['keyword'])) {
- $keyword = $data['keyword'];
- $query->where('u.user_nickname|u.real_name|u.mobile', 'like', "%$keyword%");
- }
- //年龄区间查询
- if((!empty($data['age1']) && $data['age1']!='none') && (!empty($data['age2']) && $data['age2']!='none')){
- $query->where('u.birthday',['>',strtotime($data['age1'])],['<',strtotime($data['age2'])],'and');
- $query->whereNotNull('u.birthday');
- }
- // //只有第一个年龄的情况下
- if((!empty($data['age1']) && $data['age1']!='none') && (empty($data['age2']) || $data['age2']=='none')){
- $birthday = $data['age1'];
- $query->whereRaw("YEAR(from_unixtime(u.`birthday`))=$birthday and u.birthday is not null ");
- }
- // //只有第二个年龄的情况下
- if((empty($data['age1']) || $data['age1']=='none') && (!empty($data['age2']) && $data['age2']!='none')){
- $birthday = $data['age2'];
- $query->whereRaw("YEAR(from_unixtime(u.`birthday`))=$birthday and u.birthday is not null ");
- }
- //身高区间查询
- if((!empty(input('height')) && input('height')!='none') && (!empty(input('heightt')) && input('heightt')!='none')){
- $query->where('up.height',['>',input('height')],['<',input('heightt')],'and');
- }
- //身高第一个查找
- if((!empty(input('height')) && input('height')!='none') && (empty(input('heightt')) || input('heightt')=='none')){
- $query->where('up.height',input('height'));
- }
- //身高第二个查找
- if((empty(input('height')) ||input('height')=='none') && (!empty(input('heightt')) && input('heightt')!='none')){
- $query->where('up.height',input('heightt'));
- }
- //学历
- if((!empty(input('education')) && input('education')!='none') ){
- $query->where('up.education',input('education'));
- }
- //职位
- if((!empty(input('occupation')) && input('occupation')!='none') ){
- $query->where('up.occupation',input('occupation'));
- }
- //收入
- if((!empty(input('salary')) && input('salary')!='none') ){
- $query->where('up.salary',input('salary'));
- }
- //资产
- if((!empty(input('property')) && input('property')!='none') ){
- $query->where('up.property',input('property'));
- }
- //家乡
- if((!empty(input('home_city')) && input('home_city')!='none') ){
- $query->where('up.home_province|up.home_city','like','%'.input('home_city').'%','or');
- }
- //居住地(市)
- if((!empty(input('city')) && input('city')!='none') ){
- $query->where('up.city','like','%'.input('city').'%');
- }
- //婚姻状况
- if((!empty(input('married')) && input('married')!='none') ){
- $query->where('up.married',input('married'));
- }
- //性别
- if((!empty(input('sex')) && input('sex')!='none') ){
- $query->where('u.sex',input('sex'));
- }
- })
- //待审核
- ->order("u.create_time DESC")
- ->paginate(10,false,['query'=>request()->param()]);
- // echo Db::name('user')->getLastSql();die;
- // 获取分页显示
- $page = $list->render();
- $this->assign('list', $list);
- $this->assign('page', $page);
-
- return $this->fetch();
- }
-
- /**
- * 审核通过和审核不通过的弹框
- */
- public function goconfrom(){
- $this->assign("id",input('id'));
- return $this->fetch('marketconfrom');
- }
- /**
- * 审核通过和审核不通过的弹框操作
- */
- public function doconfrom(){
- $param= $this->request->param();
- if(isset($param['yes']) && isset($param['id'])){
- //开始进行调用成功发送
- $data['agent_status'] = 1; //已审核
- $data['agent_type'] = 1; //分销用户
- $result=Db::name('user')->where('id',$param['id'])->update($data);
- // echo Db::name('user')->getLastSql();die();
- //通过id来获得用户的openid
- $userinfo=Db::name('user')->where('id',$param['id'])->find();
- if($result){
- //发送模板
- $openid = isset($userinfo['openid'])? $userinfo['openid'] : '';
- if($openid){
- $checkTime = date('Y.m.d H:i');
- $remark = "感谢您对拾光的信任,我们一起解救单身青年!点击查看分销中心";
- $msgParams = [
- 'title' => "恭喜!!您的推广红娘账号已审核通过!",
- 'remark' => $remark,
- 'type' => 'confirm',
- 'keywords' => [
- 'keyword1' => [
- 'value' =>'推广红娘',
- 'color' => '#173177',
- ],
- 'keyword2' => [
- 'value' => '审核通过',
- 'color' => '#3FAD46',
- ],
- ],
- 'url' => url('/weixin/market/index', '', '', true),
- ];
-
- Wechat::sendTplMsg($openid, $msgParams);
- }
- echo 1;die;
- }else{
- echo 0;die;
- }
- }
- if(isset($param['no']) && isset($param['id'])){
- //开始进行调用成功发送
- $data['agent_status'] = 3; //审核未通过
- $data['agent_type'] = 0; //分销用户无
- $result=Db::name('user')->where('id',$param['id'])->update($data);
- // echo Db::name('user')->getLastSql();die();
- //通过id来获得用户的openid
- $userinfo=Db::name('user')->where('id',$param['id'])->find();
- if($result){
- //发送模板
- $openid = isset($userinfo['openid'])? $userinfo['openid'] : '';
- if($openid){
- $checkTime = date('Y.m.d H:i');
- $remark = $param['noremark'];
- $msgParams = [
- 'title' => "您的推广红娘账号不通过审核!",
- 'remark' => $remark,
- 'type' => 'confirm',
- 'keywords' => [
- 'keyword1' => [
- 'value' => '推广红娘',
- 'color' => '#173177',
- ],
- 'keyword2' => [
- 'value' => '审核不通过',
- 'color' => '#c9302c',
- ],
- ],
- 'url' => url('', '', '', true),
- ];
-
- Wechat::sendTplMsg($openid, $msgParams);
- }
- echo 1;die;
- }else{
- echo 0;die;
- }
- }
- }
- /**
- * 分销员奖励交易记录表
- */
- public function markettrans(){
- //
- /**搜索条件**/
- $trans_name = $this->request->param('user_nickname');
- $money = $this->request->param('money');
- //$userEmail = trim($this->request->param('user_email'));
- //账户明细表(包含用户名称,爱心,余额)
- $account_logs = Db::name('user_balance_log')
- ->alias('blog')
- ->join('user u','blog.user_id=u.id','left')
- ->where('blog.type','neq',1)
- ->where(function (Query $query) use ($trans_name,$money) {
- if ($trans_name) {
- $query->where('u.user_nickname', 'like', "%$trans_name%");
- }
- if ($money) {
- $query->where('blog.balance', $money);
- }
- })
- ->field('blog.*,u.user_nickname')
- ->order("blog.id DESC")
- ->paginate(10,false,['query'=>request()->param()])
- ->each(function($item,$key){
- $item['source_username'] = Db::name('user')->where(['id'=> $item['source_uid'], 'user_type'=> 2])->field('user_nickname')->find();
-
- return $item;
- })
- ;
- //echo Db::name('user_balance_log')->getLastSql();die();
- $account_logs->appends(['title' => $trans_name]);
- // 获取分页显示
- $page = $account_logs->render();
-
- $this->assign("page", $page);
- $this->assign("account_logs", $account_logs);
- return $this->fetch();
-
- }
- /**
- * 分销奖励和扣除查看详情
- */
- public function transinfo(){
- $id=input('id');
- $balance_log = Db::name('user_balance_log')
- ->alias('blog')
- ->join('user u','blog.user_id=u.id','left')
- ->where(function (Query $query) use ($id) {
- if ($id) {
- $query->where('blog.id', $id);
- }
- })
- ->field('blog.*,u.user_nickname,u.real_name')
- ->find();
-
- $this->assign($balance_log);
- return $this->fetch();
- }
- /**
- * 分销记录
- */
- public function marketrecord(){
-
- // echo Db::name('user')->getLastSql().var_dump( $result);die();
- /**搜索条件**/
- $trans_name = $this->request->param('user_nickname');
- $money = $this->request->param('money');
- //$userEmail = trim($this->request->param('user_email'));
- //账户明细表(包含用户名称,爱心,余额)
- $balance_logs = Db::name('user_balance_log')
- ->alias('blog')
- ->join('user u','blog.user_id=u.id','left')
- ->whereIn('blog.type',[31,32])
- ->where(function (Query $query) use ($trans_name,$money) {
- if ($trans_name) {
- $query->where('u.user_nickname', 'like', "%$trans_name%");
- }
- if ($money) {
- $query->where('blog.balance', $money);
- }
- })
- ->field('blog.*,u.user_nickname')
- ->order("blog.id DESC")
- ->paginate(10,false,['query'=>request()->param()])
- ->each(function($item,$key){
- $item['source_username'] = Db::name('user')->where(['id'=> $item['source_uid'], 'user_type'=> 2])->field('user_nickname')->find();
-
- return $item;
- })
- ;
- //echo Db::name('user_balance_log')->getLastSql();die();
- $balance_logs->appends(['title' => $trans_name]);
- // 获取分页显示
- $page = $balance_logs->render();
- // var_dump($balance_logs);die();
- $this->assign("page", $page);
- $this->assign("balance_logs", $balance_logs);
- return $this->fetch();
- }
- //假删除用户
- public function todelete(){
- $param = $this->request->param();
- if (isset($param['ids']) && isset($param["yes"])) {
- $ids = $this->request->param('ids/a');
- Db::name('user')->where('id', 'in', $ids)->update(['agent_type' => 0,'agent_status' =>2]); //无,和待审核
- $this->success("删除成功!");
- }
- if (isset($_POST['ids']) && isset($param["no"])) {
- $ids = $this->request->param('ids/a');
- Db::name('user')->where('id', 'in', $ids)->update(['agent_type' => 1]);
- $this->success("取消删除成功!", '/market/marketexamine');
- }
- }
-
- /**
- * 显示奖励充值
- */
- public function marketshowreward(){
- $this->assign("id",input('id'));
- return $this->fetch();
- }
- /**
- * 进行奖励充值
- */
- public function markettoreward(){
- $this->assign("id",input('id'));
-
- $where = ['id' => input('id'), 'agent_type' => 1, 'agent_status' => 1];
- $result=Db::name('user')->where($where)->find();
- if ($result) {
- $awardMoney=$result['balance']+input('am');
- // 账户变动
- Db::startTrans();
- if (Member::where($where)->setInc('balance', input('am'))) {
- // 写入分销奖励日志
-
- $logTitle = "你获得了".input('ar')."奖励,额度".input('am')."元";
- $log = [
- 'change' => input('am'),
- 'type' => 31,
- 'level' => 1, //默认是1级
- 'change_type' => 1, //收入相对于客户。
- 'pay_money' => input('am'),
- 'user_id' => input('id'),
- 'source_uid' => 0,
- 'balance' => $awardMoney,
- 'description' => input('ar'),
- 'create_time' => time(),
- 'status' => 1,
- ];
- $logData['log'] = $log;
- //PRedis::set("{$cacheKey}:log", $logData, 7200);
- if(UserBalanceLog::insertGetId($log)){
- // 账户明细
- $accountData = [
- 'type' => 4,
- 'account_type' => 2,
- 'change_type' =>2,
- 'user_id' => input('id'),
- 'money' => input('am'),
- 'balance' => $awardMoney,
- 'created_at' => date('Y-m-d H:i:s'),
- 'remark' => input('ar'),
- ];
- if(AccountLog::insertGetId($accountData)){
- // 发送模板消息
- $openid = isset($result['openid'])? $result['openid'] : '';
- if($openid){
- $checkTime = date('Y.m.d H:i:s',time());
- $remark = input('ar');
- $msgParams = [
- 'title' => "您好,您有一笔奖励结算金额已入账",
- 'remark' => $remark,
- 'type' => 'income',
- 'keywords' => [
- 'keyword1' => [
- 'value' => '¥'.input('am'),
- 'color' => '#173177',
- ],
- 'keyword2' => [
- 'value' => $checkTime,
- 'color' => '#173177',
- ],
- ],
- 'url' => url('/weixin/market/income', '', '', true),
- ];
- // PRedis::set("{$cacheKey}:message", ['result' => $userInfoTwo, 'params' => $msgParams], 600);
- Wechat::sendTplMsg($openid, $msgParams);
- }
- Db::commit();
- }else{
- // PRedis::set("{$cacheKey}:account_log", $logData, 7200);
- Db::rollback();
- echo 0;die();
- }
- }else{
- //PRedis::set("{$cacheKey}:balance_log", $logData, 7200);
- Db::rollback();
- echo 0;die();
- }
- } else {
- // PRedis::set("{$cacheKey}:update_balance", $logData, 7200);
- Db::rollback();
- echo 0;die();
- }
- } else {
- // PRedis::set("{$cacheKey}:error_awardMoney", $logData, 7200);
- echo 0;die();
- }
- echo 1;die();
- }
- //提现审核
- public function withdraw(){
- $data = $this->request->param();
- session('search',[
- 'uid' => isset($data['uid'])? intval($data['uid']) : 0,
- 'keyword' => isset($data['keyword'])? trim($data['keyword']) : '',
- ]);
- // 添加返回历史修改 by wesmiler 2020-02-16
- $history = isset($data['history'])? intval($data['history']) : 0;
- if($history){
- $data = session('user_search');
- }else{
- session('user_search', $data);
- }
- // 修改 end
- //var_dump($data);die;
- $list = Db::name('user_balance_log')
- ->alias('ub')
- ->join('user u','u.id = ub.user_id','left')
- ->where(function (Query $query) use($data){
- $query->where('ub.type', 1);
- $query->where('ub.status',1); //待审核
- })
-
- ->field('ub.*,u.user_nickname,u.real_name')
- //待审核
- ->order("ub.create_time DESC")
- ->paginate(10,false,['query'=>request()->param()])
- ->each(function($item,$key){
- $item['source_username'] = Db::name('user')->where(['id'=> $item['source_uid'], 'user_type'=> 2])->field('real_name,user_nickname')->find();
-
- return $item;
- })
- ;
- //echo Db::name('user')->getLastSql();die;
- // 获取分页显示
- $page = $list->render();
- $this->assign('list', $list);
- $this->assign('page', $page);
- //var_dump($list);die();
- return $this->fetch("marketwithdraw");
- }
- //提现审核确认显示
- public function godrawconfrom(){
- $this->assign('id',input('id'));
- $this->assign('balance',input('balance'));
- return $this->fetch("marketdrawconfrom");
- }
- //进行提交审核提现。
- public function dodrawconfrom(){
- $param= $this->request->param();
-
- if(isset($param['yes']) && isset($param['id'])){
- //
- //通过userid来得到openid
- $result=Db::name('user_balance_log')
- ->alias('ub')
- ->join('user u','ub.user_id=u.id','left')
- ->where(['ub.id'=>$param['id']])
- ->field('ub.order_sn,ub.description,ub.user_id,ub.pay_money,ub.change,u.openid,ub.create_time')
- ->find();
- if (empty($result['openid'])) {
- echo 0;die;
- }
- $pay_moneys=($param['pay_money']!='')?$param['pay_money']:$result['pay_money'];
- //开始进行调用成功发送
- $order = array(
-
- 'orderNo' => $result['order_sn'], //订单号
- 'openid' => $result['openid'],
- 'amount' => $pay_moneys, //实际支付金额
- 'desc' =>$result['description'], //描述
-
- );
- //var_dump($order);die();
- $resulttrans=wechat::transferOrder($order); //进行调用发送企业到零钱打款模板信息
- //var_dump($resulttrans);die();
- if($resulttrans['result_code']=="SUCCESS"){
- // 增加账户明细
- $accountData = [
- 'type' => 8, //提现
- 'account_type' => 2, //余额类型
- 'change_type' => 1, //收入
- 'user_id' => $param['id'],
- 'money' => ($param['pay_money']!='')?$param['pay_money']:$result['pay_money'],
- 'balance' => $param['balance'],
- 'created_at' => date('Y-m-d H:i:s'),
- 'remark' => '客户进行提现',
- ];
- Db::startTrans();
- if(AccountLog::insertGetId($accountData)){
- //进行,变更审核成功。
- $data0['status'] = 2;
- $result0=Db::name('user_balance_log')->where('id',$param['id'])->update($data0);
- if($result0){
- //发送模板消息
- if($result['openid']){
- $checkTime = date('Y-m-d H:i:s',$result['create_time']);
- $giveTime = date('Y-m-d H:i:s',time());
- $remark = "您的提现已到账,请查收!";
- $msgParams=[
- 'title'=>$remark,
- 'remark'=>$remark,
- 'type' =>'withdraw',
- 'keywords' =>[
- 'keyword1'=>[
- 'value'=> ($param['pay_money']!='')?$param['pay_money']:$result['pay_money'],
- 'color'=>'#173177'
- ],
- 'keyword2'=>[
- 'value'=>$checkTime,
- 'color'=>'#173177'
- ],
- 'keyword3'=>[
- 'value'=>'商家转账入账',
- 'color'=>'#173177'
- ],
- 'keyword4'=>[
- 'value'=>$giveTime,
- 'color'=>'#173177'
- ],
- 'keyword5'=>[
- 'value'=>$result['order_sn'],
- 'color'=>'#173177',
- ]
- ],
- 'url' =>url('/weixin/Account/withdraw','','',true),
- ];
- wechat::sendTplMsg($result['openid'],$msgParams);
- }
- Db::commit();
- echo 1;die;
- }else{
- Db::rollback();
- echo 0;die;
- }
- }else{
- Db::rollback();
- echo 0;die();
- }
-
- }else{
- echo 0;die;
- }
-
-
- }
- if(isset($param['no']) && isset($param['id'])){
- //开始进行调用审核失败发送
- Db::startTrans();
- $data0['status'] = 2;
- $result0=Db::name('user_balance_log')->where('id',$param['id'])->update($data0);
-
- // $result=Activity::bookConfirm($param['id'],5,$param['noremark']);
- if(is_array($result)){
- Db::commit();
- echo 1;die;
- }else{
- //进行反扣回去
- $data0['balance'] +=$result['change'];
- Db::name('user_balance_log')->where('id',$param['id'])->update($data0);
- Db::name('user')->where('id',$result['user_id'])->update($data0);
- Db::rollback();
- echo 0;die;
- }
- }
-
- }
- //进行提交显示出团队人数。
- public function showteam(){
- return $this->fetch('marketoneuser');
- }
- //分销提现记录
- public function withdrawrecord(){
- $data = $this->request->param();
- session('search',[
- 'uid' => isset($data['uid'])? intval($data['uid']) : 0,
- 'keyword' => isset($data['keyword'])? trim($data['keyword']) : '',
- ]);
- // 添加返回历史修改 by wesmiler 2020-02-16
- $history = isset($data['history'])? intval($data['history']) : 0;
- if($history){
- $data = session('user_search');
- }else{
- session('user_search', $data);
- }
- // 修改 end
- //var_dump($data);die;
- $list = Db::name('user_balance_log')
- ->alias('ub')
- ->join('user u','u.id = ub.user_id','left')
- ->where(function (Query $query) use($data){
- $query->where('ub.type', 1);
- $query->where('ub.status','neq',1); //已审核
- })
-
- ->field('ub.*,u.user_nickname,u.real_name')
- //待审核
- ->order("ub.create_time DESC")
- ->paginate(10,false,['query'=>request()->param()])
- ->each(function($item,$key){
- $item['source_username'] = Db::name('user')->where(['id'=> $item['source_uid'], 'user_type'=> 2])->field('real_name,user_nickname')->find();
-
- return $item;
- })
- ;
- //echo Db::name('user')->getLastSql();die;
- // 获取分页显示
- $page = $list->render();
- $this->assign('list', $list);
- $this->assign('page', $page);
- return $this->fetch('marketwithdrawrecord');
- }
- //分销列表显示
- public function marketsetlist(){
- $list=Db::name('market')->paginate(10,false,['query'=>request()->param()]);
- $page = $list->render();
- $this->assign('list',$list);
- $this->assign('page',$page);
- return $this->fetch();
- }
-
- }
|