增加:餐费积分管理相关接口
This commit is contained in:
parent
eed4a097fd
commit
f807be9ead
|
|
@ -34,7 +34,17 @@ class MerchantShareholderIntegralDao extends BaseDao{
|
|||
->when(isset($params['status']) && $params['status'] !== '',function($query) use ($params){
|
||||
$query->where('status', (int)$params['status']);
|
||||
})
|
||||
->order('create_time DESC,id DESC');
|
||||
->with([
|
||||
'user' => function($query){
|
||||
$query->field('uid,nickname,avatar,phone');
|
||||
},
|
||||
'merchant' => function($query){
|
||||
$query->field('mer_id,mer_avatar,mer_name');
|
||||
},
|
||||
'level' => function($query){
|
||||
$query->field('id,title as level_name')->bind(['level_name']);
|
||||
}
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ namespace app\common\model\system\merchant;
|
|||
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
use app\common\model\user\User;
|
||||
|
||||
class MerchantShareholderIntegral extends BaseModel{
|
||||
|
||||
|
|
@ -16,8 +17,17 @@ class MerchantShareholderIntegral extends BaseModel{
|
|||
|
||||
|
||||
|
||||
public function user(){
|
||||
return $this->hasOne(User::class, 'uid', 'uid');
|
||||
}
|
||||
|
||||
public function merchant(){
|
||||
return $this->hasOne(Merchant::class,'mer_id','mer_id');
|
||||
}
|
||||
|
||||
public function level(){
|
||||
return $this->hasOne(MerchantShareholderLevel::class,'id','level_id');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,61 @@ class MerchantShareholderIntegralRepository extends BaseRepository{
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Common: 获取分组持有信息(同股东等级、门店、用户为一组)
|
||||
* Author: wu-hui
|
||||
* Time: 2024/06/20 9:32
|
||||
* @param array $params
|
||||
* @param int $page
|
||||
* @param int $limit
|
||||
* @return array
|
||||
*/
|
||||
public function groupList(array $params,int $page,int $limit){
|
||||
// 查询模型
|
||||
$query = $this->getSearchModel($params)
|
||||
->field([
|
||||
'uid',
|
||||
'mer_id',
|
||||
'level_id',
|
||||
'CONCAT(uid,"_",mer_id,"_",level_id) as group_key',
|
||||
'SUM(integral_total) as sum_integral_total',
|
||||
'SUM(integral_use) as sum_integral_use',
|
||||
'SUM(CASE status WHEN 2 THEN (integral_total - integral_use) ELSE 0 END) as sum_used_overdue',// 已过期可用
|
||||
'SUM(CASE status WHEN 0 THEN integral_total ELSE 0 END) as sum_used_freeze',// 冻结中可用
|
||||
'SUM(CASE status WHEN 1 THEN (integral_total - integral_use) ELSE 0 END) as sum_used_surplus',// 当前可用
|
||||
])
|
||||
->group('group_key')
|
||||
->order('create_time DESC,id DESC');
|
||||
// 信息获取
|
||||
$count = $query->count();
|
||||
$list = $query->page($page,$limit)->select()->toArray();
|
||||
|
||||
return compact('count','list');
|
||||
}
|
||||
/**
|
||||
* Common: 获取信息列表
|
||||
* Author: wu-hui
|
||||
* Time: 2024/06/20 10:21
|
||||
* @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 getList(array $params,int $page,int $limit){
|
||||
// 查询模型
|
||||
$query = $this->getSearchModel($params)->order('id asc');
|
||||
// 信息获取
|
||||
$count = $query->count();
|
||||
$list = $query->page($page,$limit)->select()->toArray();
|
||||
|
||||
return compact('count','list');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
namespace app\controller\admin\system\merchant;
|
||||
|
||||
|
||||
use app\common\repositories\system\merchant\MerchantShareholderIntegralRepository;
|
||||
use crmeb\basic\BaseController;
|
||||
use think\App;
|
||||
|
||||
|
||||
class ShareholderIntegral extends BaseController{
|
||||
|
||||
protected $repository;
|
||||
|
||||
public function __construct(App $app, MerchantShareholderIntegralRepository $repository){
|
||||
parent::__construct($app);
|
||||
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Common: 获取分组持有信息
|
||||
* Author: wu-hui
|
||||
* Time: 2024/06/20 9:33
|
||||
* @return mixed
|
||||
*/
|
||||
public function groupList(){
|
||||
[$page, $limit] = $this->getPage();
|
||||
$params = $this->request->params(['uid','mer_id','merchant_type']);
|
||||
$data = $this->repository->groupList((array)$params,(int)$page,(int)$limit);
|
||||
|
||||
return app('json')->success($data);
|
||||
}
|
||||
/**
|
||||
* Common: 获取明细列表
|
||||
* Author: wu-hui
|
||||
* Time: 2024/06/20 10:24
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getList(){
|
||||
[$page, $limit] = $this->getPage();
|
||||
$params = $this->request->params(['uid','mer_id','level_id','merchant_type']);
|
||||
$data = $this->repository->getList((array)$params,(int)$page,(int)$limit);
|
||||
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -170,7 +170,9 @@ Route::group(function () {
|
|||
Route::post('shareholder_level/del_info/:id','.ShareholderLevel/delInfo')->name('systemMerchantShareholderLevelDelInfo');
|
||||
Route::get('shareholder/list','.Shareholder/getList')->name('systemMerchantShareholderGetList');
|
||||
Route::post('shareholder/del_info/:id','.Shareholder/delInfo')->name('systemMerchantShareholderDelInfo');
|
||||
|
||||
// 共创股东 - 餐费积分
|
||||
Route::get('shareholder_integral/group_list','.ShareholderIntegral/groupList')->name('systemMerchantShareholderIntegralGroupList');
|
||||
Route::get('shareholder_integral/list','.ShareholderIntegral/getList')->name('systemMerchantShareholderIntegralGetList');
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue