|
@@ -3,22 +3,27 @@ package cn.rankin.apiweb.service.user;
|
|
|
import cn.rankin.apiweb.code.ApiWebCode;
|
|
|
import cn.rankin.apiweb.service.product.ProductClient;
|
|
|
import cn.rankin.apiweb.utils.SecurityManager;
|
|
|
+import cn.rankin.common.utils.api.model.APICode;
|
|
|
import cn.rankin.common.utils.api.model.APIResult;
|
|
|
import cn.rankin.common.utils.api.model.BaseCode;
|
|
|
import cn.rankin.common.utils.api.page.Page;
|
|
|
import cn.rankin.common.utils.constant.PlatForm;
|
|
|
import cn.rankin.common.utils.constant.RedisKey;
|
|
|
import cn.rankin.common.utils.service.RedisService;
|
|
|
+import cn.rankin.common.utils.util.FastJsonUtils;
|
|
|
+import cn.rankin.common.utils.util.QRCodeUtil;
|
|
|
import cn.rankin.data.api.app.dto.DeviceLoginDTO;
|
|
|
import cn.rankin.data.api.app.dto.LoginInfoDTO;
|
|
|
import cn.rankin.data.api.app.vo.DeviceUserVo;
|
|
|
import cn.rankin.data.api.app.vo.ItemVo;
|
|
|
import cn.rankin.data.api.app.vo.UserInfoVo;
|
|
|
+import cn.rankin.data.api.user.dto.QRCodeDTO;
|
|
|
import cn.rankin.data.api.user.dto.TerminalDeviceDTO;
|
|
|
import cn.rankin.data.api.user.dto.UserDeviceDTO;
|
|
|
import cn.rankin.data.api.user.entity.UserRecommend;
|
|
|
import cn.rankin.data.api.user.entity.UserTag;
|
|
|
import cn.rankin.data.api.user.entity.UserTagProductRelation;
|
|
|
+import cn.rankin.data.api.user.vo.QRCodeVo;
|
|
|
import cn.rankin.data.api.user.vo.TerminalDeviceVo;
|
|
|
import cn.rankin.data.api.user.vo.TerminalUserVo;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
@@ -31,10 +36,7 @@ import org.springframework.data.domain.Sort;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
|
|
|
|
|
|
@Service
|
|
@@ -473,4 +475,52 @@ public class UserService
|
|
|
{
|
|
|
return userClient.findRelations(userTagId, productIdList, pageNo, pageSize);
|
|
|
}
|
|
|
+
|
|
|
+ public APIResult<QRCodeVo> qrcode(String eid) {
|
|
|
+ APIResult<TerminalUserVo> apiResult = userClient.loadUserByEid(eid);
|
|
|
+ if(!apiResult.getSuccess()){
|
|
|
+ log.error("load user by eid is fail");
|
|
|
+ return APIResult.error(ApiWebCode.OPERATE_ERROR);
|
|
|
+ }
|
|
|
+ TerminalUserVo vo = apiResult.getData();
|
|
|
+ if(null == vo){
|
|
|
+ log.info("load terminalUser is null");
|
|
|
+ return APIResult.error(ApiWebCode.OPERATE_ERROR);
|
|
|
+ }
|
|
|
+
|
|
|
+ Date time = new Date();
|
|
|
+
|
|
|
+ Map qrcode = new HashMap();
|
|
|
+ qrcode.put("user",eid);
|
|
|
+ qrcode.put("time",time);
|
|
|
+ String json = FastJsonUtils.collectToString(qrcode);
|
|
|
+ String qrCode = null;
|
|
|
+
|
|
|
+ try{
|
|
|
+ qrCode = "data:image/png;base64," + QRCodeUtil.generateQRCode(json);
|
|
|
+ }catch(Exception e){
|
|
|
+ log.error("generateQRCode exception,message={}",e.getMessage());
|
|
|
+ e.printStackTrace();
|
|
|
+ return APIResult.error(ApiWebCode.SERVER_ERROR);
|
|
|
+ }
|
|
|
+
|
|
|
+ String simple = vo.getMerchantSimple();
|
|
|
+
|
|
|
+ QRCodeDTO dto = new QRCodeDTO();
|
|
|
+ dto.setEid(eid);
|
|
|
+ dto.setSimple(simple);
|
|
|
+ dto.setTime(time);
|
|
|
+ dto.setQrcode(qrCode);
|
|
|
+ QRCodeVo qrcodeVo = userClient.qrcode(dto);
|
|
|
+
|
|
|
+ return APIResult.ok(qrcodeVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ public APIResult<QRCodeVo> queryLastQRCode(String eid) {
|
|
|
+ QRCodeVo vo = userClient.queryLastQRCode(eid);
|
|
|
+ if(null == vo ){
|
|
|
+ return APIResult.error(APICode.OPERATE_ERROR);
|
|
|
+ }
|
|
|
+ return APIResult.ok(vo);
|
|
|
+ }
|
|
|
}
|