Compare commits
No commits in common. "91c761379c717f52834b0d58407ac35e9f56092b" and "601fca067d1b10fe419064201f2f4c84a5c4c410" have entirely different histories.
91c761379c
...
601fca067d
@ -1,28 +0,0 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
|
|
||||||
namespace Oms.Application.Dtos.Customers;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 人工调整客户账户余额入参。
|
|
||||||
/// </summary>
|
|
||||||
public class AdjustCustomerBalanceInput
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 客户主键。
|
|
||||||
/// </summary>
|
|
||||||
[Required]
|
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 调整差额:正数入账、负数扣减,不能为 0。
|
|
||||||
/// </summary>
|
|
||||||
[Required]
|
|
||||||
public decimal Amount { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 调整原因(必填,写入流水备注)。
|
|
||||||
/// </summary>
|
|
||||||
[Required]
|
|
||||||
[StringLength(512, MinimumLength = 2)]
|
|
||||||
public string Remark { get; set; } = string.Empty;
|
|
||||||
}
|
|
||||||
@ -52,7 +52,7 @@ public class UpdateCustomerInput
|
|||||||
public string? WechatNickname { get; set; }
|
public string? WechatNickname { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 账户余额(已废弃:更新接口忽略此字段,请走 /customer/adjust-balance 留痕)。
|
/// 账户余额;不传则保留原值。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Range(typeof(decimal), "0", "999999999999")]
|
[Range(typeof(decimal), "0", "999999999999")]
|
||||||
public decimal? Balance { get; set; }
|
public decimal? Balance { get; set; }
|
||||||
|
|||||||
@ -141,11 +141,6 @@ public class CustomerAccountFlowService : ApplicationService
|
|||||||
CustomerAccountFlowBizTypes.Recharge => "充值入账",
|
CustomerAccountFlowBizTypes.Recharge => "充值入账",
|
||||||
CustomerAccountFlowBizTypes.OrderPay => "订单支付",
|
CustomerAccountFlowBizTypes.OrderPay => "订单支付",
|
||||||
CustomerAccountFlowBizTypes.PickupPay => "揽收支付",
|
CustomerAccountFlowBizTypes.PickupPay => "揽收支付",
|
||||||
CustomerAccountFlowBizTypes.ReferralCommission => "推荐佣金",
|
|
||||||
CustomerAccountFlowBizTypes.CommissionToBalance => "佣金转入余额",
|
|
||||||
CustomerAccountFlowBizTypes.CommissionWithdraw => "佣金提现",
|
|
||||||
CustomerAccountFlowBizTypes.MarketingAdjust => "营销调整",
|
|
||||||
CustomerAccountFlowBizTypes.ManualAdjust => "人工调整",
|
|
||||||
_ => bizType
|
_ => bizType
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -56,9 +56,6 @@ public class CustomerService : ApplicationService
|
|||||||
private CustomerServiceAdvisorResolver ServiceAdvisorResolver =>
|
private CustomerServiceAdvisorResolver ServiceAdvisorResolver =>
|
||||||
LazyServiceProvider.GetRequiredService<CustomerServiceAdvisorResolver>();
|
LazyServiceProvider.GetRequiredService<CustomerServiceAdvisorResolver>();
|
||||||
|
|
||||||
private CustomerBalanceMutator BalanceMutator =>
|
|
||||||
LazyServiceProvider.GetRequiredService<CustomerBalanceMutator>();
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查询客户列表。
|
/// 查询客户列表。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -380,7 +377,10 @@ public class CustomerService : ApplicationService
|
|||||||
entity.WechatNickname = NormalizeOptionalText(input.WechatNickname);
|
entity.WechatNickname = NormalizeOptionalText(input.WechatNickname);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 余额禁止在更新接口直接改写,避免无流水留痕;请使用 AdjustBalanceAsync
|
if (input.Balance.HasValue)
|
||||||
|
{
|
||||||
|
entity.Balance = input.Balance.Value;
|
||||||
|
}
|
||||||
|
|
||||||
if (input.TotalQuota.HasValue)
|
if (input.TotalQuota.HasValue)
|
||||||
{
|
{
|
||||||
@ -435,27 +435,6 @@ public class CustomerService : ApplicationService
|
|||||||
await CustomerRepository.UpdateAsync(entity);
|
await CustomerRepository.UpdateAsync(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 人工调整客户账户余额并写入账户流水。
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="input">客户 Id、调整差额(可正可负)、必填原因。</param>
|
|
||||||
[HttpPost("/customer/adjust-balance")]
|
|
||||||
public async Task AdjustBalanceAsync(AdjustCustomerBalanceInput input)
|
|
||||||
{
|
|
||||||
if (input.Amount == 0)
|
|
||||||
{
|
|
||||||
throw new BusinessException("调整金额不能为 0");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(input.Remark) || input.Remark.Trim().Length < 2)
|
|
||||||
{
|
|
||||||
throw new BusinessException("请填写调整原因");
|
|
||||||
}
|
|
||||||
|
|
||||||
var entity = await GetCustomerOrThrowAsync(input.Id);
|
|
||||||
await BalanceMutator.AdjustManualAsync(entity, input.Amount, input.Remark.Trim());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 删除客户。
|
/// 删除客户。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -138,35 +138,6 @@ public class CustomerBalanceMutator : IScopedDependency
|
|||||||
cancellationToken);
|
cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 运营人工调整余额(正数入账、负数扣减),写入账户流水。
|
|
||||||
/// </summary>
|
|
||||||
public Task AdjustManualAsync(
|
|
||||||
Customer customer,
|
|
||||||
decimal amount,
|
|
||||||
string remark,
|
|
||||||
CancellationToken cancellationToken = default)
|
|
||||||
{
|
|
||||||
if (amount == 0)
|
|
||||||
{
|
|
||||||
throw new BusinessException("调整金额不能为 0");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(remark))
|
|
||||||
{
|
|
||||||
throw new BusinessException("调整原因不能为空");
|
|
||||||
}
|
|
||||||
|
|
||||||
return ApplyAsync(
|
|
||||||
customer,
|
|
||||||
amount,
|
|
||||||
CustomerAccountFlowBizTypes.ManualAdjust,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
remark.Trim(),
|
|
||||||
cancellationToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task ApplyAsync(
|
private async Task ApplyAsync(
|
||||||
Customer customer,
|
Customer customer,
|
||||||
decimal signedAmount,
|
decimal signedAmount,
|
||||||
|
|||||||
@ -18,7 +18,4 @@ public static class CustomerAccountFlowBizTypes
|
|||||||
public const string CommissionWithdraw = "commissionWithdraw";
|
public const string CommissionWithdraw = "commissionWithdraw";
|
||||||
|
|
||||||
public const string MarketingAdjust = "marketingAdjust";
|
public const string MarketingAdjust = "marketingAdjust";
|
||||||
|
|
||||||
/// <summary>运营人工调整账户余额。</summary>
|
|
||||||
public const string ManualAdjust = "manualAdjust";
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user