From 3e510669312d73264c073326cffae0dfed788bd8 Mon Sep 17 00:00:00 2001 From: wangfukang <15630117759@163.com> Date: Sun, 10 Nov 2024 16:31:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=9F=E8=83=BD=E4=BC=98=E5=8C=96=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application.yml | 2 +- hiver-admin/test-output/test-report.html | 16 +- .../mall/bill/vo/SupplierBillPurchaseVo.java | 7 +- .../mall/checkstock/entity/CheckStock.java | 17 ++ .../mapper/CheckStockDetailMapper.java | 3 + .../service/CheckStockDetailService.java | 3 + .../impl/CheckStockDetailServiceImpl.java | 80 +++--- .../service/impl/CheckStockServiceImpl.java | 66 ++++- .../mall/checkstock/vo/CheckStockTjVo.java | 32 +++ .../mall/controller/OrderController.java | 2 +- .../mall/pojo/dto/ReturnSaleDetailDTO.java | 16 ++ .../mall/pojo/query/ProductPageQuery.java | 3 + .../cc/hiver/mall/pojo/vo/ProductPageVO.java | 4 + .../mybatis/ProductServiceImpl.java | 253 +++++++++++++++++- .../controller/UrlMappingController.java | 75 ++++++ .../mall/urlmapping/entity/UrlMapping.java | 29 ++ .../urlmapping/mapper/UrlMappingMapper.java | 8 + .../urlmapping/service/UrlMappingService.java | 14 + .../service/impl/UrlMappingServiceImpl.java | 12 + .../mapper/CheckStockDetailMapper.xml | 24 ++ .../resources/mapper/UrlMappingMapper.xml | 12 + 21 files changed, 623 insertions(+), 55 deletions(-) create mode 100644 hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/checkstock/vo/CheckStockTjVo.java create mode 100644 hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/urlmapping/controller/UrlMappingController.java create mode 100644 hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/urlmapping/entity/UrlMapping.java create mode 100644 hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/urlmapping/mapper/UrlMappingMapper.java create mode 100644 hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/urlmapping/service/UrlMappingService.java create mode 100644 hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/urlmapping/service/impl/UrlMappingServiceImpl.java create mode 100644 hiver-modules/hiver-mall/src/main/resources/mapper/UrlMappingMapper.xml diff --git a/hiver-admin/src/main/resources/application.yml b/hiver-admin/src/main/resources/application.yml index 624d977c..a65c3ec8 100644 --- a/hiver-admin/src/main/resources/application.yml +++ b/hiver-admin/src/main/resources/application.yml @@ -347,7 +347,7 @@ ignored: - /hiver/app/dealingRecord/getDealingsRecordList - /hiver/app/customer/getCustomerData - /hiver/app/supplier/getSupplierData - - /hiver/order/redirect + - /hiver/app/urlMapping/redirect # 临时增加 - /hiver/app/logisticsOrder/addLogisticsOrder diff --git a/hiver-admin/test-output/test-report.html b/hiver-admin/test-output/test-report.html index e5012a3a..5a474ac9 100644 --- a/hiver-admin/test-output/test-report.html +++ b/hiver-admin/test-output/test-report.html @@ -35,7 +35,7 @@ Hiver
  • -ʮһ 07, 2024 20:11:47 +ʮһ 10, 2024 16:27:17
  • @@ -84,7 +84,7 @@

    passTest

    -

    20:11:48 / 0.016 secs

    +

    16:27:17 / 0.017 secs

    @@ -92,9 +92,9 @@
    #test-id=1
    passTest
    -11.07.2024 20:11:48 -11.07.2024 20:11:48 -0.016 secs +11.10.2024 16:27:17 +11.10.2024 16:27:17 +0.017 secs
    @@ -104,7 +104,7 @@ Pass - 20:11:48 + 16:27:17 Test passed @@ -128,13 +128,13 @@

    Started

    -

    ʮһ 07, 2024 20:11:47

    +

    ʮһ 10, 2024 16:27:17

    Ended

    -

    ʮһ 07, 2024 20:11:48

    +

    ʮһ 10, 2024 16:27:17

    diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/SupplierBillPurchaseVo.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/SupplierBillPurchaseVo.java index 5e52e277..481e48ce 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/SupplierBillPurchaseVo.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/bill/vo/SupplierBillPurchaseVo.java @@ -1,9 +1,12 @@ package cc.hiver.mall.bill.vo; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; import java.math.BigDecimal; +import java.util.Date; import java.util.List; /** @@ -47,8 +50,10 @@ public class SupplierBillPurchaseVo { @ApiModelProperty(value = "交易类型:0:开单;1:退货;2:回款") private Integer dealingsType; + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @ApiModelProperty(value = "交易时间") - private Integer dealingsTime; + private Date dealingsTime; @ApiModelProperty(value = "交易备注") private String dealingsRecordRemark; diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/checkstock/entity/CheckStock.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/checkstock/entity/CheckStock.java index 4686803f..9b17639b 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/checkstock/entity/CheckStock.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/checkstock/entity/CheckStock.java @@ -11,6 +11,7 @@ import org.hibernate.annotations.DynamicUpdate; import javax.persistence.Entity; import javax.persistence.Table; +import java.math.BigDecimal; @Data @Accessors(chain = true) @@ -36,4 +37,20 @@ public class CheckStock extends HiverBaseEntity { @ApiModelProperty(value = "备注") private String remark; + @ApiModelProperty(value = "盘点总款数") + private Integer totalCount; + + @ApiModelProperty(value = "多出来的总件数") + private Integer extraCount; + + @ApiModelProperty(value = "多出来的总金额") + private BigDecimal extraTotal; + + @ApiModelProperty(value = "少出来的总件数") + private Integer lessCount; + + @ApiModelProperty(value = "少出来的总金额") + private BigDecimal lessTotal; + + } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/checkstock/mapper/CheckStockDetailMapper.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/checkstock/mapper/CheckStockDetailMapper.java index b5ace345..0e62edfd 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/checkstock/mapper/CheckStockDetailMapper.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/checkstock/mapper/CheckStockDetailMapper.java @@ -2,6 +2,7 @@ package cc.hiver.mall.checkstock.mapper; import cc.hiver.mall.checkstock.entity.CheckStockDetail; import cc.hiver.mall.checkstock.pojo.CheckStockPageQuery; +import cc.hiver.mall.checkstock.vo.CheckStockTjVo; import cc.hiver.mall.deductlog.vo.WorkerDeductLogVo; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -21,4 +22,6 @@ public interface CheckStockDetailMapper extends BaseMapper { List getByCheckStockDetailByCheckIdOfPage(@Param("checkStockPageQuery")CheckStockPageQuery checkStockPageQuery); Page getByCheckStockProductByCheckId(Page page, @Param("checkStockPageQuery")CheckStockPageQuery checkStockPageQuery); + + List getCheckStockTjVos(@Param("shopId")String shopId, @Param("checkStockIds")List checkStockIds); } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/checkstock/service/CheckStockDetailService.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/checkstock/service/CheckStockDetailService.java index e43890b0..243096c3 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/checkstock/service/CheckStockDetailService.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/checkstock/service/CheckStockDetailService.java @@ -3,6 +3,7 @@ package cc.hiver.mall.checkstock.service; import cc.hiver.mall.checkstock.entity.CheckStockDetail; import cc.hiver.mall.checkstock.pojo.CheckStockPageQuery; import cc.hiver.mall.checkstock.vo.CheckStockDetailVo; +import cc.hiver.mall.checkstock.vo.CheckStockTjVo; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; @@ -17,4 +18,6 @@ public interface CheckStockDetailService extends IService { List getByCheckStockDetailByCheckId(String checkStockId); Page getByCheckStockDetailByCheckIdOfPage(CheckStockPageQuery checkStockPageQuery); + + List getCheckStockTjVos(String shopId, List checkStockIds); } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/checkstock/service/impl/CheckStockDetailServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/checkstock/service/impl/CheckStockDetailServiceImpl.java index cfd43fa2..b3f544e3 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/checkstock/service/impl/CheckStockDetailServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/checkstock/service/impl/CheckStockDetailServiceImpl.java @@ -7,6 +7,7 @@ import cc.hiver.mall.checkstock.pojo.CheckStockPageQuery; import cc.hiver.mall.checkstock.service.CheckStockDetailService; import cc.hiver.mall.checkstock.vo.CheckStockAttributeVo; import cc.hiver.mall.checkstock.vo.CheckStockDetailVo; +import cc.hiver.mall.checkstock.vo.CheckStockTjVo; import cc.hiver.mall.deductlog.vo.WorkerDeductLogVo; import cc.hiver.mall.entity.Product; import cc.hiver.mall.service.mybatis.ProductService; @@ -179,43 +180,45 @@ public class CheckStockDetailServiceImpl extends ServiceImpl productList = productService.getProductList(checkStockDetailListOfProduct.getRecords()); - // 商品id为key,商品信息为value封装被map - Map productMap = new HashMap<>(); - for (Product product : productList) { - productMap.put(product.getId(),product); - } - if (!checkStockPageQuery.getProductIdList().isEmpty()) { - final List checkStockDetailList = checkStockDetailMapper.getByCheckStockDetailByCheckIdOfPage(checkStockPageQuery); - - // 封装至返回结果中,使用Map和computeIfAbsent简化逻辑 - final Map checkStockDetailVoMap = checkStockDetailList.stream() - .collect(Collectors.toMap(CheckStockDetail::getProductId, detail -> { - final CheckStockDetailVo vo = new CheckStockDetailVo(); - vo.setCheckStockId(detail.getCheckStockId()); - vo.setProductId(detail.getProductId()); - vo.setProductName(detail.getProductName()); - vo.setProductPicture(detail.getProductPicture()); - vo.setProductSn(detail.getProductSn()); - if(productMap.containsKey(detail.getProductId())){ - vo.setPurchasePrice(productMap.get(detail.getProductId()).getPurchasePrice()); - } - vo.setCheckStockAttributeVos(new ArrayList<>()); - final CheckStockAttributeVo attributeVo = new CheckStockAttributeVo(); - attributeVo.setAttributeList(detail.getAttributeList()); - attributeVo.setStockCount(detail.getStockCount()); - attributeVo.setPdNum(detail.getPdNum()); - vo.getCheckStockAttributeVos().add(attributeVo); - return vo; - }, (vo1, vo2) -> { - vo2.getCheckStockAttributeVos().addAll(vo1.getCheckStockAttributeVos()); - return vo2; - })); - returnData.setCountId(checkStockDetailListOfProduct.getCountId()); - returnData.setCurrent(checkStockDetailListOfProduct.getCurrent()); - returnData.setTotal(checkStockDetailListOfProduct.getTotal()); - returnData.setRecords(new ArrayList<>(checkStockDetailVoMap.values())); + if(!checkStockDetailListOfProduct.getRecords().isEmpty()){ + List productList = productService.getProductList(checkStockDetailListOfProduct.getRecords()); + // 商品id为key,商品信息为value封装被map + Map productMap = new HashMap<>(); + for (Product product : productList) { + productMap.put(product.getId(),product); + } + if (!checkStockPageQuery.getProductIdList().isEmpty()) { + final List checkStockDetailList = checkStockDetailMapper.getByCheckStockDetailByCheckIdOfPage(checkStockPageQuery); + + // 封装至返回结果中,使用Map和computeIfAbsent简化逻辑 + final Map checkStockDetailVoMap = checkStockDetailList.stream() + .collect(Collectors.toMap(CheckStockDetail::getProductId, detail -> { + final CheckStockDetailVo vo = new CheckStockDetailVo(); + vo.setCheckStockId(detail.getCheckStockId()); + vo.setProductId(detail.getProductId()); + vo.setProductName(detail.getProductName()); + vo.setProductPicture(detail.getProductPicture()); + vo.setProductSn(detail.getProductSn()); + if(productMap.containsKey(detail.getProductId())){ + vo.setPurchasePrice(productMap.get(detail.getProductId()).getPurchasePrice()); + } + vo.setCheckStockAttributeVos(new ArrayList<>()); + final CheckStockAttributeVo attributeVo = new CheckStockAttributeVo(); + attributeVo.setAttributeList(detail.getAttributeList()); + attributeVo.setStockCount(detail.getStockCount()); + attributeVo.setPdNum(detail.getPdNum()); + vo.getCheckStockAttributeVos().add(attributeVo); + return vo; + }, (vo1, vo2) -> { + vo2.getCheckStockAttributeVos().addAll(vo1.getCheckStockAttributeVos()); + return vo2; + })); + returnData.setCountId(checkStockDetailListOfProduct.getCountId()); + returnData.setCurrent(checkStockDetailListOfProduct.getCurrent()); + returnData.setTotal(checkStockDetailListOfProduct.getTotal()); + returnData.setRecords(new ArrayList<>(checkStockDetailVoMap.values())); + } } return returnData; } catch (Exception e) { @@ -224,4 +227,9 @@ public class CheckStockDetailServiceImpl extends ServiceImpl getCheckStockTjVos(String shopId, List checkStockIds) { + return checkStockDetailMapper.getCheckStockTjVos(shopId, checkStockIds); + } + } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/checkstock/service/impl/CheckStockServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/checkstock/service/impl/CheckStockServiceImpl.java index 12441134..88e79b60 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/checkstock/service/impl/CheckStockServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/checkstock/service/impl/CheckStockServiceImpl.java @@ -8,10 +8,7 @@ import cc.hiver.mall.checkstock.mapper.CheckStockMapper; import cc.hiver.mall.checkstock.pojo.CheckStockPageQuery; import cc.hiver.mall.checkstock.service.CheckStockDetailService; import cc.hiver.mall.checkstock.service.CheckStockService; -import cc.hiver.mall.checkstock.vo.CheckStockAttributeVo; -import cc.hiver.mall.checkstock.vo.CheckStockDetailVo; -import cc.hiver.mall.checkstock.vo.CheckStockPageVo; -import cc.hiver.mall.checkstock.vo.CheckStockVo; +import cc.hiver.mall.checkstock.vo.*; import cc.hiver.mall.common.constant.StockLogConstant; import cc.hiver.mall.entity.Shop; import cc.hiver.mall.entity.Stock; @@ -27,7 +24,11 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * 盘点服务实现类 @@ -184,9 +185,64 @@ public class CheckStockServiceImpl extends ServiceImpl checkStockList = checkStockMapper.getCheckStockList(page, checkStockPageQuery); + final List records = checkStockList.getRecords(); + final List checkStockIds = new ArrayList<>(); + for (CheckStock record : records) { + checkStockIds.add(record.getId()); + } + // 盘点总款数、多出来的总件数、总金额、少出来的总件数、总金额 + final List checkStockTjVos = checkStockDetailService.getCheckStockTjVos(shopId, checkStockIds); + // 将结果按照盘点id分类 + final Map> checkStockTjVoMap = new HashMap<>(); + for (CheckStockTjVo checkStockTjVo : checkStockTjVos) { + final String checkStockId = checkStockTjVo.getCheckStockId(); + final List checkStockTjVoList = checkStockTjVoMap.computeIfAbsent(checkStockId, k -> new ArrayList<>()); + checkStockTjVoList.add(checkStockTjVo); + } + // 封装盘点总款数、多出来的总件数、总金额、少出来的总件数、总金额 + for (CheckStock record : records) { + final String checkStockId = record.getId(); + // 总款数 + int size = 0; + // 多出来的总件数 + int extraCount = 0; + // 多出来的总金额 + BigDecimal extraTotal = BigDecimal.ZERO; + // 少出来的总件数 + int lessCount = 0; + // 少出来的总金额 + BigDecimal lessTotal = BigDecimal.ZERO; + if (checkStockTjVoMap.containsKey(checkStockId) && checkStockTjVoMap.get(checkStockId) != null) { + // 获取Map中该次盘点的详情, + final List checkStockTjVoList = checkStockTjVoMap.get(checkStockId); + List productIds = new ArrayList<>(); + for (CheckStockTjVo checkStockTjVo : checkStockTjVoList) { + final BigDecimal purchasePrice = checkStockTjVo.getPurchasePrice() == null ? BigDecimal.ZERO : checkStockTjVo.getPurchasePrice(); + final int changeCount = checkStockTjVo.getChangeCount() == null ? 0 : checkStockTjVo.getChangeCount(); + if ("1".equals(checkStockTjVo.getChangeType())) { + extraCount += changeCount; + extraTotal = extraTotal.add(purchasePrice.multiply(BigDecimal.valueOf(changeCount))); + } else { + lessCount += Math.abs(changeCount); + lessTotal = lessTotal.add(purchasePrice.multiply(BigDecimal.valueOf(Math.abs(changeCount)))); + } + if(!productIds.contains(checkStockTjVo.getProductId())){ + productIds.add(checkStockTjVo.getProductId()); + size ++; + } + + } + record.setTotalCount(size); + record.setExtraCount(extraCount); + record.setExtraTotal(extraTotal); + record.setLessCount(lessCount); + record.setLessTotal(lessTotal); + } + } // 执行查询,并返回结果 - return checkStockMapper.getCheckStockList(page, checkStockPageQuery); + return checkStockList; } @Override diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/checkstock/vo/CheckStockTjVo.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/checkstock/vo/CheckStockTjVo.java new file mode 100644 index 00000000..be2c0b37 --- /dev/null +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/checkstock/vo/CheckStockTjVo.java @@ -0,0 +1,32 @@ +package cc.hiver.mall.checkstock.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * 统计Vo + * @author 王富康 + * @date 2024/11/8 + */ +@Data +public class CheckStockTjVo { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "商品id") + private String productId; + + @ApiModelProperty(value = "盘点id") + private String checkStockId; + + @ApiModelProperty(value = "变化数量") + private Integer changeCount; + + @ApiModelProperty(value = "商品采购价") + private BigDecimal purchasePrice; + + @ApiModelProperty(value = "变化类型:1:增加;2:减少") + private String changeType; +} diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/OrderController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/OrderController.java index e54fc2d4..06a3a7e0 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/OrderController.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/OrderController.java @@ -500,7 +500,7 @@ public class OrderController { final String wxAccessToken = jsonObject.get("access_token").getAsString(); log.info("获取小程序码getQrtAccessToken成功:{}", wxAccessToken); //获取小程序码地址 - final String wechatQrcodeUrl = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + wxAccessToken; + final String wechatQrcodeUrl = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + wxAccessToken+"&check_path=false"; final OkHttpClient client = new OkHttpClient(); final JSONObject jsonBody = new JSONObject(); jsonBody.set("scene", scene); diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/dto/ReturnSaleDetailDTO.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/dto/ReturnSaleDetailDTO.java index 84a314ec..216ff427 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/dto/ReturnSaleDetailDTO.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/dto/ReturnSaleDetailDTO.java @@ -1,5 +1,6 @@ package cc.hiver.mall.pojo.dto; +import cc.hiver.mall.productpicture.entity.ProductPicture; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -69,6 +70,21 @@ public class ReturnSaleDetailDTO implements Serializable { @ApiModelProperty(value = "货号") private String productSn; + @ApiModelProperty(value = "供应商名称") + private String supplierName; + + @ApiModelProperty(value = "商品子图") + private List productPictures; + + @ApiModelProperty(value = "客户分类价格规则") + private String customerCategoryRule; + + @ApiModelProperty(value = "商品专属分类id") + private String attrId; + + @ApiModelProperty(value = "客户购买数量") + private Integer buyCount; + private static final long serialVersionUID = 1L; diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/query/ProductPageQuery.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/query/ProductPageQuery.java index d512e0ab..32488390 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/query/ProductPageQuery.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/query/ProductPageQuery.java @@ -75,4 +75,7 @@ public class ProductPageQuery extends HiverBasePageQuery { @ApiModelProperty("客户id") private String customerId; + + @ApiModelProperty("盘点id") + private String checkStockId; } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/ProductPageVO.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/ProductPageVO.java index 68f00c3c..ef6a37b1 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/ProductPageVO.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/pojo/vo/ProductPageVO.java @@ -15,6 +15,7 @@ limitations under the License. */ package cc.hiver.mall.pojo.vo; +import cc.hiver.mall.checkstock.vo.CheckStockAttributeVo; import cc.hiver.mall.productpicture.entity.ProductPicture; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModelProperty; @@ -123,4 +124,7 @@ public class ProductPageVO { @ApiModelProperty(value = "商品购买数量") private Integer buyCount; + + @ApiModelProperty(value = "盘点明细") + private List checkStockAttributeVos; } diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductServiceImpl.java index bff8557a..09012a4d 100644 --- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductServiceImpl.java +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/serviceimpl/mybatis/ProductServiceImpl.java @@ -4,14 +4,17 @@ import cc.hiver.core.common.constant.ProductConstant; import cc.hiver.core.common.utils.SecurityUtil; import cc.hiver.core.common.utils.StringUtils; import cc.hiver.core.entity.User; +import cc.hiver.mall.checkstock.pojo.CheckStockPageQuery; +import cc.hiver.mall.checkstock.service.CheckStockService; +import cc.hiver.mall.checkstock.vo.CheckStockAttributeVo; +import cc.hiver.mall.checkstock.vo.CheckStockDetailVo; +import cc.hiver.mall.checkstock.vo.CheckStockPageVo; import cc.hiver.mall.common.constant.PurchaseConstant; import cc.hiver.mall.dao.mapper.ProductMapper; import cc.hiver.mall.entity.Product; import cc.hiver.mall.entity.ProductAttributeValue; import cc.hiver.mall.entity.Stock; -import cc.hiver.mall.pojo.dto.SaleDetailDTO; -import cc.hiver.mall.pojo.dto.SaleDetailQueryDTO; -import cc.hiver.mall.pojo.dto.SaleQueryDTO; +import cc.hiver.mall.pojo.dto.*; import cc.hiver.mall.pojo.query.ProductPageQuery; import cc.hiver.mall.pojo.vo.*; import cc.hiver.mall.productpicture.entity.ProductPicture; @@ -55,6 +58,9 @@ public class ProductServiceImpl extends ServiceImpl impl @Autowired private SaleService saleService; + @Autowired + private CheckStockService checkStockService; + @Override public IPage getShareList(ProductPageQuery productPageQuery) { if (StringUtils.isNotEmpty(productPageQuery.getEndDate())) { @@ -117,6 +123,25 @@ public class ProductServiceImpl extends ServiceImpl impl productPageVO.setBuyCount(buyCountMap.getOrDefault(productId, 0)); } } + // 增加盘点信息 + if (StringUtils.isNotEmpty(productPageQuery.getCheckStockId())) { + final CheckStockPageQuery checkStockPageQuery = new CheckStockPageQuery(); + checkStockPageQuery.setCheckStockId(productPageQuery.getCheckStockId()); + checkStockPageQuery.setProductIdList(productIdList); + checkStockPageQuery.setPageSize(200); + final CheckStockPageVo checkStock = checkStockService.getCheckStock(checkStockPageQuery); + final Page checkStockDetailVoList = checkStock.getCheckStockDetailVoList(); + final Map> checkStockAttributeVoMap = new HashMap<>(); + for (CheckStockDetailVo record : checkStockDetailVoList.getRecords()) { + checkStockAttributeVoMap.put(record.getProductId(), record.getCheckStockAttributeVos()); + } + for (ProductPageVO productPageVO : list) { + final String productId = productPageVO.getId(); + if (checkStockAttributeVoMap.containsKey(productId)) { + productPageVO.setCheckStockAttributeVos(checkStockAttributeVoMap.get(productId)); + } + } + } } page.setRecords(list); return page; @@ -475,7 +500,229 @@ public class ProductServiceImpl extends ServiceImpl impl } } } + // 20241110 新商品直接退货的也需要判断时是否需要新增商品 + SaleReturnDTO saleReturnDTO = saleQueryDTO.getSaleReturnDTO(); + if(saleReturnDTO != null){ + List returnSaleDetailList = saleReturnDTO.getReturnSaleDetailList(); + for (ReturnSaleDetailDTO returnSaleDetailDTO : returnSaleDetailList) { + // 需要新增的商品规格信息 + final ProductCategoryVo productCategoryVo = new ProductCategoryVo(); + productCategoryVo.setShopId("spfl"); + // 需要新增的 + final Map> attributeValueMap = new HashMap<>(); + + // shopId从缓存中设置 + // 判断是否新的商品,新的商品进行新增 + final String productId = returnSaleDetailDTO.getProductId(); + if (StringUtils.isEmpty(productId)) { + // 货号或者商品名称都为空的时候不新增,其他时候新增商品 + if (StringUtils.isEmpty(returnSaleDetailDTO.getProductSn()) && StringUtils.isEmpty(returnSaleDetailDTO.getProductName())) { + continue; + } + // 根据货号查询商品是否存在 + final CopyOnWriteArrayList oldProductListBySn = getByProductSn(returnSaleDetailDTO.getProductSn(), shopId, ""); + if (oldProductListBySn != null && !oldProductListBySn.isEmpty()) { + // 旧商品,赋值商品id + returnSaleDetailDTO.setProductId(oldProductListBySn.get(0).getId()); + } else { + // 新增商品 + final Product product = new Product(); + product.setCreateBy(user.getId()); + product.setCreateTime(new Date()); + product.setProductName(returnSaleDetailDTO.getProductName()); + product.setShopId(shopId); + // 默认为已上架的 + product.setDelFlag(ProductConstant.DEL_FLAG[1]); + product.setCategoryId(returnSaleDetailDTO.getCategoryId()); + product.setSupplierName(returnSaleDetailDTO.getSupplierName()); + product.setProductSn(returnSaleDetailDTO.getProductSn()); + // 零售价 + product.setPrice(returnSaleDetailDTO.getPrice()); + // 采购价 + product.setPurchasePrice(returnSaleDetailDTO.getPurchasePrice()); + // 批发价 + product.setWholesalePrice(returnSaleDetailDTO.getWholesalePrice()); + product.setProductPicture(returnSaleDetailDTO.getProductPicture()); + product.setInStorageStatus(PurchaseConstant.IN_STORAGE_STATUS[1]); + + // 放到要查询的id中 + // 填充前台传过来的数据 + returnSaleDetailDTO.setProductId(product.getId()); + if (returnSaleDetailDTO.getProductPictures() != null) { + // 新增商品图片子图 + for (ProductPicture productPicture : returnSaleDetailDTO.getProductPictures()) { + productPicture.setProductId(product.getId()); + } + addProductPictureList.addAll(returnSaleDetailDTO.getProductPictures()); + } + // 将规格及规格下的规格值提取出来 + final List stockLogList1 = returnSaleDetailDTO.getStockLogList1(); + for (SaleDetailQueryDTO saleDetailQueryDTO : stockLogList1) { + final String attributeList = saleDetailQueryDTO.getAttributeList(); + final StringBuilder newAttributeList = new StringBuilder(); + newAttributeList.append('{'); + final StringBuilder colorStr = new StringBuilder("\"颜色\":"); + final StringBuilder sizeStr = new StringBuilder("\"尺码\":"); + final JSONObject jsonObject = JSONUtil.parseObj(attributeList); + for (Map.Entry stringObjectEntry : jsonObject.entrySet()) { + final String key = stringObjectEntry.getKey(); + String value = String.valueOf(stringObjectEntry.getValue()); + // 根据规格id规格是颜色、还是尺码。 + if ("颜色".equals(key)) { + if (!value.contains("色")) { + value += '色'; + } + colorStr.append('"' + value + '"'); + } else if ("尺码".equals(key)) { + final String valueUpperCase = value.toUpperCase(); + if (value.contains("码")) { + value = valueUpperCase; + } else { + value = valueUpperCase + '码'; + } + sizeStr.append('"' + value + '"'); + } else { + // 暂不支持其他规格 + } + if (attributeValueMap.containsKey(key)) { + final List strings = attributeValueMap.get(key); + if (!strings.contains(value)) { + strings.add(value); + } + } else { + final List valueList = new ArrayList<>(); + valueList.add(value); + attributeValueMap.put(key, valueList); + } + } + newAttributeList.append(colorStr); + newAttributeList.append(','); + newAttributeList.append(sizeStr); + newAttributeList.append('}'); + saleDetailQueryDTO.setAttributeList(newAttributeList.toString()); + } + final CopyOnWriteArrayList productAttributeOfAddVos = new CopyOnWriteArrayList<>(); + for (Map.Entry> stringListEntry : attributeValueMap.entrySet()) { + final String key = stringListEntry.getKey(); + final List entryValue = stringListEntry.getValue(); + final ProductAttributeOfAddVo productAttributeOfAddVo = new ProductAttributeOfAddVo(); + productAttributeOfAddVo.setAttributeName(key); + final CopyOnWriteArrayList productAttributeValueVoList = new CopyOnWriteArrayList<>(); + for (String s : entryValue) { + final ProductAttributeValueVo productAttributeValueVo = new ProductAttributeValueVo(); + productAttributeValueVo.setValue(s); + productAttributeValueVoList.add(productAttributeValueVo); + } + productAttributeOfAddVo.setProductAttributeValueVoList(productAttributeValueVoList); + productAttributeOfAddVos.add(productAttributeOfAddVo); + } + productCategoryVo.setProductAttributeOfAddVos(productAttributeOfAddVos); + // 批量去新增,并拿到分类id,回填商品 + // 维护该商品专属分类 + final String s = productCategoryService.batchSaveCategoryAndAttribute(productCategoryVo); + // 维护该店铺的专属分类 + productCategoryService.batchSaveCategoryOfShop(productCategoryVo); + product.setAttrId(s); + addProductList.add(product); + } + } else { + // 判断规格是否需要新增 + final List categoryIdList = new ArrayList<>(); + categoryIdList.add(returnSaleDetailDTO.getAttrId()); + // 获取商品下的规格 + final List shopCategory = productCategoryService.getShopCategory(categoryIdList); + final ProductCategoryVo oldProductCategoryVo = shopCategory.get(0); + final List productAttributeOfAddVos = oldProductCategoryVo.getProductAttributeOfAddVos(); + final Map productAttributeOfAddVoMap = new HashMap<>(); + for (ProductAttributeOfAddVo productAttributeOfAddVo : productAttributeOfAddVos) { + productAttributeOfAddVoMap.put(productAttributeOfAddVo.getAttributeName(), productAttributeOfAddVo); + } + //获取颜色及规格进行拼接 + List colorProductAttributeValueVoList = new ArrayList<>(); + List sizeProductAttributeValueVoList = new ArrayList<>(); + if (productAttributeOfAddVoMap.containsKey("颜色")) { + colorProductAttributeValueVoList = productAttributeOfAddVoMap.get("颜色").getProductAttributeValueVoList(); + } + // 将所有颜色放到一个集合中 + final CopyOnWriteArrayList colorList = new CopyOnWriteArrayList<>(); + for (ProductAttributeValueVo productAttributeValueVo : colorProductAttributeValueVoList) { + colorList.add(productAttributeValueVo.getValue()); + } + if (productAttributeOfAddVoMap.containsKey("尺码")) { + sizeProductAttributeValueVoList = productAttributeOfAddVoMap.get("尺码").getProductAttributeValueVoList(); + } + // 将所有尺码放到一个集合中 + final CopyOnWriteArrayList sizeList = new CopyOnWriteArrayList<>(); + for (ProductAttributeValueVo productAttributeValueVo : sizeProductAttributeValueVoList) { + sizeList.add(productAttributeValueVo.getValue()); + } + // 判断是否需要新增规格 + // 将规格及规格下的规格值提取出来 + final List stockLogList1 = returnSaleDetailDTO.getStockLogList1(); + for (SaleDetailQueryDTO saleDetailQueryDTO : stockLogList1) { + final String attributeList = saleDetailQueryDTO.getAttributeList(); + final StringBuilder newAttributeList = new StringBuilder(); + newAttributeList.append('{'); + final StringBuilder colorStr = new StringBuilder("\"颜色\":"); + final StringBuilder sizeStr = new StringBuilder("\"尺码\":"); + final JSONObject jsonObject = JSONUtil.parseObj(attributeList); + for (Map.Entry stringObjectEntry : jsonObject.entrySet()) { + final String key = stringObjectEntry.getKey(); + String value = String.valueOf(stringObjectEntry.getValue()); + // 根据规格id规格是颜色、还是尺码。 + if ("颜色".equals(key)) { + if (!value.contains("色")) { + value += '色'; + } + colorStr.append('"' + value + '"'); + // 判断该商品是否已包含该颜色,不包含,则需要新增 + if (!colorList.contains(value)) { + final ProductAttributeValue productAttributeValue = new ProductAttributeValue(); + final String attributeId = productAttributeOfAddVoMap.get("颜色").getAttributeId(); + productAttributeValue.setAttributeId(attributeId); + productAttributeValue.setValue(value); + productAttributeValues.add(productAttributeValue); + } + } else if ("尺码".equals(key)) { + final String valueUpperCase = value.toUpperCase(); + if (value.contains("码")) { + value = valueUpperCase; + } else { + value = valueUpperCase + '码'; + } + sizeStr.append('"' + value + '"'); + // 判断该商品是否已包含该尺码,不包含,则需要新增 + if (!sizeList.contains(value)) { + final ProductAttributeValue productAttributeValue = new ProductAttributeValue(); + final String attributeId = productAttributeOfAddVoMap.get("尺码").getAttributeId(); + productAttributeValue.setAttributeId(attributeId); + productAttributeValue.setValue(value); + productAttributeValues.add(productAttributeValue); + } + } else { + // 暂不支持其他规格 + } + if (attributeValueMap.containsKey(key)) { + final List strings = attributeValueMap.get(key); + if (!strings.contains(value)) { + strings.add(value); + } + } else { + final List valueList = new ArrayList<>(); + valueList.add(value); + attributeValueMap.put(key, valueList); + } + } + newAttributeList.append(colorStr); + newAttributeList.append(','); + newAttributeList.append(sizeStr); + newAttributeList.append('}'); + saleDetailQueryDTO.setAttributeList(newAttributeList.toString()); + } + } + } + } if (!addProductList.isEmpty()) { // 批量插入商品 productMapper.batchSaveProduct(addProductList); diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/urlmapping/controller/UrlMappingController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/urlmapping/controller/UrlMappingController.java new file mode 100644 index 00000000..8b88e93e --- /dev/null +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/urlmapping/controller/UrlMappingController.java @@ -0,0 +1,75 @@ +package cc.hiver.mall.urlmapping.controller; + +import cc.hiver.core.common.utils.ResultUtil; +import cc.hiver.core.common.vo.Result; +import cc.hiver.mall.urlmapping.entity.UrlMapping; +import cc.hiver.mall.urlmapping.service.UrlMappingService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.*; + +import java.net.URI; +import java.util.List; + +@Slf4j +@RestController +@Api(tags = "二维码重定向接口") +@RequestMapping("/hiver/app/urlMapping/") +@Transactional +public class UrlMappingController { + + @Autowired + private UrlMappingService urlMappingService; + + /** + * 新增修改二维码重定向接口 + * + * @param urlMappings + * @return Result + * @author 王富康 + * @date 2024/8/11 + */ + @PostMapping("/saveOrUpdateUrlMapping") + @ApiOperation("新增修改二维码重定向接口") + public Result saveOrUpdateUrlMapping(@RequestBody List urlMappings) { + // 参数校验,id 及 longUrl 都不能为空, + urlMappings.forEach(urlMapping -> { + if (StringUtils.isEmpty(urlMapping.getId()) || StringUtils.isEmpty(urlMapping.getLongUrl())) { + throw new RuntimeException("请检查id及重定向url,两者都不可为空!"); + } + }); + final boolean save = urlMappingService.saveOrUpdateBatch(urlMappings); + if (save) { + return ResultUtil.success("执行成功!"); + } else { + return ResultUtil.error("执行失败!"); + } + } + + /** + * 根据id重定向指定地址 + * + * @param id + * @return ResponseEntity + * @author 王富康 + * @date 2024/11/8 + */ + @GetMapping("/redirect") + public ResponseEntity redirect(String id) { + if(StringUtils.isEmpty(id)){ + throw new RuntimeException("id不可为空!"); + } + final UrlMapping byId = urlMappingService.getById(id); + if (byId != null) { + return ResponseEntity.status(HttpStatus.FOUND).location(URI.create(byId.getLongUrl())).build(); + } else { + return ResponseEntity.notFound().build(); + } + } +} diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/urlmapping/entity/UrlMapping.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/urlmapping/entity/UrlMapping.java new file mode 100644 index 00000000..0f348f1a --- /dev/null +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/urlmapping/entity/UrlMapping.java @@ -0,0 +1,29 @@ +package cc.hiver.mall.urlmapping.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * 二维码重定向对应表 + * + * @author 王富康 + * @date 2024/11/8 + */ +@Data +@ApiModel(value = "二维码重定向对应表") +@TableName(value = "t_url_mapping", autoResultMap = true) +public class UrlMapping implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "主键id") + private String id; + + @ApiModelProperty(value = "重定向的连接") + private String longUrl; + +} diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/urlmapping/mapper/UrlMappingMapper.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/urlmapping/mapper/UrlMappingMapper.java new file mode 100644 index 00000000..3187c7fe --- /dev/null +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/urlmapping/mapper/UrlMappingMapper.java @@ -0,0 +1,8 @@ +package cc.hiver.mall.urlmapping.mapper; + +import cc.hiver.mall.urlmapping.entity.UrlMapping; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +public interface UrlMappingMapper extends BaseMapper { + +} diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/urlmapping/service/UrlMappingService.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/urlmapping/service/UrlMappingService.java new file mode 100644 index 00000000..fde9ae44 --- /dev/null +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/urlmapping/service/UrlMappingService.java @@ -0,0 +1,14 @@ +package cc.hiver.mall.urlmapping.service; + +import cc.hiver.mall.urlmapping.entity.UrlMapping; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * 二维码重定向对应服务 + * + * @author 王富康 + * @date 2024/11/8 + */ +public interface UrlMappingService extends IService { + +} diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/urlmapping/service/impl/UrlMappingServiceImpl.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/urlmapping/service/impl/UrlMappingServiceImpl.java new file mode 100644 index 00000000..d938de74 --- /dev/null +++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/urlmapping/service/impl/UrlMappingServiceImpl.java @@ -0,0 +1,12 @@ +package cc.hiver.mall.urlmapping.service.impl; + +import cc.hiver.mall.urlmapping.entity.UrlMapping; +import cc.hiver.mall.urlmapping.mapper.UrlMappingMapper; +import cc.hiver.mall.urlmapping.service.UrlMappingService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +@Service +public class UrlMappingServiceImpl extends ServiceImpl implements UrlMappingService { + +} diff --git a/hiver-modules/hiver-mall/src/main/resources/mapper/CheckStockDetailMapper.xml b/hiver-modules/hiver-mall/src/main/resources/mapper/CheckStockDetailMapper.xml index 610434a0..b1d52d90 100644 --- a/hiver-modules/hiver-mall/src/main/resources/mapper/CheckStockDetailMapper.xml +++ b/hiver-modules/hiver-mall/src/main/resources/mapper/CheckStockDetailMapper.xml @@ -135,4 +135,28 @@ product_picture, product_sn, shop_id, attribute_list, pd_num, change_count, stoc and check_stock_id = #{checkStockId,jdbcType=VARCHAR} and product_id = #{productId,jdbcType=VARCHAR} + + \ No newline at end of file diff --git a/hiver-modules/hiver-mall/src/main/resources/mapper/UrlMappingMapper.xml b/hiver-modules/hiver-mall/src/main/resources/mapper/UrlMappingMapper.xml new file mode 100644 index 00000000..135b5c91 --- /dev/null +++ b/hiver-modules/hiver-mall/src/main/resources/mapper/UrlMappingMapper.xml @@ -0,0 +1,12 @@ + + + + + + + + + + id, long_url + + \ No newline at end of file