123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230 |
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Linq;
- using System.Threading.Tasks;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.Extensions.Logging;
- using Library;
- using LitJson;
- using System.Data;
- using MySystem.Models.Main;
- using System.Text.RegularExpressions;
- using Aop.Api.Domain;
- using MySystem.Models;
- using Microsoft.Extensions.Localization;
- namespace MySystem.Controllers
- {
- public class HomeController : Controller
- {
- private readonly ILogger<HomeController> _logger;
- public HomeController(ILogger<HomeController> logger)
- {
- _logger = logger;
- }
- public IActionResult Index()
- {
- return View();
- }
- public string getHdOrder()
- {
- GetHaoDaFTPInfoService.Instance.GetFTPDataInfoYesterday();
- return "ok";
- }
- public string partorder()
- {
- List<string> hdorders = new List<string>();
- WebCMSEntities db = new WebCMSEntities();
- var list = db.ConsumerOrders.Select(m => new { m.Id, m.SettleAmount, m.IsAct, m.SeoTitle }).Where(m => hdorders.Contains(m.SeoTitle) && m.IsAct == 1 && m.SettleAmount == 0).OrderBy(m => m.Id).ToList();
- foreach (var sub in list)
- {
- ConsumerOrders order = db.ConsumerOrders.FirstOrDefault(m => m.Id == sub.Id);
- if (order != null)
- {
- int Status = 2;
- MerchantInfo merchant = db.MerchantInfo.FirstOrDefault(m => m.Id == order.MerchantId) ?? new MerchantInfo();
- MerchantParamSet set = Newtonsoft.Json.JsonConvert.DeserializeObject<MerchantParamSet>(order.SeoDescription);
- if (order.IsAct == 1 && order.PayMoney >= set.MinPayMoney)
- {
- MerchantAddInfo merchantAdd = db.MerchantAddInfo.FirstOrDefault(m => m.Id == order.MerchantId) ?? new MerchantAddInfo();
-
-
- if(order.SettleAmount == 0)
- {
- string settleString = HaoDaHelper.Instance.QueryOrderDivideDetail(merchantAdd.OutMchtNo, order.SeoTitle);
- JsonData jsonData = JsonMapper.ToObject(settleString);
- if(jsonData["resultCode"].ToString() == "1")
- {
- string settleAmountString = jsonData["data"]["settleAmount"].ToString();
- order.SettleAmount = int.Parse(settleAmountString);
- }
- }
-
- decimal fee = order.PayMoney;
- if (fee >= 1 && order.SettleAmount > 0)
- {
- string applyNo = "FZ" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8);
- string mchtNo = merchantAdd.OutMchtNo;
- string orderNo = order.SeoTitle;
- string acctNo = AppConfig.Haoda.AcctNo;
- string sacctNo = merchantAdd.MchtNo;
- string acctType = "0";
- decimal settleAmount = (decimal)order.SettleAmount / 100M;
- decimal divideAmt = (1 - 0.0038M) * order.PayMoney;
- divideAmt = decimal.Parse(divideAmt.ToString("f2"));
- decimal hdfee = 0.0038M * order.PayMoney * (1 - set.GetPercent / 100 - 0.01M);
- hdfee = decimal.Parse(hdfee.ToString("f2"));
- decimal servicefee = 0.01M * order.PayMoney - hdfee;
- servicefee = decimal.Parse(servicefee.ToString("f2"));
- decimal amount = order.PayMoney * (1 - 0.0038M) - servicefee;
- amount = decimal.Parse(amount.ToString("f2"));
- decimal otherAmt = settleAmount - servicefee - amount;
- if (otherAmt != 0)
- {
- amount += otherAmt;
- }
- amount = amount * 100;
- servicefee = servicefee * 100;
- string seviceAmount = servicefee.ToString("f0");
- string amountAmount = amount.ToString("f0");
- string result = HaoDaHelper.Instance.OrderDivideAccounts(OrderDivideAccountsUtil.AddValue(applyNo, mchtNo, orderNo, acctNo, sacctNo, acctType, amountAmount, seviceAmount), merchantAdd.BrandId);
- order.DivideLog = "请求分账日志:" + result;
- order.TradePayNo = applyNo;
- if (result.Contains("\"resultCode\":\"0\"") && (result.Contains("分账金额不足") || result.Contains("不存在")))
- {
- Status = 1;
- }
- }
- }
- order.Status = Status;
- if (Status == 2)
- {
- order.DivideFlag = 1;
- order.DivideDate = DateTime.Now;
- }
- }
- }
- db.SaveChanges();
- db.Dispose();
- return "ok";
- }
- public string addreturn()
- {
- List<int> ids = new List<int>();
- foreach(int id in ids)
- {
- RedisDbconn.Instance.AddList("ConsumerOrdersHd:Divi:2:List", id.ToString());
- }
- return "ok";
- }
- public string test()
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- DateTime start = DateTime.Parse("2025-01-01 00:00:00");
- Models.KxsMain.WebCMSEntities db = new Models.KxsMain.WebCMSEntities();
- List<Models.KxsMain.ChangeTypes> brands = db.ChangeTypes.ToList();
- List<Models.KxsMain.UserAccountRecord> records = db.UserAccountRecord.Where(m => m.CreateDate >= start && m.ChangeType > 300).ToList();
- foreach(Models.KxsMain.UserAccountRecord record in records)
- {
- string name = brands.FirstOrDefault(m => m.Id == record.ChangeType).Name;
- PrizePushHelper.Instance.Do(DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8), name, record.ChangeType.ToString(), record.ChangeAmount, record.UserId, "{\"brand_id\":101,\"user_id\":" + record.UserId + "}");
- }
- db.SaveChanges();
- return "ok";
- }
- }
- }
|