public TaskStatus Handle(IHttpProxy httpHandler) { using (Log log = new Log("美团.CreateOrder", false)) { httpHandler.ResponseContentType = "application/json"; var forms = httpHandler.Form.ToObject <SortedDictionary <string, string> >(); log.LogJson(forms); try { if (forms.Count > 0) { //验证sign var config = new Config(ResturantFactory.ResturantListener.OnGetPlatformConfigXml(ResturantPlatformType.Meituan)); if (forms["sign"] != MeituanHelper.Sign(forms, config.SignKey)) { throw new Exception("签名验证失败"); } handleContent(forms["order"], int.Parse(forms["ePoiId"])); } } catch (Exception ex) { using (Log logErr = new Log("美团CreateOrderCallback解析错误")) { logErr.Log(ex.ToString()); } throw ex; } httpHandler.ResponseWrite("{\"data\":\"OK\"}"); return(TaskStatus.Completed); } }
public TaskStatus Handle(IHttpProxy httpHandler) { httpHandler.ResponseContentType = "application/json"; var forms = httpHandler.Form.ToObject <SortedDictionary <string, string> >(); try { if (forms.Count > 0) { //验证sign var config = new Config(ResturantFactory.ResturantListener.OnGetPlatformConfigXml(ResturantPlatformType.Meituan)); if (forms["sign"] != MeituanHelper.Sign(forms, config.SignKey)) { throw new Exception("签名验证失败"); } Newtonsoft.Json.Linq.JObject orderJSONObj = (Newtonsoft.Json.Linq.JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(forms["tradeDetail"]); string orderId = orderJSONObj.Value <string>("orderId"); double settleAmount = orderJSONObj.Value <double>("settleAmount"); double commisionAmount = orderJSONObj.Value <double>("commisionAmount"); if (ResturantFactory.ResturantListener != null) { new Thread(() => { try { ResturantFactory.ResturantListener.OnReceiveOrderSettlement(ResturantPlatformType.Meituan, orderId, new ServiceAmountInfo() { PlatformServiceAmount = commisionAmount, SettleAmount = settleAmount }); } catch { } }).Start(); } } } catch (Exception ex) { using (Log log = new Log("美团SettlementCallback解析错误")) { log.Log(ex.ToString()); } throw ex; } httpHandler.ResponseWrite("{\"data\":\"OK\"}"); return(TaskStatus.Completed); }
public TaskStatus Handle(IHttpProxy httpHandler) { httpHandler.ResponseContentType = "application/json"; var forms = httpHandler.Form.ToObject <SortedDictionary <string, string> >(); try { if (forms.Count > 0) { //验证sign var config = new Config(ResturantFactory.ResturantListener.OnGetPlatformConfigXml(ResturantPlatformType.Meituan)); if (forms["sign"] != MeituanHelper.Sign(forms, config.SignKey)) { throw new Exception("签名验证失败"); } Newtonsoft.Json.Linq.JObject orderJSONObj = (Newtonsoft.Json.Linq.JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(forms["order"]); string orderid = orderJSONObj.Value <string>("orderId"); if (ResturantFactory.ResturantListener != null) { new Thread(() => { try { ResturantFactory.ResturantListener.OnOrderFinish(ResturantPlatformType.Meituan, orderid); } catch { } }).Start(); } } } catch (Exception ex) { using (Log log = new Log("美团OrderFinishCallback解析错误")) { log.Log(ex.ToString()); } } httpHandler.ResponseWrite("{\"data\":\"OK\"}"); return(TaskStatus.Completed); }
public TaskStatus Handle(IHttpProxy httpHandler) { httpHandler.ResponseContentType = "application/json"; var forms = httpHandler.Form.ToObject <SortedDictionary <string, string> >(); try { if (forms.Count > 0) { //验证sign var config = new Config(ResturantFactory.ResturantListener.OnGetPlatformConfigXml(ResturantPlatformType.Meituan)); if (forms["sign"] != MeituanHelper.Sign(forms, config.SignKey)) { throw new Exception("签名验证失败"); } OrderCancelInfo info = new OrderCancelInfo(); info.ErpStoreID = int.Parse(forms["ePoiId"]); var orderCancelObj = (Newtonsoft.Json.Linq.JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(forms["orderCancel"]); info.OrderID = orderCancelObj.Value <string>("orderId"); info.Reason = orderCancelObj.Value <string>("reason"); new Thread(() => { try { ResturantFactory.ResturantListener.OnOrderCancel(ResturantPlatformType.Meituan, info); } catch { } }).Start(); } } catch (Exception ex) { using (Log log = new Log("美团CancelOrderCallback解析错误")) { log.Log(ex.ToString()); } } httpHandler.ResponseWrite("{\"data\":\"OK\"}"); return(TaskStatus.Completed); }
public TaskStatus Handle(IHttpProxy httpHandler) { httpHandler.ResponseContentType = "application/json"; var forms = httpHandler.Form.ToObject <SortedDictionary <string, string> >(); try { if (forms.Count > 0) { //验证sign var config = new Config(ResturantFactory.ResturantListener.OnGetPlatformConfigXml(ResturantPlatformType.Meituan)); if (forms["sign"] != MeituanHelper.Sign(forms, config.SignKey)) { throw new Exception("签名验证失败"); } string notifyType = forms["notifyType"]; /* * part 发起退款 * agree 确认退款 * reject 驳回退款 */ OrderRefundInfo info = new OrderRefundInfo(); info.OrderID = forms["orderId"]; info.Reason = forms["reason"]; info.Money = Convert.ToDouble(forms["money"]); if (ResturantFactory.ResturantListener != null) { new Thread(() => { try { var foodJsonArr = (Newtonsoft.Json.Linq.JArray)Newtonsoft.Json.JsonConvert.DeserializeObject(forms["food"]); for (int i = 0; i < foodJsonArr.Count; i++) { var dishinfo = new RefundDishInfo(); dishinfo.DishName = foodJsonArr[i].Value <string>("food_name"); dishinfo.ErpDishId = foodJsonArr[i].Value <string>("app_food_code"); dishinfo.RefundPrice = foodJsonArr[i].Value <double>("refund_price"); dishinfo.Price = foodJsonArr[i].Value <double>("origin_food_price"); dishinfo.Quantity = foodJsonArr[i].Value <int>("count"); info.RefundDishInfos.Add(dishinfo); } } catch { } try { if (notifyType == "part") { ResturantFactory.ResturantListener.OnOrderRefund(ResturantPlatformType.Meituan, info); } else if (notifyType == "agree") { ResturantFactory.ResturantListener.OnOrderRefundCompleted(ResturantPlatformType.Meituan, info); } } catch { } }).Start(); } } } catch (Exception ex) { using (Log log = new Log("美团OrderPartRefundCallback解析错误")) { log.Log(ex.ToString()); } throw ex; } httpHandler.ResponseWrite("{\"data\":\"OK\"}"); return(TaskStatus.Completed); }
public TaskStatus Handle(IHttpProxy httpHandler) { httpHandler.ResponseContentType = "application/json"; var forms = httpHandler.Form.ToObject <SortedDictionary <string, string> >(); try { if (forms.Count > 0) { //验证sign var config = new Config(ResturantFactory.ResturantListener.OnGetPlatformConfigXml(ResturantPlatformType.Meituan)); if (forms["sign"] != MeituanHelper.Sign(forms, config.SignKey)) { throw new Exception("签名验证失败"); } Newtonsoft.Json.Linq.JObject orderJSONObj = (Newtonsoft.Json.Linq.JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(forms["orderRefund"]); string notifyType = orderJSONObj.Value <string>("notifyType"); /* * apply 发起退款 * agree 确认退款 * reject 驳回退款 * cancelRefund 用户取消退款申请 * cancelRefundComplaint 取消退款申诉 */ OrderRefundInfo info = new OrderRefundInfo(); info.OrderID = orderJSONObj.Value <string>("orderId"); info.ErpStoreID = Convert.ToInt32(forms["ePoiId"]); info.Reason = orderJSONObj.Value <string>("reason"); if (ResturantFactory.ResturantListener != null) { new Thread(() => { try { if (notifyType == "apply") { ResturantFactory.ResturantListener.OnOrderRefund(ResturantPlatformType.Meituan, info); } else if (notifyType == "agree") { ResturantFactory.ResturantListener.OnOrderRefundCompleted(ResturantPlatformType.Meituan, info); } else if (notifyType == "cancelRefund" || notifyType == "cancelRefundComplaint") { ResturantFactory.ResturantListener.OnCancelOrderRefund(ResturantPlatformType.Meituan, info); } } catch { } }).Start(); } } } catch (Exception ex) { using (Log log = new Log("美团OrderRefundCallback解析错误")) { log.Log(ex.ToString()); } } httpHandler.ResponseWrite("{\"data\":\"OK\"}"); return(TaskStatus.Completed); }