订单分成,还差最低收取手续费

This commit is contained in:
墨大叔 2024-09-27 18:03:41 +08:00
parent 3bfb58a5ba
commit f301da2af8
5 changed files with 18 additions and 11 deletions

View File

@ -430,7 +430,7 @@ export default {
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
pageSize: 20,
orderByColumn: defaultSort.prop,
isAsc: defaultSort.order,
#foreach ($column in $columns)

View File

@ -21,6 +21,7 @@ import com.ruoyi.ss.transactionBill.domain.vo.UserRechargeServiceVO;
import com.ruoyi.ss.transactionBill.service.TransactionBillService;
import com.ruoyi.ss.user.domain.SmUserVo;
import com.ruoyi.ss.user.service.ISmUserService;
import com.ruoyi.system.domain.enums.config.ConfigKey;
import com.ruoyi.system.service.ISysConfigService;
import com.ruoyi.system.service.ISysDeptService;
import org.springframework.beans.factory.annotation.Autowired;
@ -111,13 +112,12 @@ public class BonusConverterImpl implements BonusConverter {
if (DeviceServiceMode.DIRECT.getMode().equals(device.getServiceMode())) {
// 平台收取服务费
UserRechargeServiceVO userRechargeService = transactionBillService.getMchRechargeService(channel, mch, device);
String serviceType = userRechargeService.getServiceType(); // 服务费类型
BigDecimal serviceRate = userRechargeService.getServiceRate(); // 服务费
// 如果按照百分比收取服务费
if(ServiceType.PERCENT.getType().equals(serviceType)) {
result.add(this.toPo(platform, serviceRate));
point = point.subtract(serviceRate);
}
// 按照百分比收取服务费
BigDecimal serviceRate = userRechargeService.getServiceRate(); // 服务费比例
result.add(this.toPo(platform, serviceRate));
point = point.subtract(serviceRate);
}
// 代理模式
else if (DeviceServiceMode.AGENT.getMode().equals(device.getServiceMode())) {

View File

@ -24,6 +24,7 @@ import com.ruoyi.ss.store.service.StoreService;
import com.ruoyi.ss.user.domain.SmUserVo;
import com.ruoyi.ss.user.service.ISmUserService;
import com.ruoyi.ss.user.service.UserAssembler;
import com.ruoyi.system.domain.enums.config.ConfigKey;
import com.ruoyi.system.service.ISysConfigService;
import com.ruoyi.system.service.ISysDeptService;
import org.springframework.beans.factory.annotation.Autowired;
@ -215,6 +216,11 @@ public class BonusServiceImpl implements BonusService
LocalDateTime now = LocalDateTime.now();
// TODO 最低分成假设为 0.05 若判断金额小于 0.05 则全部收取若分成小于 0.05 则收取0.05元
// 获取平台的分成
BonusVO platform = bonusList.stream().filter(bonus -> bonus.getArrivalType().equals(BonusArrivalType.PLATFORM.getType())).findFirst().orElse(null);
ServiceUtil.assertion(platform == null, "平台不存在");
// 循环遍历构造分成金额
for (BonusVO bonus : bonusList) {
BigDecimal amount = money.multiply(bonus.getPoint()).divide(decimal100, 2, RoundingMode.HALF_UP);
@ -233,9 +239,7 @@ public class BonusServiceImpl implements BonusService
}
dividedAmount = dividedAmount.add(amount);
}
// 平台吃掉误差
BonusVO platform = bonusList.stream().filter(bonus -> bonus.getArrivalType().equals(BonusArrivalType.PLATFORM.getType())).findFirst().orElse(null);
ServiceUtil.assertion(platform == null, "平台不存在");
// 若存在误差则平台吃掉误差
if (dividedAmount.compareTo(money) != 0) {
BigDecimal subtract = money.subtract(dividedAmount); // 误差值
platform.setAmount(platform.getAmount().add(subtract));

View File

@ -208,6 +208,7 @@ public class Device extends BaseEntity
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "最后在线时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty("最后在线时间")
@JsonView(JsonViewProfile.App.class)
private LocalDateTime lastOnlineTime;
@ApiModelProperty("上次恢复余额的时间戳")

View File

@ -264,6 +264,8 @@ public class TransactionBillServiceImpl implements TransactionBillService, After
bo.setBonusList(bonusList);
}
// TODO 收取月费
transactionTemplate.execute(status -> {
// 新增订单
int insert = this.insertSmTransactionBill(order);