diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/mem/WxCUserBasicInfoController.java b/mallinkAdmin/src/main/java/com/iformall/controller/mem/WxCUserBasicInfoController.java index 19e17e131..6bd5f2b65 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/mem/WxCUserBasicInfoController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/mem/WxCUserBasicInfoController.java @@ -92,7 +92,7 @@ public class WxCUserBasicInfoController extends BaseController { info.setLevel(WxLevelConfigService.DEFAULT_LEVEL); } else { info.setLevel(WxLevelConfigService.DEFAULT_LEVEL); - List levelList = wxLevelConfigService.getByTenantInfo(info.getTenantInfo()); + List levelList = wxLevelConfigService.getByTenantInfo(info); for (WxLevelConfig levelConfig : levelList) { if (info.getPoins() >= levelConfig.getPoints()) { info.setLevel(levelConfig.getLevel()); @@ -107,7 +107,7 @@ public class WxCUserBasicInfoController extends BaseController { WxCUserTags uTag = wxCUserTagsService.getById(info.getTagId()); if (uTag != null && StringUtils.isNotBlank(uTag.getTags())) { List ids = JSONObject.parseArray(uTag.getTags(), Long.class); - info.setTagsList(wxCUserTagsService.findTagList(info.getTenantInfo(), ids)); + info.setTagsList(wxCUserTagsService.findTagList(info, ids)); } } } diff --git a/mallinkAdmin/src/main/java/com/iformall/tenant/TenantInfoImpl.java b/mallinkAdmin/src/main/java/com/iformall/tenant/TenantInfoImpl.java index 6a757c08d..38afaebd9 100644 --- a/mallinkAdmin/src/main/java/com/iformall/tenant/TenantInfoImpl.java +++ b/mallinkAdmin/src/main/java/com/iformall/tenant/TenantInfoImpl.java @@ -115,9 +115,6 @@ public class TenantInfoImpl implements TenantInfo { if ("wx_c_user".equals(tableName)) { return true; } - if ("wx_c_user_basic_info".equals(tableName)) { - return true; - } if ("wx_c_user_car".equals(tableName)) { return true; } diff --git a/mallinkAdmin/src/main/resources/db/migration/V202007131031__GROUP__ADD_001.sql b/mallinkAdmin/src/main/resources/db/migration/V202007131031__GROUP__ADD_001.sql index 23d729270..7626a22f0 100644 --- a/mallinkAdmin/src/main/resources/db/migration/V202007131031__GROUP__ADD_001.sql +++ b/mallinkAdmin/src/main/resources/db/migration/V202007131031__GROUP__ADD_001.sql @@ -2,4 +2,8 @@ ALTER TABLE `wx_c_user_basic_info` ADD COLUMN `parent_tenant_id` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '父租户ID' AFTER `tenant_id`; ALTER TABLE `wx_buser` -ADD COLUMN `parent_tenant_id` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '父租户ID' AFTER `tenant_id`; \ No newline at end of file +ADD COLUMN `parent_tenant_id` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '父租户ID' AFTER `tenant_id`; + +ALTER TABLE `wx_mall` +ADD COLUMN `live_support` SMALLINT(1) DEFAULT '0' COMMENT '是否支持直播(0-不支持,1-支持)'; + diff --git a/mallinkService/src/main/java/com/iformall/common/NonWebRequestAttributes.java b/mallinkService/src/main/java/com/iformall/common/NonWebRequestAttributes.java new file mode 100644 index 000000000..e9fc1d913 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/common/NonWebRequestAttributes.java @@ -0,0 +1,47 @@ +package com.iformall.common; + +import org.springframework.web.context.request.RequestAttributes; + +public class NonWebRequestAttributes implements RequestAttributes{ + + @Override + public Object getAttribute(String arg0, int arg1) { + return null; + } + + @Override + public String[] getAttributeNames(int arg0) { + return null; + } + + @Override + public String getSessionId() { + return null; + } + + @Override + public Object getSessionMutex() { + return null; + } + + @Override + public void registerDestructionCallback(String arg0, Runnable arg1, int arg2) { + + } + + @Override + public void removeAttribute(String arg0, int arg1) { + + } + + @Override + public Object resolveReference(String arg0) { + return null; + } + + @Override + public void setAttribute(String arg0, Object arg1, int arg2) { + + } + +} diff --git a/mallinkService/src/main/java/com/iformall/common/TenantThreadLocal.java b/mallinkService/src/main/java/com/iformall/common/TenantThreadLocal.java index 0e7c3e39b..8e1785ce9 100644 --- a/mallinkService/src/main/java/com/iformall/common/TenantThreadLocal.java +++ b/mallinkService/src/main/java/com/iformall/common/TenantThreadLocal.java @@ -9,27 +9,38 @@ public class TenantThreadLocal { //private static ThreadLocal parentLocal = new ThreadLocal(); public static void setCurrentThreadTenant(String tenantId,String parentId) { - RequestContextHolder.currentRequestAttributes().setAttribute("tenaneId", tenantId, RequestAttributes.SCOPE_REQUEST); - RequestContextHolder.currentRequestAttributes().setAttribute("parentTenaneId", parentId, RequestAttributes.SCOPE_REQUEST); + getRequestAttributesSafely().setAttribute("tenaneId", tenantId, RequestAttributes.SCOPE_REQUEST); + getRequestAttributesSafely().setAttribute("parentTenaneId", parentId, RequestAttributes.SCOPE_REQUEST); //local.set(tenantId); //parentLocal.set(parentId); } public static String getTenantId() { - return (String)RequestContextHolder.currentRequestAttributes().getAttribute("tenaneId", RequestAttributes.SCOPE_REQUEST); + return (String)getRequestAttributesSafely().getAttribute("tenaneId", RequestAttributes.SCOPE_REQUEST); //return local.get(); } public static String getParentTenantId() { - return (String)RequestContextHolder.currentRequestAttributes().getAttribute("parentTenaneId", RequestAttributes.SCOPE_REQUEST); + return (String)getRequestAttributesSafely().getAttribute("parentTenaneId", RequestAttributes.SCOPE_REQUEST); //return parentLocal.get(); } public static void remove() { - RequestContextHolder.currentRequestAttributes().removeAttribute("tenaneId", RequestAttributes.SCOPE_REQUEST); - RequestContextHolder.currentRequestAttributes().removeAttribute("parentTenaneId", RequestAttributes.SCOPE_REQUEST); + getRequestAttributesSafely().removeAttribute("tenaneId", RequestAttributes.SCOPE_REQUEST); + getRequestAttributesSafely().removeAttribute("parentTenaneId", RequestAttributes.SCOPE_REQUEST); //local.remove(); //parentLocal.remove(); } + //如果是非web的线程,则都为空 + public static RequestAttributes getRequestAttributesSafely(){ + RequestAttributes requestAttributes = null; + try{ + requestAttributes = RequestContextHolder.currentRequestAttributes(); + }catch (IllegalStateException e){ + requestAttributes = new NonWebRequestAttributes(); + } + return requestAttributes; + } + } diff --git a/mallinkService/src/main/java/com/iformall/domain/dto/WxCUserBasicInfoDto.java b/mallinkService/src/main/java/com/iformall/domain/dto/WxCUserBasicInfoDto.java index 394de169d..f3d6e4c22 100644 --- a/mallinkService/src/main/java/com/iformall/domain/dto/WxCUserBasicInfoDto.java +++ b/mallinkService/src/main/java/com/iformall/domain/dto/WxCUserBasicInfoDto.java @@ -2,6 +2,8 @@ package com.iformall.domain.dto; import com.baomidou.mybatisplus.annotation.TableField; import com.iformall.domain.po.base.BaseTenantEntity; +import com.iformall.domain.po.base.TenantEntity; + import lombok.Data; import lombok.EqualsAndHashCode; @@ -15,7 +17,7 @@ import java.util.List; */ @Data @EqualsAndHashCode(callSuper = true) -public class WxCUserBasicInfoDto extends BaseTenantEntity { +public class WxCUserBasicInfoDto extends TenantEntity { protected Long id; diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxBuser.java b/mallinkService/src/main/java/com/iformall/domain/po/WxBuser.java index 53df7b843..c5ac32ef3 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxBuser.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxBuser.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.iformall.domain.po.base.BaseTenantEntity; +import com.iformall.domain.po.base.TenantEntity; import com.iformall.utils.Constant; import lombok.Data; import lombok.EqualsAndHashCode; @@ -22,7 +23,7 @@ import java.util.UUID; @Data @ToString(callSuper = true) @EqualsAndHashCode(callSuper = true) -public class WxBuser extends BaseTenantEntity { +public class WxBuser extends TenantEntity { protected Long id; diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxCUserBasicInfo.java b/mallinkService/src/main/java/com/iformall/domain/po/WxCUserBasicInfo.java index 40827c8e6..ceed2dd95 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxCUserBasicInfo.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxCUserBasicInfo.java @@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonIgnore; import com.iformall.domain.po.base.BaseTenantEntity; +import com.iformall.domain.po.base.TenantEntity; + import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; @@ -19,7 +21,7 @@ import java.util.Objects; @Data @ToString(callSuper = true) @EqualsAndHashCode(callSuper = true) -public class WxCUserBasicInfo extends BaseTenantEntity { +public class WxCUserBasicInfo extends TenantEntity { protected Long id; diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxCUserCar.java b/mallinkService/src/main/java/com/iformall/domain/po/WxCUserCar.java index 1c7462c88..ac6a857ef 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxCUserCar.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxCUserCar.java @@ -2,6 +2,8 @@ package com.iformall.domain.po; import com.baomidou.mybatisplus.annotation.TableName; import com.iformall.domain.po.base.BaseTenantEntity; +import com.iformall.domain.po.base.TenantEntity; + import lombok.Data; import lombok.EqualsAndHashCode; @@ -10,7 +12,7 @@ import java.util.*; @TableName(value = "wx_c_user_car") @Data @EqualsAndHashCode(callSuper = true) -public class WxCUserCar extends BaseTenantEntity { +public class WxCUserCar extends TenantEntity { protected Long id; diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxMall.java b/mallinkService/src/main/java/com/iformall/domain/po/WxMall.java index cb8e39ac3..5f47b3579 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxMall.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxMall.java @@ -86,6 +86,8 @@ public class WxMall extends BaseEntity { private BigDecimal longitude; @io.swagger.annotations.ApiModelProperty(value="纬度",name="latitude") private BigDecimal latitude; + @io.swagger.annotations.ApiModelProperty(value="直播支持(0:不支持,1支持)",name="liveSupport") + private Integer liveSupport; @TableField(exist = false) protected List buildings; diff --git a/mallinkService/src/main/java/com/iformall/domain/po/base/BaseTenantEntity.java b/mallinkService/src/main/java/com/iformall/domain/po/base/BaseTenantEntity.java index 0345bc6f5..085d1b320 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/base/BaseTenantEntity.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/base/BaseTenantEntity.java @@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Data; import lombok.EqualsAndHashCode; +import lombok.extern.slf4j.Slf4j; + import org.apache.commons.lang3.StringUtils; /** @@ -11,6 +13,7 @@ import org.apache.commons.lang3.StringUtils; * @date 2019/4/24 14:32 */ @Data +@Slf4j @EqualsAndHashCode(callSuper = true) public class BaseTenantEntity extends BaseEntity { @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") @@ -25,6 +28,7 @@ public class BaseTenantEntity extends BaseEntity { private TenantEntity tenantInfo; public void updateTenantInfo(TenantEntity info) { + log.info("info.tenantId:"+info.getTenantId()+". info.parentTenantId:"+info.getParentTenantId()+"."); setTenantId(info.getTenantId()); if (StringUtils.isNotBlank(info.getParentTenantId())) { setParentTenantId(info.getParentTenantId()); diff --git a/mallinkService/src/main/java/com/iformall/domain/po/base/TenantEntity.java b/mallinkService/src/main/java/com/iformall/domain/po/base/TenantEntity.java index 625cc1b3e..2b93e8a36 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/base/TenantEntity.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/base/TenantEntity.java @@ -11,7 +11,9 @@ import org.apache.commons.lang3.StringUtils; @Data @EqualsAndHashCode(callSuper = true) public class TenantEntity extends BaseEntity { - @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") + private static final long serialVersionUID = 1441638860618733611L; + + @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") private String tenantId; @io.swagger.annotations.ApiModelProperty(value="父租户ID",name="parentTenantId") 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 244c2338c..71d5cae38 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxScoreRulesServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxScoreRulesServiceImpl.java @@ -450,7 +450,7 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { private int bindCarAddScore(WxCUserCar userCar) { int addScoreNumber = 0; // 1. 获取score rules - WxScoreRules scoreRules = getScoreRules(userCar.getTenantInfo()); + WxScoreRules scoreRules = getScoreRules(userCar); // 2. 获取成长值 addScoreNumber = scoreRules.getRule(EnumScoreType.BIND_CAR,WxScoreRules.SCORE); @@ -459,7 +459,7 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { updateScore(userCar.getCUserId(), addScoreNumber); // 4. 记录历史 - recordScoreHistory(addScoreNumber, userCar.getTenantInfo(), userCar.getCUserId(), EnumScoreType.BIND_CAR); + recordScoreHistory(addScoreNumber, userCar, userCar.getCUserId(), EnumScoreType.BIND_CAR); return addScoreNumber; } @@ -552,7 +552,7 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { } // 2. 记录历史 - recordReduceScoreHistory(scoreNum, reason, userInfo.getTenantInfo(), userInfo.getId(), EnumScoreType.MEM_REDUCE); + recordReduceScoreHistory(scoreNum, reason, userInfo, userInfo.getId(), EnumScoreType.MEM_REDUCE); return score; } diff --git a/mallinkService/src/main/java/com/iformall/utils/CreditUtil.java b/mallinkService/src/main/java/com/iformall/utils/CreditUtil.java index ab8cd049e..21aa58678 100644 --- a/mallinkService/src/main/java/com/iformall/utils/CreditUtil.java +++ b/mallinkService/src/main/java/com/iformall/utils/CreditUtil.java @@ -103,14 +103,14 @@ public class CreditUtil { if(Objects.isNull(wxCUserBasicInfo.getScoreDate())) { //设置过生日的用户 if (Objects.nonNull(wxCUserBasicInfo.getBirthdate()) && DateUtils.birthdaysBetween(wxCUserBasicInfo.getBirthdate()) == 0) { - birthdayScale = getBirthdayScoreScale(wxCUserBasicInfo.getTenantInfo(), wxScoreRulesService); + birthdayScale = getBirthdayScoreScale(wxCUserBasicInfo, wxScoreRulesService); } else { log.info("积分倍率计算:未设置生日或生日条件未匹配={}", wxCUserBasicInfo.getScoreDate()); } } else { //发过生日券的用户或者享受过生日积分倍率的用户 if (Objects.nonNull(wxCUserBasicInfo.getScoreDate()) && DateUtils.birthdaysBetween(wxCUserBasicInfo.getScoreDate()) == 0) { - birthdayScale = getBirthdayScoreScale(wxCUserBasicInfo.getTenantInfo(), wxScoreRulesService); + birthdayScale = getBirthdayScoreScale(wxCUserBasicInfo, wxScoreRulesService); } } diff --git a/mallinkService/src/main/resources/mapper/WxBuserMapper.xml b/mallinkService/src/main/resources/mapper/WxBuserMapper.xml index d1901bdf3..b7d62466c 100644 --- a/mallinkService/src/main/resources/mapper/WxBuserMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxBuserMapper.xml @@ -4,6 +4,7 @@ + @@ -50,7 +51,7 @@ - `id`,`tenant_id`,`open_id`,`union_id`,`nick_name`,`gender`,`avatar_url`,`phone`,`pure_phone`, + `id`,`tenant_id`,`parent_tenant_id`,`open_id`,`union_id`,`nick_name`,`gender`,`avatar_url`,`phone`,`pure_phone`, `city`,`province`,`language`,`country_code`,`register_ip`,`verify_code_phone`, `qrcode_source`,`scene`,`scene_address`,`session_key`,`score`, `update_date`,`create_date`,`app_id`,`token`,`expire_time`,`latitude`, `longitude`, @@ -70,6 +71,10 @@ and `tenant_id`= #{tenantId} + + and `parent_tenant_id`= #{parentTenantId} + + and `open_id` = #{openId} diff --git a/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml b/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml index d5da0055c..6021edd5d 100644 --- a/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml @@ -131,7 +131,7 @@ c.`id`,c.`phone`,cb.`birthdate`,cb.`education`,cb.`sex`,cb.`email`,cb.`address`,cb.`poins`,cb.`tag_id`, - cb.`create_date`,cb.`update_date`,c.`tenant_id`,cb.`name`,cb.level,cb.nick_name,`cb.act_record` + cb.`create_date`,cb.`update_date`,c.`tenant_id`,cb.`name`,cb.`level`,cb.`nick_name`,cb.`act_record`,cb.`parent_tenant_id` @@ -225,7 +225,7 @@ cub.id,cub.phone,cub.birthdate,cub.education,cub.sex,cub.email,cub.address,cub.poins,cub.tag_id, - cub.create_date,cub.update_date,cub.tenant_id,cub.name,cub.level,cub.nick_name,cub.score_date + cub.create_date,cub.update_date,cub.tenant_id,cub.name,cub.level,cub.nick_name,cub.score_date,cub.parent_tenant_id