public async Task EleSyncStock(UserDTO user) { var bak365Util = new Bak365Util(user.ConnString); //获取美团开启自动同步库存的门店 var shopConfigs = await _shopConfigService.GetAutoSyncListAsync(user.Id, 0); if (shopConfigs.Count > 0) { var account = _accountService.GetAccount(user.Id); foreach (var shopConfig in shopConfigs) { //获取门店商品 var foods = GetMtFoods(account, shopConfig.ShopNo); //获取365库存 var currentStocks = bak365Util.GetCurrentStock(shopConfig.ShopNo, (IEnumerable <string>)foods.Select(x => x.ProdNo)); var data = from a in foods join b in currentStocks on a.ProdNo equals b.ProdNo select new { ProdCate = a.ProdCode, ProdNo = a.ProdNo, Stock = b.Stock }; //同步库存 MtUpdateStock(account, shopConfig.ShopNo, data); } } }
public async Task UpDown(UserDTO user) { var account = _accountService.GetAccount(user.Id); var bak365Util = new Bak365Util(user.ConnString); var shopProds = await _stockRuleService.GetListShopProdAsync(user.Id); foreach (var shopProd in shopProds) { var currentStocks = bak365Util.GetCurrentStock(shopProd.ShopNo, shopProd.StockRuleProds.Select(x => x.ProdNo)); var data = from a in shopProd.StockRuleProds join b in currentStocks on a.ProdNo equals b.ProdNo select new StockModel() { ProdNo = a.ProdNo, MtMarkStock = a.MtStock, EleMarkStock = a.EleStock, CurrentStock = b.Stock }; await MtUpDown(account, shopProd.ShopNo, data); await EleUpDown(user.Id, shopProd.ShopNo, data); } }