Files
coreshoppro/CoreCms.Net.Web.WebApi/Controllers/CartController.cs
JianWeie a07106127e # 2022-02-12
### 1.3.5 开源社区版:
无
### 0.1.7 会员专业版:
【新增】表【CoreCmsUserShip】增加【精度longitude】【纬度latitude】【街道street】三字段。
【新增】用户地址新增及编辑增加地图选择获取街道及经纬度坐标功能。
【新增】【平台设置-订单管理】,新增【同城配送运费设置】,可设置2公里内,5公里内,10公里内,15公里内,20公里内不同距离运费。根据用户地址坐标与门店坐标进行计算。
【新增】商品详情轮播图增加视频图片混播结合功能,类似淘宝打开商品详情后显示视频并支持播放,左右滑动切换图片,实现混播。
【新增】商品添加/删除面板增加视频上传功能。
2022-02-12 02:25:01 +08:00

143 lines
4.9 KiB
C#

/***********************************************************************
* Project: CoreCms
* ProjectName: 核心内容管理系统
* Web: https://www.corecms.net
* Author: 大灰灰
* Email: jianweie@163.com
* CreateTime: 2021/1/31 21:45:10
* Description: 暂无
***********************************************************************/
using CoreCms.Net.Auth.HttpContextUser;
using CoreCms.Net.IServices;
using CoreCms.Net.Model.FromBody;
using CoreCms.Net.Utility.Helper;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using CoreCms.Net.Configuration;
using CoreCms.Net.Model.ViewModels.DTO;
using CoreCms.Net.Model.ViewModels.UI;
namespace CoreCms.Net.Web.WebApi.Controllers
{
/// <summary>
/// 购物车操作
/// </summary>
[Route("api/[controller]/[action]")]
[ApiController]
public class CartController : ControllerBase
{
private readonly IHttpContextUser _user;
private readonly ICoreCmsCartServices _cartServices;
/// <summary>
/// 构造函数
/// </summary>
public CartController(IHttpContextUser user, ICoreCmsCartServices cartServices)
{
_user = user;
_cartServices = cartServices;
}
//公共接口====================================================================================================
//验证接口====================================================================================================
#region
/// <summary>
/// 添加单个货品到购物车
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
[HttpPost]
[Authorize]
public async Task<WebApiCallBack> AddCart([FromBody] FMCartAdd entity)
{
var jm = await _cartServices.Add(_user.ID, entity.ProductId, entity.Nums, entity.type, entity.cartType, entity.objectId);
return jm;
}
#endregion
#region ======================================================================
/// <summary>
/// 获取购物车列表
/// </summary>
/// <returns></returns>
[HttpPost]
[Authorize]
public async Task<WebApiCallBack> GetList([FromBody] FMCartGetList entity)
{
var ids = CommonHelper.StringToIntArray(entity.ids);
//获取数据
var jm = await _cartServices.GetCartInfos(_user.ID, ids, entity.type, entity.areaId, entity.point, entity.couponCode, entity.receiptType, entity.userShipId, entity.objectId);
return jm;
}
#endregion ======================================================================
#region
/// <summary>
/// 获取购物车列表
/// </summary>
/// <returns></returns>
[HttpPost]
[Authorize]
public async Task<WebApiCallBack> DoDelete([FromBody] FMIntId entity)
{
var jm = new WebApiCallBack();
if (entity.id <= 0)
{
jm.msg = "请提交要删除的货品";
return jm;
}
jm = await _cartServices.DeleteByIdsAsync(entity.id, _user.ID);
return jm;
}
#endregion
#region
/// <summary>
/// 设置购物车商品数量
/// </summary>
/// <returns></returns>
[HttpPost]
[Authorize]
public async Task<WebApiCallBack> SetCartNum([FromBody] FMSetCartNum entity)
{
var jm = await _cartServices.SetCartNum(entity.id, entity.nums, _user.ID, (int)GlobalEnumVars.CartSetNumType.Set, (int)GlobalEnumVars.OrderType.Common);
return jm;
}
#endregion
#region 使==================================================
/// <summary>
/// 根据提交的数据判断哪些购物券可以使用
/// </summary>
/// <returns></returns>
[HttpPost]
[Authorize]
public async Task<WebApiCallBack> GetCartAvailableCoupon([FromBody] FMCouponForUserCouponPost entity)
{
var ids = CommonHelper.StringToIntArray(entity.ids);
var jm = await _cartServices.GetCartAvailableCoupon(_user.ID, ids);
return jm;
}
#endregion 使==================================================
}
}