Commit 323c8f54 by zhiwj

短信

parent cb780aed
package com.gic.enterprise.constant;
import org.apache.commons.lang3.StringUtils;
/**
* @author zhiwj
* @Description: 短信消费应用场景
* @date 2020-03-30 13:42
*/
public enum SmsAppEnum {
MEMBER_OPEN_CARD("MEMBER_OPEN_CARD", "会员开卡"),
GIC_MALL("GIC_MALL", "微商城"),
GIC_INTEGRAL("GIC_INTEGRAL", "积分商城"),
SMS("sms", "短信营销"),
ECM("ecm", "触点营销"),
ECM_TIMER("ecm-timer", "定时营销"),
GAME_DZP("dzp", "大转盘"),
GAME_GGK("ggk", "刮刮卡"),
GAME_KLFL("klfl", "口令福利"),
GAME_PTYX("ptyx", "拼图游戏"),
OTHER("other", "其他"),
;
private String code;
private String name;
SmsAppEnum(String code, String name) {
this.code = code;
this.name = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public static String getNameByCode(String code) {
if (StringUtils.isNotBlank(code)) {
for (SmsAppEnum smsApp : values()) {
if (smsApp.code.equals(code)) {
return smsApp.name;
}
}
}
return null;
}
}
package com.gic.enterprise.constant;
/**
* @author zhiwj
* @Description: 短信消费类型
* @date 2020-03-30 14:45
*/
public enum SmsTypeEnum {
AUTH_CODE(1, "验证码"),
NOTICE(2, "通知"),
MARKETING(3, "营销"),
;
SmsTypeEnum(Integer code, String name) {
this.code = code;
this.name = name;
}
private Integer code;
private String name;
public Integer getCode() {
return code;
}
public String getName() {
return name;
}
}
......@@ -20,7 +20,7 @@ public class InternationalSmsRecordDTO implements Serializable {
/**
*
*/
private Integer smsRecordId;
private Long smsRecordId;
/**
*
......@@ -40,7 +40,14 @@ public class InternationalSmsRecordDTO implements Serializable {
private String receivePhone;
/**
* 支付方式
*
*/
@NotBlank(message = "区号不能为空", groups = InternationalSmsRecordValid.class)
private String nationCode;
private String nationName;
/**
* 支付方式 支付方式 0套餐包 4余额支付
*/
private Integer payType;
......@@ -51,13 +58,14 @@ public class InternationalSmsRecordDTO implements Serializable {
private String appCode;
/**
* 应用name
* 应用
*/
private String appName;
/**
* 短信类型
* 短信类型 1验证码 2通知 3营销
*/
@NotNull(message = "短信类型不能为空", groups = InternationalSmsRecordValid.class)
private Integer smsType;
/**
......@@ -68,7 +76,6 @@ public class InternationalSmsRecordDTO implements Serializable {
/**
* 费用
*/
@NotNull(message = "费用不能为空", groups = InternationalSmsRecordValid.class)
private Double fee;
/**
......@@ -104,16 +111,26 @@ public class InternationalSmsRecordDTO implements Serializable {
private Integer enterpriseSmsPackageId;
/**
*
* 会员ecuId
*/
@NotBlank(message = "区号不能为空", groups = InternationalSmsRecordValid.class)
private String nationCode;
@NotNull(message = "会员ecuId不能为空", groups = InternationalSmsRecordValid.class)
private Long ecuId;
/**
*
* 会员mcuId
*/
@NotBlank(message = "区号不能为空", groups = InternationalSmsRecordValid.class)
private String nationName;
private Long mcuId;
/**
* 会员卡id
*/
@NotNull(message = "会员卡id不能为空", groups = InternationalSmsRecordValid.class)
private Long memberCardId;
/**
* 会员卡名字
*/
private String memberCardName;
/**
* 会员姓名
......@@ -121,6 +138,11 @@ public class InternationalSmsRecordDTO implements Serializable {
private String memberName;
/**
* 店招品牌
*/
private String storeBrandName;
/**
* 门店id
*/
private Integer storeId;
......@@ -141,6 +163,16 @@ public class InternationalSmsRecordDTO implements Serializable {
private String storeGroupName;
/**
* 操作人id
*/
private Integer userId;
/**
* 操作人name
*/
private String userName;
/**
* 缓存更新成功标志 1:成功
*/
private Integer cacheStatus;
......@@ -150,11 +182,11 @@ public class InternationalSmsRecordDTO implements Serializable {
*/
private Integer databaseStatus;
public Integer getSmsRecordId() {
public Long getSmsRecordId() {
return smsRecordId;
}
public void setSmsRecordId(Integer smsRecordId) {
public void setSmsRecordId(Long smsRecordId) {
this.smsRecordId = smsRecordId;
}
......@@ -182,6 +214,14 @@ public class InternationalSmsRecordDTO implements Serializable {
this.receivePhone = receivePhone;
}
public String getNationName() {
return nationName;
}
public void setNationName(String nationName) {
this.nationName = nationName;
}
public Integer getPayType() {
return payType;
}
......@@ -278,20 +318,36 @@ public class InternationalSmsRecordDTO implements Serializable {
this.enterpriseSmsPackageId = enterpriseSmsPackageId;
}
public String getNationCode() {
return nationCode;
public Long getEcuId() {
return ecuId;
}
public void setNationCode(String nationCode) {
this.nationCode = nationCode;
public void setEcuId(Long ecuId) {
this.ecuId = ecuId;
}
public String getNationName() {
return nationName;
public Long getMcuId() {
return mcuId;
}
public void setNationName(String nationName) {
this.nationName = nationName;
public void setMcuId(Long mcuId) {
this.mcuId = mcuId;
}
public Long getMemberCardId() {
return memberCardId;
}
public void setMemberCardId(Long memberCardId) {
this.memberCardId = memberCardId;
}
public String getMemberCardName() {
return memberCardName;
}
public void setMemberCardName(String memberCardName) {
this.memberCardName = memberCardName;
}
public String getMemberName() {
......@@ -302,6 +358,14 @@ public class InternationalSmsRecordDTO implements Serializable {
this.memberName = memberName;
}
public String getStoreBrandName() {
return storeBrandName;
}
public void setStoreBrandName(String storeBrandName) {
this.storeBrandName = storeBrandName;
}
public Integer getStoreId() {
return storeId;
}
......@@ -334,6 +398,22 @@ public class InternationalSmsRecordDTO implements Serializable {
this.storeGroupName = storeGroupName;
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public Integer getCacheStatus() {
return cacheStatus;
}
......@@ -349,4 +429,12 @@ public class InternationalSmsRecordDTO implements Serializable {
public void setDatabaseStatus(Integer databaseStatus) {
this.databaseStatus = databaseStatus;
}
public String getNationCode() {
return nationCode;
}
public void setNationCode(String nationCode) {
this.nationCode = nationCode;
}
}
......@@ -20,7 +20,7 @@ public class SmsRecordDTO implements Serializable {
/**
*
*/
private Integer smsRecordId;
private Long smsRecordId;
/**
*
......@@ -40,9 +40,9 @@ public class SmsRecordDTO implements Serializable {
private String receivePhone;
/**
* 支付方式
* 支付方式 支付方式 0套餐包 4余额支付
*/
private Integer payType=0;
private Integer payType;
/**
* 应用
......@@ -51,13 +51,14 @@ public class SmsRecordDTO implements Serializable {
private String appCode;
/**
* 应用name
* 应用
*/
private String appName;
/**
* 短信类型
* 短信类型 1验证码 2通知 3营销
*/
@NotNull(message = "短信类型不能为空", groups = SmsRecordValid.class)
private Integer smsType;
/**
......@@ -103,9 +104,71 @@ public class SmsRecordDTO implements Serializable {
private Integer enterpriseSmsPackageId;
/**
* 扣费类型 1:短信套餐包, 2:余额
* 会员ecuId
*/
@NotNull(message = "会员ecuId不能为空", groups = SmsRecordValid.class)
private Long ecuId;
/**
* 会员mcuId
*/
private Long mcuId;
/**
* 会员卡id
*/
private Integer deductType;
@NotNull(message = "会员卡id不能为空", groups = SmsRecordValid.class)
private Long memberCardId;
private String nationCode;
private String nationName;
/**
* 会员卡名字
*/
private String memberCardName;
/**
* 会员姓名
*/
private String memberName;
/**
* 店招品牌
*/
private String storeBrandName;
/**
* 门店id
*/
private Integer storeId;
/**
* 门店名称
*/
private String storeName;
/**
* 门店分组id
*/
private Integer storeGroupId;
/**
* 门店分组名称
*/
private String storeGroupName;
/**
* 操作人id
*/
private Integer userId;
/**
* 操作人name
*/
private String userName;
/**
* 缓存更新成功标志 1:成功
......@@ -117,11 +180,11 @@ public class SmsRecordDTO implements Serializable {
*/
private Integer databaseStatus;
public Integer getSmsRecordId() {
public Long getSmsRecordId() {
return smsRecordId;
}
public void setSmsRecordId(Integer smsRecordId) {
public void setSmsRecordId(Long smsRecordId) {
this.smsRecordId = smsRecordId;
}
......@@ -245,12 +308,100 @@ public class SmsRecordDTO implements Serializable {
this.enterpriseSmsPackageId = enterpriseSmsPackageId;
}
public Integer getDeductType() {
return deductType;
public Long getEcuId() {
return ecuId;
}
public void setEcuId(Long ecuId) {
this.ecuId = ecuId;
}
public Long getMcuId() {
return mcuId;
}
public void setMcuId(Long mcuId) {
this.mcuId = mcuId;
}
public Long getMemberCardId() {
return memberCardId;
}
public void setDeductType(Integer deductType) {
this.deductType = deductType;
public void setMemberCardId(Long memberCardId) {
this.memberCardId = memberCardId;
}
public String getMemberCardName() {
return memberCardName;
}
public void setMemberCardName(String memberCardName) {
this.memberCardName = memberCardName;
}
public String getMemberName() {
return memberName;
}
public void setMemberName(String memberName) {
this.memberName = memberName;
}
public String getStoreBrandName() {
return storeBrandName;
}
public void setStoreBrandName(String storeBrandName) {
this.storeBrandName = storeBrandName;
}
public Integer getStoreId() {
return storeId;
}
public void setStoreId(Integer storeId) {
this.storeId = storeId;
}
public String getStoreName() {
return storeName;
}
public void setStoreName(String storeName) {
this.storeName = storeName;
}
public Integer getStoreGroupId() {
return storeGroupId;
}
public void setStoreGroupId(Integer storeGroupId) {
this.storeGroupId = storeGroupId;
}
public String getStoreGroupName() {
return storeGroupName;
}
public void setStoreGroupName(String storeGroupName) {
this.storeGroupName = storeGroupName;
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public Integer getCacheStatus() {
......@@ -268,4 +419,20 @@ public class SmsRecordDTO implements Serializable {
public void setDatabaseStatus(Integer databaseStatus) {
this.databaseStatus = databaseStatus;
}
public String getNationCode() {
return nationCode;
}
public void setNationCode(String nationCode) {
this.nationCode = nationCode;
}
public String getNationName() {
return nationName;
}
public void setNationName(String nationName) {
this.nationName = nationName;
}
}
......@@ -12,17 +12,6 @@ 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:
......
......@@ -17,10 +17,11 @@ public interface SmsRecordApiService {
* @author zhiwj
* @param enterpriseId
* @param sendCount
* @param nationCode 区号,
* @return com.gic.api.base.commons.ServiceResponse<java.lang.Void>
* @throws
*/
ServiceResponse<Void> verifySendSms(Integer enterpriseId, Integer sendCount);
ServiceResponse<Void> verifySendSms(Integer enterpriseId, Integer sendCount, String nationCode);
/**
* 保存明细
......
package com.gic.enterprise.entity;
import com.gic.commons.plugin.mybatis.InjectId;
import java.util.Date;
/**
......@@ -9,7 +11,8 @@ public class TabBillingInternationalSmsRecord {
/**
*
*/
private Integer smsRecordId;
@InjectId(InjectId.IdType.SNOWFLAKE)
private Long smsRecordId;
/**
*
......@@ -97,11 +100,36 @@ public class TabBillingInternationalSmsRecord {
private String nationName;
/**
* 会员ecuId
*/
private Long ecuId;
/**
* 会员mcuId
*/
private Long mcuId;
/**
* 会员卡id
*/
private Long memberCardId;
/**
* 会员卡名字
*/
private String memberCardName;
/**
* 会员姓名
*/
private String memberName;
/**
* 店招品牌
*/
private String storeBrandName;
/**
* 门店id
*/
private Integer storeId;
......@@ -122,6 +150,16 @@ public class TabBillingInternationalSmsRecord {
private String storeGroupName;
/**
* 操作人id
*/
private Integer userId;
/**
* 操作人name
*/
private String userName;
/**
* 缓存更新成功标志 1:成功
*/
private Integer cacheStatus;
......@@ -131,11 +169,11 @@ public class TabBillingInternationalSmsRecord {
*/
private Integer databaseStatus;
public Integer getSmsRecordId() {
public Long getSmsRecordId() {
return smsRecordId;
}
public void setSmsRecordId(Integer smsRecordId) {
public void setSmsRecordId(Long smsRecordId) {
this.smsRecordId = smsRecordId;
}
......@@ -275,6 +313,38 @@ public class TabBillingInternationalSmsRecord {
this.nationName = nationName;
}
public Long getEcuId() {
return ecuId;
}
public void setEcuId(Long ecuId) {
this.ecuId = ecuId;
}
public Long getMcuId() {
return mcuId;
}
public void setMcuId(Long mcuId) {
this.mcuId = mcuId;
}
public Long getMemberCardId() {
return memberCardId;
}
public void setMemberCardId(Long memberCardId) {
this.memberCardId = memberCardId;
}
public String getMemberCardName() {
return memberCardName;
}
public void setMemberCardName(String memberCardName) {
this.memberCardName = memberCardName;
}
public String getMemberName() {
return memberName;
}
......@@ -283,6 +353,14 @@ public class TabBillingInternationalSmsRecord {
this.memberName = memberName;
}
public String getStoreBrandName() {
return storeBrandName;
}
public void setStoreBrandName(String storeBrandName) {
this.storeBrandName = storeBrandName;
}
public Integer getStoreId() {
return storeId;
}
......@@ -315,6 +393,22 @@ public class TabBillingInternationalSmsRecord {
this.storeGroupName = storeGroupName;
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public Integer getCacheStatus() {
return cacheStatus;
}
......
package com.gic.enterprise.entity;
import com.gic.commons.plugin.mybatis.InjectId;
import java.util.Date;
/**
......@@ -9,7 +11,8 @@ public class TabBillingSmsRecord {
/**
*
*/
private Integer smsRecordId;
@InjectId(InjectId.IdType.SNOWFLAKE)
private Long smsRecordId;
/**
*
......@@ -27,7 +30,7 @@ public class TabBillingSmsRecord {
private String receivePhone;
/**
* 支付方式
* 支付方式 支付方式 1微信 2支付宝 3.银行对公转账 4余额支付
*/
private Integer payType;
......@@ -37,12 +40,12 @@ public class TabBillingSmsRecord {
private String appCode;
/**
* 应用name
* 应用
*/
private String appName;
/**
* 短信类型
* 短信类型 1:普通短信 2:短信验证码
*/
private Integer smsType;
......@@ -87,11 +90,36 @@ public class TabBillingSmsRecord {
private Integer enterpriseSmsPackageId;
/**
* 会员ecuId
*/
private Long ecuId;
/**
* 会员mcuId
*/
private Long mcuId;
/**
* 会员卡id
*/
private Long memberCardId;
/**
* 会员卡名字
*/
private String memberCardName;
/**
* 会员姓名
*/
private String memberName;
/**
* 店招品牌
*/
private String storeBrandName;
/**
* 门店id
*/
private Integer storeId;
......@@ -112,6 +140,16 @@ public class TabBillingSmsRecord {
private String storeGroupName;
/**
* 操作人id
*/
private Integer userId;
/**
* 操作人name
*/
private String userName;
/**
* 缓存更新成功标志 1:成功
*/
private Integer cacheStatus;
......@@ -121,11 +159,11 @@ public class TabBillingSmsRecord {
*/
private Integer databaseStatus;
public Integer getSmsRecordId() {
public Long getSmsRecordId() {
return smsRecordId;
}
public void setSmsRecordId(Integer smsRecordId) {
public void setSmsRecordId(Long smsRecordId) {
this.smsRecordId = smsRecordId;
}
......@@ -249,6 +287,38 @@ public class TabBillingSmsRecord {
this.enterpriseSmsPackageId = enterpriseSmsPackageId;
}
public Long getEcuId() {
return ecuId;
}
public void setEcuId(Long ecuId) {
this.ecuId = ecuId;
}
public Long getMcuId() {
return mcuId;
}
public void setMcuId(Long mcuId) {
this.mcuId = mcuId;
}
public Long getMemberCardId() {
return memberCardId;
}
public void setMemberCardId(Long memberCardId) {
this.memberCardId = memberCardId;
}
public String getMemberCardName() {
return memberCardName;
}
public void setMemberCardName(String memberCardName) {
this.memberCardName = memberCardName;
}
public String getMemberName() {
return memberName;
}
......@@ -257,6 +327,14 @@ public class TabBillingSmsRecord {
this.memberName = memberName;
}
public String getStoreBrandName() {
return storeBrandName;
}
public void setStoreBrandName(String storeBrandName) {
this.storeBrandName = storeBrandName;
}
public Integer getStoreId() {
return storeId;
}
......@@ -289,6 +367,22 @@ public class TabBillingSmsRecord {
this.storeGroupName = storeGroupName;
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public Integer getCacheStatus() {
return cacheStatus;
}
......
......@@ -41,11 +41,11 @@ public interface BillingInternationalSmsRecordService {
Double getTotalFee(Integer enterpriseId, String startTime, String endTime);
Integer save(InternationalSmsRecordDTO internationalSmsRecordDTO);
Long save(InternationalSmsRecordDTO internationalSmsRecordDTO);
Integer countInternationalSmsRecord(RecordQO recordQO);
void updateCacheStatus(Integer smsRecordId);
void updateCacheStatus(Long smsRecordId);
void updateDatabaseStatus(InternationalSmsRecordDTO internationalSmsRecordDTO);
}
......@@ -46,9 +46,9 @@ public interface BillingSmsRecordService {
Double getTotalFee(Integer enterpriseId, String startTime, String endTime);
Integer saveSmsRecord(SmsRecordDTO smsRecordDTO);
Long saveSmsRecord(SmsRecordDTO smsRecordDTO);
void updateCacheStatus(Integer smsRecordId);
void updateCacheStatus(Long smsRecordId);
void updateDatabaseStatus(SmsRecordDTO smsRecordDTO);
}
......@@ -56,7 +56,7 @@ public class BillingInternationalSmsRecordServiceImpl implements BillingInternat
}
@Override
public Integer save(InternationalSmsRecordDTO internationalSmsRecordDTO) {
public Long save(InternationalSmsRecordDTO internationalSmsRecordDTO) {
TabBillingInternationalSmsRecord billingInternationalSmsRecord = EntityUtil.changeEntityByJSON(TabBillingInternationalSmsRecord.class, internationalSmsRecordDTO);
this.tabBillingInternationalSmsRecordMapper.insertSelective(billingInternationalSmsRecord);
return billingInternationalSmsRecord.getSmsRecordId();
......@@ -68,7 +68,7 @@ public class BillingInternationalSmsRecordServiceImpl implements BillingInternat
}
@Override
public void updateCacheStatus(Integer smsRecordId) {
public void updateCacheStatus(Long smsRecordId) {
TabBillingInternationalSmsRecord tabBillingInternationalSmsRecord = new TabBillingInternationalSmsRecord();
tabBillingInternationalSmsRecord.setSmsRecordId(smsRecordId);
tabBillingInternationalSmsRecord.setCacheStatus(1);
......
......@@ -59,7 +59,7 @@ public class BillingSmsRecordServiceImpl implements BillingSmsRecordService{
}
@Override
public Integer saveSmsRecord(SmsRecordDTO smsRecordDTO) {
public Long saveSmsRecord(SmsRecordDTO smsRecordDTO) {
TabBillingSmsRecord billingSmsRecord = EntityUtil.changeEntityByJSON(TabBillingSmsRecord.class, smsRecordDTO);
billingSmsRecord.setStatus(GlobalInfo.DATA_STATUS_NORMAL);
billingSmsRecord.setCreateTime(new Date());
......@@ -69,7 +69,7 @@ public class BillingSmsRecordServiceImpl implements BillingSmsRecordService{
}
@Override
public void updateCacheStatus(Integer smsRecordId) {
public void updateCacheStatus(Long smsRecordId) {
TabBillingSmsRecord smsRecord = new TabBillingSmsRecord();
smsRecord.setSmsRecordId(smsRecordId);
smsRecord.setCacheStatus(1);
......@@ -78,11 +78,11 @@ public class BillingSmsRecordServiceImpl implements BillingSmsRecordService{
@Override
public void updateDatabaseStatus(SmsRecordDTO smsRecordDTO) {
TabBillingSmsRecord smsRecord = new TabBillingSmsRecord();
smsRecord.setSmsRecordId(smsRecordDTO.getSmsRecordId());
TabBillingSmsRecord smsRecord = EntityUtil.changeEntityByJSON(TabBillingSmsRecord.class, smsRecordDTO);
// 不去修改缓存状态
smsRecord.setCacheStatus(null);
smsRecord.setDatabaseStatus(1);
smsRecord.setDeductionTime(new Date());
smsRecord.setAppName(smsRecordDTO.getAppName());
tabBillingSmsRecordMapper.updateByPrimaryKeySelective(smsRecord);
}
}
}
\ No newline at end of file
......@@ -2,16 +2,23 @@ package com.gic.enterprise.service.outer.impl;
import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.auth.dto.UserDTO;
import com.gic.auth.service.UserApiService;
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.constant.SmsAppEnum;
import com.gic.enterprise.dto.InternationalSmsRecordDTO;
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.enterprise.service.AccountStandardService;
import com.gic.enterprise.service.BillingAccountService;
import com.gic.enterprise.service.BillingInternationalSmsRecordService;
import com.gic.enterprise.service.InternationalSmsRecordApiService;
import com.gic.member.api.dto.MemberUserDTO;
import com.gic.member.api.dto.UserOwnerDTO;
import com.gic.member.api.service.MemberUserApiService;
import com.gic.member.api.service.UserOwnerApiService;
import com.gic.mq.sdk.GicMQClient;
import com.gic.store.dto.StoreDTO;
import com.gic.store.service.StoreApiService;
import com.gic.store.utils.valid.ValidUtil;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
......@@ -36,31 +43,17 @@ public class InternationalSmsRecordApiServiceImpl implements InternationalSmsRec
@Autowired
private BillingInternationalSmsRecordService billingInternationalSmsRecordService;
@Autowired
private DictApiService dictApiService;
private MemberUserApiService memberUserApiService;
@Autowired
private UserApiService userApiService;
@Autowired
private StoreApiService storeApiService;
@Autowired
private UserOwnerApiService userOwnerApiService;
@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) {
ServiceResponse paramResult = ValidUtil.allCheckValidate(internationalSmsRecordDTO, InternationalSmsRecordDTO.InternationalSmsRecordValid.class);
if (!paramResult.isSuccess()) {
......@@ -90,7 +83,7 @@ public class InternationalSmsRecordApiServiceImpl implements InternationalSmsRec
billingAccountService.deductAccountByCache(fee, internationalSmsRecordDTO.getEnterpriseId());
internationalSmsRecordDTO.setFee((double)fee / 1000);
Integer smsRecordId = billingInternationalSmsRecordService.save(internationalSmsRecordDTO);
Long smsRecordId = billingInternationalSmsRecordService.save(internationalSmsRecordDTO);
internationalSmsRecordDTO.setSmsRecordId(smsRecordId);
// 队列
......@@ -108,16 +101,76 @@ public class InternationalSmsRecordApiServiceImpl implements InternationalSmsRec
logger.info("海外短信数据库扣费:{}", arg);
InternationalSmsRecordDTO internationalSmsRecordDTO = JSON.parseObject(arg, InternationalSmsRecordDTO.class);
internationalSmsRecordDTO.setDeductionTime(new Date());
ServiceResponse<DictDTO> serviceDict = dictApiService.getDict(Constants.SMS_APP_TYPE, internationalSmsRecordDTO.getAppCode());
if (serviceDict.isSuccess()) {
DictDTO dictDTO = serviceDict.getResult();
if (dictDTO != null) {
String key = dictDTO.getKey();
internationalSmsRecordDTO.setAppName(key);
}
}
// 应用名字
internationalSmsRecordDTO.setAppName(SmsAppEnum.getNameByCode(internationalSmsRecordDTO.getAppCode()));
// 会员名字
setMemberName(internationalSmsRecordDTO);
// 操作人
setUserName(internationalSmsRecordDTO);
// 门店
setStore(internationalSmsRecordDTO);
billingAccountService.deductAccountByDatabase(internationalSmsRecordDTO.getFee(), internationalSmsRecordDTO.getEnterpriseId());
billingInternationalSmsRecordService.updateDatabaseStatus(internationalSmsRecordDTO);
return ServiceResponse.success();
}
private void setStore(InternationalSmsRecordDTO smsRecordDTO) {
ServiceResponse<UserOwnerDTO> userOwnerResp = userOwnerApiService.getUserMaxOwner(smsRecordDTO.getEnterpriseId(), smsRecordDTO.getEcuId(), 1, smsRecordDTO.getMemberCardId(), null);
if (userOwnerResp.isSuccess()) {
UserOwnerDTO userOwnerDTO = userOwnerResp.getResult();
if (userOwnerDTO != null) {
ServiceResponse<StoreDTO> storeResp = storeApiService.getStoreById(smsRecordDTO.getEnterpriseId(), Integer.valueOf(userOwnerDTO.getOwnerId()));
if (storeResp.isSuccess()) {
StoreDTO storeDTO = storeResp.getResult();
if (storeDTO != null) {
smsRecordDTO.setStoreId(storeDTO.getStoreId());
smsRecordDTO.setStoreName(storeDTO.getStoreName());
smsRecordDTO.setStoreGroupId(storeDTO.getStoreGroupId());
smsRecordDTO.setStoreGroupName(storeDTO.getStoreGroupName());
smsRecordDTO.setStoreBrandName(storeDTO.getStoreBrandNames());
}
} else {
logger.info("storeApiService.getStoreById 调用失败 :{}", storeResp.getMessage());
}
}
} else {
logger.info("UserOwnerApiService.getUserMaxOwner 调用失败:{}", userOwnerResp.getMessage());
}
}
/**
* 操作人
*/
private void setUserName(InternationalSmsRecordDTO smsRecordDTO) {
if (smsRecordDTO.getUserId() != null) {
ServiceResponse<UserDTO> userResp = userApiService.getUserById(smsRecordDTO.getUserId());
if (userResp.isSuccess()) {
UserDTO userDTO = userResp.getResult();
if (userDTO != null) {
smsRecordDTO.setUserName(smsRecordDTO.getUserName());
}
} else {
logger.info("userId:{}, UserApiService.getUserById 调用失败:{}", smsRecordDTO.getUserId(), userResp.getMessage());
}
}
}
/**
* 会员名字和会员卡号
*/
private void setMemberName(InternationalSmsRecordDTO smsRecordDTO) {
if (smsRecordDTO.getMcuId() != null) {
ServiceResponse<MemberUserDTO> memberUserDTOServiceResponse = memberUserApiService.getByMcuId(smsRecordDTO.getMcuId(), smsRecordDTO.getEnterpriseId());
if (memberUserDTOServiceResponse.isSuccess()) {
MemberUserDTO memberUserDTO = memberUserDTOServiceResponse.getResult();
if (memberUserDTO != null) {
smsRecordDTO.setMemberName(memberUserDTO.getName());
smsRecordDTO.setMemberCardName(memberUserDTO.getCardName());
}
} else {
logger.warn("mcuId:{}, enterpriseId:{}, memberUserApiService.getByMcuId调用失败:{}, ", smsRecordDTO.getMcuId(), smsRecordDTO.getEnterpriseId(), memberUserDTOServiceResponse.getMessage());
}
}
}
}
......@@ -129,4 +129,7 @@
<dubbo:reference interface="com.gic.auth.service.BusinessFrontResApiService" id="businessFrontResApiService" timeout="6000" />
<dubbo:reference interface="com.gic.marketing.process.api.service.tmpl.WxTemplateRouterApiService" id="wxTemplateRouterApiService" timeout="60000" />
<dubbo:reference interface="com.gic.member.api.service.MemberUserApiService" id="memberUserApiService" timeout="60000" />
<dubbo:reference interface="com.gic.store.service.StoreApiService" id="storeApiService" timeout="60000" />
<dubbo:reference interface="com.gic.member.api.service.UserOwnerApiService" id="userOwnerApiService" timeout="60000" />
</beans>
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