Commit 4a964aa5 by 陶光胜

Merge branch 'developer' into 'master'

Developer

See merge request !15
parents 5fbbeca4 4900ccfe
......@@ -29,7 +29,8 @@ public enum EnterpriseInitCodeEnum {
COMPLETE_WECHAT_CONFIG("completeWeChatConfig", "完成小程序配置", 4),
COMPLETE_DATA_COUNT_CONFIG("completeDataCountConfig", "完成数据统计配置", 6),
CONFIG_EFFECTIVE_ORDER("configEffectiveOrder", "完成有效订单的配置", 6),
CONFIG_PAY("configPay", "完成实付的配置", 6);
CONFIG_PAY("configPay", "完成实付的配置", 6),
INTI_MEMBER_CARD_SMS("initMemberCardSmsTemplate", "初始化会员卡的短信模板", 7);
private String code;
private String message;
......
package com.gic.enterprise.dto;
import java.io.Serializable;
import java.util.Date;
public class EnterpriseWhiteListDTO implements Serializable{
private static final long serialVersionUID = 6358427077203219902L;
/**
*
*/
private Integer whiteListId;
/**
*
*/
private Integer enterpriseId;
/**
* 商户名称
*/
private String enterpriseName;
/**
* 公司名称
*/
private String companyName;
/**
* 1:有效 0:解除白名单
*/
private Integer status;
/**
*
*/
private Date createTime;
/**
*
*/
private Date updateTime;
/**
* 账户余额
*/
private Double accountBalance;
/**
* 基础服务过期时间
*/
private Date auditTime;
public Integer getWhiteListId() {
return whiteListId;
}
public EnterpriseWhiteListDTO setWhiteListId(Integer whiteListId) {
this.whiteListId = whiteListId;
return this;
}
public Integer getEnterpriseId() {
return enterpriseId;
}
public EnterpriseWhiteListDTO setEnterpriseId(Integer enterpriseId) {
this.enterpriseId = enterpriseId;
return this;
}
public String getEnterpriseName() {
return enterpriseName;
}
public EnterpriseWhiteListDTO setEnterpriseName(String enterpriseName) {
this.enterpriseName = enterpriseName;
return this;
}
public String getCompanyName() {
return companyName;
}
public EnterpriseWhiteListDTO setCompanyName(String companyName) {
this.companyName = companyName;
return this;
}
public Integer getStatus() {
return status;
}
public EnterpriseWhiteListDTO setStatus(Integer status) {
this.status = status;
return this;
}
public Date getCreateTime() {
return createTime;
}
public EnterpriseWhiteListDTO setCreateTime(Date createTime) {
this.createTime = createTime;
return this;
}
public Date getUpdateTime() {
return updateTime;
}
public EnterpriseWhiteListDTO setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
return this;
}
public Double getAccountBalance() {
return accountBalance;
}
public EnterpriseWhiteListDTO setAccountBalance(Double accountBalance) {
this.accountBalance = accountBalance;
return this;
}
public Date getAuditTime() {
return auditTime;
}
public EnterpriseWhiteListDTO setAuditTime(Date auditTime) {
this.auditTime = auditTime;
return this;
}
}
package com.gic.enterprise.dto.wm;
import java.io.Serializable;
public class WmStoreInfoDTO implements Serializable{
private static final long serialVersionUID = 3913651638507713342L;
/**
*
*/
private Integer wmMallStoreId;
/**
* 微盟主账号
*/
private String wmMainAccount;
/**
* 微盟pid
*/
private String wmPid;
/**
* 微盟store_id
*/
private String wmStoreId;
/**
* 店铺名称
*/
private String wmPidName;
public Integer getWmMallStoreId() {
return wmMallStoreId;
}
public WmStoreInfoDTO setWmMallStoreId(Integer wmMallStoreId) {
this.wmMallStoreId = wmMallStoreId;
return this;
}
public String getWmMainAccount() {
return wmMainAccount;
}
public WmStoreInfoDTO setWmMainAccount(String wmMainAccount) {
this.wmMainAccount = wmMainAccount;
return this;
}
public String getWmPid() {
return wmPid;
}
public WmStoreInfoDTO setWmPid(String wmPid) {
this.wmPid = wmPid;
return this;
}
public String getWmStoreId() {
return wmStoreId;
}
public WmStoreInfoDTO setWmStoreId(String wmStoreId) {
this.wmStoreId = wmStoreId;
return this;
}
public String getWmPidName() {
return wmPidName;
}
public WmStoreInfoDTO setWmPidName(String wmPidName) {
this.wmPidName = wmPidName;
return this;
}
}
......@@ -169,6 +169,13 @@ public interface EnterpriseInitApiService {
ServiceResponse<Void> shortMessageServiceConfig(Integer enterpriseId);
/**
* 初始化会员卡的短信模板
* @param enterpriseId
* @return
*/
ServiceResponse<Void> initMemberCardSmsTemplate(Integer enterpriseId);
/**
* 状态改为未初始化状态
* @Title: unInitByConfigCode

* @Description:
......
package com.gic.enterprise.service;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.enterprise.dto.EnterpriseWhiteListDTO;
public interface EnterpriseWhiteListApiService {
/**
* 新增商户白名单
* @Title: saveEnterpriseWhiteList

* @Description:

* @author guojuxing
* @param enterpriseId

* @return com.gic.api.base.commons.ServiceResponse<java.lang.Void>


*/
ServiceResponse<Void> saveEnterpriseWhiteList(Integer enterpriseId);
/**
* 解除白名单
* @Title: removeEnterpriseWhiteList

* @Description:

* @author guojuxing
* @param enterpriseId

* @return com.gic.api.base.commons.ServiceResponse<java.lang.Void>


*/
ServiceResponse<Void> removeEnterpriseWhiteList(Integer enterpriseId);
/**
* 分页查询白明答
* @param search 商户名称/公司名称
* @return
*/
ServiceResponse<Page<EnterpriseWhiteListDTO>> pageEnterpriseWhiteList(String search, Integer currentPage, Integer pageSize);
/**
* 是否在白名单内
* @param enterpriseId
* @return
*/
ServiceResponse<Boolean> existEnterpriseWhiteList(Integer enterpriseId);
/**
* 账户余额
* @Title: getEnterpriseBalance

* @Description:

* @author guojuxing
* @param enterpriseId

* @return com.gic.api.base.commons.ServiceResponse<java.lang.Double>


*/
ServiceResponse<Double> getEnterpriseBalance(Integer enterpriseId);
}
......@@ -107,6 +107,14 @@ public interface WmStoreApiService {
ServiceResponse<List<WmCouponPackageDTO>> getWmListByMemberCardAreaId(Integer enterpriseId, List<Long> memberCardAreaIdList);
/**
* 会员卡域ID和企业查询的微盟店铺信息
* @param enterpriseId
* @param memberCardAreaId
* @return
*/
ServiceResponse<List<WmStoreInfoDTO>> listWmByMemberCardAreaId(Integer enterpriseId, Long memberCardAreaId);
/**
* 根据微盟主账号查询配置
* @Title: getWmStoreConfig

* @Description:
......
......@@ -3,6 +3,8 @@ package com.gic.enterprise.dao.mapper;
import com.gic.enterprise.entity.TabBillingAccount;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface TabBillingAccountMapper {
/**
* 根据主键删除
......@@ -75,4 +77,6 @@ public interface TabBillingAccountMapper {
* @return int


 */
int updateByEnterpriseIdSelective(TabBillingAccount record);
List<TabBillingAccount> listBillingAccount(@Param("enterpriseIdList") List<Integer> enterpriseIdList);
}
\ No newline at end of file
package com.gic.enterprise.dao.mapper;
import com.gic.enterprise.entity.TabEnterpriseWhiteList;
import java.util.List;
public interface TabEnterpriseWhiteListMapper {
/**
* 根据主键删除
*
* @param whiteListId 主键
* @return 更新条目数
*/
int deleteByPrimaryKey(Integer whiteListId);
/**
* 插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int insert(TabEnterpriseWhiteList record);
/**
* 动态插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int insertSelective(TabEnterpriseWhiteList record);
/**
* 根据主键查询
*
* @param whiteListId 主键
* @return 实体对象
*/
TabEnterpriseWhiteList selectByPrimaryKey(Integer whiteListId);
/**
* 根据主键动态更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int updateByPrimaryKeySelective(TabEnterpriseWhiteList record);
/**
* 根据主键更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int updateByPrimaryKey(TabEnterpriseWhiteList record);
TabEnterpriseWhiteList getEnterpriseWhiteList(Integer enterpriseId);
List<TabEnterpriseWhiteList> listEnterpriseWhiteList(String search);
}
\ No newline at end of file
package com.gic.enterprise.entity;
import java.util.Date;
/**
* tab_enterprise_white_list
*/
public class TabEnterpriseWhiteList {
/**
*
*/
private Integer whiteListId;
/**
*
*/
private Integer enterpriseId;
/**
* 商户名称
*/
private String enterpriseName;
/**
* 公司名称
*/
private String companyName;
/**
* 1:有效 0:解除白名单
*/
private Integer status;
/**
*
*/
private Date createTime;
/**
*
*/
private Date updateTime;
public Integer getWhiteListId() {
return whiteListId;
}
public TabEnterpriseWhiteList setWhiteListId(Integer whiteListId) {
this.whiteListId = whiteListId;
return this;
}
public Integer getEnterpriseId() {
return enterpriseId;
}
public TabEnterpriseWhiteList setEnterpriseId(Integer enterpriseId) {
this.enterpriseId = enterpriseId;
return this;
}
public String getEnterpriseName() {
return enterpriseName;
}
public TabEnterpriseWhiteList setEnterpriseName(String enterpriseName) {
this.enterpriseName = enterpriseName;
return this;
}
public String getCompanyName() {
return companyName;
}
public TabEnterpriseWhiteList setCompanyName(String companyName) {
this.companyName = companyName;
return this;
}
public Integer getStatus() {
return status;
}
public TabEnterpriseWhiteList setStatus(Integer status) {
this.status = status;
return this;
}
public Date getCreateTime() {
return createTime;
}
public TabEnterpriseWhiteList setCreateTime(Date createTime) {
this.createTime = createTime;
return this;
}
public Date getUpdateTime() {
return updateTime;
}
public TabEnterpriseWhiteList setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
return this;
}
}
\ No newline at end of file
package com.gic.enterprise.service;
import com.gic.enterprise.entity.TabBillingAccount;
import java.util.List;
/**
* 计费中心账户
* @ClassName: BillingAccountService

......@@ -49,4 +52,6 @@ public interface BillingAccountService {
* @return int


 */
