diff --git a/mallinkAdmin/src/main/resources/db/migration/V2023040300001_business.sql b/mallinkAdmin/src/main/resources/db/migration/V2023040300001_business.sql index 99de096c9..6c127b8f7 100644 --- a/mallinkAdmin/src/main/resources/db/migration/V2023040300001_business.sql +++ b/mallinkAdmin/src/main/resources/db/migration/V2023040300001_business.sql @@ -97,4 +97,105 @@ alter table wx_coupon_95 modify column business int(11); alter table wx_coupon_96 modify column business int(11); alter table wx_coupon_97 modify column business int(11); alter table wx_coupon_98 modify column business int(11); -alter table wx_coupon_99 modify column business int(11); \ No newline at end of file +alter table wx_coupon_99 modify column business int(11); + +alter table wx_coupon_channel_0 modify column business int(11); +alter table wx_coupon_channel_1 modify column business int(11); +alter table wx_coupon_channel_2 modify column business int(11); +alter table wx_coupon_channel_3 modify column business int(11); +alter table wx_coupon_channel_4 modify column business int(11); +alter table wx_coupon_channel_5 modify column business int(11); +alter table wx_coupon_channel_6 modify column business int(11); +alter table wx_coupon_channel_7 modify column business int(11); +alter table wx_coupon_channel_8 modify column business int(11); +alter table wx_coupon_channel_9 modify column business int(11); +alter table wx_coupon_channel_10 modify column business int(11); +alter table wx_coupon_channel_11 modify column business int(11); +alter table wx_coupon_channel_12 modify column business int(11); +alter table wx_coupon_channel_13 modify column business int(11); +alter table wx_coupon_channel_14 modify column business int(11); +alter table wx_coupon_channel_15 modify column business int(11); +alter table wx_coupon_channel_16 modify column business int(11); +alter table wx_coupon_channel_17 modify column business int(11); +alter table wx_coupon_channel_18 modify column business int(11); +alter table wx_coupon_channel_19 modify column business int(11); +alter table wx_coupon_channel_20 modify column business int(11); +alter table wx_coupon_channel_21 modify column business int(11); +alter table wx_coupon_channel_22 modify column business int(11); +alter table wx_coupon_channel_23 modify column business int(11); +alter table wx_coupon_channel_24 modify column business int(11); +alter table wx_coupon_channel_25 modify column business int(11); +alter table wx_coupon_channel_26 modify column business int(11); +alter table wx_coupon_channel_27 modify column business int(11); +alter table wx_coupon_channel_28 modify column business int(11); +alter table wx_coupon_channel_29 modify column business int(11); +alter table wx_coupon_channel_30 modify column business int(11); +alter table wx_coupon_channel_31 modify column business int(11); +alter table wx_coupon_channel_32 modify column business int(11); +alter table wx_coupon_channel_33 modify column business int(11); +alter table wx_coupon_channel_34 modify column business int(11); +alter table wx_coupon_channel_35 modify column business int(11); +alter table wx_coupon_channel_36 modify column business int(11); +alter table wx_coupon_channel_37 modify column business int(11); +alter table wx_coupon_channel_38 modify column business int(11); +alter table wx_coupon_channel_39 modify column business int(11); +alter table wx_coupon_channel_40 modify column business int(11); +alter table wx_coupon_channel_41 modify column business int(11); +alter table wx_coupon_channel_42 modify column business int(11); +alter table wx_coupon_channel_43 modify column business int(11); +alter table wx_coupon_channel_44 modify column business int(11); +alter table wx_coupon_channel_45 modify column business int(11); +alter table wx_coupon_channel_46 modify column business int(11); +alter table wx_coupon_channel_47 modify column business int(11); +alter table wx_coupon_channel_48 modify column business int(11); +alter table wx_coupon_channel_49 modify column business int(11); +alter table wx_coupon_channel_50 modify column business int(11); +alter table wx_coupon_channel_51 modify column business int(11); +alter table wx_coupon_channel_52 modify column business int(11); +alter table wx_coupon_channel_53 modify column business int(11); +alter table wx_coupon_channel_54 modify column business int(11); +alter table wx_coupon_channel_55 modify column business int(11); +alter table wx_coupon_channel_56 modify column business int(11); +alter table wx_coupon_channel_57 modify column business int(11); +alter table wx_coupon_channel_58 modify column business int(11); +alter table wx_coupon_channel_59 modify column business int(11); +alter table wx_coupon_channel_60 modify column business int(11); +alter table wx_coupon_channel_61 modify column business int(11); +alter table wx_coupon_channel_62 modify column business int(11); +alter table wx_coupon_channel_63 modify column business int(11); +alter table wx_coupon_channel_64 modify column business int(11); +alter table wx_coupon_channel_65 modify column business int(11); +alter table wx_coupon_channel_66 modify column business int(11); +alter table wx_coupon_channel_67 modify column business int(11); +alter table wx_coupon_channel_68 modify column business int(11); +alter table wx_coupon_channel_69 modify column business int(11); +alter table wx_coupon_channel_70 modify column business int(11); +alter table wx_coupon_channel_71 modify column business int(11); +alter table wx_coupon_channel_72 modify column business int(11); +alter table wx_coupon_channel_73 modify column business int(11); +alter table wx_coupon_channel_74 modify column business int(11); +alter table wx_coupon_channel_75 modify column business int(11); +alter table wx_coupon_channel_76 modify column business int(11); +alter table wx_coupon_channel_77 modify column business int(11); +alter table wx_coupon_channel_78 modify column business int(11); +alter table wx_coupon_channel_79 modify column business int(11); +alter table wx_coupon_channel_80 modify column business int(11); +alter table wx_coupon_channel_81 modify column business int(11); +alter table wx_coupon_channel_82 modify column business int(11); +alter table wx_coupon_channel_83 modify column business int(11); +alter table wx_coupon_channel_84 modify column business int(11); +alter table wx_coupon_channel_85 modify column business int(11); +alter table wx_coupon_channel_86 modify column business int(11); +alter table wx_coupon_channel_87 modify column business int(11); +alter table wx_coupon_channel_88 modify column business int(11); +alter table wx_coupon_channel_89 modify column business int(11); +alter table wx_coupon_channel_90 modify column business int(11); +alter table wx_coupon_channel_91 modify column business int(11); +alter table wx_coupon_channel_92 modify column business int(11); +alter table wx_coupon_channel_93 modify column business int(11); +alter table wx_coupon_channel_94 modify column business int(11); +alter table wx_coupon_channel_95 modify column business int(11); +alter table wx_coupon_channel_96 modify column business int(11); +alter table wx_coupon_channel_97 modify column business int(11); +alter table wx_coupon_channel_98 modify column business int(11); +alter table wx_coupon_channel_99 modify column business int(11); 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 93be81c73..5bc350362 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxScoreRules.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxScoreRules.java @@ -1,5 +1,6 @@ package com.iformall.domain.po; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; @@ -13,6 +14,7 @@ import lombok.EqualsAndHashCode; import java.util.Date; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; @@ -157,12 +159,37 @@ public class WxScoreRules extends BaseTenantEntity { return null; } + + public static JSONArray removeRuleObj(JSONArray rule,EnumScoreType scoreType) { + if (rule == null) { + return null; + } + JSONArray ret = new JSONArray(); + for (Iterator crule = rule.iterator();crule.hasNext();) { + JSONObject jo = (JSONObject) crule.next(); + Integer id = jo.getInteger(WxScoreRules.ID); + if ( id!= null && id.equals(scoreType.getCode())){ + continue; + }else { + ret.add(jo); + } + } + if (ret.size() <= 0 ) { + return null; + } + return ret; + } 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); } + public static JSONObject replaceBusinessName(JSONObject json,String businessName) { + json.replace("title", businessName); + return json; + } + public boolean checkRules() { if (rules == null) 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 7e7a632a4..912f8234f 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxScoreRulesServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxScoreRulesServiceImpl.java @@ -153,7 +153,7 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { for (int i = 0 ; i < rootBusiness.size(); i++){ WxBusiness bu = rootBusiness.get(i); if (currentBusinessRuleMap.containsKey(bu.getId())) { - businessRuleMap.put(bu.getId(),currentBusinessRuleMap.get(bu.getId())); + businessRuleMap.put(bu.getId(),WxScoreRules.replaceBusinessName(currentBusinessRuleMap.get(bu.getId()),bu.getTitle())); }else { if (!businessRuleMap.containsKey(bu.getId())){ businessRuleMap.put(bu.getId(), WxScoreRules.createBusinessDefaultJson(bu.getId(),bu.getTitle())); @@ -169,14 +169,13 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { childsJsonArray.add(businessRuleMap.get(businessId)); } JSONArray originalJSONArray = JSONArray.parseArray(scoreRules); - if (null != businessObject) { - originalJSONArray.remove(businessObject); - } + //把之前的去掉 + JSONArray otherRuleObj = WxScoreRules.removeRuleObj(originalJSONArray, EnumScoreType.CONSUMPTION); JSONObject newJSONObject = new JSONObject(); newJSONObject.put("id",EnumScoreType.CONSUMPTION.getCode()); newJSONObject.put("childs",childsJsonArray); - originalJSONArray.add(newJSONObject); - return originalJSONArray.toJSONString(); + otherRuleObj.add(newJSONObject); + return otherRuleObj.toJSONString(); } return scoreRules; }