/// <summary> /// 更新订单状态 /// </summary> /// <param name="orderId"></param> /// <param name="status"></param> /// <returns></returns> public string UpdateOrderStatus(long orderId, int status, int channel) { IOrderRepository orderRepository = ProductChannelFactory.CreateOrderRepository(Shop, (ProductChannel)channel); var order = orderRepository.GetSimpleOrderById(orderId); string remark = string.Format("<br/>【飞猪】:该订单{1} [{0}]", DateTime.Now.ToString(), ((OrderStatus)status).GetDescription()); if (order != null) { if (!string.IsNullOrEmpty(order.Remark) && order.Remark.Contains("该订单已确认发货")) { orderRepository.UpdateShipRemark(orderId, 6, remark); return("更新订单成功,该订单已发货"); } bool isSuccess = false; string message = string.Empty; isSuccess = UpdateTmallOrderStatus(orderId, status, out message); if (isSuccess) { Task.Factory.StartNew(() => { if (status == 6) { FlyPigMessageUility.ThirdCenterMessage(Shop, order.Aid); } }); try { var flag = orderRepository.UpdateShipRemark(orderId, status, remark); if (flag) { // shipLog.WriteOrder(orderId.ToString(), string.Format("【更新订单状态成功】:订单{0}", orderId)); // return "更新订单状态成功!"; } else { // shipLog.WriteOrder(orderId.ToString(), string.Format("【更新订单状态成功,保存数据库失败】:订单{0}", orderId)); } } catch (Exception ex) { // shipLog.WriteOrder(orderId.ToString(), string.Format("【更新订单状态出现异常,保存数据库失败】:具体异常:{0}", ex.ToString())); } return("更新订单状态成功!"); } else { try { if ((ProductChannel)channel == ProductChannel.BigTree) { var orderInfo = new AliTripOrderClient(Shop).GetOrderStatus(orderId); if (orderInfo != null && orderInfo.TradeStatus == "WAIT_SELLER_SEND_GOODS" && orderInfo.LogisticsStatus == "2") { orderRepository.UpdateShipRemark(orderId, 6, remark); return("更新订单成功,该订单已发货"); } } string opration = status == 6 ? "发货失败" : "不确认失败"; remark = string.Format("<br/>【飞猪】:该订单 {1},具体原因:{2} [{0}]", DateTime.Now.ToString(), opration, message); var flag = orderRepository.UpdateShipRemark(orderId, 7, remark); } catch (Exception ex) { // shipLog.WriteOrder(orderId.ToString(), string.Format("【更新订单状态出现异常】:具体异常:{0}", ex.ToString())); } return("更新订单状态失败!"); } } else { return("订单不存在!"); } }
public ServiceResult CreateOrder(int id) { var result = new ServiceResult(); try { var order = sqlSugarClient.Queryable <TB_hotelcashorder>().Where(u => u.aId == id).First(); if (order == null) { return(result.SetError("订单不存在")); } if (order.alipayPay == 0) { return(result.SetError("该订单未付款")); } if (order.state != 24) { return(result.SetError("该订单状态已变更")); } if (order.Refuse == 2) { return(result.SetError("该订单已取消")); } if (!string.IsNullOrEmpty(order.sourceOrderID)) { return(result.SetError("该订单未提交到美团,请勿重复下单")); } //List<DailyInfo> dailyInfo = JsonConvert.DeserializeObject<List<DailyInfo>>(order.DailyInfoPrice); int tBreakfast = getBreakfast(order.hotelID, order.roomID, order.ratePlanID, order.orderNO); //logWriter.Write("美团:酒店id:{0},roomID:{1},ratePlanID:{2},早餐数:{3},飞猪早餐数:{4},订单号:{5}", order.hotelID, order.roomID, order.ratePlanID, tBreakfast,order.userID,order.orderNO); //判断早餐数是否对等 if (order.userID > tBreakfast && tBreakfast != 99 && order.userID != 0) { Task.Factory.StartNew(() => { try { //当早餐数不对等时更新rp string urlUpdateRp = string.Format("http://localhost:9092/ashx/rnxUpdateRaPlan.ashx?type=rp&source=5&hid={0}", order.hotelID); string getBoby = WebHttpRequest.Get(urlUpdateRp); if (!getBoby.Contains("更新价格计划成功")) { WebHttpRequest.Get(urlUpdateRp); } int NowHour = DateTime.Now.Hour; //当前时间的时数 int NowMinute = DateTime.Now.Minute; //当前时间的分钟数 //晚上12点半后,8点前满房时自动发送短信 if ((NowHour == 0 && NowMinute > 30) || (NowHour > 0 && NowHour < 8)) { //发满房短信(发送满房信息) FlyPigMessageUility.ThirdCommunication(Shop, Convert.ToInt32(order.aId), "系统", 1); } } catch { } }); string beiZhu = string.Format("【系统】:下单失败,具体原因:早餐个数不相等,天猫:{1}, 供应商:{2},取消执行自动下单,请联系申退 [{0}] <br/>【系统】:已自动更正早餐数,无需人工手动下线该酒店或房型 [{0}]", DateTime.Now.ToString(), order.userID, tBreakfast); orderRepository.UpdateRemarkState(order.aId, 24, beiZhu); logWriter.Write("美团(供应商早餐数发生变化):飞猪酒店id:{0},酒店id:{1},roomID:{2},ratePlanID:{3},早餐数:{4},飞猪早餐数:{5},订单号:{6}", order.TaoBaoHotelId, order.hotelID, order.roomID, order.ratePlanID, tBreakfast, order.userID, order.orderNO); return(result.SetError("该订单早餐个数不相等")); } else if (order.userID < tBreakfast) { //如果供应商的早餐数大于平台的,更新rp Task.Factory.StartNew(() => { try { string urlUpdateRp = string.Format("http://localhost:9092/ashx/rnxUpdateRaPlan.ashx?type=rp&source=5&hid={0}", order.hotelID); string getBoby = WebHttpRequest.Get(urlUpdateRp); if (!getBoby.Contains("更新价格计划成功")) { WebHttpRequest.Get(urlUpdateRp); } } catch { } }); logWriter.Write("美团(平台早餐数少):飞猪酒店id:{0},酒店id:{1},roomID:{2},ratePlanID:{3},早餐数:{4},飞猪早餐数:{5},订单号:{6}", order.TaoBaoHotelId, order.hotelID, order.roomID, order.ratePlanID, tBreakfast, order.userID, order.orderNO); } string message = string.Empty; string content = string.Empty; string url = string.Empty; if (Shop == ShopType.LingZhong || Shop == ShopType.YinJi || Shop == ShopType.RenXing) { var synResult = SynChannelOrder((int)order.aId); if (synResult.IsSucess) { content = result.Message; message = string.Format("【系统】:同步订单请求成功,结果:{0} [{1}]", content, DateTime.Now.ToString()); if (order.orderType == 11) { url = string.Format("http://47.96.68.32/mtservice/orderCreate.ashx?saleorderno={0}&salesource=4", order.taoBaoOrderId, RequestUrl); } else { url = string.Format("http://47.107.30.243:9000/xw/orderCreate?saleorderno={0}", order.taoBaoOrderId); } } } else { if (Shop == ShopType.RenNiXing) { url = string.Format("http://localhost:8094/rnx/orderCreate?saleorderno={0}&salesource=32", order.taoBaoOrderId); } else { url = string.Format("http://47.96.68.32/mtservice/orderCreate.ashx?saleorderno={0}&salesource=4", order.taoBaoOrderId, RequestUrl); } } content = WebHttpRequest.GetOrder(url); if (content.Contains("可预订接口返回不可订") || content.Contains("订单提交给美团失败") || content.Contains("已售完或扣减库存失败") || content.Contains("订单价格与产品价格不符, 可能已变价") || content.Contains("失败,已变价,请判断价格再提交")) { Task.Factory.StartNew(() => { try { AliTripValidate av = new AliTripValidate(); av.CheckInTime = order.checkInDate; av.CheckOutTime = order.checkOutDate; av.HotelId = order.hotelID; av.RoomId = order.roomID; av.RatePlanId = order.ratePlanID; av.RatePlanCode = "mr" + order.hotelID + "_" + order.roomID + "_" + order.ratePlanID; av.CreateTime = DateTime.Now; av.IsFull = true; av.Channel = (int)Channel; av.Shop = (int)Shop; av.Remark = "下单满房"; SqlSugarContext.RenNiXingInstance.Insertable(av).ExecuteCommand(); string updateUrl = string.Format("http://localhost:8097/apiAshx/UpdateRoomRate.ashx?type=RoomRate&hid={0}&source={1}", order.hotelID, (int)Channel); WebHttpRequest.Get(updateUrl); orderRepository.UpdateOrderStutas(order.aId, 63); int NowHour = DateTime.Now.Hour; //当前时间的时数 int NowMinute = DateTime.Now.Minute; //当前时间的分钟数 //晚上12点半后,8点前满房时自动发送短信 if ((NowHour == 0 && NowMinute > 30) || (NowHour > 0 && NowHour < 8)) { //发满房短信(发送满房信息) FlyPigMessageUility.ThirdCommunication(Shop, Convert.ToInt32(order.aId), "系统", 1); } } catch { } }); //string caozuo = string.Format("<br/>【系统】已发送满房短信[{0}]", DateTime.Now.ToString()); ////发满房短信 //FlyPigMessageUility.ThirdCommunication(Shop,Convert.ToInt32(order.aId), "系统", 1); ////更新状态和操作 //orderRepository.UpdateRemarkStateCaoZuo(order.aId, 63,"", caozuo); } message = string.Format("<br/>【系统】:提交创建美团订单请求成功,结果:{0} [{1}]", content, DateTime.Now.ToString()); orderRepository.UpdateOrderRemark(order.aId, message); return(result.SetSucess(content)); } catch (Exception ex) { string message = string.Format("<br/>【系统】下单失败,出现异常,请手动下单,异常内容:{0}", ex.ToString()); orderRepository.UpdateOrderRemark(id, message); return(result.SetError("下单失败,出现异常,请手动下单")); } }
public ServiceResult CreateOrder(int id) { var result = new ServiceResult(); var RequestEt = new CreateOrderJsonEt(); var response = new WebServiceResponse <OrderInfoJsonEt>(); try { var order = sqlSugarClient.Queryable <TB_hotelcashorder>().Where(u => u.aId == id).First(); if (order == null) { return(result.SetError("订单不存在")); } if (order.alipayPay == 0) { return(result.SetError("该订单未付款")); } if (order.state != 24) { return(result.SetError("该订单状态已变更")); } if (order.Refuse == 2) { return(result.SetError("该订单已取消")); } if (!string.IsNullOrEmpty(order.sourceOrderID)) { return(result.SetError("该订单未提交到大都市,请勿重复下单")); } if (order.totalPrice == 0) { string remark = string.Format("【系统】:下单到大都市失败(已售完或扣减库存失败) [{0}]", DateTime.Now.ToString()); orderRepository.UpdateRemarkState(order.aId, 63, remark); int NowHour = DateTime.Now.Hour; //当前时间的时数 int NowMinute = DateTime.Now.Minute; //当前时间的分钟数 Task.Factory.StartNew(() => { try { //晚上12点半后,8点前满房时自动发送短信 if ((NowHour == 0 && NowMinute > 30) || (NowHour > 0 && NowHour < 8)) { //发满房短信(发送满房信息) FlyPigMessageUility.ThirdCommunication(Shop, Convert.ToInt32(order.aId), "系统", 1); } AliTripValidate av = new AliTripValidate(); av.CheckInTime = order.checkInDate; av.CheckOutTime = order.checkOutDate; av.HotelId = order.hotelID; av.RoomId = order.roomID; av.RatePlanId = order.ratePlanID; av.RatePlanCode = "dr" + order.hotelID + "_" + order.roomID + "_" + order.ratePlanID; av.CreateTime = DateTime.Now; av.IsFull = true; av.Channel = (int)Channel; av.Shop = (int)Shop; av.Remark = "下单满房"; SqlSugarContext.RenNiXingInstance.Insertable(av).ExecuteCommand(); string updateUrl = string.Format("http://localhost:8097/apiAshx/UpdateRoomRate.ashx?type=RoomRate&hid={0}&source={1}", order.hotelID, (int)Channel); WebHttpRequest.Get(updateUrl); } catch { } }); return(result.SetError("订单底价为0,无法下单到渠道!")); } //判断早餐数是否对等 if (order.hasChange == 1 && order.userID != 0 && order.userID > order.sRoomNum) { string beiZhu = string.Format("【系统】:下单失败,具体原因:早餐个数不相等,天猫:{1}, 供应商:{2},取消执行自动下单,请联系申退 [{0}] <br/>【系统】:已自动更正早餐数,无需人工手动下线该酒店或房型 [{0}]", DateTime.Now.ToString(), order.userID, order.sRoomNum); //string beiZhu = string.Format("【系统】:下单失败,具体原因:早餐个数不相等!已自动更正早餐数,无需人工手动下线该酒店或房型 [{0}]", DateTime.Now.ToString()); orderRepository.UpdateRemarkState(order.aId, 24, beiZhu); int NowHour = DateTime.Now.Hour; //当前时间的时数 int NowMinute = DateTime.Now.Minute; //当前时间的分钟数 Task.Factory.StartNew(() => { try { //晚上12点半后,8点前满房时自动发送短信 if ((NowHour == 0 && NowMinute > 30) || (NowHour > 0 && NowHour < 8)) { //发满房短信(发送满房信息) FlyPigMessageUility.ThirdCommunication(Shop, Convert.ToInt32(order.aId), "系统", 1); } AliTripValidate av = new AliTripValidate(); av.CheckInTime = order.checkInDate; av.CheckOutTime = order.checkOutDate; av.HotelId = order.hotelID; av.RoomId = order.roomID; av.RatePlanId = order.ratePlanID; av.RatePlanCode = "dr" + order.hotelID + "_" + order.roomID + "_" + order.ratePlanID; av.CreateTime = DateTime.Now; av.IsFull = true; av.Channel = (int)Channel; av.Shop = (int)Shop; av.Remark = "下单满房"; SqlSugarContext.RenNiXingInstance.Insertable(av).ExecuteCommand(); string updateUrl = string.Format("http://localhost:8097/apiAshx/UpdateRoomRate.ashx?type=RoomRate&hid={0}&source={1}", order.hotelID, (int)Channel); WebHttpRequest.Get(updateUrl); } catch { } }); logWriter.Write("大都市(供应商早餐数发生变化):飞猪酒店id:{0},酒店id:{1},roomID:{2},ratePlanID:{3},早餐数:{4},飞猪早餐数:{5},订单号:{6}", order.TaoBaoHotelId, order.hotelID, order.roomID, order.ratePlanID, order.sRoomNum, order.userID, order.orderNO); return(result.SetError("该订单早餐个数不相等")); } #region 订单 ContactPersonJsonEt contactPerson = new ContactPersonJsonEt(); contactPerson.GivenName = order.contactName; contactPerson.Surname = order.contactName; contactPerson.Telephone = order.contactTel; contactPerson.Email = ""; contactPerson.Address = ""; List <Guest> guestList = new List <Guest>(); List <string> guestNames = order.guestName.Split(',').ToList(); foreach (var item in guestNames) { Guest guest = new Guest(); guest.GivenName = item; guest.Surname = item; guest.Telephone = ""; guest.Email = ""; guestList.Add(guest); } GuestCount guestCount = new GuestCount(); guestCount.AdultCount = guestNames.Count; guestCount.ChildCount = 0; RequestEt.HotelCode = order.hotelID; RequestEt.RoomTypeCode = order.roomID; RequestEt.RatePlanCode = order.ratePlanID; RequestEt.NumberOfUnits = order.roomNum; RequestEt.DistributorReservationId = order.orderNO; RequestEt.TotalAmount = order.totalPrice; RequestEt.CheckIn = order.checkInDate.ToString("yyyy-MM-dd"); RequestEt.CheckOut = order.checkOutDate.ToString("yyyy-MM-dd"); RequestEt.Comment = ""; RequestEt.ContactPerson = contactPerson; RequestEt.GuestList = guestList; RequestEt.GuestCount = guestCount; response = OrderDataOpEt.Reservation(RequestEt); //记录预订日志 try { string orderText = string.Empty; string strRequest = Newtonsoft.Json.JsonConvert.SerializeObject(RequestEt); string strresponse = Newtonsoft.Json.JsonConvert.SerializeObject(response); orderText = "请求数据:" + strRequest + "\r\n" + "返回数据:" + strresponse; orderLogWriter.WriteOrder(order.orderNO, orderText); } catch (Exception exOrder) { } var createResult = new ServiceResult(); string message = string.Empty; if (response != null && response.Successful && response.ResponseEt != null) { string ProductReservationId = response.ResponseEt.ProductReservationId.ToString(); //大都市产品系统订单编号 string ErpReservationId = response.ResponseEt.ErpReservationId.ToString(); //大都市结算系统订单编号 order.sourceOrderID = ProductReservationId; message = string.Format("【大都市】:下单成功,订单号:({0}),大都市结算系统订单编号:{1} [{2}]", ProductReservationId, ErpReservationId, DateTime.Now.ToString()); //Pending: 待确认, Confirmed:已确认, Canceled:已取消, Failed:发生错误 //order.remark = string.Format("{0}【大都市】:{1} [{2}]<br/>", order.remark, message, DateTime.Now.ToString()); orderRepository.UpdateOrderRemarkAndSourceOrderID(order.aId, 3, message, ProductReservationId); return(result.SetSucess(message)); } else if (response != null && !response.Successful && !string.IsNullOrWhiteSpace(response.ErrMsg)) { message = string.Format("【系统】:提交创建大都市订单请求失败,失败原因:{1} [{0}]", DateTime.Now.ToString(), response.ErrMsg); orderRepository.UpdateRemarkState(order.aId, 7, message); return(result.SetError("下单失败,出现异常,错误原因{0}", response.ErrMsg)); } else { message = string.Format("【系统】:提交创建大都市订单请求失败,请查看渠道状态是否生成订单 [{0}]", DateTime.Now.ToString()); orderRepository.UpdateRemarkState(order.aId, 7, message); return(result.SetError("下单失败,出现异常,请查看渠道状态是否生成订单")); } #endregion return(result.SetSucess(message)); } catch (Exception ex) { string message = string.Format("<br/>【系统】下单失败,出现异常,请手动下单,异常内容:{0}", ex.ToString()); orderRepository.UpdateRemarkState(id, 7, message); return(result.SetError("下单失败,出现异常,请手动下单")); } }
/// <summary> /// 同步订单到辰亿 /// </summary> /// <param name="aid"></param> /// <returns></returns> public override ServiceResult SynChannelOrder(int aid) { var result = new ServiceResult(); string orderId = DateTime.Now.ToString("yyMMddHHmmssfff") + random.Next(1000, 9999) + random.Next(10, 99); try { var order = SqlSugarContext.ResellbaseInstance.Queryable <TB_hotelcashorder>().Where(u => u.aId == aid).First(); if (order.alipayPay == 0) { return(result.SetError("订单未支付,无法下单到渠道!")); } if (order.totalPrice == 0) { //<br/> string remark = string.Format("【系统】:下单到携程失败(已售完或扣减库存失败) [{0}]", DateTime.Now.ToString()); orderRepository.UpdateRemarkState(aid, 63, remark); int NowHour = DateTime.Now.Hour; //当前时间的时数 int NowMinute = DateTime.Now.Minute; //当前时间的分钟数 //晚上12点半后,8点前满房时自动发送短信 if ((NowHour == 0 && NowMinute > 30) || (NowHour > 0 && NowHour < 8)) { Task.Factory.StartNew(() => { try { //发满房短信(发送满房信息) FlyPigMessageUility.ThirdCommunication(Shop, Convert.ToInt32(order.aId), "系统", 1); } catch { } }); } //string caozuo = string.Format("<br/>【系统】已发送满房短信[{0}]", DateTime.Now.ToString()); ////发满房短信 //FlyPigMessageUility.ThirdCommunication(Shop, Convert.ToInt32(order.aId), "系统", 1); ////更新状态、备注及操作 //orderRepository.UpdateRemarkStateCaoZuo(order.aId, 63, remark, caozuo); return(result.SetError("订单底价为0,无法下单到渠道!")); } if (order.state != 24) { return(result.SetError("该订单状态已变更")); } if (order.Refuse == 2) { return(result.SetError("该订单已取消")); } if (!string.IsNullOrEmpty(order.sourceOrderID)) { return(result.SetSucess("该订单已提交到CY,请勿重复提交")); } int tBreakfast = getBreakfast(order.hotelID, order.roomID, order.ratePlanID, order.orderNO); //logWriter.Write("携程:酒店id:{0},roomID:{1},ratePlanID:{2},早餐数:{3},飞猪早餐数:{4},订单号:{5}", order.hotelID, order.roomID, order.ratePlanID, tBreakfast, order.userID,order.orderNO); //判断早餐数是否对等 if (order.userID > tBreakfast && tBreakfast != 99 && order.userID != 0) { Task.Factory.StartNew(() => { try { //当早餐数不对等时更新rp string urlUpdateRp = string.Format("http://localhost:9092/ashx/rnxUpdateRaPlan.ashx?type=rp&source=8&hid={0}", order.hotelID); string getBoby = WebHttpRequest.Get(urlUpdateRp); if (!getBoby.Contains("更新价格计划成功")) { WebHttpRequest.Get(urlUpdateRp); } int NowHour = DateTime.Now.Hour; //当前时间的时数 int NowMinute = DateTime.Now.Minute; //当前时间的分钟数 //晚上12点半后,8点前满房时自动发送短信 if ((NowHour == 0 && NowMinute > 30) || (NowHour > 0 && NowHour < 8)) { //发满房短信(发送满房信息) FlyPigMessageUility.ThirdCommunication(Shop, Convert.ToInt32(order.aId), "系统", 1); } } catch { } }); string beiZhu = string.Format("【系统】:下单失败,具体原因:早餐个数不相等,天猫:{1}, 供应商:{2},取消执行自动下单,请联系申退 [{0}] <br/>【系统】:已自动更正早餐数,无需人工手动下线该酒店或房型 [{0}]", DateTime.Now.ToString(), order.userID, tBreakfast); orderRepository.UpdateRemarkState(order.aId, 24, beiZhu); logWriter.Write("携程(供应商早餐数发生变化):飞猪酒店id:{0},酒店id:{1},roomID:{2},ratePlanID:{3},早餐数:{4},飞猪早餐数:{5},订单号:{6}", order.TaoBaoHotelId, order.hotelID, order.roomID, order.ratePlanID, tBreakfast, order.userID, order.orderNO); return(result.SetError("该订单早餐个数不相等")); } else if (order.userID < tBreakfast) { //else if((order.userID < tBreakfast && order.userID != 0) || tBreakfast == 99) //如果供应商的早餐数大于平台的,更新rp Task.Factory.StartNew(() => { try { string urlUpdateRp = string.Format("http://localhost:9092/ashx/rnxUpdateRaPlan.ashx?type=rp&source=8&hid={0}", order.hotelID); string getBoby = WebHttpRequest.Get(urlUpdateRp); if (!getBoby.Contains("更新价格计划成功")) { WebHttpRequest.Get(urlUpdateRp); } } catch { } }); logWriter.Write("携程(平台早餐数少):飞猪酒店id:{0},酒店id:{1},roomID:{2},ratePlanID:{3},早餐数:{4},飞猪早餐数:{5},订单号:{6}", order.TaoBaoHotelId, order.hotelID, order.roomID, order.ratePlanID, tBreakfast, order.userID, order.orderNO); } var din = SqlSugarContext.TravelskyInstance.Queryable <dingdan_info>().Where(u => u.fax == order.taoBaoOrderId.ToString()).First(); if (din == null) { din = new dingdan_info(); } else { order.sourceOrderID = din.dingdan_num; var excuteRow = SqlSugarContext.ResellbaseInstance.Updateable(order).ExecuteCommand(); if (excuteRow == 0) { //TODO 更新订单失败 } return(result.SetError("已存在单号({0}),请不要重复下单", din.dingdan_num)); } din.typeid = "0900"; din.username = order.contactName; din.userid = 0; din.dingdan_num = orderId; din.HotelID = order.hotelID; din.RoomTypeID = order.roomID; din.RatePlanID = order.ratePlanID; din.hotel_name = order.hotelName; din.city_id = 0; din.room_id = Convert.ToInt32(order.roomID); din.room_name = string.Format("({0}){1}", order.roomName, order.ratePlanName); din.num = order.roomNum; din.begin_date = order.checkInDate; din.end_date = order.checkOutDate; din.dingdan_date = DateTime.Now; din.tel = "170000000000"; //order.contactTel; din.personname = order.contactName; din.fax = order.taoBaoOrderId.ToString(); din.Version = 2; din.true_price_str = order.DailyInfoPrice; // din.total = Convert.ToInt32(order.totalPrice); // din.personnum = order.contactName.Split(',').Length; din.cause = "RMB"; din.caozuo = string.Format("系统于{0}添加订单\n", DateTime.Now.ToString()); din.snote = order.comment; din.beizhu = ""; din.price_str = order.priceStr; // din.pingtai = "xl"; string prefix = string.Empty; if (order.shopType == 5) { prefix = "xl"; } else if (order.shopType == 6) { prefix = "yj"; } else if (order.shopType == 8) { prefix = "rx"; } else if (order.shopType == 9) { prefix = "rnx"; } din.pingtai = prefix; var payPrice = order.alipayPay; if (order.orderType == 5) { payPrice = order.totalPrice; } din.ly_pingtai = string.Format("{3}:{0}:{1}:ip:127.0.0.1:cash::money:{2}", order.taoBaoOrderId, din.dingdan_date.ToString("yyyyMMddHHmmss"), order.alipayPay, prefix); din.SpecialMemo = Convert.ToDecimal(order.totalPrice / order.roomNum).ToString(); din.roomtype = Convert.ToDecimal((order.totalPrice + order.sTotalPrice) / order.roomNum).ToString(); if (order.orderType == 12) { din.PriceOrderWay = 42; } else if (order.orderType == 5) { din.PriceOrderWay = 66; } else if (order.orderType == 15) { din.PriceOrderWay = 16; } else if (order.orderType == 16) { din.PriceOrderWay = 86; } else { din.PriceOrderWay = 52; } din.state = 1; din.ExtraMoney = 0; din.PayMessage = Convert.ToDecimal(order.sTotalPrice / order.roomNum).ToString(); int rows = SqlSugarContext.TravelskyInstance.Insertable(din).ExecuteCommand(); if (rows == 0) { //TODO 更新订单失败 } order.sourceOrderID = orderId; //<br/>【系统】:同步订单成功,订单号({1}) [{2}] order.remark = string.Format("{0}【系统】:同步订单成功,订单号({1}) [{2}]<br/>", order.remark, orderId, DateTime.Now.ToString()); rows = SqlSugarContext.ResellbaseInstance.Updateable(order).ExecuteCommand(); if (rows == 0) { string sql = string.Format("delete dingdan_info where dingdan_num='{0}' ", orderId); SqlSugarContext.TravelskyInstance.Ado.ExecuteCommand(sql); return(result.SetError("同步订单失败")); } else { order.state = 3; var excuteRow = SqlSugarContext.ResellbaseInstance.Updateable(order).ExecuteCommand(); return(result.SetSucess("同步订单成功,订单号({0})", orderId)); } } catch (Exception ex) { string sql = string.Format("delete dingdan_info where dingdan_num='{0}' ", orderId); SqlSugarContext.TravelskyInstance.Ado.ExecuteCommand(sql); return(result.SetError("同步订单到数据库失败,出现异常:{0}", ex.Message)); } }