| | |
| | | using Essensoft.Paylink.Alipay.Domain; |
| | | using CoreCms.Net.Auth.HttpContextUser; |
| | | using MathNet.Numerics.Distributions; |
| | | using EnumsNET; |
| | | using CoreCms.Net.IRepository; |
| | | |
| | | namespace CoreCms.Net.Web.Admin.Controllers |
| | | { |
| | |
| | | private readonly IHttpContextUser _user; |
| | | private readonly ICoreCmsAreaServices _areaServices; |
| | | private readonly ICoreCmsGoodsCategoryServices _goodsCategoryServices; |
| | | private readonly ICoreCmsStockRepository _stockRepository; |
| | | private readonly ICoreCmsStockServices _stockServices; |
| | | private readonly ICoreCmsStockLogServices _stockLogServices; |
| | | private readonly IPuhuoShoukuanServices _puhuoShoukuanServices; |
| | | |
| | | /// <summary> |
| | | /// 构造函数 |
| | |
| | | , IHttpContextUser user |
| | | , ICoreCmsAreaServices areaServices |
| | | , ICoreCmsGoodsCategoryServices goodsCategoryServices |
| | | , ICoreCmsStockRepository stockRepository |
| | | , ICoreCmsStockServices stockServices |
| | | , ICoreCmsStockLogServices stockLogServices |
| | | , IPuhuoShoukuanServices puhuoShoukuanServices |
| | | ) |
| | | { |
| | | _webHostEnvironment = webHostEnvironment; |
| | |
| | | _user = user; |
| | | _areaServices = areaServices; |
| | | _goodsCategoryServices = goodsCategoryServices; |
| | | _stockRepository = stockRepository; |
| | | _stockServices = stockServices; |
| | | _stockLogServices = stockLogServices; |
| | | _puhuoShoukuanServices = puhuoShoukuanServices; |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | where = where.And(p => p.isdelete == false); |
| | | } |
| | | OtherData otherData = new OtherData(); |
| | | //获取数据 |
| | | var list = await _PuhuoServices.QueryPageGroupAsync(where, orderEx, orderBy, pageCurrent, pageSize, true); |
| | | var list = await _PuhuoServices.QueryPageGroupAsync(where, orderEx, orderBy, otherData, pageCurrent, pageSize, true); |
| | | //返回数据 |
| | | jm.data = list; |
| | | jm.code = 0; |
| | | jm.count = list.TotalCount; |
| | | jm.msg = "数据调用成功!"; |
| | | |
| | | |
| | | |
| | | otherData.heji1 = list.Sum(x=>x.nums); |
| | | otherData.heji2 = list.Sum(x => x.amount); |
| | | otherData.heji3 = list.Sum(x => x.tiaozhengnums); |
| | | jm.otherData = otherData; |
| | | return jm; |
| | | } |
| | | #endregion |
| | |
| | | coreCmsProduct.stock = coreCmsProduct.stock - entity.nums; |
| | | var bb = await _coreCmsProductsServices.UpdateAsync(coreCmsProduct); |
| | | |
| | | |
| | | //库存盘点 |
| | | var stockModel = new CoreCmsStock(); |
| | | stockModel.id = await _stockRepository.CreateCode(GlobalEnumVars.StockType.CheckGoods.ToString()); |
| | | stockModel.memo = entity.distributionName + " 经销商铺货"; |
| | | stockModel.type = (int)GlobalEnumVars.StockType.Out; |
| | | stockModel.manager = _user.ID; |
| | | stockModel.createTime = DateTime.Now; |
| | | |
| | | var stockLogModel = new CoreCmsStockLog(); |
| | | stockLogModel.stockId = stockModel.id; |
| | | stockLogModel.productId = entity.productsId; |
| | | stockLogModel.goodsId = entity.goodsId; |
| | | stockLogModel.nums = entity.nums; |
| | | stockLogModel.goodsName = entity.goodsName; |
| | | stockLogModel.sn = entity.productsName; |
| | | stockLogModel.bn = entity.productsName; |
| | | stockLogModel.spesDesc = entity.spesDesc; |
| | | var s = await _stockServices.InsertAsync(stockModel); |
| | | s = await _stockLogServices.InsertAsync(stockLogModel); |
| | | |
| | | |
| | | jm = await _PuhuoServices.InsertAsync(entity); |
| | | return jm; |
| | |
| | | |
| | | var jm = new AdminUiCallBack(); |
| | | |
| | | |
| | | if (entity.tiaozhengnums <= 0) |
| | | if(entity.jintui == 4) |
| | | { |
| | | jm.msg = "请填写调整数量"; |
| | | return jm; |
| | | } |
| | | |
| | | |
| | | |
| | | var puhuo = await _PuhuoServices.QueryByIdAsync(entity.id); |
| | | |
| | | if (entity.jintui == 2 && puhuo.nums < entity.tiaozhengnums) |
| | | { |
| | | jm.msg = "退货数量大于铺货数量,不能提交"; |
| | | return jm; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | var coreCmsProduct = await _coreCmsProductsServices.QueryByIdAsync(puhuo.productsId); |
| | | if (coreCmsProduct != null) |
| | | { |
| | | if (entity.jintui == 1 && coreCmsProduct.stock < entity.tiaozhengnums) |
| | | if (entity.shoukuannums <= 0) |
| | | { |
| | | jm.msg = "库存不足!"; |
| | | jm.msg = "请填写收款数量"; |
| | | return jm; |
| | | } |
| | | if (entity.jintui == 1) |
| | | |
| | | var puhuo = await _PuhuoServices.QueryByIdAsync(entity.id); |
| | | var aaaa = puhuo.shoukuannums ?? 0; |
| | | if ( puhuo.nums < (aaaa + entity.shoukuannums)) |
| | | { |
| | | puhuo.nums = puhuo.nums + entity.tiaozhengnums; |
| | | jm.msg = "收款数量大于铺货数量,不能提交"; |
| | | return jm; |
| | | } |
| | | else if (entity.jintui == 2) |
| | | { |
| | | puhuo.nums = puhuo.nums - entity.tiaozhengnums; |
| | | } |
| | | puhuo.price = coreCmsProduct.distributionPrice; |
| | | puhuo.amount = coreCmsProduct.distributionPrice * new decimal(puhuo.nums); |
| | | PuhuoShoukuan puhuoShoukuan = new PuhuoShoukuan(); |
| | | puhuoShoukuan.puhuoId = puhuo.id; |
| | | puhuoShoukuan.distributionId = puhuo.distributionId; |
| | | puhuoShoukuan.distributionName = puhuo.distributionName; |
| | | puhuoShoukuan.areaCode = puhuo.areaCode; |
| | | puhuoShoukuan.areaCodeName = puhuo.areaCodeName; |
| | | puhuoShoukuan.CategoryId = puhuo.CategoryId; |
| | | puhuoShoukuan.CategoryName = puhuo.CategoryName; |
| | | puhuoShoukuan.goodsId = puhuo.goodsId; |
| | | puhuoShoukuan.goodsName = puhuo.goodsName; |
| | | puhuoShoukuan.productsId = puhuo.productsId; |
| | | puhuoShoukuan.productsName = puhuo.productsName; |
| | | puhuoShoukuan.spesDesc = puhuo.spesDesc; |
| | | puhuoShoukuan.price = puhuo.price; |
| | | |
| | | puhuoShoukuan.nums = puhuo.nums; |
| | | puhuoShoukuan.amount = puhuo.amount; |
| | | puhuoShoukuan.shoukuannums = entity.shoukuannums.Value; |
| | | puhuoShoukuan.shoukuanamount = new decimal(entity.shoukuannums.Value) * puhuo.price; |
| | | puhuoShoukuan.isdelete = false; |
| | | puhuoShoukuan.createBy = _user.Name; |
| | | puhuoShoukuan.upDataBy = _user.Name; |
| | | puhuoShoukuan.createTime = DateTime.Now; |
| | | puhuoShoukuan.upDataTime = DateTime.Now; |
| | | jm = await _puhuoShoukuanServices.InsertAsync(puhuoShoukuan); |
| | | |
| | | |
| | | puhuo.upDataBy = _user.Name; |
| | | puhuo.upDataTime = DateTime.Now; |
| | | var sss = puhuo.shoukuannums ?? 0; |
| | | puhuo.shoukuannums = sss + entity.shoukuannums.Value; |
| | | var aaa = puhuo.shoukuanamount ?? new decimal(0); |
| | | puhuo.shoukuanamount = aaa + (new decimal(entity.shoukuannums.Value) * puhuo.price); |
| | | jm = await _PuhuoServices.UpdateAsync(puhuo); |
| | | |
| | | |
| | | |
| | | } |
| | | else |
| | | { |
| | | jm.msg = "没找到产品"; |
| | | return jm; |
| | | if (entity.tiaozhengnums <= 0 && entity.jintui != 3) |
| | | { |
| | | jm.msg = "请填写调整数量"; |
| | | return jm; |
| | | } |
| | | |
| | | |
| | | |
| | | var puhuo = await _PuhuoServices.QueryByIdAsync(entity.id); |
| | | |
| | | if (entity.jintui == 2 && puhuo.nums < entity.tiaozhengnums) |
| | | { |
| | | jm.msg = "退货数量大于铺货数量,不能提交"; |
| | | return jm; |
| | | } |
| | | |
| | | if (entity.jintui == 3 && puhuo.nums < -entity.tiaozhengnums) |
| | | { |
| | | jm.msg = "盘点减少数量大于铺货数量,不能提交"; |
| | | return jm; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | var coreCmsProduct = await _coreCmsProductsServices.QueryByIdAsync(puhuo.productsId); |
| | | if (coreCmsProduct != null) |
| | | { |
| | | if (entity.jintui == 1 && coreCmsProduct.stock < entity.tiaozhengnums) |
| | | { |
| | | jm.msg = "库存不足!"; |
| | | return jm; |
| | | } |
| | | if (entity.jintui == 1) |
| | | { |
| | | puhuo.nums = puhuo.nums + entity.tiaozhengnums; |
| | | } |
| | | else if (entity.jintui == 2) |
| | | { |
| | | puhuo.nums = puhuo.nums - entity.tiaozhengnums; |
| | | } |
| | | else if (entity.jintui == 3) |
| | | { |
| | | puhuo.nums = puhuo.nums + entity.tiaozhengnums; |
| | | } |
| | | puhuo.price = coreCmsProduct.distributionPrice; |
| | | puhuo.amount = coreCmsProduct.distributionPrice * new decimal(puhuo.nums); |
| | | } |
| | | else |
| | | { |
| | | jm.msg = "没找到产品"; |
| | | return jm; |
| | | } |
| | | |
| | | |
| | | puhuo.isdelete = false; |
| | | //entity.createBy = _user.Name; |
| | | puhuo.upDataBy = _user.Name; |
| | | //entity.createTime = DateTime.Now; |
| | | puhuo.upDataTime = DateTime.Now; |
| | | |
| | | |
| | | |
| | | if (entity.jintui == 1) |
| | | { |
| | | coreCmsProduct.stock = coreCmsProduct.stock - entity.tiaozhengnums; |
| | | } |
| | | else if (entity.jintui == 2) |
| | | { |
| | | coreCmsProduct.stock = coreCmsProduct.stock + entity.tiaozhengnums; |
| | | } |
| | | |
| | | //盘点不扣减库存 |
| | | if (entity.jintui != 3) |
| | | { |
| | | var bb = await _coreCmsProductsServices.UpdateAsync(coreCmsProduct); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | var stockModel = new CoreCmsStock(); |
| | | stockModel.id = await _stockRepository.CreateCode(GlobalEnumVars.StockType.CheckGoods.ToString()); |
| | | |
| | | |
| | | stockModel.manager = _user.ID; |
| | | stockModel.createTime = DateTime.Now; |
| | | |
| | | var stockLogModel = new CoreCmsStockLog(); |
| | | stockLogModel.stockId = stockModel.id; |
| | | stockLogModel.productId = puhuo.productsId; |
| | | stockLogModel.goodsId = puhuo.goodsId; |
| | | if (entity.jintui == 1) |
| | | { |
| | | stockModel.memo = puhuo.distributionName + " 经销商铺货"; |
| | | stockModel.type = (int)GlobalEnumVars.StockType.Out; |
| | | stockLogModel.nums = entity.tiaozhengnums; |
| | | } |
| | | else if (entity.jintui == 2) |
| | | { |
| | | stockModel.memo = puhuo.distributionName + " 经销商铺货退货"; |
| | | stockModel.type = (int)GlobalEnumVars.StockType.In; |
| | | stockLogModel.nums = entity.tiaozhengnums; |
| | | } |
| | | else if (entity.jintui == 3) |
| | | { |
| | | stockModel.memo = puhuo.distributionName + " 铺货盘点核减损耗"; |
| | | stockModel.type = (int)GlobalEnumVars.StockType.CheckPuhuo; |
| | | stockLogModel.nums = entity.tiaozhengnums; |
| | | } |
| | | |
| | | stockLogModel.goodsName = puhuo.goodsName; |
| | | stockLogModel.sn = puhuo.productsName; |
| | | stockLogModel.bn = puhuo.productsName; |
| | | stockLogModel.spesDesc = puhuo.spesDesc; |
| | | var s = await _stockServices.InsertAsync(stockModel); |
| | | s = await _stockLogServices.InsertAsync(stockLogModel); |
| | | |
| | | |
| | | |
| | | jm = await _PuhuoServices.UpdateAsync(puhuo); |
| | | } |
| | | |
| | | |
| | | puhuo.isdelete = false; |
| | | //entity.createBy = _user.Name; |
| | | puhuo.upDataBy = _user.Name; |
| | | //entity.createTime = DateTime.Now; |
| | | puhuo.upDataTime = DateTime.Now; |
| | | |
| | | |
| | | |
| | | if (entity.jintui == 1) |
| | | { |
| | | coreCmsProduct.stock = coreCmsProduct.stock - entity.tiaozhengnums; |
| | | } |
| | | else if (entity.jintui == 2) |
| | | { |
| | | coreCmsProduct.stock = coreCmsProduct.stock + entity.tiaozhengnums; |
| | | } |
| | | |
| | | var bb = await _coreCmsProductsServices.UpdateAsync(coreCmsProduct); |
| | | |
| | | |
| | | |
| | | jm = await _PuhuoServices.UpdateAsync(puhuo); |
| | | |
| | | return jm; |
| | | } |
| | | #endregion |
| | |
| | | { |
| | | var jm = new AdminUiCallBack(); |
| | | var puhuoss = await _PuhuoServices.QueryListByClauseAsync(p => p.productsId == entity.productsId); |
| | | |
| | | foreach (var puhuo in puhuoss) |
| | | { |
| | | puhuo.productsName = puhuo.productsName + " " + puhuo.spesDesc; |
| | | var distribution = await _coreCmsDistributionServices.QueryByIdAsync(puhuo.distributionId); |
| | | if (distribution != null) |
| | | { |
| | | puhuo.schoolName = distribution.schoolName; |
| | | } |
| | | } |
| | | //var model = await _PuhuoServices.QueryByIdAsync(entity.id, false); |
| | | //if (model == null) |
| | | //{ |