用户领取礼品列表

This commit is contained in:
liu 2024-07-03 15:43:02 +08:00
parent 5ac195ccfb
commit 29772c4fb4
3 changed files with 64 additions and 0 deletions

View File

@ -81,5 +81,20 @@ class UserController extends BaseAdminController
return $this->success('ok', $res);
}
//用户领取列表
public function userGiftList()
{
$uid = (new UserValidate())->goCheck('detail');
$page_no = (int)$this->request->get('page_no', 1);
$page_size = (int)$this->request->get('page_size', 15);
$params = $this->request->get();
$params['page_no'] = $page_no > 0 ? $page_no : 1;
$params['page_size'] = $page_size > 0 ? $page_size : 15;
$res = UserLogic::giftList($uid,$params);
$res['page_no'] = $params['page_no'];
$res['page_size'] = $params['page_size'];
return $this->success('ok', $res);
}
}

View File

@ -20,6 +20,7 @@ use app\common\logic\BaseLogic;
use app\common\model\finance\CapitalFlow;
use app\common\model\store_finance_flow\StoreFinanceFlow;
use app\common\model\store_order\StoreOrder;
use app\common\model\store_product_gift\StoreProductGift;
use app\common\model\user\User;
use app\common\model\user\UserAddress;
use app\common\model\user\UserRecharge;
@ -279,4 +280,18 @@ class UserLogic extends BaseLogic
}
public static function giftList($uid,$params)
{
$query = StoreProductGift::with(['store','user','goodsName'])->where('uid',$uid);
$count = $query->count();
$list = $query->page($params['page_no'],$params['page_size'])
->order('id','desc')
->select()->toArray();
return [
'lists' => $list,
'count' => $count
];
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace app\common\model\store_product_gift;
use app\common\model\BaseModel;
use app\common\model\store_branch_product\StoreBranchProduct;
use app\common\model\store_product\StoreProduct;
use app\common\model\system_store\SystemStore;
use app\common\model\user\User;
use think\model\concern\SoftDelete;
class StoreProductGift extends BaseModel
{
use SoftDelete;
protected $name = 'store_product_gift';
protected $deleteTime = 'delete_time';
public function store()
{
return $this->hasOne(SystemStore::class, 'id', 'store_id')
->bind(['store_name' => 'name', 'store_phone' => 'phone', 'store_detailed_address' => 'detailed_address', 'store_simple_address' => 'address']);
}
public function user()
{
return $this->hasOne(User::class, 'id', 'uid')->bind(['nickname', 'avatar', 'mobile']);
}
public function goodsName()
{
return $this->hasOne(StoreProduct::class,'id','product_id')->bind(['goods_name'=>'store_name','image','unit','price']);
}
}