Commit ac55e52b by guojuxing

白名单

parent f247eaf0
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.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);
}
......@@ -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{
......@@ -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);
}
}
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("enterpriseWhiteListApiServicevice")
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);
}
}
......@@ -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
<?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
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