feat: add wechat mini program mall, check-in supplement and pet skin system
This commit implements a complete WeChat mini program mall and related features: 1. Add pet skin entity and backpack item type support 2. Add make-up check-in and missed date query functions 3. Implement mall product browsing, exchange and record query 4. Add backpack management and item usage (make-up card) 5. Add pet skin equipping function 6. Fix UserBag ItemId type from int to long 7. Adjust Dockerfile exposed port to 8080 8. Fix session cookie unprotect warning
This commit is contained in:
@ -0,0 +1,52 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using QYZH.InteractiveMagazine.IService;
|
||||
using QYZH.InteractiveMagazine.Models.Dto;
|
||||
using QYZH.InteractiveMagazine.Models.Dto.Bag;
|
||||
|
||||
namespace QYZH.InteractiveMagazine.WebApi.Controllers.WeChat;
|
||||
|
||||
/// <summary>
|
||||
/// 小程序背包控制器
|
||||
/// </summary>
|
||||
public class BagController(IWxMallService mallService, ILogger<BagController> logger) : WeChatBaseController
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取背包物品列表
|
||||
/// </summary>
|
||||
/// <param name="itemType">物品类型筛选(可选): MakeUpCard, PetBg</param>
|
||||
[HttpGet("items")]
|
||||
public async Task<BaseResponse<List<UserBagOutput>>> GetBagItems([FromQuery] string? itemType = null)
|
||||
{
|
||||
var userId = GetCurrentUserId();
|
||||
if (userId == null) return Fail("未获取到用户信息") as dynamic;
|
||||
|
||||
var items = await mallService.GetBagItemsAsync(userId.Value, itemType);
|
||||
return Success(items);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 使用背包物品(补签卡等消耗品)
|
||||
/// </summary>
|
||||
[HttpPost("useItem")]
|
||||
public async Task<BaseResponse<UseItemOutput>> UseItem([FromBody] UseItemInput input)
|
||||
{
|
||||
var userId = GetCurrentUserId();
|
||||
if (userId == null) return Fail("未获取到用户信息") as dynamic;
|
||||
|
||||
var result = await mallService.UseItemAsync(userId.Value, input);
|
||||
return Success(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 宠物换肤
|
||||
/// </summary>
|
||||
[HttpPost("equipSkin")]
|
||||
public async Task<BaseResponse<object>> EquipSkin([FromBody] EquipSkinInput input)
|
||||
{
|
||||
var userId = GetCurrentUserId();
|
||||
if (userId == null) return Fail("未获取到用户信息") as dynamic;
|
||||
|
||||
await mallService.EquipSkinAsync(userId.Value, input);
|
||||
return Success<object>(null!, input.SkinId == 0 ? "已恢复默认皮肤" : "换肤成功");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,70 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using QYZH.InteractiveMagazine.IService;
|
||||
using QYZH.InteractiveMagazine.Models.Dto;
|
||||
using QYZH.InteractiveMagazine.Models.Dto.Mall;
|
||||
|
||||
namespace QYZH.InteractiveMagazine.WebApi.Controllers.WeChat;
|
||||
|
||||
/// <summary>
|
||||
/// 小程序商城控制器
|
||||
/// </summary>
|
||||
public class MallController(IWxMallService mallService, ILogger<MallController> logger) : WeChatBaseController
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取商城商品列表
|
||||
/// </summary>
|
||||
/// <param name="type">商品类型筛选(可选): MakeUpCard, PetBg</param>
|
||||
[HttpGet("products")]
|
||||
public async Task<BaseResponse<List<WxProductOutput>>> GetProducts([FromQuery] string? type = null)
|
||||
{
|
||||
var userId = GetCurrentUserId();
|
||||
if (userId == null) return Fail("未获取到用户信息") as dynamic;
|
||||
|
||||
var products = await mallService.GetProductsAsync(userId.Value, type);
|
||||
return Success(products);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取商品详情
|
||||
/// </summary>
|
||||
/// <param name="id">商品Id</param>
|
||||
[HttpGet("product/{id}")]
|
||||
public async Task<BaseResponse<WxProductOutput>> GetProductDetail(long id)
|
||||
{
|
||||
var userId = GetCurrentUserId();
|
||||
if (userId == null) return Fail("未获取到用户信息") as dynamic;
|
||||
|
||||
var product = await mallService.GetProductDetailAsync(userId.Value, id);
|
||||
if (product == null)
|
||||
return BaseResponse<WxProductOutput>.Fail(ResultCode.DENY, "商品不存在或已下架");
|
||||
|
||||
return Success(product);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 积分兑换商品
|
||||
/// </summary>
|
||||
[HttpPost("exchange")]
|
||||
public async Task<BaseResponse<ExchangeOutput>> Exchange([FromBody] ExchangeInput input)
|
||||
{
|
||||
var userId = GetCurrentUserId();
|
||||
if (userId == null) return Fail("未获取到用户信息") as dynamic;
|
||||
|
||||
var result = await mallService.ExchangeAsync(userId.Value, input);
|
||||
return Success(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取我的兑换记录
|
||||
/// </summary>
|
||||
/// <param name="limit">返回数量(默认20)</param>
|
||||
[HttpGet("exchangeRecords")]
|
||||
public async Task<BaseResponse<List<ExchangeRecordOutput>>> GetExchangeRecords([FromQuery] int limit = 20)
|
||||
{
|
||||
var userId = GetCurrentUserId();
|
||||
if (userId == null) return Fail("未获取到用户信息") as dynamic;
|
||||
|
||||
var records = await mallService.GetExchangeRecordsAsync(userId.Value, limit);
|
||||
return Success(records);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user