|
@@ -149,13 +149,13 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
String productImage = productSaveDto.getProductImage();
|
|
|
String snCode = productSaveDto.getSnCode();
|
|
|
String certificateImage = productSaveDto.getCertificateImage();
|
|
|
- String authImageLogo=productSaveDto.getAuthImageLogo();
|
|
|
+ String authImageLogo = productSaveDto.getAuthImageLogo();
|
|
|
Integer certificateImageType = productSaveDto.getCertificateImageType();
|
|
|
Integer createBy = productSaveDto.getCreateBy();
|
|
|
String purchaseWay = productSaveDto.getPurchaseWay();
|
|
|
String invoiceImage = productSaveDto.getInvoiceImage();
|
|
|
Integer source = null == productSaveDto.getSource() ? 1 : productSaveDto.getSource();
|
|
|
- List<String> snList=productSaveDto.getSnList();
|
|
|
+ List<String> snList = productSaveDto.getSnList();
|
|
|
List<ProductParamPo> paramList = productSaveDto.getParamList();
|
|
|
if (null == authId) {
|
|
|
return ResponseJson.error("参数异常,请输入授权id", null);
|
|
@@ -207,7 +207,7 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
if (null != productIdBySnCode) {
|
|
|
return ResponseJson.error("该商品SN码已存在,请重新输入", null);
|
|
|
}
|
|
|
- } else if (2 == authType){
|
|
|
+ } else if (2 == authType) {
|
|
|
// 关联设备
|
|
|
productId = productIdBySnCode;
|
|
|
// 检测机构是否已关联该设备
|
|
@@ -216,7 +216,7 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
return ResponseJson.error("不能重复关联同一台设备");
|
|
|
}
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
// 编辑
|
|
|
dbRelation = authProductMapper.getProductRelation(relationId, null, null);
|
|
|
dbProduct = authProductMapper.getProductFormData(relationId);
|
|
@@ -229,7 +229,7 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
if (null != productIdBySnCode && !productIdBySnCode.equals(productId)) {
|
|
|
return ResponseJson.error("该商品SN码已存在,请重新输入", null);
|
|
|
}
|
|
|
- } else if (2 == authType){
|
|
|
+ } else if (2 == authType) {
|
|
|
productId = productIdBySnCode;
|
|
|
// 检测机构是否已关联该设备
|
|
|
ProductRelationVo productRelation = authProductMapper.getProductRelation(null, productId, authId);
|
|
@@ -237,7 +237,7 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
return ResponseJson.error("不能重复关联同一台设备");
|
|
|
}
|
|
|
}
|
|
|
- } else if (2 == dbRelation.getAuthType()){
|
|
|
+ } else if (2 == dbRelation.getAuthType()) {
|
|
|
// 原本为关联设备
|
|
|
if (1 == authType) {
|
|
|
// 设备id为null
|
|
@@ -277,14 +277,14 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
product.setCertificateImageType(certificateImageType);
|
|
|
product.setAuthImageLogo(authImageLogo);
|
|
|
String authDate = productSaveDto.getAuthDate();
|
|
|
- product.setAuthDate(null!=authDate&&""!=authDate?authDate:null);
|
|
|
+ product.setAuthDate(null != authDate && "" != authDate ? authDate : null);
|
|
|
// 购买渠道
|
|
|
product.setPurchaseWay(purchaseWay);
|
|
|
// 发票图片
|
|
|
product.setInvoiceImage(invoiceImage);
|
|
|
// 供应商保存,直接上线;机构保存,需要供应商审核通过后才上线
|
|
|
if (1 == authType) {
|
|
|
- product.setShopAuditStatus(1 == source ? 1 : 2);
|
|
|
+ product.setShopAuditStatus(1 == source ? 1 : 2);
|
|
|
if (null != dbProduct && 1 != dbProduct.getAuditStatus()) {
|
|
|
// 被驳回的数据,编辑变为待审核状态
|
|
|
product.setStatus(2);
|
|
@@ -318,9 +318,9 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
authProductMapper.updateProductByProductId(product);
|
|
|
}
|
|
|
// 插入机构设备关联关系
|
|
|
- authProductMapper.insertProductRelation(authId, product.getProductId(), authType);
|
|
|
+ authProductMapper.insertProductRelation(authId, product.getProductId(), authType);
|
|
|
//查询最新关联id
|
|
|
- relationId=authProductMapper.getNewestRelationId();
|
|
|
+ relationId = authProductMapper.getNewestRelationId();
|
|
|
} else {
|
|
|
if (1 == dbRelation.getAuthType()) {
|
|
|
// 更新设备
|
|
@@ -381,37 +381,38 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
}
|
|
|
return ResponseJson.success("保存授权商品成功");
|
|
|
}
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public ResponseJson saveProductAndRelaTion(Integer authId,List<String> snlist,Integer authType) throws IOException{
|
|
|
+ public ResponseJson saveProductAndRelaTion(Integer authId, List<String> snlist, Integer authType) throws IOException {
|
|
|
//判断机构关联id是否有值(有则机构关联关联了其他机构属于新增操作,无则属于编辑操作)
|
|
|
String relaId = authProductMapper.getRelationId(authId);
|
|
|
- List<Integer> listSnId=new ArrayList<>();
|
|
|
- if(null!=relaId&&!"".equals(relaId)){
|
|
|
+ List<Integer> listSnId = new ArrayList<>();
|
|
|
+ if (null != relaId && !"".equals(relaId)) {
|
|
|
//根据sn码获取产品id
|
|
|
- for(int i=0;i<snlist.size();i++){
|
|
|
+ for (int i = 0; i < snlist.size(); i++) {
|
|
|
List<ProductPo> List = authProductMapper.getSnList(snlist.get(i));
|
|
|
//判断本身机构下的设备和关联机构下 设备有不有重复的
|
|
|
- if(List.get(0).getAuthId()!=authId){
|
|
|
+ if (List.get(0).getAuthId() != authId) {
|
|
|
listSnId.add(List.get(0).getProductId());
|
|
|
}
|
|
|
}
|
|
|
//根据产品id插入机构设备关联关系
|
|
|
- for(int i=0;i<snlist.size();i++){
|
|
|
+ for (int i = 0; i < snlist.size(); i++) {
|
|
|
authProductMapper.insertProductRelation(authId, listSnId.get(i), authType);
|
|
|
}
|
|
|
return ResponseJson.success("保存授权商品成功");
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
//根据sn码获取产品id
|
|
|
- for(int i=0;i<snlist.size();i++){
|
|
|
+ for (int i = 0; i < snlist.size(); i++) {
|
|
|
List<ProductPo> List = authProductMapper.getSnList(snlist.get(i));
|
|
|
//判断本身机构下的设备和关联机构下 设备有不有重复的
|
|
|
- if(List.get(0).getAuthId()!=authId){
|
|
|
+ if (List.get(0).getAuthId() != authId) {
|
|
|
listSnId.add(List.get(0).getProductId());
|
|
|
}
|
|
|
}
|
|
|
//根据产品id插入机构设备关联关系
|
|
|
- for(int i=0;i<snlist.size();i++){
|
|
|
+ for (int i = 0; i < snlist.size(); i++) {
|
|
|
authProductMapper.insertProductRelation(authId, listSnId.get(i), authType);
|
|
|
}
|
|
|
return ResponseJson.success("保存授权商品成功");
|
|
@@ -444,6 +445,7 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
+
|
|
|
public String generateAuthImageLogo(TemplateVo authTemplate, ProductFormVo product) {
|
|
|
if (null != authTemplate) {
|
|
|
// 根据模板id设置相关数据
|
|
@@ -471,7 +473,7 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- private Map<String,Object> getTemplateInfo(TemplateVo template, ProductFormVo product) {
|
|
|
+ private Map<String, Object> getTemplateInfo(TemplateVo template, ProductFormVo product) {
|
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
|
Integer templateId = template.getTemplateId();
|
|
|
if (1 == templateId) {
|
|
@@ -519,7 +521,7 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
// 添加二维码信息
|
|
|
if (StringUtils.isNotEmpty(template.getQrPosition())) {
|
|
|
// String qrCodeLink = wwwServer + "/product/auth/product-" + product.getProductId() + ".html";
|
|
|
- String qrCodeLink = zpapiServer + "/"+product.getCreateBy()+"/"+product.getPrefix()+"/approve/device/detail?id=" + product.getProductId() ;
|
|
|
+ String qrCodeLink = zpapiServer + "/" + product.getCreateBy() + "/" + product.getPrefix() + "/approve/device/detail?id=" + product.getProductId();
|
|
|
map.put("addQr1_link", qrCodeLink);
|
|
|
map.put("addQr1_size", template.getQrSize());
|
|
|
String[] split = template.getQrPosition().split(",");
|
|
@@ -532,7 +534,7 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
- private Map<String,Object> getTemplateLogoInfo(TemplateVo template, ProductFormVo product) {
|
|
|
+ private Map<String, Object> getTemplateLogoInfo(TemplateVo template, ProductFormVo product) {
|
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
|
Integer templateId = template.getTemplateId();
|
|
|
if (1 == templateId) {
|
|
@@ -596,7 +598,7 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
- private String addWaterMark(String image,Integer type) throws IOException {
|
|
|
+ private String addWaterMark(String image, Integer type) throws IOException {
|
|
|
//type:1pc,2applets
|
|
|
ClassPathResource classPathResource = new ClassPathResource("/images/newPcWaterMark.png");
|
|
|
InputStream inputStreamImg = classPathResource.getInputStream();
|
|
@@ -645,8 +647,8 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
paramList = authProductMapper.getParamsByProductId(productForm.getProductId());
|
|
|
}
|
|
|
productForm.setParamList(paramList);
|
|
|
- if(null!=productForm.getAuthDates()){
|
|
|
- SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ if (null != productForm.getAuthDates()) {
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
String authDate = simpleDateFormat.format(productForm.getAuthDates());
|
|
|
productForm.setAuthDate(authDate);
|
|
|
}
|
|
@@ -661,7 +663,7 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
@Override
|
|
|
public ResponseJson updateAllWaterMark() {
|
|
|
List<ProductPo> productList = authProductMapper.getAllImage();
|
|
|
- productList.forEach(product->{
|
|
|
+ productList.forEach(product -> {
|
|
|
try {
|
|
|
if (StringUtils.isNotEmpty(product.getImage())) {
|
|
|
//商品图片添加水印
|
|
@@ -775,7 +777,7 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
}
|
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
|
List<WxProductListVo> productList = authProductMapper.getWxProductList(listType, authId, authParty, productTypeId, snCode);
|
|
|
- productList.forEach(product->{
|
|
|
+ productList.forEach(product -> {
|
|
|
List<WxClubListVo> clubList = authProductMapper.getProductClubList(product.getProductId());
|
|
|
product.setClubList(clubList);
|
|
|
});
|
|
@@ -784,16 +786,23 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ResponseJson<AuthProductVo> getAuthProductDetails(Integer productId) {
|
|
|
- AuthProductVo authProduct = authProductMapper.getAuthProductByProductId(productId);
|
|
|
+ public ResponseJson<AuthProductVo> getAuthProductDetails(String productId) {
|
|
|
+ Integer pid = 0;
|
|
|
+ if (productId.startsWith("HC")) {
|
|
|
+ String substring = productId.substring(2);
|
|
|
+ pid = authProductMapper.findProductByQr(substring);
|
|
|
+ }else{
|
|
|
+ pid = Integer.valueOf(productId);
|
|
|
+ }
|
|
|
+ AuthProductVo authProduct = authProductMapper.getAuthProductByProductId(pid);
|
|
|
if (null == authProduct) {
|
|
|
return ResponseJson.error("商品不存在", null);
|
|
|
}
|
|
|
- authProduct.setClubList(authProductMapper.getProductClubList(productId));
|
|
|
+ authProduct.setClubList(authProductMapper.getProductClubList(pid));
|
|
|
// 商品参数
|
|
|
- authProduct.setParamList(authProductMapper.getAuthProductParams(productId));
|
|
|
+ authProduct.setParamList(authProductMapper.getAuthProductParams(pid));
|
|
|
// 增加扫码次数
|
|
|
- authProductMapper.addScanCount(productId);
|
|
|
+ authProductMapper.addScanCount(pid);
|
|
|
return ResponseJson.success(authProduct);
|
|
|
}
|
|
|
|
|
@@ -838,8 +847,8 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
// 创建时间
|
|
|
productType.setCreateTime(new Date());
|
|
|
// 设备分类图片添加水印
|
|
|
- productType.setPcImage(addWaterMark(productType.getImage(),1));
|
|
|
- productType.setAppletsImage(addWaterMark(productType.getImage(),2));
|
|
|
+ productType.setPcImage(addWaterMark(productType.getImage(), 1));
|
|
|
+ productType.setAppletsImage(addWaterMark(productType.getImage(), 2));
|
|
|
// 插入设备分类
|
|
|
authProductMapper.insertProductType(productType);
|
|
|
} else {
|
|
@@ -897,16 +906,16 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
List<ProductTypeListVo> productList = authProductMapper.getProductTypeList(listType, authUserId, name, status, auditStatus);
|
|
|
//如果是手机号则进行脱敏处理
|
|
|
//手机号脱敏处理(脱敏规则: 保留前三后四, 比如15638296218置换为156****6218)
|
|
|
- if(null!=productList&&productList.size()>0){
|
|
|
+ if (null != productList && productList.size() > 0) {
|
|
|
productList.forEach(authVo -> {
|
|
|
//判断是否是手机号
|
|
|
- String phoneNumber=authVo.getCreateBy();
|
|
|
- if(StringUtils.isNotEmpty(phoneNumber)){
|
|
|
+ String phoneNumber = authVo.getCreateBy();
|
|
|
+ if (StringUtils.isNotEmpty(phoneNumber)) {
|
|
|
// boolean matches = phoneNumber.matches("^[1][3,4,5,7,8,9][0-9]{9}$");
|
|
|
// if(matches){
|
|
|
- //脱敏处理
|
|
|
- phoneNumber = phoneNumber.replaceAll("(\\w{3})\\w*(\\w{4})", "$1****$2");
|
|
|
- authVo.setCreateBy(phoneNumber);
|
|
|
+ //脱敏处理
|
|
|
+ phoneNumber = phoneNumber.replaceAll("(\\w{3})\\w*(\\w{4})", "$1****$2");
|
|
|
+ authVo.setCreateBy(phoneNumber);
|
|
|
// }
|
|
|
}
|
|
|
});
|
|
@@ -959,7 +968,7 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
|
|
|
@Override
|
|
|
public ResponseJson<ProductFormVo> getProductInfo(Integer productId, String snCode) {
|
|
|
- ProductFormVo product = authProductMapper.getProductInfo(productId, snCode);
|
|
|
+ ProductFormVo product = authProductMapper.getProductInfo(productId, snCode);
|
|
|
if (null == product) {
|
|
|
return ResponseJson.error(-1, "设备SN码不存在", null);
|
|
|
}
|
|
@@ -976,7 +985,7 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
public ResponseJson<List<ProductListVo>> getSnCodeList(Integer authUserId, Integer authId, Integer downStatus, String productName, String sncode, String authParty) {
|
|
|
List<ProductListVo> snCodeList = new ArrayList<>();
|
|
|
List<Integer> liallSn = authProductMapper.getAllSn(authId);
|
|
|
- List<String> allSnlist =liallSn.size()==0?null: authProductMapper.getAllSnlist(liallSn);
|
|
|
+ List<String> allSnlist = liallSn.size() == 0 ? null : authProductMapper.getAllSnlist(liallSn);
|
|
|
//判断机构筛选下拉框 0全部,1与其他机构关联
|
|
|
if (1 == downStatus) {
|
|
|
//判断该机构是否与其他机构关联
|
|
@@ -985,11 +994,11 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
if (!"".equals(relationId) && null != relationId) {
|
|
|
relationIdList = relationId.split(",");
|
|
|
//获取该机构下relationIdList的sn码
|
|
|
- snCodeList = authProductMapper.getSnCodeList(authUserId, authId, relationIdList, allSnlist, productName, sncode, authParty);
|
|
|
+ snCodeList = authProductMapper.getSnCodeList(authUserId, authId, relationIdList, allSnlist, productName, sncode, authParty);
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
//获取该机构下所有的sn码
|
|
|
- snCodeList = authProductMapper.getSnCodeList(authUserId, authId, null, allSnlist, productName, sncode, authParty);
|
|
|
+ snCodeList = authProductMapper.getSnCodeList(authUserId, authId, null, allSnlist, productName, sncode, authParty);
|
|
|
}
|
|
|
|
|
|
return ResponseJson.success(snCodeList);
|
|
@@ -1002,7 +1011,7 @@ public class AuthProductServiceImpl implements AuthProductService {
|
|
|
return ResponseJson.success();
|
|
|
}
|
|
|
|
|
|
- public ResponseJson<List<ProductListVo>> getPronductInfo( Integer authId,Integer authUserId){
|
|
|
+ public ResponseJson<List<ProductListVo>> getPronductInfo(Integer authId, Integer authUserId) {
|
|
|
List<ProductListVo> pronductInfo = authProductMapper.getPronductInfo(authId, authUserId);
|
|
|
return ResponseJson.success(pronductInfo);
|
|
|
}
|