添加:代理中心 - 代理佣金明细查看
This commit is contained in:
parent
507a612390
commit
6620161689
|
|
@ -35,6 +35,12 @@ class AgentBrokerageDao extends BaseDao{
|
||||||
->when(isset($params['province_uid']) && $params['province_uid'] !== '',function($query) use ($params){
|
->when(isset($params['province_uid']) && $params['province_uid'] !== '',function($query) use ($params){
|
||||||
$query->where('province_uid', (int)$params['province_uid']);
|
$query->where('province_uid', (int)$params['province_uid']);
|
||||||
})
|
})
|
||||||
|
->when(isset($params['initiator_uid']) && $params['initiator_uid'] !== '',function($query) use ($params){
|
||||||
|
$query->where('initiator_uid', (int)$params['initiator_uid']);
|
||||||
|
})
|
||||||
|
->when(isset($params['field_staff_uid']) && $params['field_staff_uid'] !== '',function($query) use ($params){
|
||||||
|
$query->where('field_staff_uid', (int)$params['field_staff_uid']);
|
||||||
|
})
|
||||||
->with([
|
->with([
|
||||||
'userOrder' => function($query){
|
'userOrder' => function($query){
|
||||||
$query->field('order_id,order_sn,create_time,title');
|
$query->field('order_id,order_sn,create_time,title');
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,66 @@ class AgentBrokerageRepository extends BaseRepository{
|
||||||
|
|
||||||
return compact('count','list');
|
return compact('count','list');
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Common: 获取单个代理人员的佣金明细
|
||||||
|
* Author: wu-hui
|
||||||
|
* Time: 2024/02/02 17:41
|
||||||
|
* @param int $agentId
|
||||||
|
* @param int $page
|
||||||
|
* @param int $limit
|
||||||
|
* @return array
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
*/
|
||||||
|
public function getAgentCommissionList(int $agentId,int $page,int $limit){
|
||||||
|
// 类型:1=发起人,2=省公司,3=省合伙人(外勤),4=省合伙人(内勤),5=区县运营商,6=区县合伙人,7=餐厅,8=配送商
|
||||||
|
$agentInfo = app()->make(AgentRepository::class)->getSearchModel(['id'=>$agentId])->findOrEmpty()->toArray();
|
||||||
|
$totalMoney = 0;
|
||||||
|
switch((int)$agentInfo['agent_type']){
|
||||||
|
case 1:
|
||||||
|
$query = $this->dao->searchList(['initiator_uid'=>$agentInfo['uid']])
|
||||||
|
->field(['*','initiator_brokerage as brokerage']);
|
||||||
|
$totalMoney = $query->sum('initiator_brokerage');
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
$query = $this->dao->searchList(['province_uid'=>$agentInfo['uid']])
|
||||||
|
->field(['*','province_brokerage as brokerage']);
|
||||||
|
$totalMoney = $query->sum('province_brokerage');
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
$query = $this->dao->searchList(['field_staff_uid'=>$agentInfo['uid']])
|
||||||
|
->field(['*','field_staff_brokerage as brokerage']);
|
||||||
|
$totalMoney = $query->sum('field_staff_brokerage');
|
||||||
|
break;
|
||||||
|
// case 4: break;
|
||||||
|
case 5:
|
||||||
|
$query = $this->dao->searchList(['area_store_uid'=>$agentInfo['uid']])
|
||||||
|
->field(['*','area_store_brokerage as brokerage']);
|
||||||
|
$totalMoney = $query->sum('area_store_brokerage');
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
$query = $this->dao->searchList(['area_uid'=>$agentInfo['uid']])
|
||||||
|
->field(['*','area_brokerage as brokerage']);
|
||||||
|
$totalMoney = $query->sum('area_brokerage');
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
$query = $this->dao->searchList(['store_uid'=>$agentInfo['uid']])
|
||||||
|
->field(['*','store_brokerage as brokerage']);
|
||||||
|
$totalMoney = $query->sum('store_brokerage');
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
$query = $this->dao->searchList(['delivery_uid'=>$agentInfo['uid']])
|
||||||
|
->field(['*','delivery_brokerage as brokerage']);
|
||||||
|
$totalMoney = $query->sum('delivery_brokerage');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// 列表信息获取
|
||||||
|
$count = $query->count();
|
||||||
|
$list = $query->page($page,$limit)->select();
|
||||||
|
|
||||||
|
return compact('count','list', 'totalMoney');
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Common: 邀请代理人员奖励
|
* Common: 邀请代理人员奖励
|
||||||
* Author: wu-hui
|
* Author: wu-hui
|
||||||
|
|
@ -141,5 +201,4 @@ class AgentBrokerageRepository extends BaseRepository{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ namespace app\controller\api;
|
||||||
|
|
||||||
use app\common\model\system\merchant\Merchant;
|
use app\common\model\system\merchant\Merchant;
|
||||||
use app\common\repositories\marketing\AgentApplyRepository;
|
use app\common\repositories\marketing\AgentApplyRepository;
|
||||||
|
use app\common\repositories\marketing\AgentBrokerageRepository;
|
||||||
use app\common\repositories\marketing\AgentRepository;
|
use app\common\repositories\marketing\AgentRepository;
|
||||||
use crmeb\basic\BaseController;
|
use crmeb\basic\BaseController;
|
||||||
use think\App;
|
use think\App;
|
||||||
|
|
@ -199,6 +200,19 @@ class Agent extends BaseController{
|
||||||
|
|
||||||
return app('json')->success($data);
|
return app('json')->success($data);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Common: 佣金列表获取
|
||||||
|
* Author: wu-hui
|
||||||
|
* Time: 2024/02/02 17:22
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function commissionList(){
|
||||||
|
[$page, $limit] = $this->getPage();
|
||||||
|
$agentId = $this->request->param('agent_id');
|
||||||
|
$data = app()->make(AgentBrokerageRepository::class)->getAgentCommissionList((int)$agentId,(int)$page,(int)$limit);
|
||||||
|
|
||||||
|
return app('json')->success($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -391,7 +391,7 @@ Route::group('api/', function () {
|
||||||
Route::post('agent_apply', 'apply');// 提交申请信息
|
Route::post('agent_apply', 'apply');// 提交申请信息
|
||||||
Route::post('apply_record', 'applyRecord');// 申请记录
|
Route::post('apply_record', 'applyRecord');// 申请记录
|
||||||
Route::get('apply_info', 'applyInfo');// 申请信息
|
Route::get('apply_info', 'applyInfo');// 申请信息
|
||||||
|
Route::get('commission_list', 'commissionList');// 佣金明细
|
||||||
|
|
||||||
|
|
||||||
})->prefix('api.Agent/');
|
})->prefix('api.Agent/');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue