159 lines
5.7 KiB
C#
159 lines
5.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using New_College.IServices;
|
|
using New_College.Model;
|
|
using New_College.Model.Models;
|
|
using New_College.Model.ViewModels;
|
|
using New_College.Model.ViewModels.Query;
|
|
|
|
namespace New_College.Api.Controllers.Back
|
|
{
|
|
[Route("api/back/[controller]/[action]")]
|
|
[ApiController]
|
|
public class VipCardController : ControllerBase
|
|
{
|
|
private readonly IV_VipCardInfoServices iV_VipCardInfoServices;
|
|
private readonly IV_VipCardTypeServices iV_VipCardTypeServices;
|
|
private readonly IV_OrderInfoServices iV_OrderInfoServices;
|
|
private readonly IV_CustomerInfoServices _CustomerInfoServices;
|
|
private readonly ID_UserSettingBaseServices d_UserSettingBase;
|
|
public VipCardController(IV_VipCardInfoServices IV_VipCardInfoServices, IV_VipCardTypeServices IV_VipCardTypeServices, IV_OrderInfoServices IV_OrderInfoServices, IV_CustomerInfoServices customerInfoServices, ID_UserSettingBaseServices userSettingBaseServices)
|
|
{
|
|
iV_VipCardInfoServices = IV_VipCardInfoServices;
|
|
iV_VipCardTypeServices = IV_VipCardTypeServices;
|
|
iV_OrderInfoServices = IV_OrderInfoServices;
|
|
_CustomerInfoServices = customerInfoServices;
|
|
d_UserSettingBase = userSettingBaseServices;
|
|
}
|
|
/// <summary>
|
|
/// 生成卡信息
|
|
/// </summary>
|
|
/// <param name="query"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public async Task<MessageModel<List<string>>> AutoVipCardInfo([FromBody] AutoVipInfoQuery query)
|
|
{
|
|
return await iV_VipCardInfoServices.AutoVipCardInfo(query);
|
|
}
|
|
/// <summary>
|
|
/// 获取分页
|
|
/// </summary>
|
|
/// <param name="query"></param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
public async Task<MessageModel<PageModel<VipCardInfoResult>>> GetVipCardInfoByPage([FromQuery] VipCardInfoSearchQuery query)
|
|
{
|
|
return await iV_VipCardInfoServices.GetVipCardInfoByPage(query);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取单个
|
|
/// </summary>
|
|
/// <param name="query"></param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
public async Task<MessageModel<VipCardInfoResultOne>> GetVipCardInfoOne([FromQuery] IdQuery query)
|
|
{
|
|
return await iV_VipCardInfoServices.GetVipCardInfoOne(query);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加
|
|
/// </summary>
|
|
/// <param name="query"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public async Task<MessageModel<bool>> AddVipCardInfo([FromBody] VipCardInfoQuery query)
|
|
{
|
|
return await iV_VipCardInfoServices.AddVipCardInfo(query);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改
|
|
/// </summary>
|
|
/// <param name="query"></param>
|
|
/// <returns></returns>
|
|
[HttpPut]
|
|
public async Task<MessageModel<bool>> UpdateVipCardInfo(VipCardInfoQuery query)
|
|
{
|
|
return await iV_VipCardInfoServices.UpdateVipCardInfo(query);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除
|
|
/// </summary>
|
|
/// <param name="query"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public async Task<MessageModel<bool>> DeleteVipCardInfo([FromBody] IdQuery query)
|
|
{
|
|
return await iV_VipCardInfoServices.DeleteVipCardInfo(query);
|
|
}
|
|
/// <summary>
|
|
/// 获取vipcardTypeList
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public async Task<List<VipCardTypeQuery>> GetVipCardType()
|
|
{
|
|
return await iV_VipCardTypeServices.GetVipCardType();
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 根据用户是否为Vip获取相应权限
|
|
/// </summary>
|
|
/// <param name="query"></param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
public async Task<VipPowerRolesViewsDTO> CheckRoles([FromQuery] IdQuery query)
|
|
{
|
|
var response = new VipPowerRolesViewsDTO();
|
|
var custom = await _CustomerInfoServices.Query(c => c.Id == query.CustomerId);
|
|
if (custom.Any())
|
|
{
|
|
var isverfiy = await d_UserSettingBase.Query(c => c.CustomerId == query.CustomerId);
|
|
if (!isverfiy.Any())
|
|
{
|
|
await d_UserSettingBase.SyncBaseInfo(new UserSettingBaseRequest() { CustomerId = query.CustomerId.Value });
|
|
}
|
|
response.IsVip = custom.FirstOrDefault().IsVIP;
|
|
|
|
var list = await d_UserSettingBase.GetUserBaseSettings(new UserSettingBaseRequest() { CustomerId = query.CustomerId.Value });
|
|
response.pcRole = list.Where(e => e.PType == 0).Select(c => new PCRole()
|
|
{
|
|
ScoreCount = c.ScoreCount,
|
|
SearchCount = c.SearchCount,
|
|
}).FirstOrDefault();
|
|
response.minProRole = list.Where(e => e.PType == 1).Select(c => new MinProRole()
|
|
{
|
|
ScoreCount = c.ScoreCount,
|
|
SearchCount = c.SearchCount,
|
|
}).FirstOrDefault();
|
|
}
|
|
else
|
|
{
|
|
response.IsVip = false;
|
|
response.pcRole = new PCRole()
|
|
{
|
|
ScoreCount = 1,
|
|
SearchCount = 10
|
|
};
|
|
response.minProRole = new MinProRole()
|
|
{
|
|
ScoreCount = 1,
|
|
SearchCount = 10
|
|
};
|
|
|
|
}
|
|
return response;
|
|
}
|
|
|
|
}
|
|
}
|