From 60c17b3fec421a6d40f81301bebc25cdab33ad4c Mon Sep 17 00:00:00 2001 From: lin <642018748@qq.com> Date: Sat, 25 Mar 2023 12:26:53 +0800 Subject: [PATCH 1/7] fix business --- .../controller/WxBusinessController.java | 2 +- .../com/iformall/domain/po/WxScoreRules.java | 43 ++++----- .../impl/WxCreditHistoryServiceImpl.java | 2 +- .../service/impl/WxScoreRulesServiceImpl.java | 91 ++++++++++--------- 4 files changed, 67 insertions(+), 71 deletions(-) diff --git a/mallinkCApi/src/main/java/com/iformall/controller/WxBusinessController.java b/mallinkCApi/src/main/java/com/iformall/controller/WxBusinessController.java index fb0534eef..93be7abf1 100644 --- a/mallinkCApi/src/main/java/com/iformall/controller/WxBusinessController.java +++ b/mallinkCApi/src/main/java/com/iformall/controller/WxBusinessController.java @@ -22,7 +22,7 @@ public class WxBusinessController extends BaseController { @Autowired private WxBusinessService wxBusinessService; - @RedisCache + @RedisCache(expireTime = 600) @ApiOperation("业态全列表接口") @GetMapping("listAll") public ResultData listAll(Integer filter) { diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxScoreRules.java b/mallinkService/src/main/java/com/iformall/domain/po/WxScoreRules.java index 5a4cf1795..e5b9c84e4 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxScoreRules.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxScoreRules.java @@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import com.iformall.domain.po.base.BaseTenantEntity; import com.iformall.enums.EnumScoreType; +import com.iformall.utils.Constant; + import lombok.Data; import lombok.EqualsAndHashCode; @@ -30,22 +32,19 @@ public class WxScoreRules extends BaseTenantEntity { @TableField(exist = false) public static final int DEFAULT_SCALE = 10; + @TableField(exist = false) + public static final int DEFAULT_LIMIT = 0; + @TableField(exist = false) + public static final int DEFAULT_STEP = 1; + @TableField(exist = false) + public static final int DEFAULT_SCORE = 0; + @TableField(exist = false) private static final String scoreDefaultRules = "[" + "{\"id\":1,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"每日登陆\"}," + "{\"id\":2,\"childs\":[" + - " {\"businessId\":1,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}," + - " {\"businessId\":2,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}," + - " {\"businessId\":3,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}," + - " {\"businessId\":4,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}," + - " {\"businessId\":5,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}," + - " {\"businessId\":7,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}," + - " {\"businessId\":8,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}," + - " {\"businessId\":9,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}," + - " {\"businessId\":10,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}," + - " {\"businessId\":11,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}," + - " {\"businessId\":6,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}" + + " {\"businessId\":"+Constant.default_business+",\"limit\":"+DEFAULT_LIMIT+",\"step\":"+DEFAULT_STEP+",\"score\":"+DEFAULT_SCORE+" ,\"desc\":\"线上交易1元\"}" + "]}," + "{\"id\":3,\"limit\":1,\"step\":1,\"score\":0,\"desc\":\"绑定车牌1个\"}," + "{\"id\":6,\"limit\":1,\"step\":1,\"score\":0,\"desc\":\"授权手机号\"}," + @@ -57,17 +56,7 @@ public class WxScoreRules extends BaseTenantEntity { "[" + // "{\"id\":1,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"每日登陆\"}," + "{\"id\":2,\"childs\":[" + - " {\"businessId\":1,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}," + - " {\"businessId\":2,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}," + - " {\"businessId\":3,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}," + - " {\"businessId\":4,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}," + - " {\"businessId\":5,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}," + - " {\"businessId\":7,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}," + - " {\"businessId\":8,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}," + - " {\"businessId\":9,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}," + - " {\"businessId\":10,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}," + - " {\"businessId\":11,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}," + - " {\"businessId\":6,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}" + + " {\"businessId\":"+Constant.default_business+",\"limit\":"+DEFAULT_LIMIT+",\"step\":"+DEFAULT_STEP+",\"score\":"+DEFAULT_SCORE+" ,\"desc\":\"线上交易1元\"}" + "]}," + "{\"id\":3,\"limit\":1,\"step\":1,\"score\":0,\"desc\":\"绑定车牌1个\"}," + "{\"id\":6,\"limit\":1,\"step\":1,\"score\":0,\"desc\":\"授权手机号\"}," + @@ -148,11 +137,11 @@ public class WxScoreRules extends BaseTenantEntity { return null; } - public JSONObject getRuleObj(EnumScoreType scoreType) { - if (rules == null) + public static JSONObject getRuleObj(String ruleContent,EnumScoreType scoreType) { + if (ruleContent == null) return null; - List list = JSONObject.parseArray(rules, JSONObject.class); + List list = JSONObject.parseArray(ruleContent, JSONObject.class); if (list == null) return null; if (list.size() == 0) @@ -168,5 +157,9 @@ public class WxScoreRules extends BaseTenantEntity { return null; } + public static JSONObject createBusinessDefaultJson(Integer businessId) { + String json = "{\"businessId\":"+businessId+",\"limit\":"+DEFAULT_LIMIT+",\"step\":"+DEFAULT_STEP+",\"score\":"+DEFAULT_SCORE+" ,\"desc\":\"线上交易1元\"}" ; + return JSONObject.parseObject(json); + } } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCreditHistoryServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCreditHistoryServiceImpl.java index d0f3b3b35..2efd74dc6 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCreditHistoryServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCreditHistoryServiceImpl.java @@ -957,7 +957,7 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService { WxScoreRules scoreRules = wxScoreRulesService.getCreditRules(record.getTenantId()); // 2. 获取成长值 by id - JSONObject payRule = scoreRules.getRuleObj(EnumScoreType.CONSUMPTION); + JSONObject payRule = WxScoreRules.getRuleObj(scoreRules.getRules(),EnumScoreType.CONSUMPTION); // 3. 获取成长值 by 业态 JSONObject busRule = null; JSONObject busRuleOther = null; diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxScoreRulesServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxScoreRulesServiceImpl.java index 6b336b509..e2ca3bf36 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxScoreRulesServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxScoreRulesServiceImpl.java @@ -9,19 +9,24 @@ import com.iformall.domain.po.base.TenantEntity; import com.iformall.enums.*; import com.iformall.exception.MallinkException; import com.iformall.mapper.*; +import com.iformall.service.WxBusinessService; import com.iformall.service.WxCUserService; import com.iformall.service.WxScoreRulesService; import com.iformall.utils.Constant; import org.apache.commons.lang3.StringUtils; +import org.apache.ibatis.javassist.bytecode.Descriptor.Iterator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.context.annotation.Lazy; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; @Service public class WxScoreRulesServiceImpl implements WxScoreRulesService { @@ -44,6 +49,10 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { @Autowired WxMerchantMapper wxMerchantMapper; + + @Lazy + @Autowired + WxBusinessService wxBusinessService; @Override public void wxScoreRulesInit(String tenantId) { @@ -89,7 +98,7 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { List list = wxScoreRulesMapper.findList(scoreRules); if (list.size() > 0) { scoreRules = list.get(0); - scoreRules.setRules(getScoreRulesNew(scoreRules.getRules(),EnumScoreRules.SCORE)); + scoreRules.setRules(getScoreRulesNew(tenantEntity,scoreRules.getRules(),EnumScoreRules.SCORE)); } else { // 如果成长值规则不存在,启用默认值 @@ -108,49 +117,40 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { } //当成长值或积分规则新增时,将新增的数据一并返回给接口调用端 - private String getScoreRulesNew(String scoreRules,EnumScoreRules enumScoreRules){ - //getJSONObject(1) 为EnumScoreType.CONSUMPTION(2, "消费")的下标值 - JSONArray jsonArrayOld = new JSONArray(); - JSONArray jsonArrayDefault = new JSONArray(); - if(enumScoreRules.equals(EnumScoreRules.SCORE)){ - jsonArrayOld = JSONArray.parseArray(scoreRules).getJSONObject(1).getJSONArray("childs"); - String defaultRules = WxScoreRules.getScoreDefaultRules(); - jsonArrayDefault = JSONArray.parseArray(defaultRules).getJSONObject(1).getJSONArray("childs"); - }else if(enumScoreRules.equals(EnumScoreRules.CREDIT)){ - jsonArrayOld = JSONArray.parseArray(scoreRules).getJSONObject(0).getJSONArray("childs"); - String defaultRules = WxScoreRules.getCreditDefaultRules(); - jsonArrayDefault = JSONArray.parseArray(defaultRules).getJSONObject(0).getJSONArray("childs"); - } - - if (jsonArrayOld.size() < jsonArrayDefault.size()) { - JSONArray childsJsonArray = new JSONArray(); - JSONObject otherJSONObject = new JSONObject(); - //组装新的childs - for (int i = 0; i < jsonArrayDefault.size(); i++) { - JSONObject defaultJSONObject = jsonArrayDefault.getJSONObject(i); - if (i < jsonArrayOld.size()) { - JSONObject oldJSONObject = jsonArrayOld.getJSONObject(i); - if (defaultJSONObject.getString("businessId").equals(oldJSONObject.getString("businessId"))) { - childsJsonArray.add(oldJSONObject); - }else { - childsJsonArray.add(defaultJSONObject); - otherJSONObject = oldJSONObject; - } - } else { - childsJsonArray.add(defaultJSONObject); - } - } - //businessId为6的是其它需要放到最后 - childsJsonArray.remove(childsJsonArray.size()-1); - childsJsonArray.add(otherJSONObject); - //将变更后的childs替换 - JSONArray originalJSONArray = JSONArray.parseArray(scoreRules); + private String getScoreRulesNew(TenantEntity tenantEntity,String scoreRules,EnumScoreRules enumScoreRules){ + JSONObject businessObject = WxScoreRules.getRuleObj(scoreRules, EnumScoreType.CONSUMPTION); + Map businessRuleMap = new HashMap(); + if (null != businessObject) { + JSONArray jsonArrayOld = businessObject.getJSONArray("childs"); + if (null != jsonArrayOld && jsonArrayOld.size() > 0 ) { + for (int i = 0 ; i < jsonArrayOld.size(); i++) { + JSONObject o = jsonArrayOld.getJSONObject(i); + Integer bussinessId = o.getInteger("businessId"); + businessRuleMap.put(bussinessId, o); + } + } + } + //根据业态来匹配 + List rootBusiness = wxBusinessService.findListAll(tenantEntity, null, null); + if (null != rootBusiness && rootBusiness.size() > 0 ) { + for (int i = 0 ; i < rootBusiness.size(); i++){ + WxBusiness bu = rootBusiness.get(i); + if (!businessRuleMap.containsKey(bu.getId())){ + businessRuleMap.put(bu.getId(), WxScoreRules.createBusinessDefaultJson(bu.getId())); + } + } + } + + if (businessRuleMap.size() > 0 ) { + JSONArray childsJsonArray = new JSONArray(); + for (Iterator it = (Iterator) businessRuleMap.keySet().iterator();it.hasNext();) { + Integer businessId = it.next(); + childsJsonArray.add(businessRuleMap.get(businessId)); + } + JSONArray originalJSONArray = JSONArray.parseArray(scoreRules); JSONObject newJSONObject = new JSONObject(); newJSONObject.put("id",EnumScoreType.CONSUMPTION.getCode()); newJSONObject.put("childs",childsJsonArray); - //移除下标为1的JSONArray 即:EnumScoreType.CONSUMPTION(2, "消费") - originalJSONArray.remove(1); - originalJSONArray.add(1,newJSONObject); return originalJSONArray.toJSONString(); } return scoreRules; @@ -177,15 +177,18 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { WxScoreRules scoreRules = new WxScoreRules(); scoreRules.setTenantId(tenantId); scoreRules.setType(EnumScoreRules.CREDIT.getCode()); + + TenantEntity baseTenantEntity = new TenantEntity(); + baseTenantEntity.setTenantId(tenantId); List list = wxScoreRulesMapper.findList(scoreRules); if (list.size() > 0) { scoreRules = list.get(0); - scoreRules.setRules(getScoreRulesNew(scoreRules.getRules(),EnumScoreRules.CREDIT)); + scoreRules.setRules(getScoreRulesNew(baseTenantEntity,scoreRules.getRules(),EnumScoreRules.CREDIT)); } else { // 如果积分规则不存在,启用默认值 final IdWorker idWorker = IdWorker.get(); scoreRules.setId(idWorker.nextId()); - scoreRules.setRules(WxScoreRules.getCreditDefaultRules()); + scoreRules.setRules(getScoreRulesNew(baseTenantEntity,null,EnumScoreRules.CREDIT)); scoreRules.setScale(WxScoreRules.DEFAULT_SCALE); wxScoreRulesMapper.insert(scoreRules); } @@ -324,7 +327,7 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { WxScoreRules scoreRules = getScoreRules(order); // 2. 获取成长值 by id - JSONObject payRule = scoreRules.getRuleObj(EnumScoreType.CONSUMPTION); + JSONObject payRule = WxScoreRules.getRuleObj(scoreRules.getRules(),EnumScoreType.CONSUMPTION); // 3. 获取成长值 by 业态 JSONObject busRule = null; JSONObject busRuleOther = null; From 01c73f0e53217bd9e6bf11f92cfa68a1a2496aaa Mon Sep 17 00:00:00 2001 From: lin <642018748@qq.com> Date: Sat, 25 Mar 2023 14:02:51 +0800 Subject: [PATCH 2/7] fix business --- .../com/iformall/service/impl/WxScoreRulesServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxScoreRulesServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxScoreRulesServiceImpl.java index e2ca3bf36..c3c81391f 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxScoreRulesServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxScoreRulesServiceImpl.java @@ -14,7 +14,6 @@ import com.iformall.service.WxCUserService; import com.iformall.service.WxScoreRulesService; import com.iformall.utils.Constant; import org.apache.commons.lang3.StringUtils; -import org.apache.ibatis.javassist.bytecode.Descriptor.Iterator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -25,6 +24,7 @@ import org.springframework.stereotype.Service; import java.util.Date; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; @@ -143,7 +143,7 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { if (businessRuleMap.size() > 0 ) { JSONArray childsJsonArray = new JSONArray(); - for (Iterator it = (Iterator) businessRuleMap.keySet().iterator();it.hasNext();) { + for (Iterator it = (Iterator) businessRuleMap.keySet().iterator();it.hasNext();) { Integer businessId = it.next(); childsJsonArray.add(businessRuleMap.get(businessId)); } From 661f1181b8921346d3c811217f838318407c9645 Mon Sep 17 00:00:00 2001 From: lin <642018748@qq.com> Date: Sat, 25 Mar 2023 14:26:30 +0800 Subject: [PATCH 3/7] fix business --- .../com/iformall/service/impl/WxScoreRulesServiceImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxScoreRulesServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxScoreRulesServiceImpl.java index c3c81391f..b49ed2d4d 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxScoreRulesServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxScoreRulesServiceImpl.java @@ -143,7 +143,7 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { if (businessRuleMap.size() > 0 ) { JSONArray childsJsonArray = new JSONArray(); - for (Iterator it = (Iterator) businessRuleMap.keySet().iterator();it.hasNext();) { + for (Iterator it = businessRuleMap.keySet().iterator();it.hasNext();) { Integer businessId = it.next(); childsJsonArray.add(businessRuleMap.get(businessId)); } @@ -151,6 +151,7 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { JSONObject newJSONObject = new JSONObject(); newJSONObject.put("id",EnumScoreType.CONSUMPTION.getCode()); newJSONObject.put("childs",childsJsonArray); + originalJSONArray.add(newJSONObject); return originalJSONArray.toJSONString(); } return scoreRules; From 0f467753473a7a8195d0b4043527b255cf304f57 Mon Sep 17 00:00:00 2001 From: lin <642018748@qq.com> Date: Mon, 27 Mar 2023 16:15:59 +0800 Subject: [PATCH 4/7] fix business --- .../com/iformall/service/impl/WxScoreRulesServiceImpl.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxScoreRulesServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxScoreRulesServiceImpl.java index b49ed2d4d..8c6b508d8 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxScoreRulesServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxScoreRulesServiceImpl.java @@ -1,5 +1,6 @@ package com.iformall.service.impl; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.iformall.common.ErrorCode; @@ -148,6 +149,9 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { childsJsonArray.add(businessRuleMap.get(businessId)); } JSONArray originalJSONArray = JSONArray.parseArray(scoreRules); + if (null != businessObject) { + originalJSONArray.remove(businessObject); + } JSONObject newJSONObject = new JSONObject(); newJSONObject.put("id",EnumScoreType.CONSUMPTION.getCode()); newJSONObject.put("childs",childsJsonArray); @@ -156,7 +160,7 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { } return scoreRules; } - + @Override public WxScoreRules getCreditRules(String tenantId) { // String tenantId = ""; From 9494de54edf7089c88820fb4e1751a42afd20258 Mon Sep 17 00:00:00 2001 From: lin <642018748@qq.com> Date: Mon, 27 Mar 2023 17:28:14 +0800 Subject: [PATCH 5/7] fix business --- .../mem/WxScoreRulesController.java | 3 +++ .../com/iformall/domain/po/WxScoreRules.java | 27 +++++++++++++++++++ .../service/impl/WxScoreRulesServiceImpl.java | 3 +++ 3 files changed, 33 insertions(+) diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/mem/WxScoreRulesController.java b/mallinkAdmin/src/main/java/com/iformall/controller/mem/WxScoreRulesController.java index db6bc7be6..daf6f5370 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/mem/WxScoreRulesController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/mem/WxScoreRulesController.java @@ -68,6 +68,9 @@ public class WxScoreRulesController extends BaseController { }else{ return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"type"); } + if (!wxScoreRules.checkRules()) { + return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"规则内容有项重复"); + } wxScoreRulesService.saveOrUpdate(wxScoreRules); return new ResultData(); } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxScoreRules.java b/mallinkService/src/main/java/com/iformall/domain/po/WxScoreRules.java index e5b9c84e4..81827b10b 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxScoreRules.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxScoreRules.java @@ -12,7 +12,9 @@ import lombok.EqualsAndHashCode; import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * 1. 每天登录首次给成长值 @@ -161,5 +163,30 @@ public class WxScoreRules extends BaseTenantEntity { String json = "{\"businessId\":"+businessId+",\"limit\":"+DEFAULT_LIMIT+",\"step\":"+DEFAULT_STEP+",\"score\":"+DEFAULT_SCORE+" ,\"desc\":\"线上交易1元\"}" ; return JSONObject.parseObject(json); } + + public boolean checkRules() { + if (rules == null) + return true; + + List list = JSONObject.parseArray(rules, JSONObject.class); + if (list == null) + return true; + if (list.size() == 0) + return true; + + Map rootIdCount = new HashMap(); + for (JSONObject jo:list) { + Integer id = jo.getInteger(WxScoreRules.ID); + if ( id!= null){ + Integer idcont = rootIdCount.get(id); + if (null != idcont && idcont > 0) { + return false; + }else { + rootIdCount.put(id, 1); + } + } + } + return true; + } } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxScoreRulesServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxScoreRulesServiceImpl.java index 8c6b508d8..5b2a224ff 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxScoreRulesServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxScoreRulesServiceImpl.java @@ -208,6 +208,9 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { @Override public void saveOrUpdate(WxScoreRules record) { + //校验规则不能重复 + + Date date = new Date(); record.setUpdateDate(date); if (record.getId() == null) { From f7a4d6041dd569973594eb7e6a6828a2651935ce Mon Sep 17 00:00:00 2001 From: lin <642018748@qq.com> Date: Mon, 27 Mar 2023 18:38:47 +0800 Subject: [PATCH 6/7] fix business --- .../main/java/com/iformall/domain/po/WxScoreRules.java | 8 ++++---- .../iformall/service/impl/WxScoreRulesServiceImpl.java | 2 +- .../src/main/java/com/iformall/utils/Constant.java | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxScoreRules.java b/mallinkService/src/main/java/com/iformall/domain/po/WxScoreRules.java index 81827b10b..d89ba2cf9 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxScoreRules.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxScoreRules.java @@ -46,7 +46,7 @@ public class WxScoreRules extends BaseTenantEntity { "[" + "{\"id\":1,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"每日登陆\"}," + "{\"id\":2,\"childs\":[" + - " {\"businessId\":"+Constant.default_business+",\"limit\":"+DEFAULT_LIMIT+",\"step\":"+DEFAULT_STEP+",\"score\":"+DEFAULT_SCORE+" ,\"desc\":\"线上交易1元\"}" + + " {\"businessId\":"+Constant.default_business+",\"title\":\""+Constant.default_business_name+"\",\"limit\":"+DEFAULT_LIMIT+",\"step\":"+DEFAULT_STEP+",\"score\":"+DEFAULT_SCORE+" ,\"desc\":\"线上交易1元\"}" + "]}," + "{\"id\":3,\"limit\":1,\"step\":1,\"score\":0,\"desc\":\"绑定车牌1个\"}," + "{\"id\":6,\"limit\":1,\"step\":1,\"score\":0,\"desc\":\"授权手机号\"}," + @@ -58,7 +58,7 @@ public class WxScoreRules extends BaseTenantEntity { "[" + // "{\"id\":1,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"每日登陆\"}," + "{\"id\":2,\"childs\":[" + - " {\"businessId\":"+Constant.default_business+",\"limit\":"+DEFAULT_LIMIT+",\"step\":"+DEFAULT_STEP+",\"score\":"+DEFAULT_SCORE+" ,\"desc\":\"线上交易1元\"}" + + " {\"businessId\":"+Constant.default_business+",\"title\":\""+Constant.default_business_name+"\",\"limit\":"+DEFAULT_LIMIT+",\"step\":"+DEFAULT_STEP+",\"score\":"+DEFAULT_SCORE+" ,\"desc\":\"线上交易1元\"}" + "]}," + "{\"id\":3,\"limit\":1,\"step\":1,\"score\":0,\"desc\":\"绑定车牌1个\"}," + "{\"id\":6,\"limit\":1,\"step\":1,\"score\":0,\"desc\":\"授权手机号\"}," + @@ -159,8 +159,8 @@ public class WxScoreRules extends BaseTenantEntity { return null; } - public static JSONObject createBusinessDefaultJson(Integer businessId) { - String json = "{\"businessId\":"+businessId+",\"limit\":"+DEFAULT_LIMIT+",\"step\":"+DEFAULT_STEP+",\"score\":"+DEFAULT_SCORE+" ,\"desc\":\"线上交易1元\"}" ; + public static JSONObject createBusinessDefaultJson(Integer businessId,String businessNme) { + String json = "{\"businessId\":"+businessId+",\"title\":\""+businessNme+"\",\"limit\":"+DEFAULT_LIMIT+",\"step\":"+DEFAULT_STEP+",\"score\":"+DEFAULT_SCORE+" ,\"desc\":\"线上交易1元\"}" ; return JSONObject.parseObject(json); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxScoreRulesServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxScoreRulesServiceImpl.java index 5b2a224ff..88202a703 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxScoreRulesServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxScoreRulesServiceImpl.java @@ -137,7 +137,7 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { for (int i = 0 ; i < rootBusiness.size(); i++){ WxBusiness bu = rootBusiness.get(i); if (!businessRuleMap.containsKey(bu.getId())){ - businessRuleMap.put(bu.getId(), WxScoreRules.createBusinessDefaultJson(bu.getId())); + businessRuleMap.put(bu.getId(), WxScoreRules.createBusinessDefaultJson(bu.getId(),bu.getTitle())); } } } diff --git a/mallinkService/src/main/java/com/iformall/utils/Constant.java b/mallinkService/src/main/java/com/iformall/utils/Constant.java index ba8b242dc..d39ca9b69 100644 --- a/mallinkService/src/main/java/com/iformall/utils/Constant.java +++ b/mallinkService/src/main/java/com/iformall/utils/Constant.java @@ -128,6 +128,7 @@ public class Constant { //默认业态 public static final Integer default_business = 6; + public static final String default_business_name = "其他"; public static final Integer dy_business = 2; } From 4c63a210242a8020430fcee3ebf7c0f7532a4ab7 Mon Sep 17 00:00:00 2001 From: lin <642018748@qq.com> Date: Mon, 27 Mar 2023 19:03:14 +0800 Subject: [PATCH 7/7] fix business --- .../java/com/iformall/controller/sys/WxBusinessController.java | 1 + 1 file changed, 1 insertion(+) diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/sys/WxBusinessController.java b/mallinkAdmin/src/main/java/com/iformall/controller/sys/WxBusinessController.java index eb6af3352..adf5c6164 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/sys/WxBusinessController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/sys/WxBusinessController.java @@ -85,6 +85,7 @@ public class WxBusinessController extends BaseController { return new ResultData(Result.ERROR,"不能修改系统默认业态"); } } + wxBusiness.setTitle(wxBusiness.getTitle().replaceAll("\\\\", "")); wxBusinessService.saveOrUpdate(wxBusiness); return new ResultData(); }