| @@ -146,13 +146,43 @@ public class WxUserGrantController extends BaseController { | |||||
| Map resultMap = new HashMap(); | Map resultMap = new HashMap(); | ||||
| WxCUserFrom wxCUserFrom = new WxCUserFrom(); | |||||
| String appId = map.get("appId"); | String appId = map.get("appId"); | ||||
| String code = map.get("code"); | String code = map.get("code"); | ||||
| String sceneAddress = map.get("sceneAddress"); | String sceneAddress = map.get("sceneAddress"); | ||||
| String scene = map.get("scene"); | String scene = map.get("scene"); | ||||
| if (StringUtils.isNotBlank(scene) && | |||||
| !scene.equals(Constant.UNDEFINED)) { // from pages/index/index onLoad.options.scene | |||||
| wxCUserFrom.setScene(scene); | |||||
| } | |||||
| if (StringUtils.isNotBlank(sceneAddress) && | |||||
| !sceneAddress.equalsIgnoreCase(Constant.UNDEFINED)) { // from app.js onLaunch.options.scene | |||||
| wxCUserFrom.setSceneAddress(sceneAddress); | |||||
| } | |||||
| String longitude = map.get("longitude"); | String longitude = map.get("longitude"); | ||||
| String latitude = map.get("latitude"); | String latitude = map.get("latitude"); | ||||
| String systemInfo = map.get("systemInfo"); | String systemInfo = map.get("systemInfo"); | ||||
| try { | |||||
| String basicUserId = map.get("basicUserId"); | |||||
| String merchantId = map.get("merchantId"); | |||||
| if(StringUtils.isNotBlank(basicUserId)){ | |||||
| wxCUserFrom.setFromType(EnumCUserFrom.FROM_C_USER_BASIC_INFO.getCode()); | |||||
| wxCUserFrom.setFromId(Long.parseLong(basicUserId)); | |||||
| }else if(StringUtils.isNotBlank(merchantId)){ | |||||
| wxCUserFrom.setFromType(EnumCUserFrom.FROM_MERCHANT.getCode()); | |||||
| wxCUserFrom.setFromId(Long.parseLong(basicUserId)); | |||||
| }else{ | |||||
| } | |||||
| } catch (NumberFormatException e) { | |||||
| logger.error("分享参数错误",e); | |||||
| } | |||||
| //登录凭证不能为空 | //登录凭证不能为空 | ||||
| if (StringUtils.isBlank(appId)) { | if (StringUtils.isBlank(appId)) { | ||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "appId不能为空"); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "appId不能为空"); | ||||
| @@ -187,6 +217,7 @@ public class WxUserGrantController extends BaseController { | |||||
| if(wxMall == null){ | if(wxMall == null){ | ||||
| return new ResultData(ErrorCode.MALL_INFO_NOT_FOUND); | return new ResultData(ErrorCode.MALL_INFO_NOT_FOUND); | ||||
| } | } | ||||
| wxCUserFrom.updateTenantInfo(wxMall); | |||||
| resultMap.put("selectedMall", wxMall.getTenantId()); | resultMap.put("selectedMall", wxMall.getTenantId()); | ||||
| // 集团版,获取子集团list | // 集团版,获取子集团list | ||||
| @@ -272,17 +303,11 @@ public class WxUserGrantController extends BaseController { | |||||
| oldUser.setAppId(appId); | oldUser.setAppId(appId); | ||||
| oldUser.setOpenId(openId); | oldUser.setOpenId(openId); | ||||
| oldUser.setUnionId(unionId); | oldUser.setUnionId(unionId); | ||||
| if (StringUtils.isNotBlank(wxAuthorizerInfo.getOpenAppid())) { | if (StringUtils.isNotBlank(wxAuthorizerInfo.getOpenAppid())) { | ||||
| oldUser.setOpenAppId(wxAuthorizerInfo.getOpenAppid()); | oldUser.setOpenAppId(wxAuthorizerInfo.getOpenAppid()); | ||||
| } | } | ||||
| if (StringUtils.isBlank(oldUser.getSceneAddress()) || | |||||
| oldUser.getSceneAddress().equalsIgnoreCase(Constant.UNDEFINED)) { // from app.js onLaunch.options.scene | |||||
| oldUser.setSceneAddress(sceneAddress); | |||||
| } | |||||
| if (StringUtils.isBlank(oldUser.getScene()) || | |||||
| oldUser.getScene().equals(Constant.UNDEFINED)) { // from pages/index/index onLoad.options.scene | |||||
| oldUser.setScene(scene); | |||||
| } | |||||
| if (StringUtils.isNotBlank(longitude)) { | if (StringUtils.isNotBlank(longitude)) { | ||||
| oldUser.setLongitude(BigDecimal.valueOf(Double.valueOf(longitude))); | oldUser.setLongitude(BigDecimal.valueOf(Double.valueOf(longitude))); | ||||
| } | } | ||||
| @@ -302,8 +327,11 @@ public class WxUserGrantController extends BaseController { | |||||
| request.setAttribute(Constant.LOGIN_USER_KEY, oldUser.getId()); | request.setAttribute(Constant.LOGIN_USER_KEY, oldUser.getId()); | ||||
| updateCacheCUser(token, oldUser); | updateCacheCUser(token, oldUser); | ||||
| // 登录后处理 | // 登录后处理 | ||||
| wxCUserService.actionMsgAfterLogin(oldUser); | |||||
| wxCUserFrom.setCUserId(oldUser.getId()); | |||||
| wxCUserFrom.setIsNewUser(EnumYesOrNo.NO.getCode()); | |||||
| wxCUserService.actionMsgAfterLogin(wxCUserFrom); | |||||
| } else { | } else { | ||||
| // 新用户 | // 新用户 | ||||
| @@ -315,14 +343,9 @@ public class WxUserGrantController extends BaseController { | |||||
| resultMap.put("token", token); | resultMap.put("token", token); | ||||
| newUser.setRegisterIp(ipaddress); | newUser.setRegisterIp(ipaddress); | ||||
| if (StringUtils.isNotBlank(sceneAddress) && | |||||
| !sceneAddress.equalsIgnoreCase(Constant.UNDEFINED)) { // from app.js onLaunch.options.scene | |||||
| newUser.setSceneAddress(sceneAddress); | |||||
| } | |||||
| if (StringUtils.isNotBlank(scene) && | |||||
| !scene.equals(Constant.UNDEFINED)) { // from pages/index/index onLoad.options.scene | |||||
| newUser.setScene(scene); | |||||
| } | |||||
| newUser.setSceneAddress(wxCUserFrom.getSceneAddress()); | |||||
| newUser.setScene(wxCUserFrom.getScene()); | |||||
| newUser.setSessionKey(session_key); | newUser.setSessionKey(session_key); | ||||
| if (StringUtils.isNotBlank(longitude)) { | if (StringUtils.isNotBlank(longitude)) { | ||||
| newUser.setLongitude(BigDecimal.valueOf(Double.valueOf(longitude))); | newUser.setLongitude(BigDecimal.valueOf(Double.valueOf(longitude))); | ||||
| @@ -343,7 +366,9 @@ public class WxUserGrantController extends BaseController { | |||||
| updateCacheCUser(token, newUser); | updateCacheCUser(token, newUser); | ||||
| // 登录后处理 | // 登录后处理 | ||||
| wxCUserService.actionMsgAfterLogin(newUser); | |||||
| wxCUserFrom.setCUserId(newUser.getId()); | |||||
| wxCUserFrom.setIsNewUser(EnumYesOrNo.YES.getCode()); | |||||
| wxCUserService.actionMsgAfterLogin(wxCUserFrom); | |||||
| } | } | ||||
| @@ -20,6 +20,8 @@ import java.util.Date; | |||||
| @EqualsAndHashCode(callSuper = true) | @EqualsAndHashCode(callSuper = true) | ||||
| public class WxCUserFrom extends TenantEntity { | public class WxCUserFrom extends TenantEntity { | ||||
| protected Long id; | |||||
| @io.swagger.annotations.ApiModelProperty(value="cUserId",name="cUserId") | @io.swagger.annotations.ApiModelProperty(value="cUserId",name="cUserId") | ||||
| protected Long cUserId; | protected Long cUserId; | ||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| @@ -1,5 +1,6 @@ | |||||
| package com.iformall.domain.po.msg; | package com.iformall.domain.po.msg; | ||||
| import com.iformall.domain.po.WxCUserFrom; | |||||
| import lombok.Data; | import lombok.Data; | ||||
| import lombok.EqualsAndHashCode; | import lombok.EqualsAndHashCode; | ||||
| import lombok.ToString; | import lombok.ToString; | ||||
| @@ -11,15 +12,7 @@ public class FmInsideCLoginMsg extends BaseMsg{ | |||||
| private static final long serialVersionUID = 1L; | private static final long serialVersionUID = 1L; | ||||
| @io.swagger.annotations.ApiModelProperty(value = "id", name = "id") | |||||
| private Long id; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "租户ID", name = "tenantId") | |||||
| private String tenantId; | |||||
| @io.swagger.annotations.ApiModelProperty(value="父租户id",name="parentTenantId") | |||||
| private String parentTenantId; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "用户ID", name = "userId") | |||||
| private Long userId; | |||||
| private WxCUserFrom wxCUserFrom; | |||||
| } | } | ||||
| @@ -16,4 +16,5 @@ public interface WxCUserFromService { | |||||
| PageInfo<WxCUserFrom> listAsPage(WxCUserFrom record, Integer pageIndex, Integer pageSize); | PageInfo<WxCUserFrom> listAsPage(WxCUserFrom record, Integer pageIndex, Integer pageSize); | ||||
| void save(WxCUserFrom wxCUserFrom); | |||||
| } | } | ||||
| @@ -4,6 +4,7 @@ import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.dto.WxCUserBasicInfoDto; | import com.iformall.domain.dto.WxCUserBasicInfoDto; | ||||
| import com.iformall.domain.po.WxAuthorizerInfo; | import com.iformall.domain.po.WxAuthorizerInfo; | ||||
| import com.iformall.domain.po.WxCUser; | import com.iformall.domain.po.WxCUser; | ||||
| import com.iformall.domain.po.WxCUserFrom; | |||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.domain.vo.UserCountVo; | import com.iformall.domain.vo.UserCountVo; | ||||
| import com.iformall.enums.EnumScoreType; | import com.iformall.enums.EnumScoreType; | ||||
| @@ -125,7 +126,7 @@ public interface WxCUserService { | |||||
| * 登录后发消息 | * 登录后发消息 | ||||
| * @param user | * @param user | ||||
| */ | */ | ||||
| void actionMsgAfterLogin(WxCUser user); | |||||
| void actionMsgAfterLogin(WxCUserFrom wxCUserFrom); | |||||
| /** | /** | ||||
| * 登录后处理 | * 登录后处理 | ||||
| @@ -3,6 +3,7 @@ package com.iformall.service.impl; | |||||
| import com.github.pagehelper.PageHelper; | import com.github.pagehelper.PageHelper; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.common.IdWorker; | |||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.mapper.*; | import com.iformall.mapper.*; | ||||
| import com.iformall.service.*; | import com.iformall.service.*; | ||||
| @@ -12,6 +13,8 @@ import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import java.util.Date; | |||||
| @Service | @Service | ||||
| @Slf4j | @Slf4j | ||||
| public class WxCUserFromServiceImpl implements WxCUserFromService { | public class WxCUserFromServiceImpl implements WxCUserFromService { | ||||
| @@ -26,4 +29,14 @@ public class WxCUserFromServiceImpl implements WxCUserFromService { | |||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCUserFromMapper.findList(record)); | return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCUserFromMapper.findList(record)); | ||||
| } | } | ||||
| @Override | |||||
| public void save(WxCUserFrom wxCUserFrom) { | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| wxCUserFrom.setId(idWorker.nextId()); | |||||
| if(wxCUserFrom.getCreateDate() == null){ | |||||
| wxCUserFrom.setCreateDate(new Date()); | |||||
| } | |||||
| wxCUserFromMapper.insert(wxCUserFrom); | |||||
| } | |||||
| } | } | ||||
| @@ -5,10 +5,7 @@ import com.github.pagehelper.PageHelper; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.common.IdWorker; | import com.iformall.common.IdWorker; | ||||
| import com.iformall.domain.dto.WxCUserBasicInfoDto; | import com.iformall.domain.dto.WxCUserBasicInfoDto; | ||||
| import com.iformall.domain.po.WxAuthorizerInfo; | |||||
| import com.iformall.domain.po.WxCUser; | |||||
| import com.iformall.domain.po.WxCUserBasicInfo; | |||||
| import com.iformall.domain.po.WxCreditHistory; | |||||
| import com.iformall.domain.po.*; | |||||
| import com.iformall.domain.po.base.BaseCUserEntity; | import com.iformall.domain.po.base.BaseCUserEntity; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.domain.po.msg.FmInsideCLoginMsg; | import com.iformall.domain.po.msg.FmInsideCLoginMsg; | ||||
| @@ -253,12 +250,12 @@ public class WxCUserServiceImpl implements WxCUserService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void actionMsgAfterLogin(WxCUser user) { | |||||
| public void actionMsgAfterLogin(WxCUserFrom wxCUserFrom) { | |||||
| wxCUserFrom.setCreateDate(new Date()); | |||||
| FmInsideCLoginMsg loginMsg = new FmInsideCLoginMsg(); | FmInsideCLoginMsg loginMsg = new FmInsideCLoginMsg(); | ||||
| loginMsg.setId(user.getId()); | |||||
| loginMsg.updateTenantInfo(wxCUserFrom); | |||||
| loginMsg.setMsgType(EnumMsgRecordType.INSIDE_C_LOGIN.getCode()); | loginMsg.setMsgType(EnumMsgRecordType.INSIDE_C_LOGIN.getCode()); | ||||
| loginMsg.updateTenantInfo(user); | |||||
| loginMsg.setUserId(user.getUserId()); | |||||
| loginMsg.setWxCUserFrom(wxCUserFrom); | |||||
| mqBaseProducer.sendMessage(loginMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | mqBaseProducer.sendMessage(loginMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | ||||
| } | } | ||||
| @@ -8,10 +8,7 @@ import com.iformall.domain.po.msg.FmInsideCouponVerifyMsg; | |||||
| import com.iformall.enums.EnumAssignTagsTrigger; | import com.iformall.enums.EnumAssignTagsTrigger; | ||||
| import com.iformall.enums.EnumScoreType; | import com.iformall.enums.EnumScoreType; | ||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.service.WxCUserService; | |||||
| import com.iformall.service.WxCouponOrderService; | |||||
| import com.iformall.service.WxMerchantBUserService; | |||||
| import com.iformall.service.WxScoreRulesService; | |||||
| import com.iformall.service.*; | |||||
| import com.iformall.service.msg.MsgSendService; | import com.iformall.service.msg.MsgSendService; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| @@ -32,14 +29,26 @@ public class FmInsideCLoginMsgServiceImpl implements MsgSendService { | |||||
| @Autowired | @Autowired | ||||
| private WxCUserService userService; | private WxCUserService userService; | ||||
| @Autowired | |||||
| private WxCUserFromService wxCUserFromService; | |||||
| @Override | @Override | ||||
| public void send(BaseMsg baseMsg) throws Exception { | public void send(BaseMsg baseMsg) throws Exception { | ||||
| FmInsideCLoginMsg msg = (FmInsideCLoginMsg)baseMsg; | FmInsideCLoginMsg msg = (FmInsideCLoginMsg)baseMsg; | ||||
| WxCUser user = userService.getById(msg.getId(),msg.getTenantId()); | |||||
| if(user == null) { | |||||
| logger.error("用户ID未找到: " + msg.getId()); | |||||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY.getCode(), "用户ID未找到" + msg.getId()); | |||||
| if(msg.getWxCUserFrom() != null && msg.getWxCUserFrom().getCUserId() != null){ | |||||
| WxCUserFrom wxCUserFrom = msg.getWxCUserFrom(); | |||||
| Long cUserId = wxCUserFrom.getCUserId(); | |||||
| WxCUser user = userService.getById(cUserId,msg.getTenantId()); | |||||
| if(user == null) { | |||||
| logger.error("用户ID未找到: " + cUserId); | |||||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY.getCode(), "用户ID未找到" + cUserId); | |||||
| } | |||||
| userService.actionAfterLogin(user); | |||||
| if(wxCUserFrom.getFromType() != null){ | |||||
| wxCUserFromService.save(wxCUserFrom); | |||||
| } | |||||
| } | } | ||||
| userService.actionAfterLogin(user); | |||||
| } | } | ||||
| } | } | ||||