add-liche-dealer-apply
This commit is contained in:
@@ -122,10 +122,11 @@ class Member extends HD_Controller{
|
||||
{
|
||||
$id = $this->input->post('id');
|
||||
$dealer = $this->input->post('dealer');
|
||||
$manage = $this->input->post('manage');
|
||||
|
||||
$upd = [
|
||||
'dealer' => $dealer,
|
||||
];
|
||||
$upd = [];
|
||||
isset($dealer) && $upd['dealer'] = $dealer;
|
||||
isset($manage) && $upd['manage'] = $manage;
|
||||
$this->userM->update($upd, array('id' => $id));
|
||||
|
||||
return $this->show_json(SYS_CODE_SUCCESS, '操作成功');
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
<th width="20%"><span>用户名称</span></th>
|
||||
<th width="20%"><span>手机号码</span></th>
|
||||
<th width="5%"><span>是否分销</span></th>
|
||||
<th width="5%"><span>分销管理</span></th>
|
||||
<th width="20%"><span>创建时间</span></th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
@@ -40,6 +41,9 @@
|
||||
<td>
|
||||
<input type="checkbox" class="mui-switch mui-switch-anim va-mid" true-value="1" false-value="0" <?=$v['dealer']&&!$v['up_uid']?'checked':''?> onchange="set_publish(this,<?=$v['id']?>)"/>
|
||||
</td>
|
||||
<td>
|
||||
<input type="checkbox" class="mui-switch mui-switch-anim va-mid" true-value="1" false-value="0" <?=$v['manage']?'checked':''?> onchange="set_publish(this,<?=$v['id']?>,'manage')"/>
|
||||
</td>
|
||||
<td><?= date('Y-m-d H:i:s',$v['c_time']) ?></td>
|
||||
<td>
|
||||
<?if($v['umajia']){?>
|
||||
@@ -69,14 +73,14 @@
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
function set_publish(obj,id){
|
||||
function set_publish(obj,id,field='dealer'){
|
||||
var value = '';
|
||||
if($(obj).get(0).checked) {
|
||||
value = 1;
|
||||
}else{
|
||||
value = 0;
|
||||
}
|
||||
var data = {'id':id,'dealer':value};
|
||||
var data = {'id':id,[field]:value};
|
||||
$.post('/app/liche/member/edit',data,function(result){
|
||||
if(result.code){
|
||||
layer.msg(result.msg, {time: 2000,icon:1 }, function () {
|
||||
|
||||
@@ -0,0 +1,170 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by Vim
|
||||
* User: lcc
|
||||
* Desc: 分销申请
|
||||
* Date: 2021.08.19
|
||||
* Time: 14:08
|
||||
*/
|
||||
require_once APPPATH . 'controllers/wxapp/Wxapp.php';
|
||||
class Apply extends Wxapp{
|
||||
|
||||
function __construct($inputs, $app_key){
|
||||
parent::__construct($inputs, $app_key);
|
||||
$this->login_white = '';//
|
||||
$this->check_status = array();//用户状态校验
|
||||
$this->check_mobile = array();//需要手机号
|
||||
$this->check_headimg = array();//授权微信信息
|
||||
$this->majia_white = array('get');//超级管理员披上马甲可操作权限
|
||||
$this->load->model('app/deal_apply_model','apply_model');
|
||||
}
|
||||
|
||||
protected function get(){
|
||||
$uid = $this->session['uid'];
|
||||
|
||||
$page = $this->input_param('page');
|
||||
$size = $this->input_param('size');
|
||||
!$page && $page = 1;
|
||||
!$size && $size = 20;
|
||||
|
||||
$where = [
|
||||
'app_id' => $this->app_id,
|
||||
'opt_uid' => $uid,
|
||||
'status' => 0
|
||||
];
|
||||
$rows = $this->apply_model->select($where,'id desc',$page,$size,'id,remark,status,app_uid');
|
||||
$total = $this->apply_model->count($where);
|
||||
$list = [];
|
||||
if($rows){
|
||||
$app_uids = array_column($rows,'app_uid');
|
||||
$user_rows = $this->app_user_model->get_map_by_ids($app_uids,'id,mobile');
|
||||
foreach($rows as $key => $val){
|
||||
$list[] = [
|
||||
'id' => $val['id'],
|
||||
'mobile' => $user_rows[$val['app_uid']] ? $user_rows[$val['app_uid']][0]['mobile']:'',
|
||||
'remark' => $val['remark'],
|
||||
];
|
||||
}
|
||||
}
|
||||
$data = [
|
||||
'list' => $list,
|
||||
'total' => $total
|
||||
];
|
||||
if($page==1){
|
||||
$data['statistics'] = $this->statistics();
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function put(){
|
||||
$uid = $this->session['uid'];
|
||||
|
||||
$id = $this->input_param('id');
|
||||
$status = $this->input_param('status');
|
||||
$row = $this->apply_model->get(['id'=>$id,'status'=>0]);
|
||||
if(!$row){
|
||||
throw new Exception('参数错误', API_CODE_INVILD_PARAM);
|
||||
}
|
||||
$update = [
|
||||
'status' => $status==1 ? 1 : -1
|
||||
];
|
||||
$res = $this->apply_model->update($update,['id'=>$row['id']]);
|
||||
if($res){
|
||||
if($status==1){
|
||||
$this->app_user_model->update(['deal_uid'=>$uid,'dealer'=>1],['id'=>$row['app_uid']]);
|
||||
}
|
||||
throw new Exception('保存成功', API_CODE_SUCCESS);
|
||||
}else{
|
||||
throw new Exception('保存失败', API_CODE_FAIL);
|
||||
}
|
||||
}
|
||||
|
||||
protected function post(){
|
||||
$uid = $this->session['uid'];
|
||||
|
||||
$f_uid = $this->input_param('from_uid');
|
||||
$remark = $this->input_param('remark');
|
||||
if(!$f_uid || !$remark){
|
||||
throw new Exception('参数错误', API_CODE_INVILD_PARAM);
|
||||
}
|
||||
if($this->session['dealer']){
|
||||
throw new Exception('您已是分销人员', API_CODE_FAIL);
|
||||
}
|
||||
$where = [
|
||||
'app_id' => $this->app_id,
|
||||
'app_uid' => $uid,
|
||||
'status' => 0
|
||||
];
|
||||
$row = $this->apply_model->get($where);
|
||||
if($row){
|
||||
throw new Exception('申请成功', API_CODE_SUCCESS);
|
||||
}
|
||||
$add_data = [
|
||||
'app_id' => $this->app_id,
|
||||
'app_uid' => $uid,
|
||||
'opt_uid' => $f_uid,
|
||||
'remark' => $remark,
|
||||
'c_time' => time()
|
||||
];
|
||||
$this->apply_model->add($add_data);
|
||||
throw new Exception('申请成功', API_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
//获取我的分销用户
|
||||
protected function get_dealer(){
|
||||
|
||||
$page = $this->input_param('page');
|
||||
$size = $this->input_param('size');
|
||||
!$page && $page = 1;
|
||||
!$size && $size = 20;
|
||||
|
||||
$where = [
|
||||
'deal_uid' => $this->session['uid'],
|
||||
'dealer' => 1
|
||||
];
|
||||
$rows = $this->app_user_model->select($where,'id desc',$page,$size,'id,mobile');
|
||||
$total = $this->app_user_model->count($where);
|
||||
$list = [];
|
||||
if($rows){
|
||||
foreach($rows as $key => $val){
|
||||
$apply = $this->apply_model->get(['app_id'=>$this->app_id,'app_uid'=>$val['id'],'status'=>1],'remark');
|
||||
$list[] = [
|
||||
'id' => $val['id'],
|
||||
'mobile' => $val['mobile'],
|
||||
'remark' => $apply['remark']
|
||||
];
|
||||
}
|
||||
}
|
||||
$data = [
|
||||
'list' => $list,
|
||||
'total' => $total
|
||||
];
|
||||
if($page==1){
|
||||
$data['statistics'] = $this->statistics();
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
//解除分销关系
|
||||
protected function put_dealer(){
|
||||
$deal_uid = $this->session['uid'];
|
||||
$id = $this->input_param('id');
|
||||
$row = $this->app_user_model->get(['deal_uid'=>$deal_uid,'id'=>$id,'dealer'=>1]);
|
||||
if(!$row){
|
||||
throw new Exception('参数错误', API_CODE_INVILD_PARAM);
|
||||
}
|
||||
$res = $this->app_user_model->update(['deal_uid'=>0,'dealer'=>0],['id'=>$row['id']]);
|
||||
if($res){
|
||||
throw new Exception('保存成功', API_CODE_SUCCESS);
|
||||
}else{
|
||||
throw new Exception('保存失败', API_CODE_FAIL);
|
||||
}
|
||||
}
|
||||
|
||||
private function statistics(){
|
||||
$uid = $this->session['uid'];
|
||||
$dealers = $this->app_user_model->count(['deal_uid'=>$uid,'dealer'=>1]);
|
||||
$applying = $this->apply_model->count(['status'=>0,'opt_uid'=>$uid]);
|
||||
return ['dealer' => $dealers,'applying' => $applying];
|
||||
}
|
||||
}
|
||||
@@ -45,9 +45,7 @@ class Home extends Wxapp
|
||||
$img_url = $this->mdUserAccount->config()[$this->app_id]['deal']['img_url'];
|
||||
$bg_color = $this->mdUserAccount->config()[$this->app_id]['deal']['bg_color'];
|
||||
$reU = $this->app_user_model->get(array('id' => $this->uid));
|
||||
if ($reU['dealer'] != 1) {
|
||||
throw new Hd_exception('不是分销用户', API_CODE_FAIL);
|
||||
}
|
||||
|
||||
$shareTitle = $shareImg = $team_title = $team_url = $team_invite = '';
|
||||
if ($reU['up_uid'] == 0) {
|
||||
$shareTitle = '邀请您一起参与' . $this->cf_title . '分销';
|
||||
@@ -61,10 +59,14 @@ class Home extends Wxapp
|
||||
$team_url = '/pages/distribute/fans/index';
|
||||
}
|
||||
}
|
||||
$team_title && $menulist[] = array('title' => $team_title, 'url' => $team_url, 'img' => $img_url . '/distribute/index-icon-1.png');
|
||||
$menulist[] = array('title' => '佣金明细', 'url' => '/pages/distribute/reward/index', 'img' => $img_url . '/distribute/index-icon-2.png');
|
||||
$menulist[] = array('title' => '立即提现', 'url' => '/pages/distribute/cashout/index', 'img' => $img_url . '/distribute/index-icon-3.png');
|
||||
$menulist[] = array('title' => '分销商品库', 'url' => '/pages/distribute/goods/index', 'img' => $img_url . '/distribute/index-icon-4.png');
|
||||
if($this->session['dealer']){
|
||||
$menulist[] = ['title' => '推广素材', 'url' => '/pages/distribute/material/index', 'img' => $img_url . '/distribute/icon-sucai.png'];
|
||||
$menulist[] = ['title' => '推广数据', 'url' => '/pages/distribute/statistics/index', 'img' => $img_url . '/distribute/icon-shuju.png'];
|
||||
$menulist[] = ['title' => '佣金明细', 'url' => '/pages/distribute/reward/index', 'img' => $img_url . '/distribute/icon-yongjin.png'];
|
||||
!$this->session['up_uid'] && $this->session['dealer'] && $menulist[] = ['title' => '我的团队', 'url' => '/pages/distribute/team/index', 'img' => $img_url . '/distribute/icon-tuandui.png'];
|
||||
}
|
||||
$this->session['manage'] && $menulist[] = ['title' => '分销管理', 'url' => '/pages/distribute/apply/index', 'img' => $img_url . '/distribute/icon-shenqing.png'];
|
||||
$menulist[] = ['title' => '联系小狸', 'url' => '', 'img' => $img_url . '/distribute/icon-kefu.png'];
|
||||
$data = array(
|
||||
"title" => '分销',
|
||||
"bg" => array('color' => $bg_color, 'img' => $img_url . '/distribute/index-banner.png'),
|
||||
|
||||
@@ -95,6 +95,7 @@ class User extends Wxapp{
|
||||
'name' => $jsondata['alipay']['name'] ? $jsondata['alipay']['name'] : '',
|
||||
'account' => $jsondata['alipay']['account'] ? $jsondata['alipay']['account'] : '',
|
||||
],
|
||||
'isdealer' => $this->session['dealer'],
|
||||
'istop' => $istop,
|
||||
);
|
||||
|
||||
@@ -346,7 +347,9 @@ class User extends Wxapp{
|
||||
['title'=>'我的爱车','icon'=>'https://qs.haodian.cn/wechat_app/liche/mine/list-icon-1.png','url'=>'/pages/mine/myCar/index'],
|
||||
['title'=>'联系小狸','icon'=>'https://qs.haodian.cn/wechat_app/liche/mine/list-icon-3.png'],
|
||||
];
|
||||
$this->session['dealer'] && $about[] = ['title'=>'推广提现','icon'=>'https://qs.haodian.cn/wechat_app/liche/mine/list-icon-4.png','url'=>'/pages/distribute/index'];
|
||||
if($this->session['dealer'] || $this->session['manage']){
|
||||
$about[] = ['title'=>'推广提现','icon'=>'https://qs.haodian.cn/wechat_app/liche/mine/list-icon-4.png','url'=>'/pages/distribute/index'];
|
||||
}
|
||||
$data = [
|
||||
'progressOpt' => $progressOpt,
|
||||
'progress' => $progress,
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Deal_apply_model extends HD_Model
|
||||
{
|
||||
private $table_name = 'lc_app_deal_apply';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct($this->table_name, 'default');
|
||||
}
|
||||
}
|
||||
@@ -13,4 +13,23 @@ class App_liche_users_model extends HD_Model{
|
||||
{
|
||||
parent::__construct($this->table_name, 'default');
|
||||
}
|
||||
/**
|
||||
* 根据id获取数据
|
||||
* @param $ids
|
||||
* @param string $fileds
|
||||
* @return array
|
||||
*/
|
||||
public function get_map_by_ids($ids, $fileds = '')
|
||||
{
|
||||
$rows = [];
|
||||
$ids = array_filter($ids);
|
||||
if ($ids) {
|
||||
$cf_ids = implode(',', $ids);
|
||||
$where = [
|
||||
"id in ($cf_ids)" => null
|
||||
];
|
||||
$rows = $this->map('id', '', $where, '', '', '', $fileds);
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
}
|
||||
|
||||
+20
-4
@@ -7,9 +7,7 @@
|
||||
drop table if exists lc_app;
|
||||
create table lc_app (
|
||||
id int(11) not null auto_increment,
|
||||
name char(30) not null default '' comment '名称',
|
||||
logo varchar(128) not null default '' comment 'logo',
|
||||
jsondata text comment '更多数据',
|
||||
name char(30) not null default '' comment '名称', logo varchar(128) not null default '' comment 'logo', jsondata text comment '更多数据',
|
||||
c_time int(10) not null default '0' comment '创建时间',
|
||||
u_time timestamp not null default current_timestamp on update current_timestamp comment '更新时间',
|
||||
primary key (id)
|
||||
@@ -118,4 +116,22 @@ create table lc_app_deal_log (
|
||||
c_time int(11) not null default '0' comment '创建时间',
|
||||
u_time timestamp not null default current_timestamp on update current_timestamp comment '更新时间',
|
||||
primary key (id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='分销-记录表'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='分销-记录表';
|
||||
|
||||
-- ----------------------------
|
||||
-- Title:分销-申请表
|
||||
-- Author:lcc
|
||||
-- Table:lc_app_deal_apply
|
||||
-- ---------------------------
|
||||
drop table if exists lc_app_deal_apply;
|
||||
create table lc_app_deal_apply (
|
||||
id int(10) unsigned not null auto_increment comment '自增id',
|
||||
app_id int(10) unsigned not null default '0' comment '小程序id',
|
||||
app_uid int(10) unsigned not null default '0' comment '用户id',
|
||||
opt_uid int(10) unsigned not null default '0' comment '审核用户uid',
|
||||
remark varchar(255) not null default '' comment '备注',
|
||||
status tinyint(1) not null default '0' comment '状态(-1审核未通过 0待审核 1审核通过)',
|
||||
c_time int(10) unsigned not null default '0' comment '创建时间',
|
||||
u_time timestamp not null default current_timestamp on update current_timestamp comment '更新时间',
|
||||
primary key (id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='分销-申请表';
|
||||
|
||||
+4
-3
@@ -18,9 +18,10 @@ create table lc_app_liche_users (
|
||||
u_time timestamp not null default current_timestamp on update current_timestamp,
|
||||
primary key (id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='狸车小程序用户表';
|
||||
alter table lc_app_liche_users add dealer tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否分销' after jsondata;
|
||||
alter table lc_app_liche_users add up_uid int(10) NOT NULL DEFAULT '0' COMMENT '上级uid' after dealer;
|
||||
|
||||
alter table lc_app_liche_users add dealer tinyint(1) not null default '0' comment '是否分销' after jsondata;
|
||||
alter table lc_app_liche_users add up_uid int(10) not null default '0' comment '上级uid' after dealer;
|
||||
alter table lc_app_liche_users add manage tinyint(1) not null default 0 comment '是否分销管理' after dealer;
|
||||
alter table lc_app_liche_users add deal_uid int(10) not null default 0 comment '审核分销uid' after dealer;
|
||||
|
||||
-- ----------------------------
|
||||
-- Title:狸车小程序cms
|
||||
|
||||
Reference in New Issue
Block a user