Commit 2245de3d by guojuxing

商户初始化

parent f1cf63a0
......@@ -12,7 +12,10 @@ public enum EnterpriseInitCodeEnum {
PerfectMenuConfig("perfectMenuConfig", "完善自定义菜单配置"),
BingWeChat("bingWeChat", "至少绑定一个小程序"),
PerfectWeChatPage("perfectWeChatPage", "完善小程序页面装修"),
ShortMessageServiceConfig("shortMessageServiceConfig", "完成短信业务配置");
ShortMessageServiceConfig("shortMessageServiceConfig", "完成短信业务配置"),
CompleteMemberCardConfig("completeMemberCardConfig", "完成会员卡配置"),
CompleteServiceNumberConfig("completeServiceNumberConfig", "完成服务号配置"),
CompleteWeChatConfig("completeWeChatConfig", "完成小程序配置");
private String code;
private String message;
......@@ -40,10 +43,23 @@ public enum EnterpriseInitCodeEnum {
public static boolean isRightCode(String code) {
for (EnterpriseInitCodeEnum codeEnum : values()) {
if (codeEnum.getCode().equals(code)) {
if (isNotInclude(code) && codeEnum.getCode().equals(code)) {
return true;
}
}
return false;
}
private static boolean isNotInclude(String code) {
if (EnterpriseInitCodeEnum.CompleteMemberCardConfig.getMessage().equals(code)) {
return false;
}
if (EnterpriseInitCodeEnum.CompleteServiceNumberConfig.getMessage().equals(code)) {
return false;
}
if (EnterpriseInitCodeEnum.CompleteWeChatConfig.getMessage().equals(code)) {
return false;
}
return true;
}
}
......@@ -61,4 +61,11 @@ public interface TabEnterpriseInitMapper {
List<TabEnterpriseInit> listByParentId(@Param("parentId") Integer parentId, @Param("enterpriseId") Integer enterpriseId);
int initEnterpriseConfigInfo(@Param("enterpriseId") Integer enterpriseId);
int updateParentIdBatch(@Param("enterpriseId") Integer enterpriseId,
@Param("parentConfigCode") String parentConfigCode,
@Param("configCodeList") List<String> configCodeList);
int deleteByEnterpriseId(Integer enterpriseId);
}
\ No newline at end of file
package com.gic.enterprise.service.impl;
import com.gic.enterprise.constant.EnterpriseInitCodeEnum;
import com.gic.enterprise.dao.mapper.TabEnterpriseInitMapper;
import com.gic.enterprise.entity.TabEnterpriseInit;
import com.gic.enterprise.service.EnterpriseInitService;
......@@ -52,11 +53,29 @@ public class EnterpriseInitServiceImpl implements EnterpriseInitService{
@Override
@Transactional(rollbackFor = Exception.class)
public void initEnterpriseConfigInfo(Integer enterpriseId) {
tabEnterpriseInitMapper.deleteByEnterpriseId(enterpriseId);
//
tabEnterpriseInitMapper.initEnterpriseConfigInfo(enterpriseId);
List<String> memberCardConfigList = new ArrayList<>(4);
memberCardConfigList.add(EnterpriseInitCodeEnum.CreateMemberCard.getCode());
memberCardConfigList.add(EnterpriseInitCodeEnum.CreateMemberGrade.getCode());
tabEnterpriseInitMapper.updateParentIdBatch(enterpriseId, EnterpriseInitCodeEnum.CompleteMemberCardConfig.getCode(), memberCardConfigList);
List<String> serviceNumberList = new ArrayList<>(4);
serviceNumberList.add(EnterpriseInitCodeEnum.BindServiceNumber.getCode());
serviceNumberList.add(EnterpriseInitCodeEnum.PerfectAutoReplyConfig.getCode());
serviceNumberList.add(EnterpriseInitCodeEnum.PerfectMenuConfig.getCode());
tabEnterpriseInitMapper.updateParentIdBatch(enterpriseId, EnterpriseInitCodeEnum.CompleteServiceNumberConfig.getCode(), memberCardConfigList);
List<String> weChatPageList = new ArrayList<>(4);
weChatPageList.add(EnterpriseInitCodeEnum.PerfectWeChatPage.getCode());
tabEnterpriseInitMapper.updateParentIdBatch(enterpriseId, EnterpriseInitCodeEnum.CompleteWeChatConfig.getCode(), memberCardConfigList);
}
@Override
public TabEnterpriseInit getById(Integer initId) {
return tabEnterpriseInitMapper.selectByPrimaryKey(initId);
}
}
......@@ -233,8 +233,8 @@
t2.parent_id,
#{enterpriseId},
t2.sort,
t2.create_time,
t2.update_time,
now(),
now(),
t2.config_code,
t2. LEVEL,
t2.is_init_config
......@@ -243,4 +243,29 @@
WHERE
t2.enterprise_id = - 1
</insert>
<update id="updateParentIdBatch">
UPDATE tab_enterprise_init a
SET a.parent_id = (
SELECT
b.enterprise_init_id
FROM
tab_enterprise_init b
WHERE
b.enterprise_id = #{enterpriseId}
AND b.config_code = #{parentConfigCode}
)
WHERE
a.enterprise_id = #{enterpriseId}
AND a.config_code in
<foreach collection="configCodeList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</update>
<delete id="deleteByEnterpriseId" parameterType="java.lang.Integer">
delete from tab_enterprise_init
where enterprise_id = #{enterpriseId,jdbcType=INTEGER}
</delete>
</mapper>
\ No newline at end of file
......@@ -16,6 +16,7 @@ import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
public class EnterpriseApiServiceImplTest extends AbstractJUnit4SpringContextTests{
@Autowired
private EnterpriseApiService enterpriseApiService;
@Test
public void saveEnterprise() throws Exception {
EnterpriseDTO dto = new EnterpriseDTO();
......
......@@ -168,7 +168,7 @@ public class EnterpriseController {
data.put("isInitConfig", t.getIsInitConfig());
data.put("level", t.getLevel());
data.put("configUrl", t.getConfigUrl());
List<Map<String, Object>> children = changeListToTree(t.getParentId(), list);
List<Map<String, Object>> children = changeListToTree(t.getEnterpriseInitId(), list);
data.put("children", children);
result.add(data);
}
......
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