调整红包余额查询

This commit is contained in:
luofei 2024-01-21 14:20:18 +08:00
parent 06d34cd24a
commit 6aaf02c5a0
2 changed files with 10 additions and 2 deletions

View File

@ -183,11 +183,13 @@ class StoreActivityUserDao extends BaseDao
->whereIn('type', $type)
->where('status', StoreConsumptionUser::STATUS_UNUSED)
->sum('balance');
$query = UserBill::where('uid', $userId)
$query = UserBill::with('storeConsumptionUser')
->field('link_id,create_time')
->where('uid', $userId)
->where('category', 'red_pack')
->where('type', "red_pack_{$type}");
$count = $query->count();
$record = $query->page($page)->limit($limit)->select();
$record = $query->page($page)->limit($limit)->select()->toArray();
return ['total_amount' => $totalAmount, 'count' => $count, 'record' => $record];
}

View File

@ -15,6 +15,7 @@ namespace app\common\model\user;
use app\common\model\BaseModel;
use app\common\model\store\consumption\StoreConsumptionUser;
class UserBill extends BaseModel
{
@ -44,4 +45,9 @@ class UserBill extends BaseModel
return $this->hasOne(User::class, 'uid', 'uid');
}
public function storeConsumptionUser()
{
return $this->hasOne(StoreConsumptionUser::class, 'coupon_user_id', 'link_id')->bind(['order_amount', 'coupon_price']);
}
}