You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
286 lines
5.9 KiB
286 lines
5.9 KiB
<?php
|
|
namespace app\massage\controller;
|
|
use app\AdminRest;
|
|
use app\massage\model\City;
|
|
use app\massage\model\Coach;
|
|
use app\massage\model\CoachTimeList;
|
|
use app\massage\model\Comment;
|
|
use app\massage\model\Commission;
|
|
use app\massage\model\Order;
|
|
|
|
use app\massage\model\Salesman;
|
|
use app\massage\model\User;
|
|
use app\shop\model\OrderGoods;
|
|
|
|
use app\shop\model\Wallet;
|
|
use think\App;
|
|
use app\shop\model\Order as Model;
|
|
use think\facade\Db;
|
|
|
|
|
|
class AdminSalesman extends AdminRest
|
|
{
|
|
|
|
|
|
protected $model;
|
|
|
|
public function __construct(App $app) {
|
|
|
|
parent::__construct($app);
|
|
|
|
$this->model = new Salesman();
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
* @author chenniang
|
|
* @DataTime: 2023-04-21 11:17
|
|
* @功能说明:业务员列表
|
|
*/
|
|
public function salesmanList(){
|
|
|
|
$input = $this->_param;
|
|
|
|
$dis[] = ['a.uniacid','=',$this->_uniacid];
|
|
//是否是代理商
|
|
if($this->_user['is_admin']==0){
|
|
|
|
$dis[] = ['a.admin_id','=',$this->_user['id']];
|
|
|
|
}
|
|
|
|
if(!empty($input['admin_id'])){
|
|
|
|
$dis[] = ['a.admin_id','=',$input['admin_id']];
|
|
|
|
}
|
|
|
|
if(!empty($input['status'])){
|
|
|
|
$dis[] = ['a.status','=',$input['status']];
|
|
|
|
}else{
|
|
|
|
$dis[] = ['a.status','>',-1];
|
|
}
|
|
|
|
if(!empty($input['start_time'])&&!empty($input['end_time'])){
|
|
|
|
$dis[] = ['a.create_time','between',"{$input['start_time']},{$input['end_time']}"];
|
|
|
|
}
|
|
|
|
$where = [];
|
|
|
|
if(!empty($input['name'])){
|
|
|
|
$where[] = ['a.user_name','like','%'.$input['name'].'%'];
|
|
$where[] = ['a.phone','like','%'.$input['name'].'%'];
|
|
}
|
|
|
|
$data = $this->model->adminDataList($dis,$where,$input['limit']);
|
|
//获取各类状态的数量
|
|
$list = [
|
|
|
|
0=>'all',
|
|
|
|
1=>'ing',
|
|
|
|
2=>'pass',
|
|
|
|
4=>'nopass',
|
|
];
|
|
|
|
foreach ($list as $key=>$value){
|
|
|
|
$dis = [
|
|
|
|
'uniacid' => $this->_uniacid,
|
|
];
|
|
|
|
if(!empty($key)){
|
|
|
|
$dis['status'] = $key;
|
|
}
|
|
//是否是代理商
|
|
if($this->_user['is_admin']==0){
|
|
|
|
$dis['admin_id'] = $this->_user['id'];
|
|
}
|
|
|
|
$data[$value] = $this->model->where($dis)->where('status','>',-1)->count();
|
|
}
|
|
|
|
return $this->success($data);
|
|
}
|
|
|
|
|
|
/**
|
|
* @author chenniang
|
|
* @DataTime: 2023-04-21 11:30
|
|
* @功能说明:业务员详情
|
|
*/
|
|
public function salesmanInfo(){
|
|
|
|
$input = $this->_param;
|
|
|
|
$dis = [
|
|
|
|
'id' => $input['id']
|
|
];
|
|
|
|
$data = $this->model->dataInfo($dis);
|
|
|
|
$admin_model = new \app\massage\model\Admin();
|
|
|
|
$user_modle = new User();
|
|
|
|
$data['admin_name'] = $admin_model->where(['id'=>$data['admin_id'],'status'=>1])->value('agent_name');
|
|
|
|
$data['nickName'] = $user_modle->where(['id'=>$data['user_id'],'status'=>1])->value('nickName');
|
|
|
|
return $this->success($data);
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
* @author chenniang
|
|
* @DataTime: 2023-04-21 11:31
|
|
* @功能说明:审核业务员
|
|
*/
|
|
public function checkSalesman(){
|
|
|
|
$input = $this->_input;
|
|
|
|
$diss = [
|
|
|
|
'id' => $input['id']
|
|
];
|
|
|
|
$salesman = $this->model->dataInfo($diss);
|
|
|
|
if(isset($input['status'])&&in_array($input['status'],[2,4])&&$salesman['status']==1){
|
|
|
|
$input['sh_time'] = time();
|
|
}
|
|
//删除需要判断佣金提现
|
|
if(isset($input['status'])&&$input['status']==-1){
|
|
|
|
if($salesman['cash']>0){
|
|
|
|
$this->errorMsg('业务员还有佣金未提现');
|
|
}
|
|
|
|
$dis = [
|
|
|
|
'top_id' => $input['id'],
|
|
|
|
'status' => 1,
|
|
|
|
'type' => 12
|
|
];
|
|
|
|
$cash_model = new Commission();
|
|
|
|
$cash = $cash_model->dataInfo($dis);
|
|
|
|
if(!empty($cash)){
|
|
|
|
$this->errorMsg('业务员还有佣金未到账');
|
|
|
|
}
|
|
|
|
$dis = [
|
|
|
|
'coach_id' => $input['id'],
|
|
|
|
'status' => 1,
|
|
|
|
'type' => 6
|
|
];
|
|
|
|
$wallet_model = new \app\massage\model\Wallet();
|
|
|
|
$wallet = $wallet_model->dataInfo($dis);
|
|
|
|
if(!empty($wallet)){
|
|
|
|
$this->errorMsg('业务员还有提现未处理');
|
|
}
|
|
|
|
}
|
|
|
|
$res = $this->model->dataUpdate($diss,$input);
|
|
|
|
return $this->success($res);
|
|
}
|
|
|
|
|
|
/**
|
|
* @author chenniang
|
|
* @DataTime: 2023-04-21 11:17
|
|
* @功能说明:业务员数据列表
|
|
*/
|
|
public function salesmanDataList(){
|
|
|
|
$input = $this->_param;
|
|
|
|
$dis[] = ['a.uniacid','=',$this->_uniacid];
|
|
//是否是代理商
|
|
if($this->_user['is_admin']==0){
|
|
|
|
$dis[] = ['a.admin_id','=',$this->_user['id']];
|
|
|
|
}
|
|
|
|
$dis[] = ['a.status','=',2];
|
|
|
|
if(!empty($input['start_time'])&&!empty($input['end_time'])){
|
|
|
|
$dis[] = ['a.sh_time','between',"{$input['start_time']},{$input['end_time']}"];
|
|
|
|
}
|
|
|
|
$where = [];
|
|
|
|
if(!empty($input['name'])){
|
|
|
|
$where[] = ['a.user_name','like','%'.$input['name'].'%'];
|
|
|
|
$where[] = ['a.phone','like','%'.$input['name'].'%'];
|
|
|
|
$where[] = ['b.nickName','like','%'.$input['name'].'%'];
|
|
}
|
|
|
|
$data = $this->model->adminDataList($dis,$where,$input['limit']);
|
|
|
|
if(!empty($data['data'])){
|
|
|
|
$wallet_model = new \app\massage\model\Wallet();
|
|
|
|
foreach ($data['data'] as &$v){
|
|
//累计提现
|
|
$v['wallet_price'] = $wallet_model->where(['coach_id'=>$v['id'],'type'=>6])->where('status','in',[1,2])->sum('apply_price');
|
|
//总成交金额
|
|
$v['order_price'] = $this->model->salesmanOrderPrice($v['id']);
|
|
|
|
}
|
|
}
|
|
|
|
return $this->success($data);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|