public async Task <object> PostShenJiaRecharge([FromBody] ShenJiaRechargeViewModel model) { MessageBase2 result = new MessageBase2(); RechargeRecordDto dto = new RechargeRecordDto() { UserId = model.UserId, OrderNo = SysHelper.GenerateTradeNo(), Money = model.Money, WareDesc = model.Type, //"身家充值", OrderName = model.Type, //"身家充值" Type = model.Type }; int id = await _rechargeRecordService.AddAsync(dto); string passbackParams = "merchantType=身家充值&id=" + id; if (model.PayType == "Ali") { result.Data = AliPaySdk.Signature(model.Type, model.Type, model.Money.ToString(CultureInfo.InvariantCulture), dto.OrderNo, passbackParams); } if (model.PayType == "Wx") { result.Data = WxPaySdk.UnifiedOrder(model.Type, model.Type, model.Money.ToString(CultureInfo.InvariantCulture), dto.OrderNo, HttpContext.GetUserIp(), passbackParams); } return(result); }
public async Task <object> Post([FromBody] ExchangeEventViewModel model) { MessageBase2 result = new MessageBase2(); var dto = await _exchangeService.FindAsync(model.ExId); decimal postage = dto.Postage == 0 ? await _postageService.GetPostageAsync() : dto.Postage; //邮费 string totalAmount = ""; //金额 string outTradeNo = SysHelper.GenerateTradeNo(); int dep = 0; //押金 decimal shenJia = 0; switch (model.Examine) { case "身家兑换": shenJia = dto.Official.ToDecimal();; if (shenJia - (await _memberService.FindAsync(model.UserId)).ShenJia > 0) { result.Success = Permanent.FAILED; result.Error = (int)StatusCodeEnum.FORBIDDEN; result.ErrorMsg = "身家不足"; return(result); } totalAmount = postage.ToString(CultureInfo.InvariantCulture); //邮费 break; case "会员租赁": dep = await _memberService.GetDepositAsync(model.UserId, dto.Official.ToInt32()); //总押金 totalAmount = (postage + dep).ToString("0.00"); //邮费+押金 break; case "单次租赁": decimal price = dto.Rent == 0 ? 30 : dto.Rent; dep = await _memberService.GetDepositAsync(model.UserId, dto.Official.ToInt32()); //总押金 totalAmount = (postage + dep + price).ToString("0.00"); //邮费+押金+30 break; case "兑换券": postage = 0; dep = await _memberService.GetDepositAsync(model.UserId, dto.Official.ToInt32()); //总押金 totalAmount = (postage + dep).ToString("0.00"); //邮费+押金 break; } ExchangeEventDto eedto = new ExchangeEventDto() { Deposit = dep, UserId = model.UserId, OrderNo = outTradeNo, Examine = model.Examine, AddressId = model.AddressId, ExId = model.ExId, VouId = model.VoucherId, Postage = postage.ToDecimal(), ShenJia = shenJia }; int eeId = await _exchangeEventService.AddAsync(eedto); string passbackParams = "merchantType=兑换租赁&id=" + eeId; if (model.PayType == "Ali") { result.Data = AliPaySdk.Signature(dto.Title, model.Examine, totalAmount, outTradeNo, passbackParams); } if (model.PayType == "Wx") { result.Data = WxPaySdk.UnifiedOrder(dto.Title, model.Examine, totalAmount, outTradeNo, HttpContext.GetUserIp(), passbackParams); } return(result); //页面输出的response.Body就是orderString 可以直接给客户端请求,无需再做处理。 }