public PayResult ToPayResult() { try { PayResult result = new PayResult(); result.appid = GetValue("appid") == null ? "" : GetValue("appid").ToString(); result.mch_id = GetValue("mch_id") == null ? "" : GetValue("mch_id").ToString(); result.attach = GetValue("attach") == null ? "" : GetValue("attach").ToString(); result.err_code = GetValue("err_code") == null ? "" : GetValue("err_code").ToString(); result.err_code_des = GetValue("err_code_des") == null ? "" : GetValue("err_code_des").ToString(); result.fee_type = GetValue("fee_type") == null ? "" : GetValue("fee_type").ToString(); result.is_subscribe = GetValue("is_subscribe") == null ? "" : GetValue("is_subscribe").ToString(); result.openid = GetValue("openid") == null ? "" : GetValue("openid").ToString(); result.out_trade_no = GetValue("out_trade_no") == null ? "" : GetValue("out_trade_no").ToString(); result.result_code = GetValue("result_code") == null ? "" : GetValue("result_code").ToString(); result.time_end = DateTime.ParseExact(GetValue("time_end").ToString(), "yyyyMMddHHmmss", null); result.total_fee = Convert.ToInt32(GetValue("total_fee").ToString()); result.trade_type = GetValue("trade_type") == null ? "" : GetValue("trade_type").ToString(); result.transaction_id = GetValue("transaction_id") == null ? "" : GetValue("transaction_id").ToString(); if (!string.IsNullOrEmpty(result.attach)) { //支付类型是在支付的时候paytype参数带过来的 string paytype = WxUtils.getAttachValue(result.attach, "paytype"); if (!string.IsNullOrEmpty(paytype)) { int type; if (int.TryParse(paytype, out type)) { result.paytype = type; } } else { log4net.LogHelper.WriteError(typeof(ResultNotify), new WxPayException("警报:回调函数获取不到支付类型!")); } } if (string.IsNullOrEmpty(result.transaction_id) || string.IsNullOrEmpty(result.openid)) { return(null); } return(result); } catch (Exception ex) { throw ex; } }
//回调根据PayResult处理回调 public bool NotifyOper(PayResult result) { if (WxUtils.getAttachValue(result.attach, "from") == "city") { CityMordersBLL citybll = new CityMordersBLL(result); string orderidstr = WxUtils.getAttachValue(result.attach, "orderid"); if (string.IsNullOrEmpty(orderidstr)) { log4net.LogHelper.WriteError(GetType(), new Exception(JsonConvert.SerializeObject(result))); return(false); } int orderid = Convert.ToInt32(orderidstr); CityMorders order = citybll.GetModel(orderid); //修改订单支付状态 if (order == null) { Exception ex = new Exception("警报:根据支付单号找不到相关订单!" + " out_trade_no='" + result.out_trade_no + "'"); log4net.LogHelper.WriteError(GetType(), ex); log4net.LogHelper.WriteError(GetType(), new Exception(JsonConvert.SerializeObject(result))); return(false); } if (order.payment_status != 0) { return(false); } if (order.Percent < 0 || order.Percent > 100) { Exception ex = new Exception("警报:出现异常订单!订单提成百分比为:" + order.Percent + " out_trade_no='" + result.out_trade_no + "'"); log4net.LogHelper.WriteError(GetType(), ex); log4net.LogHelper.WriteError(GetType(), new Exception(JsonConvert.SerializeObject(result))); return(false); } citybll.Order = order; //修改order支付商户 order.mch_id = result.mch_id; order.appid = result.appid; citybll.Update(order); switch (result.paytype) { //小程序商城 case (int)ArticleTypeEnum.MiniappGoods: return(citybll.MiniappStoreGoods()); //小程序餐饮 case (int)ArticleTypeEnum.MiniappFoodGoods: return(citybll.MiniappFoodGoods()); //小程序储值 case (int)ArticleTypeEnum.MiniappSaveMoneySet: return(citybll.MiniappSaveMoney()); //小程序砍价 case (int)ArticleTypeEnum.MiniappBargain: return(citybll.MiniappBargainMoney()); //小程序拼团 case (int)ArticleTypeEnum.MiniappGroups: return(citybll.MiniappStoreGroup()); //小程序专业版 case (int)ArticleTypeEnum.MiniappEnt: return(citybll.MiniappEntGoods()); //小程序足浴版 case (int)ArticleTypeEnum.MiniappFootbath: return(citybll.MiniappFootbath()); case (int)ArticleTypeEnum.MiniappMultiStore: return(citybll.MiniappMultiStore()); //小程序专业版积分兑换(微信+积分方式兑换) case (int)ArticleTypeEnum.MiniappExchangeActivity: return(citybll.PayMiniappExchangeActivity()); //小程序同城模板 case (int)ArticleTypeEnum.City_StoreBuyMsg: return(citybll.cityBuyMsg()); //小程序直接微信转账 case (int)ArticleTypeEnum.MiniappWXDirectPay: return(citybll.PayByStoredvalue()); //智慧餐厅 case (int)ArticleTypeEnum.DishOrderPay: return(citybll.PayDishOrder()); case (int)ArticleTypeEnum.DishStorePayTheBill: return(citybll.PayDishStorePayTheBill()); case (int)ArticleTypeEnum.DishCardAccount: return(citybll.PayDishCardAccount()); //平台版小程序分类信息发帖 case (int)ArticleTypeEnum.PlatMsgPay: return(citybll.PlatMsgPay()); //付费内容支付购买 case (int)ArticleTypeEnum.PayContent: return(citybll.PayContentCallBack()); //子模版订单平台支付 case (int)ArticleTypeEnum.PlatChildOrderInPlatPay: //平台子模版支付 case (int)ArticleTypeEnum.PlatChildOrderPay: return(citybll.MiniappPlatChildGoods()); //拼享惠支付 case (int)ArticleTypeEnum.PinOrderPay: return(citybll.PayPinOrder()); //平台子模版支付 case (int)ArticleTypeEnum.QiyeOrderPay: return(citybll.QiyePayOrder()); //平台店铺入驻支付 case (int)ArticleTypeEnum.PlatAddStorePay: return(citybll.PlatAddStorePay()); //平台店铺续期支付 case (int)ArticleTypeEnum.PlatStoreAddTimePay: return(citybll.PlatStoreAddTimePay()); //专业版预约表单付费 case (int)ArticleTypeEnum.EntSubscribeFormPay: return(citybll.EntSubscribeFormPay()); } } return(false); }