|
|
|
@ -5,7 +5,6 @@ import com.alibaba.fastjson.JSON;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.heyu.api.alibaba.request.mm.VvAnonymousUserLoginRequest;
|
|
|
|
import com.heyu.api.alibaba.request.mm.VvAnonymousUserLoginRequest;
|
|
|
|
import com.heyu.api.alibaba.request.mm.VvAppBuyerInfoRequest;
|
|
|
|
import com.heyu.api.alibaba.request.mm.VvAppBuyerInfoRequest;
|
|
|
|
import com.heyu.api.alibaba.request.mm.VvAppLoginRequest;
|
|
|
|
|
|
|
|
import com.heyu.api.alibaba.request.mm.order.VvActivityDTO;
|
|
|
|
import com.heyu.api.alibaba.request.mm.order.VvActivityDTO;
|
|
|
|
import com.heyu.api.alibaba.request.vv.AppUserLoginRequest;
|
|
|
|
import com.heyu.api.alibaba.request.vv.AppUserLoginRequest;
|
|
|
|
import com.heyu.api.common.annotation.Describe;
|
|
|
|
import com.heyu.api.common.annotation.Describe;
|
|
|
|
@ -19,8 +18,6 @@ import com.heyu.api.data.dto.WeiChatLoginDTO;
|
|
|
|
import com.heyu.api.data.entity.vv.VvBuyerEntity;
|
|
|
|
import com.heyu.api.data.entity.vv.VvBuyerEntity;
|
|
|
|
import com.heyu.api.data.entity.vv.VvPromoterBuyerEntity;
|
|
|
|
import com.heyu.api.data.entity.vv.VvPromoterBuyerEntity;
|
|
|
|
import com.heyu.api.data.entity.vv.VvPromoterEntity;
|
|
|
|
import com.heyu.api.data.entity.vv.VvPromoterEntity;
|
|
|
|
import com.heyu.api.data.enums.UserLoginFlagEnums;
|
|
|
|
|
|
|
|
import com.heyu.api.data.service.impl.AppBaseRequest;
|
|
|
|
|
|
|
|
import com.heyu.api.data.utils.*;
|
|
|
|
import com.heyu.api.data.utils.*;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
@ -28,9 +25,9 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.LinkedList;
|
|
|
|
import java.util.LinkedList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Random;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
@Slf4j
|
|
|
|
@RestController
|
|
|
|
@RestController
|
|
|
|
@ -78,10 +75,12 @@ public class AppUserLoginController {
|
|
|
|
target.setSessionKey(weiChatLoginDTO.getSessionKey());
|
|
|
|
target.setSessionKey(weiChatLoginDTO.getSessionKey());
|
|
|
|
vvBuyerDao.insertOrUpdateVvBuyer(target);
|
|
|
|
vvBuyerDao.insertOrUpdateVvBuyer(target);
|
|
|
|
// 默认24 小时
|
|
|
|
// 默认24 小时
|
|
|
|
BuyerDTO buyerDTO = buildBuyerLoginInfoCacheRedisDB(target, RedisUtils.DEFAULT_EXPIRE, null);
|
|
|
|
BuyerDTO buyerDTO = buildBuyerLoginInfoCacheRedisDB(target, RedisUtils.DEFAULT_EXPIRE, null,1);
|
|
|
|
|
|
|
|
insertPromoter(request.getToken(),buyerDTO);
|
|
|
|
return R.ok().put("buyer", buyerDTO);
|
|
|
|
return R.ok().put("buyer", buyerDTO);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// http://localhost:8888/app/user/anonymous/login
|
|
|
|
// http://localhost:8888/app/user/anonymous/login
|
|
|
|
@RequestMapping("/anonymous/login")
|
|
|
|
@RequestMapping("/anonymous/login")
|
|
|
|
@Describe("匿名用户登录")
|
|
|
|
@Describe("匿名用户登录")
|
|
|
|
@ -92,42 +91,66 @@ public class AppUserLoginController {
|
|
|
|
log.info("AnonymousUserLoginAesPassword anonymous value:{}", JSON.toJSONString(request));
|
|
|
|
log.info("AnonymousUserLoginAesPassword anonymous value:{}", JSON.toJSONString(request));
|
|
|
|
return R.error("设备号不对");
|
|
|
|
return R.error("设备号不对");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Random random = new Random(100000000L);
|
|
|
|
BuyerDTO buyerDTO = null;
|
|
|
|
VvBuyerEntity target = new VvBuyerEntity();
|
|
|
|
String activityInfoStr = redisUtils.get(request.getToken());
|
|
|
|
target.setIsTest(UserLoginFlagEnums.anonymous_user.getFlag());
|
|
|
|
if (StringUtils.isNotEmpty(activityInfoStr)) {
|
|
|
|
target.setId(random.nextLong());
|
|
|
|
buyerDTO = JSONObject.parseObject(activityInfoStr, BuyerDTO.class);
|
|
|
|
BuyerDTO buyerDTO = buildBuyerLoginInfoCacheRedisDB(target, RedisUtils.thirty_minute, request.getDeviceId());
|
|
|
|
// 真实用户登录
|
|
|
|
replaceActivityInfo(request, "/app/user/anonymous/login");
|
|
|
|
if(buyerDTO.getBuyerId() > 0 ){
|
|
|
|
|
|
|
|
VvBuyerEntity target = vvBuyerDao.selectVvBuyerById(buyerDTO.getBuyerId());
|
|
|
|
|
|
|
|
buyerDTO = buildBuyerLoginInfoCacheRedisDB(target, RedisUtils.DEFAULT_EXPIRE, null,1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 假登陆
|
|
|
|
|
|
|
|
if(buyerDTO == null){
|
|
|
|
|
|
|
|
VvBuyerEntity target = new VvBuyerEntity();
|
|
|
|
|
|
|
|
target.setId(0L);
|
|
|
|
|
|
|
|
target.setIsTest(0);
|
|
|
|
|
|
|
|
buyerDTO = buildBuyerLoginInfoCacheRedisDB(target, RedisUtils.thirty_minute, request.getDeviceId(), 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
insertPromoter(request.getToken(),buyerDTO);
|
|
|
|
return R.ok().put("buyer", buyerDTO);
|
|
|
|
return R.ok().put("buyer", buyerDTO);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void insert(String token,Long wasBuyerId) {
|
|
|
|
public void insertPromoter(String requestToken ,BuyerDTO buyerDTO) {
|
|
|
|
|
|
|
|
String activityInfo = redisUtils.get(ApiConstants.token_activity + requestToken);
|
|
|
|
String activityInfo = redisUtils.get(ApiConstants.token_activity + token);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VvActivityDTO vvActivityDTO = null;
|
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(activityInfo)) {
|
|
|
|
if (StringUtils.isNotEmpty(activityInfo)) {
|
|
|
|
vvActivityDTO = JSONObject.parseObject(activityInfo, VvActivityDTO.class);
|
|
|
|
VvActivityDTO vvActivityDTO = JSONObject.parseObject(activityInfo, VvActivityDTO.class);
|
|
|
|
VvBuyerEntity wasBuyerEntity = vvBuyerDao.selectVvBuyerById(wasBuyerId);
|
|
|
|
VvBuyerEntity wasBuyerEntity = vvBuyerDao.selectVvBuyerById(buyerDTO.getBuyerId());
|
|
|
|
|
|
|
|
if(wasBuyerEntity ==null ){
|
|
|
|
|
|
|
|
wasBuyerEntity = new VvBuyerEntity();
|
|
|
|
|
|
|
|
wasBuyerEntity.setId(0L);
|
|
|
|
|
|
|
|
wasBuyerEntity.setBuyerName("");
|
|
|
|
|
|
|
|
wasBuyerEntity.setBuyerPhone("");
|
|
|
|
|
|
|
|
wasBuyerEntity.setBuyerWeixin("");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 换token
|
|
|
|
|
|
|
|
Date endTime = new Date(vvActivityDTO.getActivityExpiredTime());
|
|
|
|
|
|
|
|
int second = DateUtils.betweenSecond(new Date(),endTime);
|
|
|
|
|
|
|
|
redisUtils.set(ApiConstants.token_activity + buyerDTO.getToken(), JSON.toJSONString(vvActivityDTO),second);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<Long> promoterBuyerIdList = new LinkedList<>();
|
|
|
|
List<Long> promoterBuyerIdList = new LinkedList<>();
|
|
|
|
promoterBuyerIdList.add(vvActivityDTO.getBuyerId());
|
|
|
|
promoterBuyerIdList.add(vvActivityDTO.getBuyerId());
|
|
|
|
|
|
|
|
|
|
|
|
List<VvBuyerEntity> promoterBuyerList = vvBuyerDao.selectVvBuyerByIdList(promoterBuyerIdList);
|
|
|
|
List<VvBuyerEntity> promoterBuyerList = vvBuyerDao.selectVvBuyerByIdList(promoterBuyerIdList);
|
|
|
|
VvPromoterEntity vvPromoter = new VvPromoterEntity();
|
|
|
|
VvPromoterEntity vvPromoter = new VvPromoterEntity();
|
|
|
|
vvPromoter.setActivityId(vvActivityDTO.getActivityId());
|
|
|
|
vvPromoter.setActivityId(vvActivityDTO.getActivityId());
|
|
|
|
|
|
|
|
vvPromoter.setPromoterCode(vvActivityDTO.getPromoterCode());
|
|
|
|
|
|
|
|
vvPromoter.setBuyerInfo(JSONObject.toJSONString(vvActivityDTO));
|
|
|
|
|
|
|
|
vvPromoterDao.insertVvPromoter(vvPromoter);
|
|
|
|
for (VvBuyerEntity promoterBuyerEntity : promoterBuyerList) {
|
|
|
|
for (VvBuyerEntity promoterBuyerEntity : promoterBuyerList) {
|
|
|
|
VvPromoterBuyerEntity vvPromoterBuyerEntity = new VvPromoterBuyerEntity();
|
|
|
|
VvPromoterBuyerEntity vvPromoterBuyerEntity = new VvPromoterBuyerEntity();
|
|
|
|
vvPromoterBuyerEntity.setPromoterId(null);
|
|
|
|
vvPromoterBuyerEntity.setPromoterId(vvPromoter.getId());
|
|
|
|
vvPromoterBuyerEntity.setPromoterBuyerId(promoterBuyerEntity.getId());
|
|
|
|
vvPromoterBuyerEntity.setPromoterBuyerId(promoterBuyerEntity.getId());
|
|
|
|
vvPromoterBuyerEntity.setPromoterBuyerName(promoterBuyerEntity.getBuyerName());
|
|
|
|
vvPromoterBuyerEntity.setPromoterBuyerName(promoterBuyerEntity.getBuyerName());
|
|
|
|
vvPromoterBuyerEntity.setPromoterBuyerPhone(promoterBuyerEntity.getBuyerPhone());
|
|
|
|
vvPromoterBuyerEntity.setPromoterBuyerPhone(promoterBuyerEntity.getBuyerPhone());
|
|
|
|
vvPromoterBuyerEntity.setPromoterBuyerWeixin(promoterBuyerEntity.getBuyerWeixin());
|
|
|
|
vvPromoterBuyerEntity.setPromoterBuyerWeixin(promoterBuyerEntity.getBuyerWeixin());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vvPromoterBuyerEntity.setWasBuyerId(wasBuyerEntity.getId());
|
|
|
|
vvPromoterBuyerEntity.setWasBuyerId(wasBuyerEntity.getId());
|
|
|
|
vvPromoterBuyerEntity.setWasBuyerName(wasBuyerEntity.getBuyerName());
|
|
|
|
vvPromoterBuyerEntity.setWasBuyerName(wasBuyerEntity.getBuyerName());
|
|
|
|
vvPromoterBuyerEntity.setWasBuyerPhone(wasBuyerEntity.getBuyerPhone());
|
|
|
|
vvPromoterBuyerEntity.setWasBuyerPhone(wasBuyerEntity.getBuyerPhone());
|
|
|
|
@ -135,32 +158,8 @@ public class AppUserLoginController {
|
|
|
|
vvPromoterBuyerDao.insertOrUpdateVvPromoterBuyer(vvPromoterBuyerEntity);
|
|
|
|
vvPromoterBuyerDao.insertOrUpdateVvPromoterBuyer(vvPromoterBuyerEntity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// http://localhost:8888/app/user/target/login
|
|
|
|
|
|
|
|
@RequestMapping("/target/login")
|
|
|
|