Commit 54d0facd by guojuxing

实付配置调整

parent b506bcb9
......@@ -34,6 +34,11 @@ public class DataActuallyPaidConfigDTO implements Serializable{
private Integer configStatus;
/**
* 1:已经配置过 0:未配置过
*/
private Integer hasConfig;
/**
* 1:有效
*/
private Integer status;
......@@ -114,4 +119,13 @@ public class DataActuallyPaidConfigDTO implements Serializable{
this.updateTime = updateTime;
return this;
}
public Integer getHasConfig() {
return hasConfig;
}
public DataActuallyPaidConfigDTO setHasConfig(Integer hasConfig) {
this.hasConfig = hasConfig;
return this;
}
}
......@@ -86,20 +86,6 @@ public interface DataConfigApiService {
ServiceResponse<Void> configActuallyPaid(Integer enterpriseId, Integer memberBusiness, Integer performanceCount, Integer memberBusinessOfGoods);
/**
* 是否已经配置过会员业务(实付)
* @param enterpriseId
* @return
*/
ServiceResponse<Boolean> hasConfigMemberBusiness(Integer enterpriseId);
/**
* 是否已经配置过业绩统计(实付)
* @param enterpriseId
* @return
*/
ServiceResponse<Boolean> hasConfigPerformanceCount(Integer enterpriseId);
/**
* 实付配置信息
* @Title: listActuallyPaidConfig

* @Description:
......
......@@ -58,5 +58,5 @@ public interface TabDataActuallyPaidConfigMapper {
int delete(@Param("enterpriseId") Integer enterpriseId, @Param("classify") Integer classify);
int count(@Param("enterpriseId") Integer enterpriseId, @Param("classify") Integer classify);
TabDataActuallyPaidConfig get(@Param("enterpriseId") Integer enterpriseId, @Param("classify") Integer classify);
}
\ No newline at end of file
......@@ -27,6 +27,11 @@ public class TabDataActuallyPaidConfig {
private Integer configStatus;
/**
* 1:已经配置过 0:未配置过
*/
private Integer hasConfig;
/**
* 1:有效
*/
private Integer status;
......@@ -103,4 +108,13 @@ public class TabDataActuallyPaidConfig {
this.updateTime = updateTime;
return this;
}
public Integer getHasConfig() {
return hasConfig;
}
public TabDataActuallyPaidConfig setHasConfig(Integer hasConfig) {
this.hasConfig = hasConfig;
return this;
}
}
\ No newline at end of file
......@@ -17,6 +17,8 @@ public interface DataActuallyPaidConfigService {

*/
Integer saveActuallyPaidConfig(DataActuallyPaidConfigDTO dto);
Integer saveActuallyPaidConfig(TabDataActuallyPaidConfig dto);
/**
* @Title: listByEnterpriseId

* @Description:
......@@ -38,10 +40,10 @@ public interface DataActuallyPaidConfigService {
int delete(Integer enterpriseId, Integer classify);
/**
* 查询无效的记录,用于判断是否修改过配置,如果修改过,不允许再次edit
*
* @param enterpriseId
* @param classify
* @return
*/
int count(Integer enterpriseId, Integer classify);
TabDataActuallyPaidConfig get(Integer enterpriseId, Integer classify);
}
......@@ -10,6 +10,7 @@ import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@Service("dataActuallyPaidConfigService")
public class DataActuallyPaidConfigServiceImpl implements DataActuallyPaidConfigService{
......@@ -28,6 +29,16 @@ public class DataActuallyPaidConfigServiceImpl implements DataActuallyPaidConfig
}
@Override
public Integer saveActuallyPaidConfig(TabDataActuallyPaidConfig dto) {
Date now = new Date();
dto.setCreateTime(now);
dto.setUpdateTime(now);
dto.setStatus(1);
tabDataActuallyPaidConfigMapper.insert(dto);
return dto.getActuallyPaidConfigId();
}
@Override
public List<TabDataActuallyPaidConfig> listByEnterpriseId(Integer enterpriseId) {
return tabDataActuallyPaidConfigMapper.listByEnterpriseId(enterpriseId);
}
......@@ -38,7 +49,7 @@ public class DataActuallyPaidConfigServiceImpl implements DataActuallyPaidConfig
}
@Override
public int count(Integer enterpriseId, Integer classify) {
return tabDataActuallyPaidConfigMapper.count(enterpriseId, classify);
public TabDataActuallyPaidConfig get(Integer enterpriseId, Integer classify) {
return tabDataActuallyPaidConfigMapper.get(enterpriseId, classify);
}
}
......@@ -124,8 +124,16 @@ public class DataConfigApiServiceImpl implements DataConfigApiService {
if (dto.getClassify() == null) {
dto.setClassify(1);
}
if (dataActuallyPaidConfigService.count(dto.getEnterpriseId(), dto.getClassify()) > 0) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "已经配置过,不允许再次配置");
TabDataActuallyPaidConfig temp = dataActuallyPaidConfigService.get(dto.getEnterpriseId(), dto.getClassify());
if (temp != null && temp.getHasConfig() == 1) {
//return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "已经配置过,不允许再次配置");
continue;
}
if (temp == null) {
//如果是第一次生成,则
dto.setHasConfig(0);
} else {
dto.setHasConfig(1);
}
dataActuallyPaidConfigService.delete(dto.getEnterpriseId(), dto.getClassify());
dto.setConfigStatus(Optional.ofNullable(dto.getConfigStatus()).orElse(0));
......@@ -176,16 +184,6 @@ public class DataConfigApiServiceImpl implements DataConfigApiService {
}
@Override
public ServiceResponse<Boolean> hasConfigMemberBusiness(Integer enterpriseId) {
return ServiceResponse.success(dataActuallyPaidConfigService.count(enterpriseId, 1) > 0);
}
@Override
public ServiceResponse<Boolean> hasConfigPerformanceCount(Integer enterpriseId) {
return ServiceResponse.success(dataActuallyPaidConfigService.count(enterpriseId, 3) > 0);
}
@Override
public ServiceResponse<List<DataActuallyPaidConfigDTO>> listActuallyPaidConfig(Integer enterpriseId) {
List<TabDataActuallyPaidConfig> list = dataActuallyPaidConfigService.listByEnterpriseId(enterpriseId);
if (CollectionUtils.isEmpty(list)) {
......@@ -200,18 +198,18 @@ public class DataConfigApiServiceImpl implements DataConfigApiService {
public ServiceResponse<DataActuallyPaidConfig> getDataActuallyPaidConfig(Integer enterpriseId) {
List<TabDataActuallyPaidConfig> list = dataActuallyPaidConfigService.listByEnterpriseId(enterpriseId);
if (CollectionUtils.isNotEmpty(list)) {
Map<String, Integer> map = list.stream().collect(Collectors.toMap(e -> e.getClassify().toString(), e -> e.getConfigStatus()));
Map<String, TabDataActuallyPaidConfig> map = list.stream().collect(Collectors.toMap(e -> e.getClassify().toString(), e -> e));
//如果没有配置,默认数据
Integer memberBusiness = map.get("1");
Integer performanceCount = map.get("3");
Integer memberBusinessOfGoods = map.get("6");
Integer memberBusiness = map.get("1").getConfigStatus();
Integer performanceCount = map.get("3").getConfigStatus();
Integer memberBusinessOfGoods = map.get("6").getConfigStatus();
return ServiceResponse.success(new DataActuallyPaidConfig()
.setEnterpriseId(enterpriseId)
.setMemberBusiness(memberBusiness)
.setPerformanceCount(performanceCount)
.setHasConfigMemberBusiness(dataActuallyPaidConfigService.count(enterpriseId, 1) > 0)
.setHasConfigPerformanceCount(dataActuallyPaidConfigService.count(enterpriseId, 3) > 0)
.setHasConfigMemberBusinessOfGoods(dataActuallyPaidConfigService.count(enterpriseId, 6) > 0)
.setHasConfigMemberBusiness(map.get("1").getHasConfig() == 1)
.setHasConfigPerformanceCount(map.get("3").getHasConfig() == 1)
.setHasConfigMemberBusinessOfGoods(map.get("6").getHasConfig() == 1)
.setMemberBusinessOfGoods(memberBusinessOfGoods));
}
return ServiceResponse.success(new DataActuallyPaidConfig().setEnterpriseId(enterpriseId).setMemberBusiness(0).setPerformanceCount(0).setMemberBusinessOfGoods(0));
......
......@@ -6,12 +6,13 @@
<result column="enterprise_id" jdbcType="INTEGER" property="enterpriseId" />
<result column="classify" jdbcType="INTEGER" property="classify" />
<result column="config_status" jdbcType="INTEGER" property="configStatus" />
<result column="has_config" jdbcType="INTEGER" property="hasConfig" />
<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">
actually_paid_config_id, enterprise_id, classify, config_status, status, create_time,
actually_paid_config_id, enterprise_id, classify, config_status, has_config, status, create_time,
update_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
......@@ -26,10 +27,10 @@
</delete>
<insert id="insert" parameterType="com.gic.enterprise.entity.TabDataActuallyPaidConfig" useGeneratedKeys="true" keyProperty="actuallyPaidConfigId">
insert into tab_data_actually_paid_config (actually_paid_config_id, enterprise_id,
classify, config_status, status,
classify, config_status, has_config, status,
create_time, update_time)
values (#{actuallyPaidConfigId,jdbcType=INTEGER}, #{enterpriseId,jdbcType=INTEGER},
#{classify,jdbcType=INTEGER}, #{configStatus,jdbcType=INTEGER}, #{status,jdbcType=INTEGER},
#{classify,jdbcType=INTEGER}, #{configStatus,jdbcType=INTEGER}, #{hasConfig,jdbcType=INTEGER}, #{status,jdbcType=INTEGER},
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.gic.enterprise.entity.TabDataActuallyPaidConfig">
......@@ -47,6 +48,9 @@
<if test="configStatus != null">
config_status,
</if>
<if test="hasConfig != null">
has_config,
</if>
<if test="status != null">
status,
</if>
......@@ -70,6 +74,9 @@
<if test="configStatus != null">
#{configStatus,jdbcType=INTEGER},
</if>
<if test="hasConfig != null">
#{hasConfig,jdbcType=INTEGER},
</if>
<if test="status != null">
#{status,jdbcType=INTEGER},
</if>
......@@ -93,6 +100,9 @@
<if test="configStatus != null">
config_status = #{configStatus,jdbcType=INTEGER},
</if>
<if test="hasConfig != null">
has_config = #{hasConfig,jdbcType=INTEGER},
</if>
<if test="status != null">
status = #{status,jdbcType=INTEGER},
</if>
......@@ -110,6 +120,7 @@
set enterprise_id = #{enterpriseId,jdbcType=INTEGER},
classify = #{classify,jdbcType=INTEGER},
config_status = #{configStatus,jdbcType=INTEGER},
has_config = #{hasConfig,jdbcType=INTEGER},
status = #{status,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
......@@ -131,10 +142,10 @@
and status = 1
</update>
<select id="count" resultType="int">
select count(1) from tab_data_actually_paid_config
<select id="get" resultMap="BaseResultMap">
select <include refid="Base_Column_List"></include> from tab_data_actually_paid_config
where enterprise_id = #{enterpriseId}
and classify = #{classify}
and status = 0
and status = 1
</select>
</mapper>
\ No newline at end of file
......@@ -6,6 +6,8 @@ import java.util.Map;
import java.util.stream.Collectors;
import com.gic.enterprise.ano.IgnoreLogin;
import com.gic.enterprise.dto.EnterpriseDTO;
import com.gic.enterprise.service.EnterpriseApiService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.LogManager;
......@@ -54,6 +56,8 @@ public class DataConfigController {
private MemberCardApiService memberCardApiService;
@Autowired
private EnterpriseInitApiService enterpriseInitApiService;
@Autowired
private EnterpriseApiService enterpriseApiService;
@RequestMapping("list-all-applet")
......@@ -97,7 +101,16 @@ public class DataConfigController {
@IgnoreLogin
@RequestMapping("/init-actually-data-config")
public RestResponse initActuallyDataConfig(Integer enterpriseId) {
return ResultControllerUtils.commonResult(dataConfigApiService.initActuallyPaidData(enterpriseId));
if (enterpriseId == null) {
ServiceResponse<List<EnterpriseDTO>> result = enterpriseApiService.listEnterpriseByName(null);
if (result.isSuccess()) {
List<EnterpriseDTO> list = result.getResult();
if (CollectionUtils.isNotEmpty(list)) {
list.forEach(e -> dataConfigApiService.initActuallyPaidData(e.getEnterpriseId()));
}
}
}
return RestResponse.success();
}
@RequestMapping("config-wechat-member")
......
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