int createBillingAccount(Integer enterpriseId);
List<TabBillingAccount> listBillingAccount(List<Integer> enterpriseIdList);
}
package com.gic.enterprise.service;
import com.gic.enterprise.dto.EnterpriseWhiteListDTO;
import com.gic.enterprise.entity.TabEnterpriseWhiteList;
import com.github.pagehelper.Page;
public interface EnterpriseWhiteListService {
/**
* 新增商户白名单
* @Title: saveEnterpriseWhiteList

* @Description:

* @author guojuxing
* @param dto

* @return void


*/
void saveEnterpriseWhiteList(EnterpriseWhiteListDTO dto);
/**
* 解除白名单
* @Title: removeEnterpriseWhiteList

* @Description:

* @author guojuxing
* @param enterpriseId

* @return com.gic.api.base.commons.ServiceResponse<java.lang.Void>


*/
void removeEnterpriseWhiteList(Integer enterpriseId);
/**
* 分页查询白明答
* @param search 商户名称/公司名称
* @return
*/
Page<TabEnterpriseWhiteList> pageEnterpriseWhiteList(String search, Integer currentPage, Integer pageSize);
/**
* 是否在白名单内
* @param enterpriseId
* @return
*/
TabEnterpriseWhiteList getEnterpriseWhiteList(Integer enterpriseId);
}
......@@ -19,6 +19,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
@Service("billingAccountService")
public class BillingAccountServiceImpl implements BillingAccountService{
......@@ -94,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);
......@@ -104,4 +105,9 @@ public class BillingAccountServiceImpl implements BillingAccountService{
return tabBillingAccountMapper.insert(record);
}
@Override
public List<TabBillingAccount> listBillingAccount(List<Integer> enterpriseIdList) {
return tabBillingAccountMapper.listBillingAccount(enterpriseIdList);
}
}
package com.gic.enterprise.service.impl;
import com.gic.commons.util.EntityUtil;
import com.gic.enterprise.dao.mapper.TabEnterpriseWhiteListMapper;
import com.gic.enterprise.dto.EnterpriseWhiteListDTO;
import com.gic.enterprise.entity.TabEnterpriseWhiteList;
import com.gic.enterprise.service.EnterpriseWhiteListService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
@Service("enterpriseWhiteListService")
public class EnterpriseWhiteListServiceImpl implements EnterpriseWhiteListService{
@Autowired
private TabEnterpriseWhiteListMapper tabEnterpriseWhiteListMapper;
@Override
public void saveEnterpriseWhiteList(EnterpriseWhiteListDTO dto) {
Date now = new Date();
TabEnterpriseWhiteList record = EntityUtil.changeEntityNew(TabEnterpriseWhiteList.class, dto);
record.setUpdateTime(now);
record.setCreateTime(now);
record.setStatus(1);
tabEnterpriseWhiteListMapper.insert(record);
}
@Override
public void removeEnterpriseWhiteList(Integer enterpriseId) {
TabEnterpriseWhiteList record = tabEnterpriseWhiteListMapper.getEnterpriseWhiteList(enterpriseId);
record.setStatus(0);
tabEnterpriseWhiteListMapper.updateByPrimaryKeySelective(record);
}
@Override
public Page<TabEnterpriseWhiteList> pageEnterpriseWhiteList(String search, Integer currentPage, Integer pageSize) {
PageHelper.startPage(currentPage, pageSize);
return (Page<TabEnterpriseWhiteList>) tabEnterpriseWhiteListMapper.listEnterpriseWhiteList(search);
}
@Override
public TabEnterpriseWhiteList getEnterpriseWhiteList(Integer enterpriseId) {
return tabEnterpriseWhiteListMapper.getEnterpriseWhiteList(enterpriseId);
}
}
......@@ -55,6 +55,8 @@ public class BillingAccountApiServiceImpl implements BillingAccountApiService {
private Config config;
@Autowired
private SmsSendApiService smsSendApiService;
@Autowired
private EnterpriseWhiteListService enterpriseWhiteListService;
@Override
public ServiceResponse<BillingAccountDTO> getByEnterpriseId(Integer enterpriseId) {
......@@ -231,23 +233,33 @@ public class BillingAccountApiServiceImpl implements BillingAccountApiService {
@Override
public ServiceResponse<Integer> deductAccount(double totalFee, Integer enterpriseId) {
int i = billingAccountService.deductAccount(totalFee, enterpriseId);
LOGGER.info("扣费是否成功:{}", i > 0);
if (i > 0) {
TabBillingAccount account = this.billingAccountService.getByEnterpriseId(enterpriseId);
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>";
this.pushMessageApiService.pushMessage(enterpriseId, "系统消息", "商户欠费", content);
// 待办事项
sendTotoItem(enterpriseId);
RedisUtil.setCache("message:" + enterpriseId, 1, 1l, TimeUnit.DAYS);
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) {
Object cache = RedisUtil.getCache("message:" + enterpriseId);
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 ServiceResponse.failure(ErrorCode.OPERATION_FAILED.getCode(), "余额不足");
}
return ServiceResponse.success(i);
} else {
return EnterpriseServiceResponse.failure(ErrorCode.OPERATION_FAILED);
int i = billingAccountService.deductAccount(totalFee, enterpriseId);
return ServiceResponse.success(i);
}
}
......@@ -257,21 +269,28 @@ public class BillingAccountApiServiceImpl implements BillingAccountApiService {
List<EnterpriseDTO> enterpriseDTOList = enterpriseService.listEnterprise();
for (EnterpriseDTO enterpriseDTO : enterpriseDTOList) {
Integer enterpriseId = enterpriseDTO.getEnterpriseId();
TabBillingAccount account = this.billingAccountService.getByEnterpriseId(enterpriseId);
if (account.getAccountBalance() <= 0) {
String[] smsArr = new String[]{enterpriseDTO.getEnterpriseName(), String.valueOf(-account.getAccountBalance())};
ServiceResponse<UserDTO> userResult = userApiService.getUserByEnterpriseId(enterpriseId);
UserDTO userDTO = userResult.getResult();
ServiceResponse<Void> smsSendResult = smsSendApiService.sendPlatformSms("GICJFZX001",
enterpriseId, userDTO.getPhoneAreaCode(), userDTO.getPhoneNumber(), smsArr);
if (!smsSendResult.isSuccess()) {
LOGGER.warn(smsSendResult.getMessage());
if (isNotInWhiteList(enterpriseId)) {
TabBillingAccount account = this.billingAccountService.getByEnterpriseId(enterpriseId);
if (account.getAccountBalance() <= 500) {
String[] smsArr = new String[]{enterpriseDTO.getEnterpriseName(), String.valueOf(-account.getAccountBalance())};
ServiceResponse<UserDTO> userResult = userApiService.getUserByEnterpriseId(enterpriseId);
UserDTO userDTO = userResult.getResult();
ServiceResponse<Void> smsSendResult = smsSendApiService.sendPlatformSms("GICJFZX001",
enterpriseId, userDTO.getPhoneAreaCode(), userDTO.getPhoneNumber(), smsArr);
if (!smsSendResult.isSuccess()) {
LOGGER.warn(smsSendResult.getMessage());
}
}
}
}
return ServiceResponse.success();
}
private boolean isNotInWhiteList(Integer enterpriseId) {
// 判断商户在不在白名单中
return this.enterpriseWhiteListService.getEnterpriseWhiteList(enterpriseId) == null;
}
private void sendTotoItem(Integer enterpriseId) {
TodoItemDTO todoItemDTO = new TodoItemDTO();
UserDTO userDTO = userApiService.getUserByEnterpriseId(enterpriseId).getResult();
......
......@@ -169,6 +169,11 @@ public class EnterpriseInitApiServiceImpl implements EnterpriseInitApiService{
}
@Override
public ServiceResponse<Void> initMemberCardSmsTemplate(Integer enterpriseId) {
return initByConfigCode(EnterpriseInitCodeEnum.INTI_MEMBER_CARD_SMS.getCode(), enterpriseId);
}
@Override
public ServiceResponse<Void> unInitByConfigCode(String configCode, Integer enterpriseId) {
if (!EnterpriseInitCodeEnum.isRightCode(configCode)) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "初始化配置代码参数有误");
......
package com.gic.enterprise.service.outer.impl;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.PageHelperUtils;
import com.gic.enterprise.dto.EnterpriseWhiteListDTO;
import com.gic.enterprise.entity.TabBillingAccount;
import com.gic.enterprise.entity.TabEnterprise;
import com.gic.enterprise.entity.TabEnterpriseWhiteList;
import com.gic.enterprise.error.ErrorCode;
import com.gic.enterprise.service.BillingAccountService;
import com.gic.enterprise.service.EnterpriseService;
import com.gic.enterprise.service.EnterpriseWhiteListApiService;
import com.gic.enterprise.service.EnterpriseWhiteListService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service("enterpriseWhiteListApiService")
public class EnterpriseWhiteListApiServiceImpl implements EnterpriseWhiteListApiService{
@Autowired
private EnterpriseWhiteListService enterpriseWhiteListService;
@Autowired
private EnterpriseService enterpriseService;
@Autowired
private BillingAccountService billingAccountService;
@Override
public ServiceResponse<Void> saveEnterpriseWhiteList(Integer enterpriseId) {
TabEnterpriseWhiteList record = enterpriseWhiteListService.getEnterpriseWhiteList(enterpriseId);
if (record != null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "重复配置");
}
TabEnterprise enterprise = enterpriseService.getEnterpriseById(enterpriseId);
enterpriseWhiteListService.saveEnterpriseWhiteList(new EnterpriseWhiteListDTO()
.setCompanyName(enterprise.getCompanyName())
.setEnterpriseName(enterprise.getEnterpriseName())
.setEnterpriseId(enterpriseId));
return ServiceResponse.success();
}
@Override
public ServiceResponse<Void> removeEnterpriseWhiteList(Integer enterpriseId) {
TabEnterpriseWhiteList record = enterpriseWhiteListService.getEnterpriseWhiteList(enterpriseId);
if (record == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "未配置");
}
enterpriseWhiteListService.removeEnterpriseWhiteList(enterpriseId);
return ServiceResponse.success();
}
@Override
public ServiceResponse<Page<EnterpriseWhiteListDTO>> pageEnterpriseWhiteList(String search, Integer currentPage, Integer pageSize) {
com.github.pagehelper.Page<TabEnterpriseWhiteList> page = enterpriseWhiteListService
.pageEnterpriseWhiteList(search, currentPage, pageSize);
Page<EnterpriseWhiteListDTO> resultPage = PageHelperUtils.changePageHelperToCurrentPage(page, EnterpriseWhiteListDTO.class);
if (resultPage != null) {
List<EnterpriseWhiteListDTO> list = resultPage.getResult();
if (CollectionUtils.isNotEmpty(list)) {
List<Integer> enterpriseIdList = list.stream().map(e -> e.getEnterpriseId()).collect(Collectors.toList());
List<TabBillingAccount> accountList = billingAccountService.listBillingAccount(enterpriseIdList);
Map<String, Double> accountMap = accountList
.stream()
.collect(Collectors.toMap(e -> e.getEnterpriseId().toString(), e -> e.getAccountBalance()));
List<TabEnterprise> enterpriseList = enterpriseService.listEnterpriseByIds(enterpriseIdList);
Map<String, Date> enterpriseMap = enterpriseList
.stream()
.collect(Collectors.toMap(e -> e.getEnterpriseId().toString(), e -> e.getAuditTime()));
list.forEach(e -> {
e.setAccountBalance(accountMap.get(e.getEnterpriseId().toString()));
e.setAuditTime(enterpriseMap.get(e.getEnterpriseId().toString()));
});
}
}
return ServiceResponse.success(resultPage);
}
@Override
public ServiceResponse<Boolean> existEnterpriseWhiteList(Integer enterpriseId) {
TabEnterpriseWhiteList record = enterpriseWhiteListService.getEnterpriseWhiteList(enterpriseId);
if (record == null) {
return ServiceResponse.success(false);
}
return ServiceResponse.success(true);
}
@Override
public ServiceResponse<Double> getEnterpriseBalance(Integer enterpriseId) {
TabBillingAccount obj = billingAccountService.getByEnterpriseId(enterpriseId);
if (obj != null) {
return ServiceResponse.success(obj.getAccountBalance());
}
return ServiceResponse.success(0D);
}
}
......@@ -61,6 +61,8 @@ public class SmsRecordApiServiceImpl implements SmsRecordApiService {
private UserOwnerApiService userOwnerApiService;
@Autowired
private InternationalSmsRecordApiService internationalSmsRecordApiService;
@Autowired
private EnterpriseWhiteListService enterpriseWhiteListService;
@Override
public ServiceResponse<Void> verifySendSms(Integer enterpriseId, Integer sendCount, String nationCode) {
......@@ -90,7 +92,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 +275,8 @@ public class SmsRecordApiServiceImpl implements SmsRecordApiService {
}
}
}
private boolean isNotInWhiteList(Integer enterpriseId) {
return this.enterpriseWhiteListService.getEnterpriseWhiteList(enterpriseId) == null;
}
}
\ No newline at end of file
......@@ -177,6 +177,28 @@ public class WmStoreApiServiceImpl implements WmStoreApiService {
return ServiceResponse.success(Collections.emptyList());
}
@Override
public ServiceResponse<List<WmStoreInfoDTO>> listWmByMemberCardAreaId(Integer enterpriseId, Long memberCardAreaId) {
if (memberCardAreaId == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "会员卡域ID为空");
}
List<TabWmStore> list = wmStoreService.getHasAuth(enterpriseId);
if (CollectionUtils.isNotEmpty(list)) {
return ServiceResponse.success(list
.stream()
.filter(e -> {
//
if (memberCardAreaId.toString().contains(getMemberCardArea(e.getWmMallStoreId()))) {
return true;
}
return false;
})
.map(e -> EntityUtil.changeEntityNew(WmStoreInfoDTO.class, e))
.collect(Collectors.toList()));
}
return ServiceResponse.success(Collections.emptyList());
}
private String getMemberCardArea(Integer wmMallStoreId) {
ServiceResponse<Long> result = weimobMerchantService.getMcuAreaId(wmMallStoreId);
if (result.isSuccess()) {
......
......@@ -129,6 +129,7 @@
<dubbo:service interface="com.gic.enterprise.service.DataConfigApiService" ref="dataConfigApiService" timeout="6000" />
<dubbo:service interface="com.gic.enterprise.service.AppletQrcodeApiService" ref="appletQrcodeApiService" timeout="6000" />
<dubbo:service interface="com.gic.enterprise.service.WmStoreSyncLogApiService" ref="wmStoreSyncLogApiService" timeout="6000" />
<dubbo:service interface="com.gic.enterprise.service.EnterpriseWhiteListApiService" ref="enterpriseWhiteListApiService" timeout="6000" />
<dubbo:reference interface="com.gic.mall.share.api.service.ShopApiService" id="shopApiService" timeout="6000" />
......
......@@ -148,4 +148,16 @@
</set>
where enterprise_id = #{enterpriseId,jdbcType=INTEGER}
</update>
<select id="listBillingAccount" resultMap="BaseResultMap">
select <include refid="Base_Column_List"></include>
from tab_billing_account
<if test="enterpriseIdList != null and enterpriseIdList.size() &gt; 0">
where enterprise_id in
<foreach close=")" collection="enterpriseIdList" index="index" item="enterpriseId" open="(" separator=",">
#{enterpriseId}
</foreach>
</if>
</select>
</mapper>
\ No newline at end of file
......@@ -283,7 +283,7 @@
a.company_name companyName,
a.create_time createTime,
a.is_init_complete isInitComplete,
GROUP_CONCAT(b.upper_limit separator '-') licenseUpperLimitStr,
GROUP_CONCAT(b.upper_limit ORDER BY b.enterprise_license_id separator '-') licenseUpperLimitStr,
a.version_code versionCode,
a.version_name versionName,
a.audit_time expirationTime,
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gic.enterprise.dao.mapper.TabEnterpriseWhiteListMapper">
<resultMap id="BaseResultMap" type="com.gic.enterprise.entity.TabEnterpriseWhiteList">
<id column="white_list_id" jdbcType="INTEGER" property="whiteListId" />
<result column="enterprise_id" jdbcType="INTEGER" property="enterpriseId" />
<result column="enterprise_name" jdbcType="VARCHAR" property="enterpriseName" />
<result column="company_name" jdbcType="VARCHAR" property="companyName" />
<result column="status" jdbcType="INTEGER" property="status" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<sql id="Base_Column_List">
white_list_id, enterprise_id, enterprise_name, company_name, status, create_time,
update_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_enterprise_white_list
where white_list_id = #{whiteListId,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from tab_enterprise_white_list
where white_list_id = #{whiteListId,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.gic.enterprise.entity.TabEnterpriseWhiteList">
insert into tab_enterprise_white_list (white_list_id, enterprise_id, enterprise_name,
company_name, status, create_time,
update_time)
values (#{whiteListId,jdbcType=INTEGER}, #{enterpriseId,jdbcType=INTEGER}, #{enterpriseName,jdbcType=VARCHAR},
#{companyName,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.gic.enterprise.entity.TabEnterpriseWhiteList">
insert into tab_enterprise_white_list
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="whiteListId != null">
white_list_id,
</if>
<if test="enterpriseId != null">
enterprise_id,
</if>
<if test="enterpriseName != null">
enterprise_name,
</if>
<if test="companyName != null">
company_name,
</if>
<if test="status != null">
status,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="whiteListId != null">
#{whiteListId,jdbcType=INTEGER},
</if>
<if test="enterpriseId != null">
#{enterpriseId,jdbcType=INTEGER},
</if>
<if test="enterpriseName != null">
#{enterpriseName,jdbcType=VARCHAR},
</if>
<if test="companyName != null">
#{companyName,jdbcType=VARCHAR},
</if>
<if test="status != null">
#{status,jdbcType=INTEGER},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.gic.enterprise.entity.TabEnterpriseWhiteList">
update tab_enterprise_white_list
<set>
<if test="enterpriseId != null">
enterprise_id = #{enterpriseId,jdbcType=INTEGER},
</if>
<if test="enterpriseName != null">
enterprise_name = #{enterpriseName,jdbcType=VARCHAR},
</if>
<if test="companyName != null">
company_name = #{companyName,jdbcType=VARCHAR},
</if>
<if test="status != null">
status = #{status,jdbcType=INTEGER},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where white_list_id = #{whiteListId,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.gic.enterprise.entity.TabEnterpriseWhiteList">
update tab_enterprise_white_list
set enterprise_id = #{enterpriseId,jdbcType=INTEGER},
enterprise_name = #{enterpriseName,jdbcType=VARCHAR},
company_name = #{companyName,jdbcType=VARCHAR},
status = #{status,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where white_list_id = #{whiteListId,jdbcType=INTEGER}
</update>
<select id="getEnterpriseWhiteList" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List"></include>
from tab_enterprise_white_list
where enterprise_id = #{enterpriseId}
and status = 1
</select>
<select id="listEnterpriseWhiteList" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List"></include>
from tab_enterprise_white_list
where status = 1
<if test="search != null and search != ''">
and (enterprise_name like concat('%', #{search}, '%') or company_name like concat('%', #{search}, '%'))
</if>
</select>
</mapper>
\ No newline at end of file
......@@ -25,7 +25,8 @@ import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.*;
import org.redisson.api.RMap;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -633,19 +634,19 @@ public class WmStoreSyncController {
LOGGER.info("实体门店批量到微盟结果:{}", JSON.toJSONString(weimobResult));
if (!weimobResult.isSuccess()) {
HashMap<String, String> map = JSON.parseObject(weimobResult.getMessage(), HashMap.class);
HashMap<Integer, String> map = JSON.parseObject(weimobResult.getMessage(), HashMap.class);
StringBuilder errorIds = new StringBuilder();
Map<String, String> errorMessage = new HashMap<>(16);
for (Map.Entry<String, String> entry : map.entrySet()) {
for (Map.Entry<Integer, String> entry : map.entrySet()) {
errorIds.append(entry.getKey()).append(GlobalInfo.FLAG_COMMA);
errorMessage.put(entry.getKey(), entry.getValue());
errorMessage.put(entry.getKey().toString(), entry.getValue());
}
//因为是一条一条处理,所以失败了,就不会有成功的,不用 导购同步逻辑
List<StoreDTO> hasSuccessStoreList = getStoreList(errorIds.toString(), enterpriseId);
hasSuccessStoreList.forEach(e -> rMap.put(e.getRegionId() + "-" + e.getStoreCode(),
errorMessage.get(storeDTO.getStoreInfoId())));
errorMessage.get(storeDTO.getStoreInfoId().toString())));
} else {
rMap.put(regionName + "-" + storeCode, "成功");
//同步过的记录日志,不能再次同步
......@@ -951,7 +952,7 @@ public class WmStoreSyncController {
writer.newLine();
for (Map.Entry<String, String> entry : rMap.entrySet()) {
//防止0被忽略
writer.append("'").append(entry.getKey()).append(",");
writer.append(entry.getKey()).append(",");
writer.append(entry.getValue()).append(",");
writer.newLine();
......@@ -994,13 +995,16 @@ public class WmStoreSyncController {
public static List<Map<Integer, String>> readXlsOfBranch(InputStream in, int row) {
List<Map<Integer, String>> result = new ArrayList<Map<Integer, String>>();
try {
HSSFWorkbook hssfWorkbook = new HSSFWorkbook(in);
Workbook workbook = WorkbookFactory.create(in);
// HSSFWorkbook hssfWorkbook = new HSSFWorkbook(in);
for (int numSheet = 0; numSheet < 1; numSheet++) {
HSSFSheet hssfSheet = hssfWorkbook.getSheetAt(numSheet);
Sheet sheet = workbook.getSheetAt(numSheet);
// HSSFSheet hssfSheet = hssfWorkbook.getSheetAt(numSheet);
//getPhysicalNumberOfRows:实际有数据的行数,去掉空行
for (int rowNum = row - 1, rowLength = hssfSheet.getPhysicalNumberOfRows(); rowNum <= rowLength; rowNum++) {
HSSFRow hssfRow = hssfSheet.getRow(rowNum);
for (int rowNum = row - 1, rowLength = sheet.getPhysicalNumberOfRows(); rowNum <= rowLength; rowNum++) {
Row hssfRow = sheet.getRow(rowNum);
// HSSFRow hssfRow = hssfSheet.getRow(rowNum);
if (hssfRow == null) {
continue;
}
......@@ -1010,7 +1014,8 @@ public class WmStoreSyncController {
Map<Integer, String> map = new HashMap<Integer, String>();
for (int colix = minColix; colix < maxColix; colix++) {
HSSFCell hssfCell = hssfRow.getCell(colix);
Cell hssfCell = hssfRow.getCell(colix);
// HSSFCell hssfCell = hssfRow.getCell(colix);
if (hssfCell == null) {
map.put(colix, "");
} else {
......@@ -1025,6 +1030,8 @@ public class WmStoreSyncController {
}
} catch (IOException e) {
e.printStackTrace();
} catch (InvalidFormatException e) {
e.printStackTrace();
}
return result;
}
......
......@@ -193,6 +193,11 @@
<artifactId>gic-authcenter-api</artifactId>
<version>${gic-authcenter-api}</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-member-config-api</artifactId>
<version>${gic-member-config-api}</version>
</dependency>
</dependencies>
<dependencyManagement>
......
......@@ -6,6 +6,8 @@ import java.util.*;
import com.gic.authcenter.security.core.constant.DataResourceEnum;
import com.gic.authcenter.security.core.dto.AuthcenterUserDetails;
import com.gic.enterprise.constants.Constants;
import com.gic.member.config.api.service.MemberCardApiService;
import com.gic.operation.web.vo.MemberCardVO;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
......@@ -103,6 +105,8 @@ public class EnterpriseController {
private MarketUserApiService marketUserApiService;
@Autowired
private MarketAppCategoryApiService marketAppCategoryApiService;
@Autowired
private MemberCardApiService memberCardApiService;
@RequestMapping("/save-enterprise")
public RestResponse saveEnterprise(
......@@ -237,6 +241,29 @@ public class EnterpriseController {
return RestResponse.success(changeListToTree(0, dtoList));
}
@RequestMapping("/list-all-member-card")
public RestResponse listAllMemberCard(Integer enterpriseId) {
return ResultControllerUtils.commonResult(memberCardApiService.getAll(enterpriseId), MemberCardVO.class);
}
/**
* 初始化会员卡的短信模板
* @Title: initMemberCardSmsTemplate

* @Description:

* @author guojuxing
* @param enterpriseId

* @return com.gic.commons.webapi.reponse.RestResponse


*/
@RequestMapping("/init-member-card-sms-template")
public RestResponse initMemberCardSmsTemplate(Integer enterpriseId) {
//todo
return RestResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "初始化会员模板还未开发完毕");
// ServiceResponse<Void> initMemberCardSmsTemplateResult = enterpriseInitApiService
// .initMemberCardSmsTemplate(enterpriseId);
// return ResultControllerUtils.commonResult(initMemberCardSmsTemplateResult);
}
@RequestMapping("/edit-enterprise")
public RestResponse editEnterprise(EnterpriseDTO enterpriseDTO) {
return ResultControllerUtils.commonResult(enterpriseApiService.editEnterprise(enterpriseDTO));
......
......@@ -9,6 +9,8 @@ import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.ConfigService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -37,6 +39,8 @@ import com.gic.open.api.service.market.MarketUserApiService;
@RestController
public class LoginController {
private static final Logger LOGGER = LogManager.getLogger(LoginController.class);
@Autowired
private OperationUserApiService operationUserApiService;
@Autowired
......@@ -93,6 +97,8 @@ public class LoginController {
@RequestMapping("login-gic")
public RestResponse login(Integer enterpriseId, String redirectUrl) throws IOException {
long startTime = System.currentTimeMillis();
Config config = ConfigService.getConfig("COMMON.4.0-gic-properties");
String url = config.getProperty("service_host", "").replace("/gic", "");
if (StringUtils.isBlank(redirectUrl)) {
......@@ -155,7 +161,7 @@ public class LoginController {
}
//查询全部的操作模块
Map<String, MenuInfo> moduleMap = new HashMap<>(16);
ServiceResponse<List<MenuDTO>> allGicMenu = menuApiService.getSuperAdminMenuNotTree(enterpriseId);
ServiceResponse<List<MenuDTO>> allGicMenu = menuApiService.getAllMenuNotTree(enterpriseDTO.getVersionCode());
if (allGicMenu.isSuccess()) {
List<MenuDTO> temp = allGicMenu.getResult();
List<MenuInfo> tempMenuInfoList = EntityUtil.changeEntityListNew(MenuInfo.class, temp);
......@@ -177,6 +183,8 @@ public class LoginController {
//塞缓存
token = UserDetailUtils.setUserDetail(userDetail);
LOGGER.info("单点登录所花时间:{}", System.currentTimeMillis() - startTime);
String SSO_LOGIN_URL = url + "/gic-auth-web/login-for-operation";
return RestResponse.success(SSO_LOGIN_URL + "?token=" + token + "&redirectUrl=" + redirectUrl);
}
......
package com.gic.operation.web.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.io.Serializable;
public class MemberCardVO implements Serializable{
private static final long serialVersionUID = 1276175656828771005L;
@JsonFormat(shape = JsonFormat.Shape.STRING)
private Long id;
/**
* 会员卡基本信息表主键
*/
@JsonFormat(shape = JsonFormat.Shape.STRING)
private Long cardConfigId;
private Integer ownerId;
private String cardCode;
private String cardName;
/**
* 1-自有,2-共享
*/
private Byte type;
private int gradeCount;
public Long getId() {
return id;
}
public MemberCardVO setId(Long id) {
this.id = id;
return this;
}
public Long getCardConfigId() {
return cardConfigId;
}
public MemberCardVO setCardConfigId(Long cardConfigId) {
this.cardConfigId = cardConfigId;
return this;
}
public Integer getOwnerId() {
return ownerId;
}
public MemberCardVO setOwnerId(Integer ownerId) {
this.ownerId = ownerId;
return this;
}
public String getCardCode() {
return cardCode;
}
public MemberCardVO setCardCode(String cardCode) {
this.cardCode = cardCode;
return this;
}
public String getCardName() {
return cardName;
}
public MemberCardVO setCardName(String cardName) {
this.cardName = cardName;
return this;
}
public Byte getType() {
return type;
}
public MemberCardVO setType(Byte type) {
this.type = type;
return this;
}
public int getGradeCount() {
return gradeCount;
}
public MemberCardVO setGradeCount(int gradeCount) {
this.gradeCount = gradeCount;
return this;
}
}
......@@ -91,4 +91,5 @@
<dubbo:reference interface="com.gic.mall.share.api.service.PayConfigApiService" id="payConfigApiService" timeout="6000"/>
<dubbo:reference interface="com.gic.authcenter.api.service.GicDepartmentService" id="gicDepartmentService" timeout="6000" />
<dubbo:reference interface="com.gic.member.config.api.service.MemberCardApiService" id="memberCardApiService" timeout="6000" />
</beans>
\ 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