Browse Source

分账金额调整,四舍五入

lcl 1 year ago
parent
commit
cf3b52bb3a
2 changed files with 17 additions and 5 deletions
  1. 14 3
      Controllers/HomeController.cs
  2. 3 2
      Util/HaoDa/WeChatPayBackService.cs

+ 14 - 3
Controllers/HomeController.cs

@@ -26,7 +26,7 @@ namespace MySystem.Controllers
             return View();
         }
 
-        public string test()
+        public string test(decimal a)
         {
             // List<int> MerchantIds = new List<int>();
             // MerchantIds.Add(5);
@@ -85,9 +85,20 @@ namespace MySystem.Controllers
             //     function.WriteLog("\n\n", "返现id");
             // }
 
-            // db.Dispose();            
+            // db.Dispose();
 
-            return "ok";
+            decimal hdfee = 0.0038M * a * (1 - 0.9M - 0.01M);
+            hdfee = decimal.Parse(hdfee.ToString("f2"));
+            decimal servicefee = 0.01M * a - hdfee;
+            servicefee = decimal.Parse(servicefee.ToString("f2"));
+            decimal amount = a*(1-0.0038M) - servicefee;
+
+            amount = amount * 100; //金额(分)
+            servicefee = servicefee * 100;
+            string seviceAmount = servicefee.ToString("f0"); //服务费
+            string amountAmount = amount.ToString("f0");
+
+            return amountAmount + ":" + seviceAmount;
         }
 
         public string bindapp(int mid)

+ 3 - 2
Util/HaoDa/WeChatPayBackService.cs

@@ -154,7 +154,7 @@ namespace MySystem
                                     string sacctNo = merchantAdd.MchtNo; //账户号,收款商户号
                                     string acctType = "0"; //账户类型(0:商户收款账户(大B),1:分账接收方账户(小B))
                                     
-                                    decimal hdfee = 0.0038M * order.PayMoney * (1 - set.GetPercent - 0.01M);
+                                    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"));
@@ -169,7 +169,8 @@ namespace MySystem
                                     amount = amount * 100; //金额(分)
                                     servicefee = servicefee * 100;
                                     string seviceAmount = servicefee.ToString("f0"); //服务费
-                                    string result = HaoDaHelper.Instance.OrderDivideAccounts(OrderDivideAccountsUtil.AddValue(applyNo, mchtNo, orderNo, acctNo, sacctNo, acctType, amount.ToString().Split('.')[0], seviceAmount));
+                                    string amountAmount = amount.ToString("f0");
+                                    string result = HaoDaHelper.Instance.OrderDivideAccounts(OrderDivideAccountsUtil.AddValue(applyNo, mchtNo, orderNo, acctNo, sacctNo, acctType, amountAmount, seviceAmount));
                                     order.DivideLog = "请求分账日志:" + result;
                                     if(result.Contains("\"resultCode\":\"0\"") && (result.Contains("分账金额不足") || result.Contains("不存在")))
                                     {