parent
b6fc8f6078
commit
ccc85713f2
|
|
@ -6,6 +6,7 @@
|
|||
namespace app\common\repositories\user;
|
||||
|
||||
use app\common\dao\user\IntegralDao;
|
||||
use app\common\model\store\order\StoreOrder;
|
||||
use app\common\repositories\BaseRepository;
|
||||
use app\common\repositories\system\merchant\MerchantRepository;
|
||||
use think\facade\Log;
|
||||
|
|
@ -158,13 +159,49 @@ class IntegralRepository extends BaseRepository
|
|||
|
||||
return compact('count','list');
|
||||
}
|
||||
/**
|
||||
* Common: 持有积分统计
|
||||
* Author: wu-hui
|
||||
* Time: 2023/11/18 14:06
|
||||
* @param array $params
|
||||
* @return array|array[]
|
||||
*/
|
||||
public function getStat(array $params){
|
||||
$query = $this->dao->getSearch([])
|
||||
->when((int)$params['uid'] > 0,function($query) use ($params){
|
||||
$query->where('uid', (int)$params['uid']);
|
||||
})
|
||||
->when((int)$params['mer_id'] > 0,function($query) use ($params){
|
||||
$query->where('mer_id', (int)$params['mer_id']);
|
||||
});
|
||||
$orderQuery = app()->make(StoreOrder::class)
|
||||
->when((int)$params['uid'] > 0,function($query) use ($params){
|
||||
$query->where('uid', (int)$params['uid']);
|
||||
})
|
||||
->when((int)$params['mer_id'] > 0,function($query) use ($params){
|
||||
$query->where('mer_id', (int)$params['mer_id']);
|
||||
});
|
||||
|
||||
// 商户信息统计
|
||||
$holdMerIntegral = (float)$query->where('mer_id','>',0)->sum('number');
|
||||
$useMerIntegral = (float)$orderQuery->sum('use_mer_integral');
|
||||
if((int)$params['mer_id'] > 0){
|
||||
return [
|
||||
['className' => 'el-icon-coin','count' => $holdMerIntegral,'field' => '分','name' => '持有本商户积分(总)'],
|
||||
['className' => 'el-icon-coin','count' => $useMerIntegral,'field' => '分','name' => '已使用本商户积分(总)'],
|
||||
];
|
||||
}
|
||||
// 平台信息统计
|
||||
$holdPlatformIntegral = (float)$query->where('mer_id','=',0)->sum('number');
|
||||
$usePlatformIntegral = (float)$orderQuery->sum('use_platform_integral');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return [
|
||||
['className' => 'el-icon-coin','count' => $holdPlatformIntegral,'field' => '分','name' => '持有平台积分(总)'],
|
||||
['className' => 'el-icon-coin','count' => $usePlatformIntegral,'field' => '分','name' => '已使用平台积分(总)'],
|
||||
['className' => 'el-icon-coin','count' => $holdMerIntegral,'field' => '分','name' => '持有商户积分(总)'],
|
||||
['className' => 'el-icon-coin','count' => $useMerIntegral,'field' => '分','name' => '已使用商户积分(总)'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,6 +98,18 @@ class UserIntegral extends BaseController
|
|||
|
||||
return app('json')->success($data);
|
||||
}
|
||||
/**
|
||||
* Common: 持有积分统计
|
||||
* Author: wu-hui
|
||||
* Time: 2023/11/18 14:16
|
||||
* @return mixed
|
||||
*/
|
||||
public function holdListTitle(){
|
||||
$params = $this->request->params(['uid','mer_id']);
|
||||
$data = app()->make(IntegralRepository::class)->getStat((array)$params);
|
||||
|
||||
return app('json')->success($data);
|
||||
}
|
||||
/**
|
||||
* Common: 获取赠送积分记录
|
||||
* Author: wu-hui
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ namespace app\controller\merchant\user;
|
|||
use app\common\repositories\store\coupon\StoreCouponUserRepository;
|
||||
use app\common\repositories\store\order\StoreOrderRepository;
|
||||
use app\common\repositories\user\IntegralGiveRecordRepository;
|
||||
use app\common\repositories\user\IntegralRepository;
|
||||
use app\common\repositories\user\UserBillRepository;
|
||||
use app\common\repositories\user\UserLabelRepository;
|
||||
use app\common\repositories\user\UserMerchantRepository;
|
||||
|
|
@ -77,6 +78,34 @@ class UserIntegral extends BaseController
|
|||
|
||||
return app('json')->success($data);
|
||||
}
|
||||
/**
|
||||
* Common: 持有积分列表
|
||||
* Author: wu-hui
|
||||
* Time: 2023/11/18 13:51
|
||||
* @return mixed
|
||||
*/
|
||||
public function holdList(){
|
||||
[$page, $limit] = $this->getPage();
|
||||
$params = $this->request->params(['uid']);
|
||||
$params['mer_id'] = $this->request->merId();
|
||||
|
||||
$data = app()->make(IntegralRepository::class)->getAllIntegralList((array)$params,(int)$page,(int)$limit);
|
||||
|
||||
return app('json')->success($data);
|
||||
}
|
||||
/**
|
||||
* Common: 持有积分统计
|
||||
* Author: wu-hui
|
||||
* Time: 2023/11/18 14:00
|
||||
* @return mixed
|
||||
*/
|
||||
public function holdListTitle(){
|
||||
$params = $this->request->params(['uid']);
|
||||
$params['mer_id'] = $this->request->merId();
|
||||
|
||||
$data = app()->make(IntegralRepository::class)->getStat((array)$params);
|
||||
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,11 +57,13 @@ Route::group(function () {
|
|||
Route::get('hold_list', '.UserIntegral/holdIntegral')->name('systemUserIntegralHoldList')->option([
|
||||
'_alias' => '持有积分',
|
||||
]);
|
||||
Route::get('hold_list_title','.UserIntegral/holdListTitle')->name('systemUserIntegralHoldListTitle')->option([
|
||||
'_alias' => '持有积分统计',
|
||||
]);
|
||||
Route::get('give_list', '.UserIntegral/giveIntegral')->name('systemUserIntegralGiveList')->option([
|
||||
'_alias' => '赠送积分',
|
||||
]);
|
||||
|
||||
|
||||
})->prefix('admin.user')->option([
|
||||
'_path' => '/marketing/integral/hold',
|
||||
'_auth' => true,
|
||||
|
|
|
|||
|
|
@ -465,7 +465,12 @@ Route::group(function () {
|
|||
Route::get('give_list','/giveRecord')->name('merchantIntegralGiveRecord')->option([
|
||||
'_alias' => '赠送记录',
|
||||
]);
|
||||
|
||||
Route::get('hold_list','/holdList')->name('merchantIntegralHoldList')->option([
|
||||
'_alias' => '持有积分',
|
||||
]);
|
||||
Route::get('hold_list_title','/holdListTitle')->name('merchantIntegralHoldListTitle')->option([
|
||||
'_alias' => '持有积分统计',
|
||||
]);
|
||||
})->prefix('merchant.user.UserIntegral')->option([
|
||||
'_path' => '/marketing/integral/log',
|
||||
'_auth' => true,
|
||||
|
|
|
|||
Loading…
Reference in New Issue