| @@ -92,7 +92,7 @@ public class WxCUserBasicInfoController extends BaseController { | |||
| info.setLevel(WxLevelConfigService.DEFAULT_LEVEL); | |||
| } else { | |||
| info.setLevel(WxLevelConfigService.DEFAULT_LEVEL); | |||
| List<WxLevelConfig> levelList = wxLevelConfigService.getByTenantInfo(info.getTenantInfo()); | |||
| List<WxLevelConfig> 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<Long> ids = JSONObject.parseArray(uTag.getTags(), Long.class); | |||
| info.setTagsList(wxCUserTagsService.findTagList(info.getTenantInfo(), ids)); | |||
| info.setTagsList(wxCUserTagsService.findTagList(info, ids)); | |||
| } | |||
| } | |||
| } | |||
| @@ -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; | |||
| } | |||
| @@ -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`; | |||
| 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-支持)'; | |||
| @@ -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) { | |||
| } | |||
| } | |||
| @@ -9,27 +9,38 @@ public class TenantThreadLocal { | |||
| //private static ThreadLocal<String> parentLocal = new ThreadLocal<String>(); | |||
| 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; | |||
| } | |||
| } | |||
| @@ -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; | |||
| @@ -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; | |||
| @@ -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; | |||
| @@ -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; | |||
| @@ -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<WxMallBuilding> buildings; | |||
| @@ -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()); | |||
| @@ -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") | |||
| @@ -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; | |||
| } | |||
| @@ -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); | |||
| } | |||
| } | |||
| @@ -4,6 +4,7 @@ | |||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxBuser"> | |||
| <id column="id" jdbcType="BIGINT" property="id"/> | |||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | |||
| <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/> | |||
| <result column="open_id" jdbcType="VARCHAR" property="openId"/> | |||
| <result column="union_id" jdbcType="VARCHAR" property="unionId"/> | |||
| <result column="nick_name" jdbcType="VARCHAR" property="nickName"/> | |||
| @@ -50,7 +51,7 @@ | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `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} | |||
| </if> | |||
| <if test=" null != parentTenantId "> | |||
| and `parent_tenant_id`= #{parentTenantId} | |||
| </if> | |||
| <if test=" null != openId "> | |||
| and `open_id` = #{openId} | |||
| </if> | |||
| @@ -131,7 +131,7 @@ | |||
| <sql id="allUserColumns"> | |||
| 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` | |||
| </sql> | |||
| <update id="updateScore" parameterType="com.iformall.domain.po.WxCUserBasicInfo"> | |||
| @@ -225,7 +225,7 @@ | |||
| <sql id="allColumnsOfScoreList"> | |||
| 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 | |||
| </sql> | |||
| <select id="findListByScore" parameterType="com.iformall.domain.dto.WxCUserBasicInfoDto" resultMap="BaseResultMap"> | |||
| @@ -354,6 +354,7 @@ | |||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/> | |||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/> | |||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | |||
| <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/> | |||
| <result column="name" jdbcType="VARCHAR" property="name"/> | |||
| <result column="level" jdbcType="VARCHAR" property="level"/> | |||
| <result column="nick_name" jdbcType="VARCHAR" property="nickName"/> | |||
| @@ -365,7 +366,7 @@ | |||
| <sql id="allVoColumns"> | |||
| cu.`id`,cu.`phone`,cu.`birthdate`,cu.`education`,cu.`sex`,cu.`email`,cu.`address`,cu.`poins`,cu.`tag_id`, | |||
| cu.`create_date`,cu.`update_date`,cu.`tenant_id`,cu.`name`,cu.`level`,cu.`nick_name`, | |||
| cut.`tags`,cu.`credit`,cu.`active_time`,cu.`act_record` | |||
| cut.`tags`,cu.`credit`,cu.`active_time`,cu.`act_record`,cu.`parent_tenant_id` | |||
| </sql> | |||
| <sql id="dynamicVoWhereConditions"> | |||
| @@ -35,6 +35,7 @@ | |||
| <result column="group_support" jdbcType="INTEGER" property="groupSupport"/> | |||
| <result column="latitude" jdbcType="DECIMAL" property="latitude"/> | |||
| <result column="longitude" jdbcType="DECIMAL" property="longitude"/> | |||
| <result column="live_support" jdbcType="INTEGER" property="liveSupport"/> | |||
| </resultMap> | |||
| @@ -44,7 +45,7 @@ | |||
| `img_url`,`img_url_h`, `weap_note`, `img_qrcode_weapp`, `img_qrcode_wemp`, | |||
| `weapp_share_title`,`weapp_share_cover_img`, `pos_qrcode_rule`, | |||
| `sale_type`, `valid_start`, `valid_end`,`business_hours`,`introduction`,`img`, | |||
| `group_support`,`latitude`,`longitude` | |||
| `group_support`,`latitude`,`longitude`,`live_support` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||