|
|
|
@ -52,7 +52,6 @@ public class CallCostServiceImpl implements CallCostService {
|
|
|
|
|
private final MessageNotificationRepository messageNotificationRepository;
|
|
|
|
|
private final UserMessageService userMessageService;
|
|
|
|
|
private final OnlineUserService onlineUserService;
|
|
|
|
|
|
|
|
|
|
private final double price = 0.18;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -90,7 +89,12 @@ public class CallCostServiceImpl implements CallCostService {
|
|
|
|
|
if (duration > callDuration) {
|
|
|
|
|
//账户余额
|
|
|
|
|
CompanyDto companyById = companyService.findCompanyById(companyId);
|
|
|
|
|
deduction(info, list, companyId, companyById);
|
|
|
|
|
|
|
|
|
|
CallSettlement callSettlement = deduction(info, list, companyId, companyById);
|
|
|
|
|
callSettlement.setCreateTime(DateUtil.date());
|
|
|
|
|
callSettlement.setCompanyId(companyId);
|
|
|
|
|
callCostRepository.save(callSettlement);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -103,7 +107,8 @@ public class CallCostServiceImpl implements CallCostService {
|
|
|
|
|
* @param companyId
|
|
|
|
|
*/
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public void deduction(PayTemplateUser info, List<AllCallInfo> list, Long companyId, CompanyDto companyById) throws Exception {
|
|
|
|
|
public CallSettlement deduction(PayTemplateUser info, List<AllCallInfo> list, Long companyId, CompanyDto companyById) throws Exception {
|
|
|
|
|
CallSettlement callSettlement = new CallSettlement();
|
|
|
|
|
long userId = info.getUserId();
|
|
|
|
|
Double userBalance = companyById.getUserBalance();
|
|
|
|
|
//查看时间内 是否有过扣减
|
|
|
|
@ -127,6 +132,7 @@ public class CallCostServiceImpl implements CallCostService {
|
|
|
|
|
//余额足够
|
|
|
|
|
if (estimateAmount + userBalance > deductAmount + estimateAmountToDay) {
|
|
|
|
|
companyService.updateUserBalanceByCompanyId(deductAmount + estimateAmountToDay - estimateAmount, companyId);
|
|
|
|
|
callSettlement.setEstimateAmount(estimateAmountToDay);
|
|
|
|
|
} else {
|
|
|
|
|
//不够的情况 不加预扣
|
|
|
|
|
if (estimateAmount + userBalance > deductAmount) {
|
|
|
|
@ -149,8 +155,11 @@ public class CallCostServiceImpl implements CallCostService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
callSettlement.setDeductAmount(deductAmount);
|
|
|
|
|
callSettlement.setDeductDuration(duration1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return callSettlement;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|