添加:权重值管理

This commit is contained in:
wuhui_zzw 2023-12-27 11:46:19 +08:00
parent ef516f06a8
commit 58659a686f
4 changed files with 123 additions and 2 deletions

View File

@ -15,6 +15,35 @@ class WeightValueLogRepository extends BaseRepository{
public function __construct(WeightValueLogDao $dao){
$this->dao = $dao;
}
/**
* Common: 获取变更记录
* Author: wu-hui
* Time: 2023/12/27 11:24
* @param array $params
* @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 getRecord(array $params,int $page,int $limit):array{
$query = $this->dao->getSearch([])
->withoutField('product_id,order_id,order_product_id,source')
->when((int)$params['uid'] > 0,function($query) use ($params){
$query->where('uid', (int)$params['uid']);
})
->with([
'user' => function($query){
$query->field('uid,nickname,avatar')->bind(['nickname','avatar']);
}
])
->order('id DESC');
$count = $query->count();
$list = $query->page($page,$limit)->select();
return compact('count','list');
}

View File

@ -68,9 +68,38 @@ class WeightValueRepository extends BaseRepository{
return $currentLevelList;
}
/**
* Common: 获取用户权重值持有信息
* Author: wu-hui
* Time: 2023/12/27 11:13
* @param array $params
* @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 getHoldList(array $params,int $page,int $limit):array{
$query = $this->dao->getSearch([])
->when((int)$params['uid'] > 0,function($query) use ($params){
$query->where('uid', (int)$params['uid']);
})
->with([
'user' => function($query){
$query->field('uid,nickname,avatar')->bind(['nickname','avatar']);
}
])
->group('uid')
->order('id DESC');
$count = $query->count();
$list = $query
->field('id,uid,brokerage_level,sum(quantity) as sum_quantity')
->page($page,$limit)
->select();
return compact('count','list');
}

View File

@ -0,0 +1,56 @@
<?php
namespace app\controller\admin\store\marketing;
use app\common\repositories\store\platformCommission\WeightValueLogRepository;
use app\common\repositories\store\platformCommission\WeightValueRepository;
use crmeb\basic\BaseController;
use think\App;
class PlatformCommissionWeightValue extends BaseController{
protected $repository;
public function __construct(App $app,WeightValueRepository $repository){
parent::__construct($app);
$this->repository = $repository;
}
/**
* Common: 持有列表
* Author: wu-hui
* Time: 2023/12/27 11:13
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function holdList(){
[$page, $limit] = $this->getPage();
$params = $this->request->params(['uid']);
$data = $this->repository->getHoldList((array)$params,(int)$page,(int)$limit);
return app('json')->success($data);
}
/**
* Common: 变更记录
* Author: wu-hui
* Time: 2023/12/27 11:29
* @param WeightValueLogRepository $repository
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function changeRecord(WeightValueLogRepository $repository){
[$page, $limit] = $this->getPage();
$params = $this->request->params(['uid']);
$data = $repository->getRecord((array)$params,(int)$page,(int)$limit);
return app('json')->success($data);
}
}

View File

@ -440,6 +440,13 @@ Route::group(function () {
Route::get('record_list', '.platformCommission/recordList')->name('platformCommissionRecordList')->option([
'_alias' => '抽成记录',
]);
// 权重值
Route::get('weight_value_hold_list', '.platformCommissionWeightValue/holdList')->name('platformCommissionWeightValueHoldList')->option([
'_alias' => '持有信息',
]);
Route::get('weight_value_change_record', '.platformCommissionWeightValue/changeRecord')->name('platformCommissionWeightValueChangeRecord')->option([
'_alias' => '变更记录',
]);