mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 18:53:25 +08:00
【新增】增加DTO类库,将逐步完善dto层。 【修复】修复【分类】切换后,切换回来未清零原始数据,导致更新数据重复的问题。 【调整】移除模板库功能,防止出现审核因为模板库页面存在而导致的审核失败。暂将模板库的代码存放到会员QQ群内,方便下载使用。 【调整】代码生成器【Repository.tpl】移除Cache手动增删改,【SqlSugarSetup】增加sqlsugar自动检测增删改后清理二级缓存。 【调整】后端新增秒杀独立组件,用于区分团购及秒杀的差异,首页新增秒杀组件。 【优化】重写首页所有组件样式及接口数据获取效率。 【优化】优化拼团,秒杀,团购,接龙数据获取逻辑,提升列表及详情页面数据获取效率。 【优化】调整拼团,秒杀,团购,服务商品推广海报为新式海报效果。增加服务商品推广海报。 【优化】清理h5相关代码判断,移除h5支付组件,提高响应速度。 【优化】移除小程序前端冗余代码。加快代码执行效率。
179 lines
5.8 KiB
C#
179 lines
5.8 KiB
C#
/***********************************************************************
|
||
* Project: CoreCms
|
||
* ProjectName: 核心内容管理系统
|
||
* Web: https://www.corecms.net
|
||
* Author: 大灰灰
|
||
* Email: jianweie@163.com
|
||
* CreateTime: 2021/1/31 21:45:10
|
||
* Description: 暂无
|
||
***********************************************************************/
|
||
|
||
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Threading.Tasks;
|
||
using CoreCms.Net.Auth.HttpContextUser;
|
||
using CoreCms.Net.Configuration;
|
||
using CoreCms.Net.IServices;
|
||
using CoreCms.Net.Model.Entities;
|
||
using CoreCms.Net.Model.FromBody;
|
||
using CoreCms.Net.Model.ViewModels.UI;
|
||
using CoreCms.Net.Utility.Extensions;
|
||
using Microsoft.AspNetCore.Http;
|
||
using Microsoft.AspNetCore.Mvc;
|
||
using SqlSugar;
|
||
|
||
namespace CoreCms.Net.Web.WebApi.Controllers
|
||
{
|
||
/// <summary>
|
||
/// 拼团接口
|
||
/// </summary>
|
||
[Route("api/[controller]/[action]")]
|
||
[ApiController]
|
||
public class PinTuanController : ControllerBase
|
||
{
|
||
|
||
private readonly IHttpContextUser _user;
|
||
private readonly ICoreCmsPinTuanGoodsServices _pinTuanGoodsServices;
|
||
private readonly ICoreCmsPinTuanRuleServices _pinTuanRuleServices;
|
||
private readonly ICoreCmsProductsServices _productsServices;
|
||
private readonly ICoreCmsPinTuanRecordServices _pinTuanRecordServices;
|
||
private readonly ICoreCmsGoodsServices _goodsServices;
|
||
|
||
|
||
/// <summary>
|
||
/// 构造函数
|
||
/// </summary>
|
||
public PinTuanController(IHttpContextUser user
|
||
, ICoreCmsPinTuanGoodsServices pinTuanGoodsServices
|
||
, ICoreCmsPinTuanRuleServices pinTuanRuleServices
|
||
, ICoreCmsProductsServices productsServices
|
||
, ICoreCmsPinTuanRecordServices pinTuanRecordServices, ICoreCmsGoodsServices goodsServices)
|
||
{
|
||
_user = user;
|
||
_pinTuanGoodsServices = pinTuanGoodsServices;
|
||
_pinTuanRuleServices = pinTuanRuleServices;
|
||
_productsServices = productsServices;
|
||
_pinTuanRecordServices = pinTuanRecordServices;
|
||
_goodsServices = goodsServices;
|
||
}
|
||
|
||
|
||
#region 拼团列表
|
||
/// <summary>
|
||
/// 拼团列表
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public async Task<WebApiCallBack> GetList([FromBody] FMPageByIntId entity)
|
||
{
|
||
WebApiCallBack jm;
|
||
|
||
var userId = 0;
|
||
if (_user != null)
|
||
{
|
||
userId = _user.ID;
|
||
}
|
||
jm = await _pinTuanRuleServices.GetPinTuanList(userId, entity.page, entity.limit);
|
||
return jm;
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 获取拼团商品信息
|
||
/// <summary>
|
||
/// 获取拼团商品信息
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public async Task<WebApiCallBack> GetGoodsInfo([FromBody] FMIntId entity)
|
||
{
|
||
var jm = new WebApiCallBack();
|
||
|
||
var userId = 0;
|
||
if (_user != null)
|
||
{
|
||
userId = _user.ID;
|
||
}
|
||
|
||
var showSku = entity.data.ObjectToBool();
|
||
|
||
var pinTuanRule = await _pinTuanRuleServices.QueryByClauseAsync(p => p.id == entity.id, true, true);
|
||
if (pinTuanRule == null)
|
||
{
|
||
jm.msg = "拼团获取失败";
|
||
return jm;
|
||
}
|
||
var pinTuanGood = await _pinTuanGoodsServices.QueryByClauseAsync(p => p.ruleId == entity.id, true, true);
|
||
|
||
jm.status = true;
|
||
jm.msg = "获取详情成功";
|
||
jm.data = await _pinTuanGoodsServices.GetGoodsInfo(pinTuanRule, pinTuanGood.goodsId, userId, true, true, showSku);
|
||
|
||
return jm;
|
||
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 获取货品信息
|
||
/// <summary>
|
||
/// 获取货品信息
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public async Task<WebApiCallBack> GetProductInfo([FromBody] FMGetProductInfo entity)
|
||
{
|
||
var jm = new WebApiCallBack();
|
||
|
||
var products = await _productsServices.GetProductInfo(entity.id, false, 0, entity.type);
|
||
if (products == null)
|
||
{
|
||
jm.msg = GlobalErrorCodeVars.Code10000;
|
||
return jm;
|
||
}
|
||
//把拼团的一些属性等加上
|
||
var info = await _pinTuanRuleServices.QueryMuchFirstAsync<CoreCmsPinTuanRule, CoreCmsPinTuanGoods, CoreCmsPinTuanRule>(
|
||
(join1, join2) => new object[] { JoinType.Left, join1.id == join2.ruleId },
|
||
(join1, join2) => join1, (join1, join2) => join2.goodsId == products.goodsId);
|
||
|
||
if (info == null)
|
||
{
|
||
jm.msg = GlobalErrorCodeVars.Code10000;
|
||
return jm;
|
||
}
|
||
products.pinTuanRule = info;
|
||
jm.status = true;
|
||
jm.data = products;
|
||
return jm;
|
||
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 根据订单id取拼团信息,用在订单详情页
|
||
/// <summary>
|
||
/// 根据订单id取拼团信息,用在订单详情页
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public async Task<WebApiCallBack> GetPinTuanTeam([FromBody] FMGetPinTuanTeamPost entity)
|
||
{
|
||
var jm = new WebApiCallBack();
|
||
|
||
if (string.IsNullOrEmpty(entity.orderId) && entity.teamId == 0)
|
||
{
|
||
jm.msg = GlobalErrorCodeVars.Code15606;
|
||
return jm;
|
||
}
|
||
jm = await _pinTuanRecordServices.GetTeamList(entity.teamId, entity.orderId);
|
||
|
||
return jm;
|
||
}
|
||
|
||
#endregion
|
||
|
||
}
|
||
}
|