|
@@ -1,14 +1,19 @@
|
|
|
package com.abi.qms.platform.service.impl;
|
|
|
|
|
|
+import com.abi.qms.platform.dao.entity.BaseActive;
|
|
|
+import com.abi.qms.platform.dao.entity.BaseMaterial;
|
|
|
+import com.abi.qms.platform.dao.entity.QrPackage;
|
|
|
+import com.abi.qms.platform.dao.mapper.BaseActiveMapper;
|
|
|
+import com.abi.qms.platform.dao.mapper.BaseMaterialMapper;
|
|
|
+import com.abi.qms.platform.dao.mapper.QrPackageMapper;
|
|
|
+import com.abi.qms.platform.dao.tablestore.entity.QrCode;
|
|
|
import com.abi.qms.platform.dto.req.GetActUrlReq;
|
|
|
import com.abi.qms.platform.dto.res.GetActUrlRes;
|
|
|
import com.abi.qms.platform.service.ActUrlRouteService;
|
|
|
+import com.abi.task.common.tablestore.TableStorePlusUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.util.StringUtils;
|
|
|
-
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -20,18 +25,81 @@ import java.util.List;
|
|
|
@Service
|
|
|
public class ActUrlRouteServiceImpl implements ActUrlRouteService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private TableStorePlusUtils tableStorePlusUtils;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private QrPackageMapper qrPackageMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private BaseMaterialMapper baseMaterialMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private BaseActiveMapper baseActiveMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 获取url
|
|
|
**/
|
|
|
@Override
|
|
|
- public GetActUrlRes getActUrl(GetActUrlReq getActUrlReq) {
|
|
|
+ public GetActUrlRes getActUrl(GetActUrlReq req) {
|
|
|
+ //查询码信息
|
|
|
+ QrCode qrCode = tableStorePlusUtils.selectOne(QrCode.class, req.getQrCode());
|
|
|
+
|
|
|
+ //1-判断是否和入参的码包一致吗,防止外网随意调用
|
|
|
+ //如果码查不到或者码有问题,就随便返回一个活动,防止黑产拿我当试码机
|
|
|
+ if(qrCode==null || qrCode.getPackageId()==null || qrCode.getPackageId().equals(req.getQrPackageId())){
|
|
|
+ getFakeUrlForAntiFraud(req.getQrCode());
|
|
|
+ }
|
|
|
|
|
|
+ //查询码包对应的活动url
|
|
|
+ String activeUrl = getPackageActiveUrl(qrCode.getPackageId());
|
|
|
|
|
|
+ //2-如果没有活动,或者活动么有url,放回固定的静态页面
|
|
|
+ if(StringUtils.isBlank(activeUrl)){
|
|
|
+ activeUrl = getDefaultUrl();
|
|
|
+ }
|
|
|
|
|
|
- //TODO
|
|
|
- return null;
|
|
|
+ GetActUrlRes res = new GetActUrlRes();
|
|
|
+ res.setActiveUrl(activeUrl);
|
|
|
+
|
|
|
+ return res;
|
|
|
}
|
|
|
|
|
|
+ //TODO
|
|
|
+ private String getFakeUrlForAntiFraud(String qrCode){
|
|
|
+ return "";
|
|
|
+ }
|
|
|
|
|
|
+ //TODO
|
|
|
+ private String getDefaultUrl(){
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取码包的活动url
|
|
|
+ * @param qrPackageId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String getPackageActiveUrl(Long qrPackageId){
|
|
|
+ //查码包
|
|
|
+ QrPackage qrPackage = qrPackageMapper.selectById(qrPackageId);
|
|
|
+ if(qrPackage==null || qrPackage.getMaterialId()==null){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ //查物料
|
|
|
+ BaseMaterial baseMaterial = baseMaterialMapper.selectById(qrPackage.getMaterialId());
|
|
|
+ if(baseMaterial==null || baseMaterial.getActiveId()==null){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ //查活动
|
|
|
+ BaseActive baseActive = baseActiveMapper.selectById(baseMaterial.getActiveId());
|
|
|
+ if(baseActive==null || StringUtils.isBlank(baseActive.getActiveUrl())){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ return baseActive.getActiveUrl();
|
|
|
+ }
|
|
|
|
|
|
}
|