静默登录获取unionid

This commit is contained in:
2024-02-07 17:32:07 +08:00
parent e3ee4595da
commit fe11b0f211
2 changed files with 9 additions and 3 deletions

View File

@@ -24,7 +24,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@@ -94,7 +93,7 @@ public class LpkCustomerService extends MybatisBaseService<LpkCustomerMapper, Lp
if (!jsonObject.containsKey("openid")) { if (!jsonObject.containsKey("openid")) {
return rb.setMsg("未获得openid请联系管理员"); return rb.setMsg("未获得openid请联系管理员");
} }
// String unionid = jsonObject.get("unionid").toString(); String unionid = jsonObject.get("unionid").toString();
String openid = jsonObject.get("openid").toString(); String openid = jsonObject.get("openid").toString();
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
// map.put("unionid",unionid); // map.put("unionid",unionid);
@@ -106,7 +105,7 @@ public class LpkCustomerService extends MybatisBaseService<LpkCustomerMapper, Lp
//新增用户 //新增用户
LpkCustomer newCustomer = new LpkCustomer(); LpkCustomer newCustomer = new LpkCustomer();
newCustomer.setWxMpOpenid(openid); newCustomer.setWxMpOpenid(openid);
// newCustomer.setUnionId(unionid); newCustomer.setUnionId(unionid);
newCustomer.setCreateTime(new Date()); newCustomer.setCreateTime(new Date());
newCustomer.setIsPurchase("1"); newCustomer.setIsPurchase("1");
newCustomer.setIsNewUser("1"); newCustomer.setIsNewUser("1");
@@ -136,6 +135,10 @@ public class LpkCustomerService extends MybatisBaseService<LpkCustomerMapper, Lp
baseMapper.updateById(lpkCustomer); baseMapper.updateById(lpkCustomer);
lpkCustomer = fetchBySid(lpkCustomer.getSid()); lpkCustomer = fetchBySid(lpkCustomer.getSid());
} }
if(StringUtils.isBlank(lpkCustomer.getUnionId())){
lpkCustomer.setUnionId(unionid);
baseMapper.updateById(lpkCustomer);
}
StpUtil.login(lpkCustomer.getId()); StpUtil.login(lpkCustomer.getId());
SaTokenInfo tokenInfo = StpUtil.getTokenInfo(); SaTokenInfo tokenInfo = StpUtil.getTokenInfo();
lpkCustomer.setToken(tokenInfo.getTokenValue()); lpkCustomer.setToken(tokenInfo.getTokenValue());

View File

@@ -50,6 +50,9 @@ public class NewcomerRecoRecordService extends MybatisBaseService<NewcomerRecoRe
ResultBean rb = new ResultBean(); ResultBean rb = new ResultBean();
NewcomerRecoRecord newcomerRecoRecord = new NewcomerRecoRecord(); NewcomerRecoRecord newcomerRecoRecord = new NewcomerRecoRecord();
List<RecommendNewUserBag> bags=recommendNewUserBagService.list(new QueryWrapper<RecommendNewUserBag>().eq("isGrounding","1")); List<RecommendNewUserBag> bags=recommendNewUserBagService.list(new QueryWrapper<RecommendNewUserBag>().eq("isGrounding","1"));
if(StringUtils.isBlank(dto.getCustomerSid())){
return rb.setMsg("参数不全");
}
if(bags.size()==0){ if(bags.size()==0){
newcomerRecoRecord.setSid(""); newcomerRecoRecord.setSid("");
return rb.success().setData(newcomerRecoRecord); return rb.success().setData(newcomerRecoRecord);