| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091 |
- <?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\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',1)->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',1)->update($data)){
- $this->success('保存成功!');
- }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('parent_id',$item['id'])->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_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.openid', 'not in','');
- $query->where('u.parent_id',$data['id']);
- //代表是否付费定制
- ($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');
- 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;
- $result=Db::name('user')->where('id',$param['id'])->update($data);
- // echo Db::name('user')->getLastSql();die();
- //$result=Activity::bookConfirm($param['id'],3);
- // if(is_array($result)){
- if($result){
- echo 1;die;
- }else{
- echo 0;die;
- }
- }
- if(isset($param['no']) && isset($param['id'])){
- //开始进行调用审核失败发送
- // $result=Activity::bookConfirm($param['id'],5,$param['noremark']);
- if(is_array($result)){
- 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')
- ->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();
- $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')
- ->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]);
- $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'));
- return $this->fetch();
- }
- //提现审核
- 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'));
- 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')
- ->find();
- if (empty($result['openid'])) {
- echo 0;die;
- }
- //开始进行调用成功发送
- $order = array(
-
- 'orderNo' => $result['order_sn'], //订单号
- 'openid' => $result['openid'],
- 'amount' => $result['pay_money'], //实际支付金额
- 'desc' =>$result['description'], //描述
-
- );
- $resulttrans=wechat::transferOrder($order);
- if($resulttrans['result_code']=="SUCCESS"){
- //进行,变更审核成功。
- $data0['status'] = 2;
- $result=Db::name('user_balance_log')->where('id',$param['id'])->update($data0);
- if($result){
- echo 1;die;
- }else{
- echo 0;die;
- }
- }else{
- echo 0;die;
- }
-
-
- }
- if(isset($param['no']) && isset($param['id'])){
- //开始进行调用审核失败发送
- // $result=Activity::bookConfirm($param['id'],5,$param['noremark']);
- if(is_array($result)){
- 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);
- echo 0;die;
- }
- }
-
- }
- //进行提交显示出团队人数。
- public function showteam(){
- return $this->fetch('marketoneuser');
- }
-
- }
|