增加了商品库相关的方法
This commit is contained in:
parent
5948a22142
commit
7d1715bd45
@ -14,16 +14,21 @@ import com.suisung.mall.common.pojo.req.WxUserInfoReq;
|
||||
import com.suisung.mall.common.service.GeTuiPushService;
|
||||
import com.suisung.mall.common.service.impl.BaseControllerImpl;
|
||||
import com.suisung.mall.common.utils.I18nUtil;
|
||||
import com.suisung.mall.common.utils.StringUtils;
|
||||
import com.suisung.mall.common.utils.UserInfoService;
|
||||
import com.suisung.mall.common.utils.phone.PhoneNumberUtils;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.log4j.Log4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.util.Pair;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -34,6 +39,7 @@ import java.util.Map;
|
||||
* @author Xinze
|
||||
* @since 2021-03-30
|
||||
*/
|
||||
@Log4j
|
||||
@Api(tags = "用户基本信息表")
|
||||
@RestController
|
||||
@RequestMapping("/mobile/account/login")
|
||||
@ -72,7 +78,27 @@ public class LoginController extends BaseControllerImpl {
|
||||
clinkContent = "";
|
||||
}
|
||||
|
||||
return geTuiPushService.pushMessageToCid(paramsJSON.getStr("cid"), title, paramsJSON.getStr("message"), clickType, clinkContent);
|
||||
String message = paramsJSON.getStr("message") + System.currentTimeMillis();
|
||||
|
||||
JSONObject transmission = new JSONObject();
|
||||
transmission.put("title", "小发同城");
|
||||
transmission.put("message", message);
|
||||
transmission.put("order", StringUtils.genLklOrderNo(8));
|
||||
|
||||
List<String> cidList = new ArrayList<>();
|
||||
cidList.add("5932378d5a63fd1d028d47ac7a8f0c03");
|
||||
cidList.add("d4df466ea274314ec1025bafa0043f8b");
|
||||
|
||||
Pair<Boolean, String> pair1 = geTuiPushService.pushTransmissionToCid("5932378d5a63fd1d028d47ac7a8f0c03", transmission.toString());
|
||||
Pair<Boolean, String> pair2 = geTuiPushService.pushTransmissionToCid("d4df466ea274314ec1025bafa0043f8b", transmission.toString());
|
||||
Pair<Boolean, String> pair3 = geTuiPushService.pushMessageToCid("5932378d5a63fd1d028d47ac7a8f0c03", title, message, clickType, clinkContent);
|
||||
Pair<Boolean, String> pair4 = geTuiPushService.pushMessageToCid("d4df466ea274314ec1025bafa0043f8b", title, message, clickType, clinkContent);
|
||||
log.info("透传h5 {}" + pair1.getSecond());
|
||||
log.info("透传android {}" + pair2.getSecond());
|
||||
log.info("消息h5 {}" + pair3.getSecond());
|
||||
log.info("消息android {}" + pair4.getSecond());
|
||||
|
||||
return geTuiPushService.pushMessageToCid("d4df466ea274314ec1025bafa0043f8b", title, paramsJSON.getStr("message"), clickType, clinkContent);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/testcase", method = RequestMethod.GET)
|
||||
|
||||
@ -0,0 +1,61 @@
|
||||
package com.suisung.mall.common.modules.library;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("library_product")
|
||||
@ApiModel(value = "商品库的商品", description = "商品库的商品表")
|
||||
public class LibraryProduct implements Serializable {
|
||||
|
||||
@TableId(value = "id", type = IdType.INPUT)
|
||||
@ApiModelProperty(value = "商品ID", position = 1, example = "1001")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "商品名", position = 2, example = "小米12 Pro")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "条形码/Barcode", position = 3, example = "6923450657713")
|
||||
private String barcode;
|
||||
|
||||
@ApiModelProperty(value = "商品分类", position = 4, example = "手机")
|
||||
private String category;
|
||||
|
||||
@ApiModelProperty(value = "商品原价", position = 5, example = "4999.00")
|
||||
private BigDecimal price;
|
||||
|
||||
@ApiModelProperty(value = "商品关键字", position = 6, example = "智能手机,5G,骁龙8Gen1")
|
||||
private String keywords;
|
||||
|
||||
@ApiModelProperty(value = "封面图主图", position = 7, example = "/media/images/product/1001.jpg")
|
||||
private String thumb;
|
||||
|
||||
@ApiModelProperty(value = "排序值,越小越前面", position = 8, example = "50")
|
||||
private Integer seq;
|
||||
|
||||
@ApiModelProperty(value = "来源ID", position = 9, example = "vendor_001")
|
||||
private String source;
|
||||
|
||||
@ApiModelProperty(value = "状态 1-有效 2-无效", position = 10, example = "1")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "创建时间", position = 11, example = "2023-01-01 12:00:00")
|
||||
private Date createdAt;
|
||||
|
||||
@ApiModelProperty(value = "更新时间", position = 12, example = "2023-01-02 15:30:00")
|
||||
private Date updatedAt;
|
||||
}
|
||||
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 2025. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.suisung.mall.common.modules.library;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("library_product_image")
|
||||
@ApiModel(value = "商品库的商品图片", description = "商品库的商品图片表")
|
||||
public class LibraryProductImage implements Serializable {
|
||||
|
||||
@TableId(value = "id", type = IdType.INPUT)
|
||||
@ApiModelProperty(value = "图片ID", position = 1, example = "5001")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "商品ID", position = 2, example = "1001")
|
||||
private Long productId;
|
||||
|
||||
@ApiModelProperty(value = "图片地址", position = 3,
|
||||
example = "/media/images/product/1001.jpg")
|
||||
private String imageUrl;
|
||||
|
||||
@ApiModelProperty(value = "是否主图 1-主图 0-副图", position = 4, example = "1")
|
||||
private Boolean isMain;
|
||||
|
||||
@ApiModelProperty(value = "排序值,越小越前面", position = 5, example = "10")
|
||||
private Integer seq;
|
||||
|
||||
@ApiModelProperty(value = "状态 1-有效 2-无效", position = 6, example = "1")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "创建时间", position = 7, example = "2023-01-01 12:30:00")
|
||||
private Date createdAt;
|
||||
|
||||
@ApiModelProperty(value = "更新时间", position = 8, example = "2023-01-01 13:15:00")
|
||||
private Date updatedAt;
|
||||
}
|
||||
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (c) 2025. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.suisung.mall.common.pojo.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value = "商品库的商品信息", description = "商品库的商品信息")
|
||||
public class LibraryProductDTO implements Serializable {
|
||||
private Long id;
|
||||
private String name;
|
||||
private String barcode;
|
||||
private String keywords;
|
||||
private String thumb;
|
||||
private BigDecimal price;
|
||||
|
||||
private List<ProductImage> product_image_list;
|
||||
|
||||
/**
|
||||
* 处理所有图片URL,添加域名前缀
|
||||
*
|
||||
* @param imageDomain 图片域名
|
||||
*/
|
||||
public void processImageUrls(String imageDomain) {
|
||||
// 处理主图
|
||||
this.thumb = addDomainPrefix(imageDomain, this.thumb);
|
||||
|
||||
// 处理图片列表
|
||||
if (this.product_image_list != null) {
|
||||
for (ProductImage image : this.product_image_list) {
|
||||
if (image != null) {
|
||||
image.image_url = addDomainPrefix(imageDomain, image.getImage_url());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 为URL添加域名前缀(如果URL不是以http/https开头)
|
||||
*
|
||||
* @param imageDomain 图片域名
|
||||
* @param url 图片URL
|
||||
* @return 添加域名前缀后的URL
|
||||
*/
|
||||
private String addDomainPrefix(String imageDomain, String url) {
|
||||
if (url == null || url.startsWith("http://") || url.startsWith("https://")) {
|
||||
return url;
|
||||
}
|
||||
return imageDomain + (url.startsWith("/") ? url : "/" + url);
|
||||
}
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value = "商品库的商品图片", description = "商品库的商品图片")
|
||||
public static class ProductImage implements Serializable {
|
||||
private Long product_id;
|
||||
private String image_url;
|
||||
private Integer is_main;
|
||||
private Integer seq;
|
||||
}
|
||||
}
|
||||
@ -13,6 +13,7 @@ import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.service.GeTuiPushService;
|
||||
import com.suisung.mall.common.service.impl.BaseControllerImpl;
|
||||
import com.suisung.mall.shop.lakala.service.LakalaApiService;
|
||||
import com.suisung.mall.shop.library.service.LibraryProductService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@ -24,6 +25,8 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Api(tags = "拉卡拉相关接口 - 前端控制器")
|
||||
@RestController
|
||||
@ -36,15 +39,24 @@ public class LakalaController extends BaseControllerImpl {
|
||||
@Resource
|
||||
private GeTuiPushService geTuiPushService;
|
||||
|
||||
@Resource
|
||||
private LibraryProductService libraryProductService;
|
||||
|
||||
@ApiOperation(value = "测试案例", notes = "测试案例")
|
||||
@RequestMapping(value = "/testcase", method = RequestMethod.POST)
|
||||
public Object testcase(@RequestBody JSONObject paramsJSON) {
|
||||
return lakalaPayService.applyLedgerMerEc(paramsJSON.getStr("mchMobile"));
|
||||
// return lakalaPayService.applyLedgerMerEc(paramsJSON.getStr("mchMobile"));
|
||||
// return lakalaPayService.LedgerMerEcDownload(975790666910121984L);
|
||||
|
||||
// return geTuiPushService.pushMessageToSingleByCid("f9da7081a7951cff6d7f1d4e2d2f270b", "", "从 shop 发消息", "none", "");
|
||||
|
||||
// return "";
|
||||
|
||||
List<String> tags = new ArrayList<>();
|
||||
tags.add("纯净水");
|
||||
tags.add("放心");
|
||||
return libraryProductService.matchLibraryProducts(paramsJSON.getStr("barcode"), paramsJSON.getStr("productName"), tags);
|
||||
|
||||
}
|
||||
|
||||
@ApiOperation(value = "本地文件转base64", notes = "本地文件转base64")
|
||||
|
||||
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) 2025. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.suisung.mall.shop.library.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.suisung.mall.common.modules.library.LibraryProductImage;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface LibraryProductImageMapper extends BaseMapper<LibraryProductImage> {
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2025. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.suisung.mall.shop.library.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.suisung.mall.common.modules.library.LibraryProduct;
|
||||
import com.suisung.mall.common.pojo.dto.LibraryProductDTO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface LibraryProductMapper extends BaseMapper<LibraryProduct> {
|
||||
|
||||
/**
|
||||
* 匹配商品
|
||||
* 如果 barcode 匹配到数据,其他条件不会被匹配
|
||||
* 如果 barcode 未匹配到数据,则其他条件会正常去匹配
|
||||
*
|
||||
* @param barcode 国标条形码
|
||||
* @param productName 商品名称
|
||||
* @param keywords 多个商品标签,商品关键字
|
||||
* @return
|
||||
*/
|
||||
List<LibraryProductDTO> matchLibraryProducts(@Param("barcode") String barcode, @Param("productName") String productName, @Param("keywords") List<String> keywords);
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
/*
|
||||
* Copyright (c) 2025. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.suisung.mall.shop.library.service;
|
||||
|
||||
public interface LibraryProductImageService {
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (c) 2025. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.suisung.mall.shop.library.service;
|
||||
|
||||
import com.suisung.mall.common.pojo.dto.LibraryProductDTO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface LibraryProductService {
|
||||
|
||||
/**
|
||||
* 匹配商品
|
||||
* 如果 barcode 匹配到数据,其他条件不会被匹配
|
||||
* 如果 barcode 未匹配到数据,则其他条件会正常去匹配
|
||||
*
|
||||
* @param barcode 国标条形码
|
||||
* @param productName 商品名称
|
||||
* @param keywords 多个商品标签,商品关键字
|
||||
* @return
|
||||
*/
|
||||
List<LibraryProductDTO> matchLibraryProducts(String barcode, String productName, List<String> keywords);
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright (c) 2025. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.suisung.mall.shop.library.service.impl;
|
||||
|
||||
import com.suisung.mall.common.modules.library.LibraryProductImage;
|
||||
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
||||
import com.suisung.mall.shop.library.mapper.LibraryProductImageMapper;
|
||||
import com.suisung.mall.shop.library.service.LibraryProductImageService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class LibraryProductImageServiceImpl extends BaseServiceImpl<LibraryProductImageMapper, LibraryProductImage> implements LibraryProductImageService {
|
||||
}
|
||||
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2025. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
* Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
|
||||
* Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
|
||||
* Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
|
||||
* Vestibulum commodo. Ut rhoncus gravida arcu.
|
||||
*/
|
||||
|
||||
package com.suisung.mall.shop.library.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.suisung.mall.common.modules.library.LibraryProduct;
|
||||
import com.suisung.mall.common.pojo.dto.LibraryProductDTO;
|
||||
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
||||
import com.suisung.mall.shop.library.mapper.LibraryProductMapper;
|
||||
import com.suisung.mall.shop.library.service.LibraryProductService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class LibraryProductImpl extends BaseServiceImpl<LibraryProductMapper, LibraryProduct> implements LibraryProductService {
|
||||
|
||||
@Resource
|
||||
private LibraryProductMapper libraryProductMapper;
|
||||
|
||||
@Value("${static_domain}")
|
||||
private String staticDomain;
|
||||
|
||||
/**
|
||||
* 匹配商品
|
||||
* 如果 barcode 匹配到数据,其他条件不会被匹配
|
||||
* 如果 barcode 未匹配到数据,则其他条件会正常去匹配
|
||||
*
|
||||
* @param barcode 国标条形码
|
||||
* @param productName 商品名称
|
||||
* @param keywords 多个商品标签,商品关键字
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<LibraryProductDTO> matchLibraryProducts(String barcode, String productName, List<String> keywords) {
|
||||
if (StringUtils.isAllBlank(barcode, productName) && CollUtil.isEmpty(keywords)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<LibraryProductDTO> list = libraryProductMapper.matchLibraryProducts(barcode, productName, keywords);
|
||||
if (CollectionUtil.isEmpty(list)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
// 使用 Stream 处理图片 URLs
|
||||
list.forEach(product -> product.processImageUrls(staticDomain));
|
||||
return list;
|
||||
|
||||
}
|
||||
}
|
||||
@ -118,6 +118,7 @@ logging:
|
||||
springfox: error
|
||||
# 项目主域名
|
||||
main_domain: @project.domain@
|
||||
static_domain: @project.static_domain@
|
||||
# 个推
|
||||
getui:
|
||||
# Url前缀
|
||||
|
||||
@ -118,6 +118,7 @@ logging:
|
||||
springfox: error
|
||||
# 项目主域名
|
||||
main_domain: @project.domain@
|
||||
static_domain: @project.static_domain@
|
||||
# 个推
|
||||
getui:
|
||||
# Url前缀
|
||||
|
||||
@ -124,6 +124,7 @@ logging:
|
||||
springfox: error
|
||||
# 项目主域名
|
||||
main_domain: @project.domain@
|
||||
static_domain: @project.static_domain@
|
||||
# 个推
|
||||
getui:
|
||||
# Url前缀
|
||||
|
||||
@ -122,6 +122,7 @@ logging:
|
||||
springfox: error
|
||||
# 项目主域名
|
||||
main_domain: @project.domain@
|
||||
static_domain: @project.static_domain@
|
||||
# 个推
|
||||
getui:
|
||||
# Url前缀
|
||||
|
||||
@ -122,6 +122,7 @@ logging:
|
||||
springfox: error
|
||||
# 项目主域名
|
||||
main_domain: @project.domain@
|
||||
static_domain: @project.static_domain@
|
||||
# 个推
|
||||
getui:
|
||||
# Url前缀
|
||||
|
||||
@ -0,0 +1,149 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.suisung.mall.shop.library.mapper.LibraryProductMapper">
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
*
|
||||
</sql>
|
||||
|
||||
|
||||
<resultMap id="LibraryProductDTOResult" type="com.suisung.mall.common.pojo.dto.LibraryProductDTO">
|
||||
<!--商品库商品对象映射-->
|
||||
<id property="id" column="id"/>
|
||||
<result property="name" column="name"/>
|
||||
<result property="barcode" column="barcode"/>
|
||||
<result property="keywords" column="keywords"/>
|
||||
<result property="thumb" column="thumb"/>
|
||||
<result property="price" column="price"/>
|
||||
|
||||
<!-- 商品库商品图片集合映射-->
|
||||
<collection property="product_image_list"
|
||||
ofType="com.suisung.mall.common.pojo.dto.LibraryProductDTO$ProductImage">
|
||||
<result property="product_id" column="product_id"/>
|
||||
<result property="image_url" column="image_url"/>
|
||||
<result property="is_main" column="is_main"/>
|
||||
<result property="seq" column="seq"/>
|
||||
</collection>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<select id="matchLibraryProducts" resultMap="LibraryProductDTOResult">
|
||||
<!-- 使用 UNION ALL 组合两个查询 -->
|
||||
<choose>
|
||||
<!-- 情况1:如果 barcode 不为空,优先查询 barcode -->
|
||||
<when test="barcode != null and barcode != ''">
|
||||
SELECT
|
||||
p.id,
|
||||
p.name,
|
||||
p.barcode,
|
||||
p.price,
|
||||
p.keywords,
|
||||
p.thumb,
|
||||
pi.product_id,
|
||||
pi.image_url,
|
||||
pi.is_main,
|
||||
pi.seq,
|
||||
1 AS query_priority <!-- 标记为第一优先级查询 -->
|
||||
FROM library_product p
|
||||
JOIN library_product_image pi ON p.id = pi.product_id
|
||||
WHERE p.barcode = #{barcode}
|
||||
|
||||
UNION ALL
|
||||
|
||||
<!-- 仅当 barcode 不存在时才执行此查询 -->
|
||||
SELECT
|
||||
p.id,
|
||||
p.name,
|
||||
p.barcode,
|
||||
p.price,
|
||||
p.keywords,
|
||||
p.thumb,
|
||||
pi.product_id,
|
||||
pi.image_url,
|
||||
pi.is_main,
|
||||
pi.seq,
|
||||
2 AS query_priority <!-- 标记为第二优先级查询 -->
|
||||
FROM library_product p
|
||||
JOIN library_product_image pi ON p.id = pi.product_id
|
||||
WHERE
|
||||
p.barcode != #{barcode}
|
||||
|
||||
<choose>
|
||||
<when test="productName != null and productName != '' and keywords != null and keywords.size > 0">
|
||||
AND (
|
||||
p.name LIKE CONCAT('%', #{productName}, '%')
|
||||
OR
|
||||
<foreach collection="keywords" item="keyword" separator="OR">
|
||||
p.keywords LIKE CONCAT('%', #{keyword}, '%')
|
||||
</foreach>
|
||||
)
|
||||
</when>
|
||||
<otherwise>
|
||||
<if test="productName != null and productName != ''">
|
||||
AND p.name LIKE CONCAT('%', #{productName}, '%')
|
||||
</if>
|
||||
|
||||
<if test="keywords != null and keywords.size > 0">
|
||||
AND (
|
||||
<foreach collection="keywords" item="keyword" separator="OR">
|
||||
p.keywords LIKE CONCAT('%', #{keyword}, '%')
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
</otherwise>
|
||||
</choose>
|
||||
|
||||
AND NOT EXISTS ( <!-- 确保 barcode 在库中不存在 -->
|
||||
SELECT 1 FROM library_product WHERE barcode = #{barcode}
|
||||
)
|
||||
</when>
|
||||
|
||||
<!-- 情况2:如果 barcode 为空,直接查询 name -->
|
||||
<otherwise>
|
||||
SELECT
|
||||
p.id,
|
||||
p.name,
|
||||
p.barcode,
|
||||
p.price,
|
||||
p.keywords,
|
||||
p.thumb,
|
||||
pi.product_id,
|
||||
pi.image_url,
|
||||
pi.is_main,
|
||||
pi.seq,
|
||||
1 AS query_priority
|
||||
FROM library_product p
|
||||
JOIN library_product_image pi ON p.id = pi.product_id
|
||||
<where>
|
||||
<choose>
|
||||
<when test="productName != null and productName != '' and keywords != null and keywords.size > 0">
|
||||
AND (
|
||||
p.name LIKE CONCAT('%', #{productName}, '%')
|
||||
OR
|
||||
<foreach collection="keywords" item="keyword" separator="OR">
|
||||
p.keywords LIKE CONCAT('%', #{keyword}, '%')
|
||||
</foreach>
|
||||
)
|
||||
</when>
|
||||
<otherwise>
|
||||
<if test="productName != null and productName != ''">
|
||||
AND p.name LIKE CONCAT('%', #{productName}, '%')
|
||||
</if>
|
||||
|
||||
<if test="keywords != null and keywords.size > 0">
|
||||
AND (
|
||||
<foreach collection="keywords" item="keyword" separator="OR">
|
||||
p.keywords LIKE CONCAT('%', #{keyword}, '%')
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
</otherwise>
|
||||
</choose>
|
||||
</where>
|
||||
</otherwise>
|
||||
</choose>
|
||||
|
||||
<!-- 按优先级和 ID 排序 -->
|
||||
ORDER BY query_priority, id DESC
|
||||
</select>
|
||||
</mapper>
|
||||
1
pom.xml
1
pom.xml
@ -346,6 +346,7 @@
|
||||
<upload.filepath>D:/wwwroot/mall/public/static</upload.filepath>
|
||||
<!--项目域名-->
|
||||
<project.domain>https://mall.gpxscs.cn</project.domain>
|
||||
<project.static_domain>https://static.gpxscs.cn</project.static_domain>
|
||||
</properties>
|
||||
<activation>
|
||||
<activeByDefault>false</activeByDefault>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user