username@email.com
2024-04-12 5f4384bdab4697cc0a678fb17e55603a91a4750b
CoreCms.Net.Services/Cart/CoreCmsCartServices.cs
@@ -12,10 +12,12 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using CoreCms.Net.Auth.HttpContextUser;
using CoreCms.Net.Configuration;
using CoreCms.Net.IRepository;
using CoreCms.Net.IRepository.UnitOfWork;
using CoreCms.Net.IServices;
using CoreCms.Net.IServices.baifenbingfa;
using CoreCms.Net.Loging;
using CoreCms.Net.Model.Entities;
using CoreCms.Net.Model.Entities.Expression;
@@ -57,6 +59,8 @@
        private readonly ICoreCmsSolitaireServices _solitaireServices;
        private readonly ICoreCmsUserShipServices _userShipServices;
        private readonly ICoreCmsStoreServices _storeServices;
        private readonly IBfbfComAPIService  _bfbfComAPIService;
        private readonly IHttpContextUser _user;
        public CoreCmsCartServices(
            ICoreCmsCartRepository dal
@@ -69,7 +73,17 @@
            , ICoreCmsUserServices userServices
            , ICoreCmsSettingServices settingServices
            , ICoreCmsProductsServices productsServices
            , ICoreCmsPinTuanGoodsServices pinTuanGoodsServices, ICoreCmsPromotionConditionServices promotionConditionServices, ICoreCmsGoodsServices goodsServices, ICoreCmsGoodsCategoryServices goodsCategoryServices, ICoreCmsPromotionResultServices promotionResultServices, ICoreCmsPinTuanRecordServices pinTuanRecordServices, ICoreCmsSolitaireServices solitaireServices, ICoreCmsUserShipServices userShipServices, ICoreCmsStoreServices storeServices)
            , ICoreCmsPinTuanGoodsServices pinTuanGoodsServices
            , IBfbfComAPIService bfbfComAPIService
            ,ICoreCmsPromotionConditionServices promotionConditionServices
            , ICoreCmsGoodsServices goodsServices
            , ICoreCmsGoodsCategoryServices goodsCategoryServices
            , ICoreCmsPromotionResultServices promotionResultServices
            , ICoreCmsPinTuanRecordServices pinTuanRecordServices
            , ICoreCmsSolitaireServices solitaireServices
            , ICoreCmsUserShipServices userShipServices
            , ICoreCmsStoreServices storeServices
            ,IHttpContextUser user)
        {
            this._dal = dal;
            base.BaseDal = dal;
@@ -92,6 +106,8 @@
            _solitaireServices = solitaireServices;
            _userShipServices = userShipServices;
            _storeServices = storeServices;
            _bfbfComAPIService = bfbfComAPIService;
            _user   = user;
        }
        #region 设置购物车商品数量====================================================
@@ -426,8 +442,9 @@
        /// <param name="ids">已选择货号</param>
        /// <param name="type">购物车类型/同订单类型</param>
        /// <param name="objectId">关联非订单类型数据序列</param>
        /// <param name="goodsId">goodsId</param>
        /// <returns></returns>
        public async Task<WebApiCallBack> GetCartDtoData(int userId, int[] ids = null, int type = 1, int objectId = 0)
        public async Task<WebApiCallBack> GetCartDtoData(int userId, int[] ids = null, int type = 1, int objectId = 0, int goodsId = 0)
        {
            var jm = new WebApiCallBack() { methodDescription = "获取购物车原始列表(未核算)" };
@@ -447,6 +464,17 @@
            {
                carts = await _dal.QueryListByClauseAsync(p => p.userId == userId && p.type == type, p => p.id, OrderByType.Asc);
            }
            if (goodsId>0)
            {
                var products = await  _productsServices.GetProducts(goodsId);
                int[] ss =  products.Select(x => x.id).ToArray();
                carts = carts.Where(p => ss.Contains(p.productId)).ToList();
            }
            var cartDto = new CartDto { userId = userId, type = type };
            foreach (var item in carts)
@@ -503,6 +531,16 @@
            {
                case (int)GlobalEnumVars.OrderType.Common:
                    //标准模式不需要修改订单数据和商品数据
                    {
                        if(await _bfbfComAPIService.IsDictionary(_user.ID))
                        {
                            foreach (var item in cartDto.list)
                            {
                                item.products.price=item.products.distributionPrice;
                            }
                        }
                    }
                    break;
                case (int)GlobalEnumVars.OrderType.PinTuan:
                    //拼团模式走拼团价,去修改商品价格
@@ -568,11 +606,11 @@
        /// <param name="userShipId">用户收货地址</param>
        /// <param name="objectId">关联非普通订单营销类型序列</param>
        /// <returns></returns>
        public async Task<WebApiCallBack> GetCartInfos(int userId, int[] ids, int orderType, int areaId, int point, string couponCode, int deliveryType = (int)GlobalEnumVars.OrderReceiptType.Logistics, int userShipId = 0, int objectId = 0)
        public async Task<WebApiCallBack> GetCartInfos(int userId, int[] ids, int orderType, int areaId, int point, string couponCode, int deliveryType = (int)GlobalEnumVars.OrderReceiptType.Logistics, int userShipId = 0, int objectId = 0,  int goodsId = 0)
        {
            var jm = new WebApiCallBack() { methodDescription = "获取处理后的购物车信息" };
            var cartDto = new CartDto(); //必须初始化
            var cartDtoData = await GetCartDtoData(userId, ids, orderType, objectId);
            var cartDtoData = await GetCartDtoData(userId, ids, orderType, objectId, goodsId);
            if (!cartDtoData.status)
            {
                jm.msg = "1";