Commit 32de13c1 by guojuxing

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

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