Commit 32de13c1 by guojuxing

Merge remote-tracking branch 'origin/developer' into developer

parents ac55e52b bef3afca
......@@ -95,7 +95,7 @@ public class BillingAccountServiceImpl implements BillingAccountService{
record.setCreateTime(new Date());
record.setUpdateTime(new Date());
record.setEnterpriseId(enterpriseId);
record.setCreditLine(5000);
record.setCreditLine(0);
record.setAutoRecharge(0);
record.setAccountBalance(0D);
......
......@@ -231,23 +231,33 @@ public class BillingAccountApiServiceImpl implements BillingAccountApiService {
@Override
public ServiceResponse<Integer> deductAccount(double totalFee, Integer enterpriseId) {
if (isNotInWhiteList(enterpriseId)) {
TabBillingAccount billingAccount = billingAccountService.getByEnterpriseId(enterpriseId);
Double accountBalance = billingAccount.getAccountBalance();
if (accountBalance >= 0) {
int i = billingAccountService.deductAccount(totalFee, enterpriseId);
LOGGER.info("扣费是否成功:{}", i > 0);
if (i > 0) {
TabBillingAccount account = this.billingAccountService.getByEnterpriseId(enterpriseId);
if(account.getAccountBalance() <= 0){
if (account.getAccountBalance() <= 0) {
Object cache = RedisUtil.getCache("message:" + enterpriseId);
if(cache == null){
String content = "您的GIC商户余额已欠费"+(-account.getAccountBalance())+"元,为了不影响业务的开展,请及时<a href='"+config.getHost()+"cost-center/billing-center/recharge'>充值</a>";
if (cache == null) {
// String content = "您的GIC商户余额已欠费"+(-account.getAccountBalance())+"元,为了不影响业务的开展,请及时<a href='"+config.getHost()+"cost-center/billing-center/recharge'>充值</a>";
String content = "您的GIC商户余额已不足500元,为了不影响业务的开展,请及时<a href='" + config.getHost() + "cost-center/billing-center/recharge'>充值</a>";
this.pushMessageApiService.pushMessage(enterpriseId, "系统消息", "商户欠费", content);
// 待办事项
sendTotoItem(enterpriseId);
RedisUtil.setCache("message:" + enterpriseId, 1, 1l, TimeUnit.DAYS);
}
}
}
return ServiceResponse.success(i);
} else {
return EnterpriseServiceResponse.failure(ErrorCode.OPERATION_FAILED);
return ServiceResponse.failure(ErrorCode.OPERATION_FAILED.getCode(), "余额不足");
}
} else {
int i = billingAccountService.deductAccount(totalFee, enterpriseId);
return ServiceResponse.success(i);
}
}
......@@ -257,8 +267,9 @@ public class BillingAccountApiServiceImpl implements BillingAccountApiService {
List<EnterpriseDTO> enterpriseDTOList = enterpriseService.listEnterprise();
for (EnterpriseDTO enterpriseDTO : enterpriseDTOList) {
Integer enterpriseId = enterpriseDTO.getEnterpriseId();
if (isNotInWhiteList(enterpriseId)) {
TabBillingAccount account = this.billingAccountService.getByEnterpriseId(enterpriseId);
if (account.getAccountBalance() <= 0) {
if (account.getAccountBalance() <= 500) {
String[] smsArr = new String[]{enterpriseDTO.getEnterpriseName(), String.valueOf(-account.getAccountBalance())};
ServiceResponse<UserDTO> userResult = userApiService.getUserByEnterpriseId(enterpriseId);
UserDTO userDTO = userResult.getResult();
......@@ -269,9 +280,15 @@ public class BillingAccountApiServiceImpl implements BillingAccountApiService {
}
}
}
}
return ServiceResponse.success();
}
private boolean isNotInWhiteList(Integer enterpriseId) {
// todo 判断商户在不在白名单中
return true;
}
private void sendTotoItem(Integer enterpriseId) {
TodoItemDTO todoItemDTO = new TodoItemDTO();
UserDTO userDTO = userApiService.getUserByEnterpriseId(enterpriseId).getResult();
......
......@@ -90,7 +90,7 @@ public class SmsRecordApiServiceImpl implements SmsRecordApiService {
Integer unitFee = accountStandardService.queryUnitFee(enterpriseId, AccountStandardEnum.SMS.getCode());
double needFee = (double) (missCount * unitFee) / 1000;
if (needFee - accountBalance > billingAccount.getCreditLine()) {
if (needFee - accountBalance > billingAccount.getCreditLine() && isNotInWhiteList(enterpriseId)) {
logger.info("enterpriseId:{}, 余额:{}, 发送条数:{}, 不能发送", enterpriseId, accountBalance, sendCount);
return EnterpriseServiceResponse.failure(ErrorCode.OPERATION_FAILED.getCode(), "余额不足, 不能发送");
} else {
......@@ -273,4 +273,9 @@ public class SmsRecordApiServiceImpl implements SmsRecordApiService {
}
}
}
private boolean isNotInWhiteList(Integer enterpriseId) {
// todo 判断商户在不在白名单中
return true;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment