From 7f26cd7c3e492062418cdc7dbe9d7ce14cbe5f05 Mon Sep 17 00:00:00 2001 From: username@email.com <yzy2002yzy@163.com> Date: 星期三, 26 六月 2024 11:47:37 +0800 Subject: [PATCH] 铺货修改 --- CoreCms.Net.Web.Admin/Controllers/baifenbingfa/PuhuoController.cs | 282 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 223 insertions(+), 59 deletions(-) diff --git a/CoreCms.Net.Web.Admin/Controllers/baifenbingfa/PuhuoController.cs b/CoreCms.Net.Web.Admin/Controllers/baifenbingfa/PuhuoController.cs index a0ccdb2..da67438 100644 --- a/CoreCms.Net.Web.Admin/Controllers/baifenbingfa/PuhuoController.cs +++ b/CoreCms.Net.Web.Admin/Controllers/baifenbingfa/PuhuoController.cs @@ -42,6 +42,8 @@ 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 { @@ -66,6 +68,10 @@ 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> /// 鏋勯�犲嚱鏁� @@ -81,6 +87,10 @@ , IHttpContextUser user , ICoreCmsAreaServices areaServices , ICoreCmsGoodsCategoryServices goodsCategoryServices + , ICoreCmsStockRepository stockRepository + , ICoreCmsStockServices stockServices + , ICoreCmsStockLogServices stockLogServices + , IPuhuoShoukuanServices puhuoShoukuanServices ) { _webHostEnvironment = webHostEnvironment; @@ -94,6 +104,10 @@ _user = user; _areaServices = areaServices; _goodsCategoryServices = goodsCategoryServices; + _stockRepository = stockRepository; + _stockServices = stockServices; + _stockLogServices = stockLogServices; + _puhuoShoukuanServices = puhuoShoukuanServices; } @@ -321,13 +335,21 @@ { 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 @@ -832,7 +854,26 @@ 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; @@ -883,74 +924,187 @@ 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 @@ -1010,6 +1164,16 @@ { 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) //{ -- Gitblit v1.9.1