Пример #1
0
        private static async Task <string> NewMethod(SavingModel item, HttpClientHandler handler, UserInfoModel userInfo, decimal balance)
        {
            string NotUserInfo = null;

            if (balance == item.Price)
            {
                NotUserInfo += item.Name + item.Type.ToString() + "信息准确,";
            }
            else if (balance < item.Price)
            {
                RechargeInputModel RechargeInput = new RechargeInputModel
                {
                    Balance      = item.Price - balance,
                    ChannelType  = ChannelType.数据导入,
                    Money        = item.Price - balance,
                    OwnerId      = userInfo.Id,
                    SavingSource = SavingSource.平台已有数据导入,
                    SavingType   = item.Type
                };
                NotUserInfo += item.Name + "充值" + await PostRecharge(handler, RechargeInput);
            }
            else if (balance > item.Price)
            {
                WithholdInputModel withhold = new WithholdInputModel
                {
                    PayPrice = balance - item.Price,
                    PayType  = PayType.余额支付,
                    UserId   = userInfo.Id
                };
                NotUserInfo += item.Name + "扣款" + await PostWithhold(handler, withhold);
            }

            return(NotUserInfo);
        }
Пример #2
0
        private static async Task <string> PostRecharge(HttpClientHandler handler, RechargeInputModel recharge)
        {
            string NotUserInfo = "";

            using (var http = new HttpClient(handler))
            {
                var content = new StringContent(JsonConvert.SerializeObject(recharge), Encoding.UTF8, "application/json");


                var response = await http.PostAsync("https://loosen.microfeel.net/api/saving/recharge", content);

                response.EnsureSuccessStatusCode();

                if (response.IsSuccessStatusCode)
                {
                    NotUserInfo += recharge.SavingType.ToString() + ":" + recharge.Balance;
                }
            }

            return(NotUserInfo);
        }