Commit 87378aba by zhiwj

bug

parent 46ff5826
......@@ -9,7 +9,8 @@ package com.gic.enterprise.constant;
public enum AccountStandardEnum {
SMS(2, "短信"),
VOICE(3, "语音"),
CALL(4, "双向呼叫")
CALL(4, "双向呼叫"),
INTERNATIONAL_SMS(4, "海外短信")
;
private Integer code;
private String msg;
......
......@@ -12,6 +12,17 @@ import com.gic.enterprise.dto.InternationalSmsRecordDTO;
public interface InternationalSmsRecordApiService {
/**
* @Title: verifySendInternationalSms
* @Description: 发送海外短信
* @author zhiwj
* @param enterpriseId
* @param sendCount
* @return com.gic.api.base.commons.ServiceResponse<java.lang.Void>
* @throws
*/
ServiceResponse<Void> verifySendInternationalSms(Integer enterpriseId, Integer sendCount);
/**
* 保存明细
* @Title: saveInternationalSmsRecord
* @Description:
......
......@@ -3,13 +3,14 @@ package com.gic.enterprise.service.outer.impl;
import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.GICMQClientUtil;
import com.gic.enterprise.constant.AccountStandardEnum;
import com.gic.enterprise.constant.Constants;
import com.gic.enterprise.dto.DictDTO;
import com.gic.enterprise.dto.InternationalSmsRecordDTO;
import com.gic.enterprise.service.BillingAccountService;
import com.gic.enterprise.service.BillingInternationalSmsRecordService;
import com.gic.enterprise.service.DictApiService;
import com.gic.enterprise.service.InternationalSmsRecordApiService;
import com.gic.enterprise.entity.TabBillingAccount;
import com.gic.enterprise.error.ErrorCode;
import com.gic.enterprise.response.EnterpriseServiceResponse;
import com.gic.enterprise.service.*;
import com.gic.mq.sdk.GicMQClient;
import com.gic.store.utils.valid.ValidUtil;
import org.apache.logging.log4j.LogManager;
......@@ -36,6 +37,28 @@ public class InternationalSmsRecordApiServiceImpl implements InternationalSmsRec
private BillingInternationalSmsRecordService billingInternationalSmsRecordService;
@Autowired
private DictApiService dictApiService;
@Autowired
private AccountStandardService accountStandardService;
@Override
public ServiceResponse<Void> verifySendInternationalSms(Integer enterpriseId, Integer sendCount) {
if (enterpriseId == null || sendCount == null) {
return EnterpriseServiceResponse.failure(ErrorCode.PARAMETER_ERROR);
}
TabBillingAccount billingAccount = billingAccountService.getByEnterpriseId(enterpriseId);
Double accountBalance = billingAccount.getAccountBalance();
Integer unitFee = accountStandardService.queryUnitFee(enterpriseId, AccountStandardEnum.SMS.getCode());
double needFee = (double) (sendCount * unitFee) / 1000;
if (needFee - accountBalance > 5000d) {
logger.info("enterpriseId:{}, 余额:{}, 发送条数:{}, 不能发送", enterpriseId, accountBalance, sendCount);
return EnterpriseServiceResponse.failure(ErrorCode.OPERATION_FAILED.getCode(), "余额不足, 不能发送");
} else {
logger.info("enterpriseId:{}, 余额:{}, 发送条数:{}, 可以发送", enterpriseId, accountBalance, sendCount);
return EnterpriseServiceResponse.success();
}
}
@Override
public ServiceResponse<Void> saveInternationalSmsRecord(InternationalSmsRecordDTO internationalSmsRecordDTO) {
......
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