| | |
| | | /// <param name="userId"></param> |
| | | /// <param name="numType"></param> |
| | | /// <param name="type"></param> |
| | | /// <param name="isCustomizable"></param> |
| | | /// <returns></returns> |
| | | public async Task<WebApiCallBack> SetCartNum(int id, int nums, int userId, int numType, int type = 1) |
| | | { |
| | |
| | | jm.msg = "获取购物车数据失败"; |
| | | return jm; |
| | | } |
| | | var outData = await Add(userId, cartModel.productId, nums, numType, type); |
| | | var outData = await Add(userId, cartModel.productId, nums, numType, type,isCustomizable:cartModel.isCustomizable); |
| | | jm.status = outData.status; |
| | | jm.msg = jm.status ? GlobalConstVars.SetDataSuccess : GlobalConstVars.SetDataFailure; |
| | | jm.otherData = outData; |
| | |
| | | /// <param name="numType">数量类型/1是直接增加/2是赋值</param> |
| | | /// <param name="cartTypes">1普通购物还是2团购秒杀3团购模式4秒杀模式6砍价模式7赠品</param> |
| | | /// <param name="objectId">关联对象类型</param> |
| | | /// <param name="isCustomizable">关联对象类型</param> |
| | | /// <returns></returns> |
| | | public async Task<WebApiCallBack> Add(int userId, int productId, int nums, int numType, int cartTypes = 1, int objectId = 0) |
| | | public async Task<WebApiCallBack> Add(int userId, int productId, int nums, int numType, int cartTypes = 1, int objectId = 0,bool isCustomizable = false) |
| | | { |
| | | var jm = new WebApiCallBack(); |
| | | |
| | |
| | | if (products == null) |
| | | { |
| | | jm.msg = "获取货品信息失败"; |
| | | return jm; |
| | | } |
| | | if(isCustomizable==true&&products.isCustomizable!=true) |
| | | { |
| | | jm.msg = "该货物不支持定制"; |
| | | return jm; |
| | | } |
| | | //判断是否下架 |
| | |
| | | productId = productId, |
| | | nums = nums, |
| | | type = cartTypes, |
| | | objectId = objectId |
| | | objectId = objectId, |
| | | //支持定制 |
| | | isCustomizable= isCustomizable, |
| | | }; |
| | | var outId = await _dal.InsertAsync(catInfo); |
| | | jm.status = outId > 0; |
| | |
| | | /// <param name="userId">用户序列</param> |
| | | /// <param name="nums">加入购物车数量</param> |
| | | /// <param name="ruleId">规则序列</param> |
| | | /// <param name="ruleId">货品是否定制</param> |
| | | public async Task<WebApiCallBack> AddCartHavePinTuan(int productId, int userId = 0, int nums = 1, int ruleId = 0) |
| | | { |
| | | var jm = new WebApiCallBack(); |
| | |
| | | cartProducts.type = item.type; |
| | | cartProducts.weight = goodsWeight; |
| | | cartProducts.products = productInfo; |
| | | cartProducts.isCustomizable = item.isCustomizable; |
| | | //如果传过来了购物车数据,就算指定的购物车的数据,否则,就算全部购物车的数据 |
| | | if (ids != null && ids.Any() && ids.Contains(item.id)) |
| | | { |
| | |
| | | } |
| | | //单条商品总价 |
| | | item.products.amount = Math.Round(item.nums * (decimal)item.products.price, 2); |
| | | //定制商品添加定制价格 |
| | | if (item.isCustomizable) |
| | | //是定制商品 |
| | | { |
| | | item.products.amount += _bfbfComAPIService.CommandCustomizable(item.nums); |
| | | item.CustomizableMoney = _bfbfComAPIService.CommandCustomizable(item.nums); |
| | | } |
| | | |
| | | if (item.isSelect) |
| | | { |