| @@ -0,0 +1,3 @@ | |||||
| ALTER TABLE `wx_user_channel` | |||||
| DROP INDEX `scene_address_index`, | |||||
| ADD UNIQUE INDEX `scene_address_index`(`scene_address`) USING BTREE; | |||||
| @@ -86,7 +86,9 @@ public class WxGameController extends BaseController { | |||||
| public ResultData getCount(String gameId) { | public ResultData getCount(String gameId) { | ||||
| try { | try { | ||||
| Long gameIdL = Long.valueOf(gameId); | Long gameIdL = Long.valueOf(gameId); | ||||
| return wxGameService.getCount(gameIdL,getMemberId()); | |||||
| ResultData resultData = wxGameService.getCount(gameIdL, getMemberId()); | |||||
| logger.info("游戏次数详情-----"+resultData.data.toString()); | |||||
| return resultData; | |||||
| } catch (Exception e){ | } catch (Exception e){ | ||||
| e.printStackTrace(); | e.printStackTrace(); | ||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | ||||
| @@ -222,9 +222,6 @@ public class WxUserGrantController extends BaseController { | |||||
| String session_key = null; | String session_key = null; | ||||
| String openId = null; | String openId = null; | ||||
| String unionId = null; | String unionId = null; | ||||
| boolean boolHaveUnionId = false; | |||||
| boolean boolFindByUnionId = false; | |||||
| Long userId = null; | |||||
| try { | try { | ||||
| WxMaJscode2SessionResult session = wxMaService.jsCode2SessionInfo(code); | WxMaJscode2SessionResult session = wxMaService.jsCode2SessionInfo(code); | ||||
| @@ -237,9 +234,6 @@ public class WxUserGrantController extends BaseController { | |||||
| session_key = session.getSessionKey(); | session_key = session.getSessionKey(); | ||||
| openId = session.getOpenid(); | openId = session.getOpenid(); | ||||
| unionId = session.getUnionid(); | unionId = session.getUnionid(); | ||||
| // if (StringUtils.isNotBlank(unionId)) { | |||||
| // boolHaveUnionId = true; | |||||
| // } | |||||
| logger.info("session_key: " + session_key + ", openId: " + openId + ", unionId: " + unionId); | logger.info("session_key: " + session_key + ", openId: " + openId + ", unionId: " + unionId); | ||||
| resultMap.put("openId", openId); | resultMap.put("openId", openId); | ||||
| @@ -249,75 +243,31 @@ public class WxUserGrantController extends BaseController { | |||||
| } | } | ||||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | ||||
| request.setAttribute(Constant.TENANT_ID, wxMall.getTenantId()); | |||||
| request.setAttribute(Constant.PARENT_TENANT_ID, wxMall.getParentTenantId()); | |||||
| String ipaddress = IPUtil.getIpAddr(request); | String ipaddress = IPUtil.getIpAddr(request); | ||||
| WxCUser newUser = new WxCUser(); | WxCUser newUser = new WxCUser(); | ||||
| newUser.updateTenantInfo(wxMall.getTenantInfo()); | newUser.updateTenantInfo(wxMall.getTenantInfo()); | ||||
| newUser.setAppId(appId); | newUser.setAppId(appId); | ||||
| newUser.setOpenId(openId); | newUser.setOpenId(openId); | ||||
| if (boolHaveUnionId) { | |||||
| newUser.setUnionId(unionId); | |||||
| } | |||||
| WxCUser oldUser = null; | |||||
| // if (boolHaveUnionId) { | |||||
| // // 优先根据unionId查询 | |||||
| // WxCUser userQ = new WxCUser(); | |||||
| // userQ.updateTenantInfo(wxMall.getTenantInfo()); | |||||
| // userQ.setUnionId(unionId); | |||||
| // oldUser = wxCUserService.getByObject(userQ); | |||||
| // if(oldUser != null) { | |||||
| // boolFindByUnionId = true; | |||||
| // } | |||||
| // } | |||||
| if (oldUser == null) { | |||||
| oldUser = wxCUserService.getByOpenId(newUser); | |||||
| } | |||||
| WxCUser oldUser = wxCUserService.getByOpenId(newUser); | |||||
| if (oldUser != null) { | if (oldUser != null) { | ||||
| // 已有用户 | // 已有用户 | ||||
| token = oldUser.createToken(new Date(),oldUser.getTenantId()); | token = oldUser.createToken(new Date(),oldUser.getTenantId()); | ||||
| resultMap.put("token", token); | resultMap.put("token", token); | ||||
| request.setAttribute(Constant.LOGIN_USER_KEY, oldUser.getId()); | |||||
| request.setAttribute(Constant.TENANT_ID, oldUser.getTenantId()); | |||||
| if(StringUtils.isBlank(oldUser.getParentTenantId()) && StringUtils.isNotBlank(wxMall.getParentTenantId())){ | if(StringUtils.isBlank(oldUser.getParentTenantId()) && StringUtils.isNotBlank(wxMall.getParentTenantId())){ | ||||
| oldUser.setParentTenantId(wxMall.getParentTenantId()); | oldUser.setParentTenantId(wxMall.getParentTenantId()); | ||||
| } | } | ||||
| if(StringUtils.isNotBlank(oldUser.getParentTenantId())){ | |||||
| request.setAttribute(Constant.PARENT_TENANT_ID, oldUser.getParentTenantId()); | |||||
| } | |||||
| // 老用户,给出来已选中的mall | |||||
| // if (mallList != null) { | |||||
| // WxMall selectedMall = null; | |||||
| // if (StringUtils.isNotBlank(oldUser.getParentTenantId())) { | |||||
| // final String lastSubTenant = oldUser.getTenantId(); | |||||
| // List<WxMall> selMallList = mallList.stream().filter(ml -> ml.getTenantId().equalsIgnoreCase(lastSubTenant)).collect(Collectors.toList()); | |||||
| // if (selMallList.size() > 0) { | |||||
| // selectedMall = selMallList.get(0); | |||||
| // } | |||||
| // } | |||||
| // if (selectedMall == null){ | |||||
| // WxMall firstMall = mallList.get(0); | |||||
| // if (firstMall != null) { | |||||
| // selectedMall = firstMall; | |||||
| // } | |||||
| // } | |||||
| // if (selectedMall != null) { | |||||
| // request.setAttribute(Constant.TENANT_ID, selectedMall.getTenantId()); | |||||
| // resultMap.put("selectedMall", selectedMall.getTenantId()); | |||||
| //// oldUser.setParentTenantId(selectedMall.getParentTenantId()); | |||||
| // } | |||||
| // } | |||||
| oldUser.setRegisterIp(ipaddress); | oldUser.setRegisterIp(ipaddress); | ||||
| oldUser.setSessionKey(session_key); | oldUser.setSessionKey(session_key); | ||||
| oldUser.setAppId(appId); | oldUser.setAppId(appId); | ||||
| oldUser.setOpenId(openId); | oldUser.setOpenId(openId); | ||||
| if (boolHaveUnionId) { | |||||
| oldUser.setUnionId(unionId); | |||||
| } | |||||
| oldUser.setUnionId(unionId); | |||||
| if (StringUtils.isNotBlank(wxAuthorizerInfo.getOpenAppid())) { | if (StringUtils.isNotBlank(wxAuthorizerInfo.getOpenAppid())) { | ||||
| oldUser.setOpenAppId(wxAuthorizerInfo.getOpenAppid()); | oldUser.setOpenAppId(wxAuthorizerInfo.getOpenAppid()); | ||||
| } | } | ||||
| @@ -326,7 +276,7 @@ public class WxUserGrantController extends BaseController { | |||||
| oldUser.setSceneAddress(sceneAddress); | oldUser.setSceneAddress(sceneAddress); | ||||
| } | } | ||||
| if (StringUtils.isBlank(oldUser.getScene()) || | if (StringUtils.isBlank(oldUser.getScene()) || | ||||
| oldUser.getScene().equals(Constant.UNDEFINED)) { // from pages/index/index onLoad.options.scene | |||||
| oldUser.getScene().equals(Constant.UNDEFINED)) { // from pages/index/index onLoad.options.scene | |||||
| oldUser.setScene(scene); | oldUser.setScene(scene); | ||||
| } | } | ||||
| if (StringUtils.isNotBlank(longitude)) { | if (StringUtils.isNotBlank(longitude)) { | ||||
| @@ -343,12 +293,14 @@ public class WxUserGrantController extends BaseController { | |||||
| } | } | ||||
| oldUser.setLoginCount(oldUser.getLoginCount() + 1); | oldUser.setLoginCount(oldUser.getLoginCount() + 1); | ||||
| oldUser.setActiveTime(new Date()); | |||||
| wxCUserService.saveOrUpdate(oldUser); | wxCUserService.saveOrUpdate(oldUser); | ||||
| request.setAttribute(Constant.LOGIN_USER_KEY, oldUser.getId()); | |||||
| // 登录后处理 | |||||
| int score = wxCUserService.actionAfterLogin(oldUser, boolFindByUnionId); | |||||
| updateCacheCUser(token, oldUser); | updateCacheCUser(token, oldUser); | ||||
| resultMap.put("score", score); | |||||
| // 登录后处理 | |||||
| wxCUserService.actionAfterLogin(oldUser); | |||||
| } else { | } else { | ||||
| // 新用户 | // 新用户 | ||||
| newUser.updateTenantInfo(wxMall.getTenantInfo()); | newUser.updateTenantInfo(wxMall.getTenantInfo()); | ||||
| @@ -356,6 +308,7 @@ public class WxUserGrantController extends BaseController { | |||||
| newUser.setParentTenantId(wxMall.getParentTenantId()); | newUser.setParentTenantId(wxMall.getParentTenantId()); | ||||
| } | } | ||||
| token = newUser.createToken(new Date(),newUser.getTenantId()); | token = newUser.createToken(new Date(),newUser.getTenantId()); | ||||
| resultMap.put("token", token); | |||||
| newUser.setRegisterIp(ipaddress); | newUser.setRegisterIp(ipaddress); | ||||
| if (StringUtils.isNotBlank(sceneAddress) && | if (StringUtils.isNotBlank(sceneAddress) && | ||||
| @@ -380,30 +333,14 @@ public class WxUserGrantController extends BaseController { | |||||
| newUser.setExtraInfo(extraInfo.toJSONString()); | newUser.setExtraInfo(extraInfo.toJSONString()); | ||||
| } | } | ||||
| newUser.setLoginCount(1); | newUser.setLoginCount(1); | ||||
| oldUser.setActiveTime(new Date()); | |||||
| wxCUserService.saveOrUpdate(newUser); | wxCUserService.saveOrUpdate(newUser); | ||||
| resultMap.put("token", token); | |||||
| request.setAttribute(Constant.LOGIN_USER_KEY, newUser.getId()); | request.setAttribute(Constant.LOGIN_USER_KEY, newUser.getId()); | ||||
| request.setAttribute(Constant.TENANT_ID, newUser.getTenantId()); | |||||
| if(StringUtils.isNotBlank(newUser.getParentTenantId())){ | |||||
| request.setAttribute(Constant.PARENT_TENANT_ID, newUser.getParentTenantId()); | |||||
| } | |||||
| // if (mallList != null) { | |||||
| // WxMall firstMall = mallList.get(0); | |||||
| // if (firstMall != null) { | |||||
| // // 默认选中第一个mall, 或者经纬度最近的那个 | |||||
| // request.setAttribute(Constant.TENANT_ID, firstMall.getTenantId()); | |||||
| // resultMap.put("selectedMall", firstMall.getTenantId()); | |||||
| // newUser.setParentTenantId(firstMall.getTenantId()); | |||||
| // } | |||||
| // } | |||||
| // 登录后处理 | |||||
| int score = wxCUserService.actionAfterLogin(newUser, null); | |||||
| resultMap.put("score", score); | |||||
| updateCacheCUser(token, newUser); | updateCacheCUser(token, newUser); | ||||
| // 登录后处理 | |||||
| wxCUserService.actionAfterLogin(newUser); | |||||
| } | } | ||||
| if (StringUtils.isBlank(token) || "null".equals(token) || "undefined".equals(token) ) { | if (StringUtils.isBlank(token) || "null".equals(token) || "undefined".equals(token) ) { | ||||
| @@ -82,6 +82,13 @@ public class BaseMyBatisConfiguration { | |||||
| wxbasicChildSharding.setCount(100); | wxbasicChildSharding.setCount(100); | ||||
| wxbasicChildSharding.setRule(EnumShardingRule.HASH.getCode()); | wxbasicChildSharding.setRule(EnumShardingRule.HASH.getCode()); | ||||
| shardingList.add(wxbasicChildSharding); | shardingList.add(wxbasicChildSharding); | ||||
| ShardingSphere wxCUserFromSharding = new ShardingSphere(); | |||||
| wxCUserFromSharding.setColumn("tenant_id"); | |||||
| wxCUserFromSharding.setTableName("wx_c_user_from"); | |||||
| wxCUserFromSharding.setCount(100); | |||||
| wxCUserFromSharding.setRule(EnumShardingRule.HASH.getCode()); | |||||
| shardingList.add(wxCUserFromSharding); | |||||
| ShardingSphere wxOrderSharding = new ShardingSphere(); | ShardingSphere wxOrderSharding = new ShardingSphere(); | ||||
| wxOrderSharding.setColumn("tenant_id"); | wxOrderSharding.setColumn("tenant_id"); | ||||
| @@ -5,7 +5,6 @@ import com.alibaba.fastjson.JSONObject; | |||||
| import com.baomidou.mybatisplus.annotation.TableField; | import com.baomidou.mybatisplus.annotation.TableField; | ||||
| import com.baomidou.mybatisplus.annotation.TableName; | import com.baomidou.mybatisplus.annotation.TableName; | ||||
| import com.fasterxml.jackson.annotation.JsonIgnore; | import com.fasterxml.jackson.annotation.JsonIgnore; | ||||
| import com.iformall.domain.po.base.BaseEntity; | |||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.domain.po.base.TenantEntityWithoutFinalTenantId; | import com.iformall.domain.po.base.TenantEntityWithoutFinalTenantId; | ||||
| @@ -0,0 +1,104 @@ | |||||
| package com.iformall.domain.po; | |||||
| import com.baomidou.mybatisplus.annotation.TableField; | |||||
| import com.baomidou.mybatisplus.annotation.TableName; | |||||
| import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | |||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import com.iformall.enums.EnumCUserFrom; | |||||
| import com.iformall.enums.EnumUserType; | |||||
| import com.iformall.enums.EnumYesOrNo; | |||||
| import lombok.Data; | |||||
| import lombok.EqualsAndHashCode; | |||||
| import lombok.ToString; | |||||
| import java.util.Date; | |||||
| @TableName(value = "wx_c_user_from") | |||||
| @JsonIgnoreProperties(ignoreUnknown = true) | |||||
| @Data | |||||
| @ToString(callSuper = true) | |||||
| @EqualsAndHashCode(callSuper = true) | |||||
| public class WxCUserFrom extends TenantEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value="cUserId",name="cUserId") | |||||
| protected Long cUserId; | |||||
| @TableField(exist = false) | |||||
| @io.swagger.annotations.ApiModelProperty(value="cUserNickName",name="cUserNickName") | |||||
| protected String cUserNickName; | |||||
| @io.swagger.annotations.ApiModelProperty(value="二维码来源,小程序",name="scene") | |||||
| private String scene; | |||||
| @io.swagger.annotations.ApiModelProperty(value="渠道,小程序",name="sceneAddress") | |||||
| private String sceneAddress; | |||||
| @TableField(exist = false) | |||||
| @io.swagger.annotations.ApiModelProperty(value="sceneAddress描述",name="sceneAddressDesc") | |||||
| private String sceneAddressDesc; | |||||
| @io.swagger.annotations.ApiModelProperty(value="EnumCUserFrom",name="fromType") | |||||
| private Integer fromType; | |||||
| @TableField(exist = false) | |||||
| @io.swagger.annotations.ApiModelProperty(value="fromType描述",name="fromTypeDesc") | |||||
| private String fromTypeDesc; | |||||
| public String getFromTypeDesc(){ | |||||
| if(this.getFromType() != null){ | |||||
| EnumCUserFrom anEnum = EnumCUserFrom.getEnum(this.getFromType()); | |||||
| if(anEnum != null){ | |||||
| fromTypeDesc = anEnum.getMessage(); | |||||
| } | |||||
| } | |||||
| return fromTypeDesc; | |||||
| } | |||||
| @io.swagger.annotations.ApiModelProperty(value="来源ID",name="fromId") | |||||
| protected Long fromId; | |||||
| @TableField(exist = false) | |||||
| @io.swagger.annotations.ApiModelProperty(value="来源Name",name="fromName") | |||||
| protected String fromName; | |||||
| @io.swagger.annotations.ApiModelProperty(value="是否新用户(0:否1:是)EnumYesOrNo",name="isNewUser") | |||||
| private Integer isNewUser; | |||||
| @TableField(exist = false) | |||||
| @io.swagger.annotations.ApiModelProperty(value="是否新用户",name="isNewUserStr") | |||||
| private String isNewUserStr; | |||||
| public String getIsNewUserStr(){ | |||||
| if(this.getIsNewUser() != null){ | |||||
| EnumYesOrNo anEnum = EnumYesOrNo.getEnum(this.getFromType()); | |||||
| if(anEnum != null){ | |||||
| isNewUserStr = anEnum.getMessage(); | |||||
| } | |||||
| } | |||||
| return isNewUserStr; | |||||
| } | |||||
| @io.swagger.annotations.ApiModelProperty(value="分享者 EnumUserType",name="shareUserType") | |||||
| private Integer shareUserType; | |||||
| @TableField(exist = false) | |||||
| @io.swagger.annotations.ApiModelProperty(value="shareUserType描述",name="shareUserType") | |||||
| private String shareUserTypeDesc; | |||||
| public String getShareUserTypeDesc(){ | |||||
| if(this.getShareUserType() != null){ | |||||
| EnumUserType anEnum = EnumUserType.getEnum(this.getFromType()); | |||||
| if(anEnum != null){ | |||||
| shareUserTypeDesc = anEnum.getMessage(); | |||||
| } | |||||
| } | |||||
| return shareUserTypeDesc; | |||||
| } | |||||
| @io.swagger.annotations.ApiModelProperty(value="分享者",name="shareUser") | |||||
| protected Long shareUser; | |||||
| @TableField(exist = false) | |||||
| @io.swagger.annotations.ApiModelProperty(value="分享者",name="shareUserName") | |||||
| protected String shareUserName; | |||||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | |||||
| private Date createDate; | |||||
| @TableField(exist = false) | |||||
| protected Date startDate; | |||||
| @TableField(exist = false) | |||||
| protected Date endDate; | |||||
| } | |||||
| @@ -8,6 +8,7 @@ import lombok.ToString; | |||||
| @ToString(callSuper = true) | @ToString(callSuper = true) | ||||
| @EqualsAndHashCode(callSuper = true) | @EqualsAndHashCode(callSuper = true) | ||||
| public class FmInsideCLoginMsg extends BaseMsg{ | public class FmInsideCLoginMsg extends BaseMsg{ | ||||
| private static final long serialVersionUID = 1L; | private static final long serialVersionUID = 1L; | ||||
| @io.swagger.annotations.ApiModelProperty(value = "租户ID", name = "tenantId") | @io.swagger.annotations.ApiModelProperty(value = "租户ID", name = "tenantId") | ||||
| @@ -17,6 +18,5 @@ public class FmInsideCLoginMsg extends BaseMsg{ | |||||
| @io.swagger.annotations.ApiModelProperty(value = "用户ID", name = "cUserId") | @io.swagger.annotations.ApiModelProperty(value = "用户ID", name = "cUserId") | ||||
| private Long cUserId; | private Long cUserId; | ||||
| @io.swagger.annotations.ApiModelProperty(value = "是否从unionId更新", name = "findByUnionId") | |||||
| private Boolean findByUnionId; | |||||
| } | } | ||||
| @@ -9,8 +9,11 @@ public enum EnumCUserFrom { | |||||
| FROM_C_USER(1,"来源于微信用户"), | FROM_C_USER(1,"来源于微信用户"), | ||||
| FROM_C_USER_BASIC_INFO(2,"来源于会员"), | FROM_C_USER_BASIC_INFO(2,"来源于会员"), | ||||
| FROM_MERCHANT(3,"来源于微信用户"), | |||||
| FROM_COUPON_CHANNEL(4,"来源于卷"), | |||||
| FROM_MERCHANT_B_USER(3,"来源于B端用户"), | |||||
| FROM_MALL_USER_INFO(4,"来源于A端用户"), | |||||
| FROM_MERCHANT(5,"来源于门店"), | |||||
| FROM_COUPON_CHANNEL(6,"来源于卷"), | |||||
| FROM_ACTIVITY(7,"来源于活动"), | |||||
| ; | ; | ||||
| public static EnumCUserFrom getEnum(Integer code) { | public static EnumCUserFrom getEnum(Integer code) { | ||||
| @@ -0,0 +1,12 @@ | |||||
| package com.iformall.mapper; | |||||
| import com.iformall.common.CommonMapper; | |||||
| import com.iformall.domain.po.WxCUserFrom; | |||||
| import java.util.List; | |||||
| public interface WxCUserFromMapper extends CommonMapper<WxCUserFrom, Long>{ | |||||
| List<WxCUserFrom> findList(WxCUserFrom record); | |||||
| } | |||||
| @@ -0,0 +1,19 @@ | |||||
| package com.iformall.service; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.WxCUserFrom; | |||||
| public interface WxCUserFromService { | |||||
| /** | |||||
| * 根据实体查询分页列表 | |||||
| * | |||||
| * @param record | |||||
| * @param pageIndex | |||||
| * @param pageSize | |||||
| * @return | |||||
| */ | |||||
| PageInfo<WxCUserFrom> listAsPage(WxCUserFrom record, Integer pageIndex, Integer pageSize); | |||||
| } | |||||
| @@ -125,14 +125,14 @@ public interface WxCUserService { | |||||
| * 登录后发消息 | * 登录后发消息 | ||||
| * @param user | * @param user | ||||
| */ | */ | ||||
| void actionMsgAfterLogin(WxCUser user, Boolean findByUnionId); | |||||
| void actionMsgAfterLogin(WxCUser user); | |||||
| /** | /** | ||||
| * 登录后处理 | * 登录后处理 | ||||
| * @param user | * @param user | ||||
| * @return | * @return | ||||
| */ | */ | ||||
| int actionAfterLogin(WxCUser user, Boolean findByUnionId); | |||||
| int actionAfterLogin(WxCUser user); | |||||
| /** | /** | ||||
| * 积分 | * 积分 | ||||
| @@ -653,6 +653,7 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService,IExc | |||||
| List<WxCUserBasicChild> childrenList = record.getChildrenList(); | List<WxCUserBasicChild> childrenList = record.getChildrenList(); | ||||
| if(childrenList != null && childrenList.size() > 0){ | if(childrenList != null && childrenList.size() > 0){ | ||||
| for (WxCUserBasicChild child:childrenList) { | for (WxCUserBasicChild child:childrenList) { | ||||
| child.setCUserId(record.getId()); | |||||
| wxCUserBasicChildService.saveOrUpdate(child); | wxCUserBasicChildService.saveOrUpdate(child); | ||||
| } | } | ||||
| } | } | ||||
| @@ -0,0 +1,29 @@ | |||||
| package com.iformall.service.impl; | |||||
| import com.github.pagehelper.PageHelper; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.*; | |||||
| import com.iformall.mapper.*; | |||||
| import com.iformall.service.*; | |||||
| import lombok.extern.slf4j.Slf4j; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | |||||
| @Service | |||||
| @Slf4j | |||||
| public class WxCUserFromServiceImpl implements WxCUserFromService { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| WxCUserFromMapper wxCUserFromMapper; | |||||
| @Override | |||||
| public PageInfo<WxCUserFrom> listAsPage(WxCUserFrom record, Integer pageIndex, Integer pageSize) { | |||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCUserFromMapper.findList(record)); | |||||
| } | |||||
| } | |||||
| @@ -88,19 +88,19 @@ public class WxCUserServiceImpl implements WxCUserService { | |||||
| Date curr = new Date(); | Date curr = new Date(); | ||||
| if (user.getId() == null) { | if (user.getId() == null) { | ||||
| // 检查用户是否已有同一微信开放平台账号 | // 检查用户是否已有同一微信开放平台账号 | ||||
| if(StringUtils.isNotBlank(user.getUnionId()) && StringUtils.isNotBlank(user.getOpenAppId())) { | |||||
| WxCUser oldUser = wxCUserMapper.findByUnionId(user); | |||||
| if(oldUser != null) { | |||||
| // 已有,更新 | |||||
| user.setId(oldUser.getId()); | |||||
| user.setLoginCount(oldUser.getLoginCount()==null?0:oldUser.getLoginCount() + 1); | |||||
| user.setUpdateDate(curr); | |||||
| user.updateTenantInfo(oldUser); | |||||
| // TODO 是否其他信息需要更新 | |||||
| ret = wxCUserMapper.updateById(user); | |||||
| return ret; | |||||
| } | |||||
| } | |||||
| // if(StringUtils.isNotBlank(user.getUnionId()) && StringUtils.isNotBlank(user.getOpenAppId())) { | |||||
| // WxCUser oldUser = wxCUserMapper.findByUnionId(user); | |||||
| // if(oldUser != null) { | |||||
| // // 已有,更新 | |||||
| // user.setId(oldUser.getId()); | |||||
| // user.setLoginCount(oldUser.getLoginCount()==null?0:oldUser.getLoginCount() + 1); | |||||
| // user.setUpdateDate(curr); | |||||
| // user.updateTenantInfo(oldUser); | |||||
| // // TODO 是否其他信息需要更新 | |||||
| // ret = wxCUserMapper.updateById(user); | |||||
| // return ret; | |||||
| // } | |||||
| // } | |||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| user.setId(idWorker.nextId()); | user.setId(idWorker.nextId()); | ||||
| user.setLoginCount(1); | user.setLoginCount(1); | ||||
| @@ -253,18 +253,17 @@ public class WxCUserServiceImpl implements WxCUserService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void actionMsgAfterLogin(WxCUser user, Boolean findByUnionId) { | |||||
| public void actionMsgAfterLogin(WxCUser user) { | |||||
| FmInsideCLoginMsg loginMsg = new FmInsideCLoginMsg(); | FmInsideCLoginMsg loginMsg = new FmInsideCLoginMsg(); | ||||
| loginMsg.setMsgType(EnumMsgRecordType.INSIDE_C_LOGIN.getCode()); | loginMsg.setMsgType(EnumMsgRecordType.INSIDE_C_LOGIN.getCode()); | ||||
| loginMsg.updateTenantInfo(user); | loginMsg.updateTenantInfo(user); | ||||
| loginMsg.setCUserId(user.getId()); | loginMsg.setCUserId(user.getId()); | ||||
| loginMsg.setFindByUnionId(findByUnionId); | |||||
| mqBaseProducer.sendMessage(loginMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | mqBaseProducer.sendMessage(loginMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | ||||
| } | } | ||||
| @Override | @Override | ||||
| public int actionAfterLogin(WxCUser user, Boolean findByUnionId) { | |||||
| public int actionAfterLogin(WxCUser user) { | |||||
| int score = 0; | int score = 0; | ||||
| int credit = 0; | int credit = 0; | ||||
| // 成长值 | // 成长值 | ||||
| @@ -291,43 +290,28 @@ public class WxCUserServiceImpl implements WxCUserService { | |||||
| if (wxCUserBasicInfo != null) { | if (wxCUserBasicInfo != null) { | ||||
| WxCUserBasicInfo basicInfo = new WxCUserBasicInfo(); | WxCUserBasicInfo basicInfo = new WxCUserBasicInfo(); | ||||
| basicInfo.setId(wxCUserBasicInfo.getId()); | basicInfo.setId(wxCUserBasicInfo.getId()); | ||||
| basicInfo.setFinalTenantId(user.getFinalTenantId()); | |||||
| basicInfo.setActiveTime(new Date()); | basicInfo.setActiveTime(new Date()); | ||||
| int loingcount = 0; | int loingcount = 0; | ||||
| try { | try { | ||||
| loingcount = Integer.parseInt(wxCUserBasicInfo.getLoginCount().toString()); | loingcount = Integer.parseInt(wxCUserBasicInfo.getLoginCount().toString()); | ||||
| }catch(Exception e) { | }catch(Exception e) { | ||||
| } | } | ||||
| basicInfo.setFinalTenantId(user.getFinalTenantId()); | |||||
| basicInfo.setLoginCount(loingcount+1); | basicInfo.setLoginCount(loingcount+1); | ||||
| wxCUserBasicInfoService.update(basicInfo); | wxCUserBasicInfoService.update(basicInfo); | ||||
| wxCUserTagsService.triggerAssignTags(EnumAssignTagsTrigger.ASSIGN_TAGS_TRIGGER_LOGIN, user,user); | |||||
| } | } | ||||
| WxCUser wxCUser = getById(user.getId(),user.getTenantId()); | |||||
| if (wxCUser != null) { | |||||
| WxCUser cUser = new WxCUser(); | |||||
| cUser.setId(user.getId()); | |||||
| cUser.setActiveTime(new Date()); | |||||
| cUser.setTenantId(user.getTenantId()); | |||||
| saveOrUpdate(cUser); | |||||
| } | |||||
| wxCUserTagsService.triggerAssignTags(EnumAssignTagsTrigger.ASSIGN_TAGS_TRIGGER_LOGIN, wxCUser,user); | |||||
| } | |||||
| // 用户从unionId来的,可能会有重复 | |||||
| // if(findByUnionId != null) { | |||||
| // if(findByUnionId) { | |||||
| // WxCUser userQ = new WxCUser(); | |||||
| // userQ.setOpenAppId(user.getAppId()); | |||||
| // userQ.setOpenId(user.getOpenId()); | |||||
| // List<WxCUser> userList = wxCUserMapper.findList(userQ); | |||||
| // if(userList.size() > 1) { | |||||
| // for(WxCUser tempUser: userList) { | |||||
| // if(tempUser.getUnionId() == null) { | |||||
| // // 删除 无unionId的用户 | |||||
| // wxCUserMapper.deleteById(tempUser.getId()); | |||||
| // } | |||||
| // } | |||||
| // } | |||||
| // WxCUser wxCUser = getById(user.getId(),user.getTenantId()); | |||||
| // if (wxCUser != null) { | |||||
| // WxCUser cUser = new WxCUser(); | |||||
| // cUser.setId(user.getId()); | |||||
| // cUser.setActiveTime(new Date()); | |||||
| // cUser.setTenantId(user.getTenantId()); | |||||
| // saveOrUpdate(cUser); | |||||
| // } | // } | ||||
| // } | |||||
| } | |||||
| String key = Constant.tokenPrev + user.getToken(); | String key = Constant.tokenPrev + user.getToken(); | ||||
| if(baseCUserTokenRedisTemplate.hasKey(key)){ | if(baseCUserTokenRedisTemplate.hasKey(key)){ | ||||
| baseCUserTokenRedisTemplate.delete(key); | baseCUserTokenRedisTemplate.delete(key); | ||||
| @@ -349,10 +333,7 @@ public class WxCUserServiceImpl implements WxCUserService { | |||||
| wxCreditHistory.setChangePurpose(enumScoreType.getMessage()); | wxCreditHistory.setChangePurpose(enumScoreType.getMessage()); | ||||
| wxCreditHistory.setOperatorType(EnumUserType.CUSERBASIC.getCode()); | wxCreditHistory.setOperatorType(EnumUserType.CUSERBASIC.getCode()); | ||||
| wxCreditHistory.setOperatorId(user.getUserId()); | wxCreditHistory.setOperatorId(user.getUserId()); | ||||
| // wxCreditHistory.setCreditNum(user.getCredit()); | |||||
| // wxCreditHistory.setCreditAmount(user.getCredit()); | |||||
| WxCreditHistory record = wxCreditHistoryService.saveOrUpdate(wxCreditHistory); | WxCreditHistory record = wxCreditHistoryService.saveOrUpdate(wxCreditHistory); | ||||
| // user.setCredit(record.getCreditAmount()); | |||||
| return record.getCreditAmount(); | return record.getCreditAmount(); | ||||
| } | } | ||||
| @@ -40,7 +40,6 @@ public class FmInsideCLoginMsgServiceImpl implements MsgSendService { | |||||
| logger.error("用户ID未找到: " + msg.getCUserId()); | logger.error("用户ID未找到: " + msg.getCUserId()); | ||||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY.getCode(), "用户ID未找到" + msg.getCUserId()); | throw new MallinkException(ErrorCode.USER_IS_EMPTY.getCode(), "用户ID未找到" + msg.getCUserId()); | ||||
| } | } | ||||
| userService.actionAfterLogin(user, msg.getFindByUnionId()); | |||||
| userService.actionAfterLogin(user); | |||||
| } | } | ||||
| } | } | ||||
| @@ -0,0 +1,109 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||||
| <mapper namespace="com.iformall.mapper.WxCUserFromMapper"> | |||||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCUserFrom"> | |||||
| <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="c_user_id" jdbcType="BIGINT" property="cUserId" /> | |||||
| <result column="c_user_nick_name" jdbcType="VARCHAR" property="cUserNickName" /> | |||||
| <result column="scene" jdbcType="VARCHAR" property="scene"/> | |||||
| <result column="scene_address" jdbcType="VARCHAR" property="sceneAddress"/> | |||||
| <result column="scene_address_desc" jdbcType="VARCHAR" property="sceneAddressDesc" /> | |||||
| <result column="from_type" jdbcType="INTEGER" property="fromType" /> | |||||
| <result column="from_id" jdbcType="BIGINT" property="fromId" /> | |||||
| <result column="from_name" jdbcType="VARCHAR" property="fromName" /> | |||||
| <result column="is_new_user" jdbcType="INTEGER" property="isNewUser" /> | |||||
| <result column="share_user_type" jdbcType="INTEGER" property="shareUserType" /> | |||||
| <result column="share_user" jdbcType="BIGINT" property="shareUser" /> | |||||
| <result column="share_user_name" jdbcType="VARCHAR" property="shareUserName" /> | |||||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | |||||
| </resultMap> | |||||
| <sql id="allColumns"> | |||||
| wcuf.`id`,wcuf.`tenant_id`,wcuf.`parent_tenant_id`,wcuf.`c_user_id`,wcuf.`scene`,wcuf.`scene_address`, | |||||
| wcuf.`from_type`,wcuf.`from_id`,wcuf.`is_new_user`,wcuf.`share_user_type`,wcuf.`share_user`,wcuf.`create_date` | |||||
| </sql> | |||||
| <sql id="dynamicWhereConditions"> | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> | |||||
| and wcuf.`id` = #{id} | |||||
| </if> | |||||
| <if test=" null != tenantId and '' != tenantId"> | |||||
| and wcuf.`tenant_id` = #{tenantId} | |||||
| </if> | |||||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||||
| and wcuf.`parent_tenant_id` = #{parentTenantId} | |||||
| </if> | |||||
| <if test=" null != cUserId "> | |||||
| and wcuf.`c_user_id` = #{cUserId} | |||||
| </if> | |||||
| <if test=" null != scene and '' != scene"> | |||||
| and wcuf.`scene` = #{scene} | |||||
| </if> | |||||
| <if test=" null != sceneAddress and '' != sceneAddress"> | |||||
| and wcuf.`scene_address` = #{sceneAddress} | |||||
| </if> | |||||
| <if test=" null != fromType "> | |||||
| and wcuf.`from_type` = #{fromType} | |||||
| </if> | |||||
| <if test=" null != fromId "> | |||||
| and wcuf.`from_id` = #{fromId} | |||||
| </if> | |||||
| <if test=" null != isNewUser "> | |||||
| and wcuf.`is_new_user` = #{isNewUser} | |||||
| </if> | |||||
| <if test=" null != shareUserType "> | |||||
| and wcuf.`share_user_type` = #{shareUserType} | |||||
| </if> | |||||
| <if test=" null != shareUser "> | |||||
| and wcuf.`share_user` = #{shareUser} | |||||
| </if> | |||||
| <if test=" null != startTime "> | |||||
| and wcuf.`create_date` >= #{startTime} | |||||
| </if> | |||||
| <if test=" null != endTime"> | |||||
| and wcuf.`create_date` <= #{endTime} | |||||
| </if> | |||||
| <if test=" null != ids "> | |||||
| and wcuf.id in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
| #{idItem} | |||||
| </foreach> | |||||
| </if> | |||||
| order by wcuf.`create_date` desc | |||||
| </sql> | |||||
| <select id="findList" parameterType="com.iformall.domain.po.WxCUserFrom" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> | |||||
| ,(select nick_name from wx_c_user where id = wcuf.c_user_id ) c_user_nick_name | |||||
| ,(select description from wx_user_channel where scene_address = wcuf.scene_address ) scene_address_desc | |||||
| ,case when wcuf.from_type = 1 then (select nick_name from wx_c_user where id = wcuf.from_id) | |||||
| when wcuf.from_type = 2 then (select nick_name from wx_c_user_basic_info where id = wcuf.from_id) | |||||
| when wcuf.from_type = 3 then (select name from wx_merchant_b_user where id = wcuf.from_id) | |||||
| when wcuf.from_type = 4 then (select name from mall_user_info where id = wcuf.from_id) | |||||
| when wcuf.from_type = 5 then (select name from wx_merchant where id = wcuf.from_id) | |||||
| when wcuf.from_type = 6 then (select title from wx_coupon_channel where id = wcuf.from_id) | |||||
| when wcuf.from_type = 7 then (select title from wx_activity where id = wcuf.from_id) | |||||
| else '' end from_name | |||||
| ,case when wcuf.share_user_type = 1 then (select nick_name from wx_c_user where id = wcuf.share_user) | |||||
| when wcuf.share_user_type = 2 then (select nick_name from wx_c_user_basic_info where id = wcuf.share_user) | |||||
| when wcuf.share_user_type = 3 then (select name from wx_merchant_b_user where id = wcuf.share_user) | |||||
| when wcuf.share_user_type = 4 then (select name from mall_user_info where id = wcuf.share_user) | |||||
| else '' end share_user_name | |||||
| from wx_c_user_from wcuf | |||||
| <include refid="dynamicWhereConditions" /> | |||||
| </select> | |||||
| </mapper> | |||||