增加 oem 返利表的结算
This commit is contained in:
1 parent
4128fc8cc6
commit
9f8e656fcf
5 files changed
+251
-18
No files matched your search
@@ -0,0 +1,45 @@
|
||||
using KJD_Web.Services.Users;
|
||||
using Store.Contracts.User.Entitys;
|
||||
using Store.Contracts.User.Enums;
|
||||
using System.Reflection;
|
||||
|
||||
namespace WebServiceTest;
|
||||
|
||||
[TestFixture]
|
||||
public class UserFloorPriceTest
|
||||
{
|
||||
private static int Calculate(List<OEMMarkupRuleEntity> rules, string? oemId) =>
|
||||
(int)typeof(UserService).GetMethod("CalculateUserFloorPrice", BindingFlags.NonPublic | BindingFlags.Static)!
|
||||
.Invoke(null, new object[] { rules, new UserEntity { UserName = "user", OemId = oemId },
|
||||
UserPaymentTypes.中转仓扣费支出, 220 })!;
|
||||
|
||||
[TestCase("B", false, 220)]
|
||||
[TestCase("B", true, 232)]
|
||||
[TestCase(null, true, 232)]
|
||||
public void FloorIncludesOnlyMatchingUpstreamMarkup(string? oemId, bool hasRule, int expected)
|
||||
{
|
||||
var rules = new List<OEMMarkupRuleEntity>
|
||||
{
|
||||
new() { TargetType = OEMMarkupTargetType.User, TargetId = "user", SetterOemId = "B",
|
||||
PaymentType = UserPaymentTypes.中转仓扣费支出, Markup = 50 },
|
||||
new() { TargetType = OEMMarkupTargetType.OEM, TargetId = oemId ?? "00000000",
|
||||
PaymentType = UserPaymentTypes.同步物流, Markup = 99 },
|
||||
new() { TargetType = OEMMarkupTargetType.OEM, TargetId = "other",
|
||||
PaymentType = UserPaymentTypes.中转仓扣费支出, Markup = 99 }
|
||||
};
|
||||
if (hasRule) rules.Add(new() { TargetType = OEMMarkupTargetType.OEM, TargetId = oemId ?? "00000000",
|
||||
PaymentType = UserPaymentTypes.中转仓扣费支出, Markup = 12 });
|
||||
Assert.That(Calculate(rules, oemId), Is.EqualTo(expected));
|
||||
}
|
||||
|
||||
[TestCase(-1, 1, typeof(InvalidOperationException))]
|
||||
[TestCase(12, 2, typeof(InvalidOperationException))]
|
||||
[TestCase(int.MaxValue, 1, typeof(OverflowException))]
|
||||
public void CorruptRulesAndOverflowAreRejected(int markup, int count, Type errorType)
|
||||
{
|
||||
var rule = new OEMMarkupRuleEntity { TargetType = OEMMarkupTargetType.OEM, TargetId = "B",
|
||||
PaymentType = UserPaymentTypes.中转仓扣费支出, Markup = markup };
|
||||
var error = Assert.Throws<TargetInvocationException>(() => Calculate(Enumerable.Repeat(rule, count).ToList(), "B"));
|
||||
Assert.That(error!.InnerException, Is.TypeOf(errorType));
|
||||
}
|
||||
}
|
||||
@@ -52,11 +52,11 @@ internal class UserTest
|
||||
//[TestCase("15698175212")]
|
||||
//[TestCase("18238114231")]
|
||||
//[TestCase("15870095938")]
|
||||
//[TestCase("13388889999")]
|
||||
[TestCase("13388889999")]
|
||||
//[TestCase("15907090308")]
|
||||
//[TestCase("17837688880")]
|
||||
//[TestCase("13048056467")]
|
||||
[TestCase("17337708962")]
|
||||
//[TestCase("17337708962")]
|
||||
//[TestCase("13459139999")]
|
||||
//[TestCase("18737568536")]
|
||||
//[TestCase("18949822610")]
|
||||
|
||||
Reference in new issue
Block a user