|
|
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject; |
|
|
import com.iformall.common.IdWorker; |
|
|
import com.iformall.common.IdWorker; |
|
|
import com.iformall.domain.po.*; |
|
|
import com.iformall.domain.po.*; |
|
|
import com.iformall.enums.EnumBusiness; |
|
|
import com.iformall.enums.EnumBusiness; |
|
|
|
|
|
import com.iformall.enums.EnumScoreRules; |
|
|
import com.iformall.enums.EnumScoreType; |
|
|
import com.iformall.enums.EnumScoreType; |
|
|
import com.iformall.mapper.WxCUserBasicInfoMapper; |
|
|
import com.iformall.mapper.WxCUserBasicInfoMapper; |
|
|
import com.iformall.mapper.WxCUserMapper; |
|
|
import com.iformall.mapper.WxCUserMapper; |
|
|
@@ -60,7 +61,7 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { |
|
|
|
|
|
|
|
|
WxScoreRules scoreRules = new WxScoreRules(); |
|
|
WxScoreRules scoreRules = new WxScoreRules(); |
|
|
scoreRules.setTenantId(tenantId); |
|
|
scoreRules.setTenantId(tenantId); |
|
|
scoreRules.setType(1); |
|
|
|
|
|
|
|
|
scoreRules.setType(EnumScoreRules.SCORE.getCode()); |
|
|
List<WxScoreRules> list = wxScoreRulesMapper.findList(scoreRules); |
|
|
List<WxScoreRules> list = wxScoreRulesMapper.findList(scoreRules); |
|
|
if (list.size() > 0) { |
|
|
if (list.size() > 0) { |
|
|
scoreRules = list.get(0); |
|
|
scoreRules = list.get(0); |
|
|
@@ -83,6 +84,7 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { |
|
|
|
|
|
|
|
|
//当成长值或积分规则新增时,将新增的数据一并返回给接口调用端 |
|
|
//当成长值或积分规则新增时,将新增的数据一并返回给接口调用端 |
|
|
private String getScoreRulesNew(String scoreRules){ |
|
|
private String getScoreRulesNew(String scoreRules){ |
|
|
|
|
|
//getJSONObject(1) 为EnumScoreType.CONSUMPTION(2, "消费")的下标值 |
|
|
JSONArray jsonArrayOld = JSONArray.parseArray(scoreRules).getJSONObject(1).getJSONArray("childs"); |
|
|
JSONArray jsonArrayOld = JSONArray.parseArray(scoreRules).getJSONObject(1).getJSONArray("childs"); |
|
|
JSONArray jsonArrayDefault = JSONArray.parseArray(WxScoreRules.getDefaultRules()).getJSONObject(1).getJSONArray("childs"); |
|
|
JSONArray jsonArrayDefault = JSONArray.parseArray(WxScoreRules.getDefaultRules()).getJSONObject(1).getJSONArray("childs"); |
|
|
if (jsonArrayOld.size() < jsonArrayDefault.size()) { |
|
|
if (jsonArrayOld.size() < jsonArrayDefault.size()) { |
|
|
@@ -109,8 +111,9 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { |
|
|
//将变更后的childs替换 |
|
|
//将变更后的childs替换 |
|
|
JSONArray originalJSONArray = JSONArray.parseArray(scoreRules); |
|
|
JSONArray originalJSONArray = JSONArray.parseArray(scoreRules); |
|
|
JSONObject newJSONObject = new JSONObject(); |
|
|
JSONObject newJSONObject = new JSONObject(); |
|
|
newJSONObject.put("id",2); |
|
|
|
|
|
|
|
|
newJSONObject.put("id",EnumScoreType.CONSUMPTION.getCode()); |
|
|
newJSONObject.put("childs",childsJsonArray); |
|
|
newJSONObject.put("childs",childsJsonArray); |
|
|
|
|
|
//移除下标为1的JSONArray 即:EnumScoreType.CONSUMPTION(2, "消费") |
|
|
originalJSONArray.remove(1); |
|
|
originalJSONArray.remove(1); |
|
|
originalJSONArray.add(1,newJSONObject); |
|
|
originalJSONArray.add(1,newJSONObject); |
|
|
return originalJSONArray.toJSONString(); |
|
|
return originalJSONArray.toJSONString(); |
|
|
@@ -133,7 +136,7 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { |
|
|
|
|
|
|
|
|
WxScoreRules scoreRules = new WxScoreRules(); |
|
|
WxScoreRules scoreRules = new WxScoreRules(); |
|
|
scoreRules.setTenantId(tenantId); |
|
|
scoreRules.setTenantId(tenantId); |
|
|
scoreRules.setType(2); |
|
|
|
|
|
|
|
|
scoreRules.setType(EnumScoreRules.CREDIT.getCode()); |
|
|
List<WxScoreRules> list = wxScoreRulesMapper.findList(scoreRules); |
|
|
List<WxScoreRules> list = wxScoreRulesMapper.findList(scoreRules); |
|
|
if (list.size() > 0) { |
|
|
if (list.size() > 0) { |
|
|
scoreRules = list.get(0); |
|
|
scoreRules = list.get(0); |
|
|
@@ -166,7 +169,7 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { |
|
|
wxScoreRulesMapper.updateByPrimaryKeySelective(record); |
|
|
wxScoreRulesMapper.updateByPrimaryKeySelective(record); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (record != null && record.getType() == 1) { |
|
|
|
|
|
|
|
|
if (record != null && record.getType() == EnumScoreRules.SCORE.getCode()) { |
|
|
// 缓存存在,删除缓存 |
|
|
// 缓存存在,删除缓存 |
|
|
String key = keyPrev + record.getTenantId(); |
|
|
String key = keyPrev + record.getTenantId(); |
|
|
boolean hasKey = scoreRulesRedisTemplate.hasKey(key); |
|
|
boolean hasKey = scoreRulesRedisTemplate.hasKey(key); |
|
|
@@ -175,7 +178,7 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { |
|
|
logger.info("WxScoreRulesServiceImpl.saveOrUpdate() : 从缓存中删除成长值设置 >> " + record.toString()); |
|
|
logger.info("WxScoreRulesServiceImpl.saveOrUpdate() : 从缓存中删除成长值设置 >> " + record.toString()); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if (record != null && record.getType() == 2) { |
|
|
|
|
|
|
|
|
if (record != null && record.getType() == EnumScoreRules.CREDIT.getCode()) { |
|
|
// 缓存存在,删除缓存 |
|
|
// 缓存存在,删除缓存 |
|
|
String key = creditKeyPrev + record.getTenantId(); |
|
|
String key = creditKeyPrev + record.getTenantId(); |
|
|
boolean hasKey = scoreRulesRedisTemplate.hasKey(key); |
|
|
boolean hasKey = scoreRulesRedisTemplate.hasKey(key); |
|
|
|