public IActionResult Index() { var returnModels = new Dictionary <string, string>(); var returnString = ""; var infos = MeiTShop.BindShopInfo(_httpClientFactory); if (infos != null) { var appCodes = string.Empty; foreach (var info in infos.data) { appCodes += info + ","; } appCodes = appCodes.Substring(0, appCodes.Length - 1); var shopDetails = MeiTShop.ShopDetailInfo(_httpClientFactory, appCodes); foreach (var rShopDetail in shopDetails.data) { returnModels.Add(rShopDetail.app_poi_code, rShopDetail.name); //判断是否已经存在门店 var exist = _meiTConfigService.GetMeiTConfigByShopId(rShopDetail.app_poi_code); if (exist == null) { //像数据库中插入数据 var configBuild = new MeiTConfig { AppKey = "2863", AppSecret = "728e9163c49542ac20c4bf473e731f66", InterUrl = "", Name = rShopDetail.name, ShopId = rShopDetail.app_poi_code, Zp_ShopId = "1", Zp_ShopName = "1" }; _meiTConfigService.Add(configBuild); } else { continue; } } returnString = JsonConvert.SerializeObject(returnModels); } return(Content(returnString)); }
public async void HandleToZp(OrderPayed model, List <OrderProduct> products) { var configInfo = _meiTConfigService.GetMeiTConfigByShopId(model.app_poi_code); if (configInfo != null && !string.IsNullOrEmpty(configInfo.Zp_ShopId)) { //获取当前门店的菜品 var cpList = _meiTProductInfoService.ListProductInfo(model.app_poi_code); if (cpList == null || cpList.Count == 0) { return; } var insertData = new MeiTOrder_ZpOrder { OrderId = model.order_id, CQ_KT_DC_TH = "自结美团", Bas_text = "自结外卖", People = model.dinners_number, Cope = model.total, TotalPrice = model.original_price - model.shipping_fee, Ptdjh = "#" + model.day_seq + "美团外卖", door_id = configInfo.Zp_ShopId, door_name = configInfo.Zp_ShopName, WM_PT = "MT", }; if (model.delivery_time != 0) { insertData.DeliverTime = CommonHelper.GenericTimeStamp(model.delivery_time); } if (products != null && products.Count > 0) { var zpCp = ""; foreach (var orderProduct in products) { var cpInfo = cpList.FirstOrDefault(p => p.ProductName == orderProduct.food_name); if (cpInfo == null || string.IsNullOrEmpty(cpInfo.Zp_ProductId)) { continue; } else { zpCp += "<" + cpInfo.Zp_ProductId + "^" + orderProduct.quantity + "^" + orderProduct.food_property + '^' + orderProduct.price.ToString("0.00") + ">"; } } //计算餐盒费 var boxPrice = products.Sum(p => p.box_num * p.box_price); zpCp += "<990103^" + boxPrice + "^^1.00>"; insertData.Eat_BM_CP = zpCp; insertData.Eat_allremark = ZpOrderRemark(model.day_seq, WebUtility.UrlDecode(model.caution)); } try { //将结果插入数据库 await _Conn.InsertAsync(insertData); } catch { //直接抛掉错误 throw; } } }