diff --git a/app/common/model/user/IntegralGiveRecord.php b/app/common/model/user/IntegralGiveRecord.php index 7cd1fad..c941173 100644 --- a/app/common/model/user/IntegralGiveRecord.php +++ b/app/common/model/user/IntegralGiveRecord.php @@ -7,6 +7,7 @@ namespace app\common\model\user; use app\common\model\BaseModel; +use app\common\model\system\merchant\Merchant; class IntegralGiveRecord extends BaseModel { @@ -33,7 +34,7 @@ class IntegralGiveRecord extends BaseModel public function operateUser() { - return $this->hasOne(User::class, 'operate_uid', 'uid'); + return $this->hasOne(User::class, 'uid', 'operate_uid'); } public function user() @@ -41,4 +42,8 @@ class IntegralGiveRecord extends BaseModel return $this->hasOne(User::class, 'uid', 'uid'); } + public function mer(){ + return $this->hasOne(Merchant::class,'mer_id','mer_id'); + } + } diff --git a/app/common/repositories/user/IntegralGiveRecordRepository.php b/app/common/repositories/user/IntegralGiveRecordRepository.php index c19e447..28f847e 100644 --- a/app/common/repositories/user/IntegralGiveRecordRepository.php +++ b/app/common/repositories/user/IntegralGiveRecordRepository.php @@ -8,7 +8,6 @@ namespace app\common\repositories\user; use app\common\dao\user\IntegralGiveRecordDao; use app\common\repositories\BaseRepository; - /** * Common: ... * Author: wu-hui @@ -30,14 +29,43 @@ class IntegralGiveRecordRepository extends BaseRepository { $this->dao = $dao; } + /** + * Common: 获取赠送记录 + * Author: wu-hui + * Time: 2023/11/14 10:52 + * @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 getGiveRecord(array $params,int $page,int $limit):array{ + // 基本条件 + $where = []; + if((int)$params['operate_uid'] > 0) $where['operate_uid'] = $params['operate_uid']; + if((int)$params['uid'] > 0) $where['uid'] = $params['uid']; + if((int)$params['mer_id'] > 0) $where['mer_id'] = $params['mer_id']; + // 查询 + $query = $this->dao->getSearch($where) + ->with([ + 'mer' => function($query){ + $query->field('mer_id,mer_name,mer_avatar'); + }, + 'user' => function($query){ + $query->field('uid,nickname,avatar'); + }, + 'operateUser' => function($query){ + $query->field('uid,nickname,avatar'); + } + ]) + ->order('create_time DESC'); + $count = $query->count(); + $list = $query->page($page,$limit)->select(); - - - - - - - + return compact('count','list'); + } diff --git a/app/controller/admin/user/UserIntegral.php b/app/controller/admin/user/UserIntegral.php index 3244d24..9fe09e7 100644 --- a/app/controller/admin/user/UserIntegral.php +++ b/app/controller/admin/user/UserIntegral.php @@ -9,6 +9,7 @@ use app\common\repositories\store\ExcelRepository; use app\common\repositories\system\CacheRepository; use app\common\repositories\system\config\ConfigClassifyRepository; use app\common\repositories\system\config\ConfigValueRepository; +use app\common\repositories\user\IntegralGiveRecordRepository; use app\common\repositories\user\IntegralRepository; use app\common\repositories\user\UserBillRepository; use app\validate\admin\IntegralConfigValidate; @@ -82,7 +83,13 @@ class UserIntegral extends BaseController return app('json')->success('保存成功'); } - // 持有积分列表 + + /** + * Common: 持有积分列表 + * Author: wu-hui + * Time: 2023/11/14 10:11 + * @return mixed + */ public function holdIntegral(){ [$page, $limit] = $this->getPage(); $params = $this->request->params(['uid','mer_id']); @@ -91,9 +98,20 @@ class UserIntegral extends BaseController return app('json')->success($data); } + /** + * Common: 获取赠送积分记录 + * Author: wu-hui + * Time: 2023/11/14 13:36 + * @return mixed + */ + public function giveIntegral(){ + $params = $this->request->params(['operate_uid','uid','mer_id']); + [$page, $limit] = $this->getPage(); + $data = app()->make(IntegralGiveRecordRepository::class)->getGiveRecord((array)$params,(int)$page,(int)$limit); - + return app('json')->success($data); + } diff --git a/app/controller/merchant/user/UserIntegral.php b/app/controller/merchant/user/UserIntegral.php index 16e6d50..50a94db 100644 --- a/app/controller/merchant/user/UserIntegral.php +++ b/app/controller/merchant/user/UserIntegral.php @@ -8,6 +8,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\UserBillRepository; use app\common\repositories\user\UserLabelRepository; use app\common\repositories\user\UserMerchantRepository; @@ -60,4 +61,22 @@ class UserIntegral extends BaseController return app('json')->success($this->repository->getStat($this->request->merId())); } + + /** + * Common: 获取赠送积分记录 + * Author: wu-hui + * Time: 2023/11/14 10:52 + * @return mixed + */ + public function giveRecord(){ + $params = $this->request->params(['operate_uid','uid']); + $params['mer_id'] = $this->request->merId(); + [$page, $limit] = $this->getPage(); + + $data = app()->make(IntegralGiveRecordRepository::class)->getGiveRecord((array)$params,(int)$page,(int)$limit); + + return app('json')->success($data); + } + + } diff --git a/route/admin/marketing.php b/route/admin/marketing.php index c6aec12..c67943c 100644 --- a/route/admin/marketing.php +++ b/route/admin/marketing.php @@ -57,7 +57,9 @@ Route::group(function () { Route::get('hold_list', '.UserIntegral/holdIntegral')->name('systemUserIntegralHoldList')->option([ '_alias' => '持有积分', ]); - + Route::get('give_list', '.UserIntegral/giveIntegral')->name('systemUserIntegralGiveList')->option([ + '_alias' => '赠送积分', + ]); })->prefix('admin.user')->option([ diff --git a/route/merchant/marketing.php b/route/merchant/marketing.php index 275549b..80d0193 100644 --- a/route/merchant/marketing.php +++ b/route/merchant/marketing.php @@ -462,6 +462,10 @@ Route::group(function () { Route::get('title','/getTitle')->name('merchantIntegralTitle')->option([ '_alias' => '统计', ]); + Route::get('give_list','/giveRecord')->name('merchantIntegralGiveRecord')->option([ + '_alias' => '赠送记录', + ]); + })->prefix('merchant.user.UserIntegral')->option([ '_path' => '/marketing/integral/log', '_auth' => true,