public ResultMsg Agree(int id) { var item = orderService.GetById(id); if (item != null && item.orderState == OrderStates.applyRefund) { var account = AccountService.GetByUserId(item.userId); if (account == null) { return new ResultMsg() { Code = -1, CodeText = "会员账户异常" } } ; JsApiPay jsApiPay = new JsApiPay(); jsApiPay.openid = account.openID; jsApiPay.total_fee = (int)(item.payAmount * 100); try { //var orderNo = WxPayApi.GenerateOutTradeNo(); if (jsApiPay.total_fee > 0 && !string.IsNullOrWhiteSpace(item.orderNo)) { WxPayData unifiedResult = jsApiPay.GetUnifiedTransferResult(item.orderNo, "", "订单取消"); if (!unifiedResult.GetValue("return_code").Equals("SUCCESS")) { WxPayAPI.Log.Error(this.GetType().ToString(), "UnifiedTransfer response error!"); return(new ResultMsg() { Code = -1, CodeText = "订单取消失败" }); } if (!unifiedResult.IsSet("mch_appid") || !unifiedResult.IsSet("mchid")) { WxPayAPI.Log.Error(this.GetType().ToString(), "UnifiedTransfer response error!"); return(new ResultMsg() { Code = -1, CodeText = "订单取消失败" }); } } item.orderState = OrderStates.refund; TransactionHelper.BeginTransaction(); if (item.point > 0) { account.presentExp += item.presentExp; account.activatePoint += item.activatePoint; OperationPointLog log = new OperationPointLog(); log.account = ""; log.point = item.point; log.remark = "订单取消"; log.submitTime = DateTime.Now; log.userId = account.userId; OperationPointLogService.Insert(log); AccountService.Update(account); } orderService.Update(item); TransactionHelper.Commit(); return(new ResultMsg() { Code = 0 }); } catch (Exception ex) { WxPayAPI.Log.Error(this.GetType().ToString(), ex.Message.ToString()); return(new ResultMsg() { Code = -1, CodeText = ex.Message.ToString() }); } } return(new ResultMsg() { Code = -1, CodeText = "订单不存在或者状态不正常" }); } }