/// <summary> /// 获取价格,执行修改 /// </summary> /// <param name="pkid"></param> /// <param name="shopCode"></param> /// <param name="pid"></param> /// <param name="itemId"></param> /// <param name="skuId"></param> /// <param name="itemCode"></param> /// <returns></returns> public static async Task <decimal?> SyncThirdPartyPrice(long pkid, string shopCode, string pid, long itemId, long skuId, string itemCode) { decimal price = 0; //第三方价格 string title = string.Empty; //第三方标题 switch (shopCode) { case "京东自营": var jdPrice = await JingDongShopManage.GetJingDongPrice(skuId.ToString()); if (jdPrice != null) { price = jdPrice.Price; title = jdPrice.Title; } break; case "麦轮胎官网": var mailuntaiPrice = await GetItemPrice(itemId.ToString(), client => client.GetMailuntaiPriceAsync); if (mailuntaiPrice != null) { price = mailuntaiPrice.Price; title = mailuntaiPrice.Title; } break; case "养车无忧": var yangche51Price = await GetItemPrice(itemCode, client => client.GetYangche51PriceAsync); if (yangche51Price != null) { price = yangche51Price.Price; title = yangche51Price.Title; } break; case "汽配龙": await Task.Delay(100); var qplPriceModel = await QPLShopManage.GetQPLPrice(pid); if (qplPriceModel.Data != null) { price = qplPriceModel.Data.ListPrice; title = qplPriceModel.Data.ProductName; } break; case "汽车超人零售": var qccrRetailPrice = await GetItemPrice(itemId.ToString(), client => client.GetQccrRetailPriceAsync); if (qccrRetailPrice != null) { price = qccrRetailPrice.Price; title = qccrRetailPrice.Title; } break; case "汽车超人批发": var qccrTradePrice = await GetItemPrice(itemId.ToString(), client => client.GetQccrTradePriceAsync); if (qccrTradePrice != null) { price = qccrTradePrice.Price; title = qccrTradePrice.Title; } break; case "康众官网": var carzonePrice = await GetItemPrice(itemCode, client => client.GetCarzonePriceFromAppAsync); if (carzonePrice != null) { price = carzonePrice.Price; title = carzonePrice.Title; } break; default: var taobaoPrice = await TaobaoShopManage.GetTabaoPrice(itemId.ToString()); if (taobaoPrice != null) { price = taobaoPrice.Price; title = taobaoPrice.Title; } break; } //获取到价格,执行修改 if (price > 0) { using (var cmd = new SqlCommand(@"UPDATE Tuhu_productcatalog..CompetingProductsMonitor WITH (ROWLOCK) SET Price = @Price, Title = @Title, LastUpdateDateTime = GETDATE() WHERE PKID=@PKID" )) { cmd.Parameters.AddWithValue("@Price", price); cmd.Parameters.AddWithValue("@Title", title); cmd.Parameters.AddWithValue("@PKID", pkid); await DbHelper.ExecuteNonQueryAsync(cmd); return(price); } } return(null); }
public ActionResult PriceMonitorConfig(CompetingProductsMonitorEntity model) { if (model == null) { return(Json(-2)); } switch (model.ShopCode) { case "京东自营": { var price = GetItemPrice(model.ItemID.ToString(), client => client.GetJingdongPrice); if (price == null) { return(Json(-4)); } model.Price = price.Price; model.Title = price.Title; model.SkuID = model.ItemID; model.ItemID = 0; } break; case "麦轮胎官网": { var price = GetItemPrice(model.ItemID.ToString(), client => client.GetMailuntaiPrice); if (price == null) { return(Json(-4)); } model.Price = price.Price; model.Title = price.Title; } break; case "养车无忧": { var price = GetItemPrice(model.ItemCode, client => client.GetYangche51Price); if (price == null) { return(Json(-4)); } model.Price = price.Price; model.Title = price.Title; //清除ItemID model.ItemID = 0; model.SkuID = 0; } break; case "汽配龙": { var qplProductInfo = QPLShopManage.GetQPLPrice(model.Pid); model.Price = qplProductInfo.Item1; model.Title = qplProductInfo.Item2; model.ItemID = 0; model.SkuID = 0; model.ItemCode = string.Empty; } break; case "汽车超人零售": { var price = GetItemPrice(model.ItemID.ToString(), client => client.GetQccrRetailPrice); if (price == null) { return(Json(-4)); } model.Price = price.Price; model.Title = price.Title; } break; case "汽车超人批发": { var price = GetItemPrice(model.ItemID.ToString(), client => client.GetQccrTradePrice); if (price == null) { return(Json(-4)); } model.Price = price.Price; model.Title = price.Title; } break; case "康众官网": { var price = GetItemPrice(model.ItemCode.ToString(), client => client.GetCarzonePriceFromApp); if (price == null) { return(Json(-4)); } model.Price = price.Price; model.Title = price.Title; } break; default: { var price = GetItemPrice(model.ItemID.ToString(), client => client.GetTaobaoPrice); if (price == null) { return(Json(-4)); } model.Price = price.Price; model.Title = price.Title; } break; } var manager = new CompetingProductsMonitorManager(); var result = manager.Insert(model); return(result > 0 ? Json(model) : Json(result)); }