Browse Source

Merge remote-tracking branch 'origin/master'

wangming 1 day ago
parent
commit
6d2850362e
25 changed files with 520 additions and 117 deletions
  1. 69 1
      yami-shop-api/src/main/java/com/yami/shop/api/controller/OrderRefundController.java
  2. 2 0
      yami-shop-api/src/main/java/com/yami/shop/api/listener/SubmitOrderListener.java
  3. 11 0
      yami-shop-bean/src/main/java/com/yami/shop/bean/model/CategoryProd.java
  4. 60 0
      yami-shop-bean/src/main/java/com/yami/shop/bean/model/CategoryProdHb.java
  5. 6 0
      yami-shop-bean/src/main/java/com/yami/shop/bean/param/CategoryProductDTO.java
  6. 26 8
      yami-shop-platform/src/main/java/com/yami/shop/platform/controller/CategoryPropController.java
  7. 48 0
      yami-shop-platform/src/main/java/com/yami/shop/platform/controller/CategoryPropHbController.java
  8. 0 11
      yami-shop-platform/src/main/java/com/yami/shop/platform/controller/ShopCategoryController.java
  9. 1 1
      yami-shop-platform/src/main/java/com/yami/shop/platform/controller/hb/GoodsController.java
  10. 2 2
      yami-shop-platform/src/main/resources/application.yml
  11. 22 0
      yami-shop-service/src/main/java/com/yami/shop/dao/CategoryProdHbMapper.java
  12. 7 0
      yami-shop-service/src/main/java/com/yami/shop/dao/CategoryProdMapper.java
  13. 24 0
      yami-shop-service/src/main/java/com/yami/shop/service/CategoryProdHbService.java
  14. 22 0
      yami-shop-service/src/main/java/com/yami/shop/service/CategoryProdService.java
  15. 0 6
      yami-shop-service/src/main/java/com/yami/shop/service/IShopCategoryService.java
  16. 1 5
      yami-shop-service/src/main/java/com/yami/shop/service/hb/IHBGoodsService.java
  17. 12 31
      yami-shop-service/src/main/java/com/yami/shop/service/hb/impl/HBGoodsService.java
  18. 25 0
      yami-shop-service/src/main/java/com/yami/shop/service/impl/CategoryProdHbServiceImpl.java
  19. 82 4
      yami-shop-service/src/main/java/com/yami/shop/service/impl/CategoryProdServiceImpl.java
  20. 0 27
      yami-shop-service/src/main/java/com/yami/shop/service/impl/ShopCategoryServiceImpl.java
  21. 21 0
      yami-shop-service/src/main/resources/mapper/CategoryProdHbMapper.xml
  22. 27 14
      yami-shop-service/src/main/resources/mapper/CategoryProdMapper.xml
  23. 1 1
      yami-shop-service/src/main/resources/mapper/PointsRecordMapper.xml
  24. 27 6
      yami-shop-service/src/main/resources/mapper/UserMapper.xml
  25. 24 0
      yami-shop-user/yami-shop-user-comment/src/main/java/com/yami/shop/user/comment/service/impl/UserScoreDetailServiceImpl.java

+ 69 - 1
yami-shop-api/src/main/java/com/yami/shop/api/controller/OrderRefundController.java

@@ -20,8 +20,10 @@ import com.yami.shop.common.exception.GlobalException;
 import com.yami.shop.common.util.Arith;
 import com.yami.shop.common.util.PageParam;
 import com.yami.shop.common.util.RefundSnUtils;
+import com.yami.shop.dao.OrderItemMapper;
 import com.yami.shop.dao.OrderRefundRecordMapper;
 import com.yami.shop.dao.OrderRefundSkuMapper;
+import com.yami.shop.dao.PointsRecordMapper;
 import com.yami.shop.delivery.comment.api.paotui.PaoTuiApi;
 import com.yami.shop.delivery.comment.api.paotui.model.request.AddWithoutShopRequest;
 import com.yami.shop.delivery.comment.api.paotui.model.request.DeliveryCpriceRequest;
@@ -81,6 +83,9 @@ public class OrderRefundController {
 
     private final UserAddrService userAddrService;
 
+    @Autowired
+    private OrderItemMapper orderItemMapper;
+
 
     private final TransportManagerService transportManagerService;
 
@@ -99,6 +104,9 @@ public class OrderRefundController {
     @Autowired
     private SkuService skuService;
 
+    @Autowired
+    PointsRecordMapper pointsRecordMapper;
+
 
     @GetMapping("getIsDistribution")
     @ApiOperation(value = "获取是否在配送中")
@@ -378,7 +386,8 @@ public class OrderRefundController {
             long refundPoints = Math.round(refundTotalPoints);
             newOrderRefund.setOffsetPoints(Math.min(refundPoints, orderPoints));
         }
-
+        //需要再这里调用获取过期积分和退款积分
+//        getExpiredAndReturn(newOrderRefund,order,orderRefundSkuList);
         OrderRefund orderRefund = orderRefundService.applyRefund(newOrderRefund);
         if (!orderRefundSkuList.isEmpty()) {
             orderRefundSkuList.forEach(c -> {
@@ -801,4 +810,63 @@ public class OrderRefundController {
         return false;
     }
 
+    /**
+     * 获取过期积分和退还积分
+     * @param orderRefund
+     * @param order
+     * @param orderRefundSkuList
+     */
+    private void getExpiredAndReturn(OrderRefund orderRefund,Order order,List<OrderRefundSku> orderRefundSkuList){
+        //退款的积分 将所有的钱都转为积分对比
+        int totalRefundScore = 0;//需要退款的积分,部分退款时不需要退运费。
+        //该未过期的积分
+        long noRefundExpiredScore = 0L;
+        //改订单总的积分
+        long orderSumScore = 0L;
+
+        int freightAmountScore = -(int) Arith.mul(order.getFreightAmount(), 100);//需要退的总积分,先把运费剔除掉
+        for (OrderRefundSku orderRefundSku : orderRefundSkuList) {
+            Integer productCount = orderRefundSku.getProductCount();
+            OrderItem orderItem = orderItemMapper.selectById(orderRefundSku.getOrderItemId());
+            totalRefundScore =  (int) (totalRefundScore+ Arith.mul(productCount * orderItem.getPrice(), 100));
+        }
+        if (orderRefund.getRefundType()==1){
+            totalRefundScore+=freightAmountScore;
+        }
+
+        List<PointsRecord> pointsRecords = pointsRecordMapper.findByOrderNumber(order.getOrderNumber(), 2);
+        for (PointsRecord pointsRecord : pointsRecords) {
+            if (pointsRecord.getExpiryStatus()==1){
+                int i=0;
+                if (pointsRecord.getPointsAudit()==2){
+                    i =pointsRecord.getVariablePoints().intValue();
+                }else if(pointsRecord.getPointsAudit()==1){
+                    i = pointsRecord.getPoints().intValue();
+                }
+                noRefundExpiredScore+=i;
+            }
+            if (pointsRecord.getPointsAudit()==2){
+                orderSumScore +=pointsRecord.getVariablePoints().intValue();
+            }else if(pointsRecord.getPointsAudit()==1){
+                orderSumScore += pointsRecord.getPoints().intValue();
+            }
+        }
+        if (order.getOffsetPoints()>0&&totalRefundScore!=0){
+            if (order.getOffsetPoints()>=totalRefundScore){
+                orderRefund.setOffsetPoints(Long.valueOf(totalRefundScore));
+                if (totalRefundScore<=orderSumScore){
+                    if (totalRefundScore>noRefundExpiredScore){
+                        orderRefund.setRefundExpiredScore(totalRefundScore-noRefundExpiredScore);
+                    }
+                }
+            }else {
+                orderRefund.setOffsetPoints(order.getOffsetPoints());
+                if (order.getOffsetPoints()<=orderSumScore){
+                    if (order.getOffsetPoints()>noRefundExpiredScore){
+                        orderRefund.setRefundExpiredScore(order.getOffsetPoints()-noRefundExpiredScore);
+                    }
+                }
+            }
+        }
+    }
 }

+ 2 - 0
yami-shop-api/src/main/java/com/yami/shop/api/listener/SubmitOrderListener.java

@@ -23,6 +23,7 @@ import com.yami.shop.bean.enums.OrderType;
 import com.yami.shop.bean.event.SubmitOrderEvent;
 import com.yami.shop.bean.model.*;
 import com.yami.shop.bean.order.SubmitOrderOrder;
+import com.yami.shop.common.enums.PayType;
 import com.yami.shop.common.exception.GlobalException;
 import com.yami.shop.common.util.Arith;
 import com.yami.shop.dao.*;
@@ -150,6 +151,7 @@ public class SubmitOrderListener {
                     Double mul = Arith.mul(actualTotal, 100);
                     Double vp = Double.valueOf(point);
                     if (vp >= mul) {
+                        order.setPayType(PayType.SCOREPAY.value());
                         order.setIsPayed(1);
                         order.setPayTime(new Date());
                         order.setHbOrderStatus(OrderStatus.CONSIGNMENT.value());

+ 11 - 0
yami-shop-bean/src/main/java/com/yami/shop/bean/model/CategoryProd.java

@@ -33,6 +33,17 @@ public class CategoryProd implements Serializable {
      */
 
     private Long prodId;
+    /**
+     * 商品名称
+     */
+    @TableField(exist = false)
+    private String prodName;
+
+    /**
+     * 商品上架状态(0:商家下架、1:上架、2:违规下架、3:平台审核)
+     */
+    @TableField(exist = false)
+    private Integer status;
 
     private String code;
 

+ 60 - 0
yami-shop-bean/src/main/java/com/yami/shop/bean/model/CategoryProdHb.java

@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2018-2999 广州亚米信息科技有限公司 All rights reserved.
+ *
+ * https://www.gz-yami.com/
+ *
+ * 未经允许,不可做商业用途!
+ *
+ * 版权所有,侵权必究!
+ */
+
+package com.yami.shop.bean.model;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+import java.util.Date;
+
+@Data
+@TableName("tz_category_prod_hb")
+public class CategoryProdHb implements Serializable {
+    @TableId
+    private Long id;
+
+    /**
+     * 分类编码
+     */
+    private String code;
+
+
+    /**
+     * 商品属性id即表tz_prod_prop中的prop_id
+     */
+    private Long prodId;
+    /**
+     * 商品名称
+     */
+    @TableField(exist = false)
+    private String prodName;
+
+    /**
+     * 商品上架状态(0:商家下架、1:上架、2:违规下架、3:平台审核)
+     */
+    @TableField(exist = false)
+    private Integer status;
+
+    /**
+     * 0 正常,1 删除
+     */
+    private Integer isDelete;
+
+    /**
+     * 创建时间
+     */
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+}

+ 6 - 0
yami-shop-bean/src/main/java/com/yami/shop/bean/param/CategoryProductDTO.java

@@ -13,6 +13,12 @@ public class CategoryProductDTO {
     @NotNull(message = "门店分类id不能为空")
     private Long categoryId;
 
+    /**
+     * 分类ParentCode
+     */
+    @NotNull(message = "分类ParentCode不能为空")
+    private String parentCode;
+
      /**
      * 分类code
      */

+ 26 - 8
yami-shop-platform/src/main/java/com/yami/shop/platform/controller/CategoryPropController.java

@@ -14,19 +14,20 @@ import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.yami.shop.bean.model.CategoryProd;
+import com.yami.shop.bean.param.CategoryProductDTO;
 import com.yami.shop.common.util.PageParam;
 import com.yami.shop.common.util.R;
 import com.yami.shop.service.CategoryProdService;
+import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
+import javax.validation.Valid;
 import java.util.List;
 
 
 /**
- * 分类绑定商品管理
+ * 门店分类绑定商品管理
  *
  * @author fbj
  * @version 1.0.0
@@ -57,11 +58,28 @@ public class CategoryPropController {
      */
     @GetMapping("/pageByCode")
     public R<IPage<CategoryProd>> pageByCode(CategoryProd categoryProd, PageParam<CategoryProd> page) {
-        IPage<CategoryProd> list = categoryProdService.page(page, new LambdaQueryWrapper<CategoryProd>()
-                .eq(CategoryProd::getCode, categoryProd.getCode())
-                .eq(CategoryProd::getIsDelete, 0)
-                .eq(ObjectUtil.isNotEmpty(categoryProd.getShopId()), CategoryProd::getShopId, categoryProd.getShopId()));
+        IPage<CategoryProd> list = categoryProdService.pageByCode(categoryProd, page);
         return R.SUCCESS(list);
     }
 
+
+    /**
+     * 绑定分类商品
+     */
+    @PostMapping("/categoryProduct")
+    @ApiOperation(value = "绑定门店分类商品", notes = "绑定门店分类商品")
+    public R categoryProduct(@Valid @RequestBody CategoryProductDTO categoryProductDTO) {
+        categoryProdService.categoryProduct(categoryProductDTO);
+        return R.SUCCESS("绑定商品成功");
+    }
+
+    /**
+     * 取消分类绑定商品
+     */
+    @PostMapping("/cancelCategoryProduct")
+    @ApiOperation(value = "取消分类绑定商品", notes = "取消分类绑定商品")
+    public R cancelCategoryProduct(@Valid @RequestBody CategoryProductDTO categoryProductDTO) {
+        categoryProdService.cancelCategoryProduct(categoryProductDTO);
+        return R.SUCCESS();
+    }
 }

+ 48 - 0
yami-shop-platform/src/main/java/com/yami/shop/platform/controller/CategoryPropHbController.java

@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2018-2999 广州亚米信息科技有限公司 All rights reserved.
+ *
+ * https://www.gz-yami.com/
+ *
+ * 未经允许,不可做商业用途!
+ *
+ * 版权所有,侵权必究!
+ */
+
+package com.yami.shop.platform.controller;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.yami.shop.bean.model.CategoryProdHb;
+import com.yami.shop.common.util.PageParam;
+import com.yami.shop.common.util.R;
+import com.yami.shop.service.CategoryProdHbService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+
+/**
+ * 海博分类绑定商品管理
+ *
+ * @author fbj
+ * @version 1.0.0
+ * @since 2025-9-26
+ */
+@RestController
+@RequestMapping("/platform/categoryProdHb")
+public class CategoryPropHbController {
+
+    @Autowired
+    private CategoryProdHbService categoryProdHbService;
+
+
+    /**
+     * 分页通过code查询分类绑定商品
+     */
+    @GetMapping("/pageByCode")
+    public R<IPage<CategoryProdHb>> pageByCode(CategoryProdHb categoryProd, PageParam<CategoryProdHb> page) {
+        IPage<CategoryProdHb> list = categoryProdHbService.pageByCode(categoryProd, page);
+        return R.SUCCESS(list);
+    }
+
+}

+ 0 - 11
yami-shop-platform/src/main/java/com/yami/shop/platform/controller/ShopCategoryController.java

@@ -189,16 +189,5 @@ public class ShopCategoryController {
         return R.FAIL("删除门店前台类目失败");
     }
 
-    /**
-     * 绑定分类商品
-     */
-    @PostMapping("/categoryProduct")
-    @ApiOperation(value = "绑定门店分类商品", notes = "绑定门店分类商品")
-    public R categoryProduct(@Valid @RequestBody CategoryProductDTO categoryProductDTO) {
-        shopCategoryService.categoryProduct(categoryProductDTO);
-        return R.SUCCESS("绑定商品成功");
-    }
-
-
 
 }

+ 1 - 1
yami-shop-platform/src/main/java/com/yami/shop/platform/controller/hb/GoodsController.java

@@ -30,7 +30,7 @@ public class GoodsController {
      * @param HBRequest 海博商品请求参数
      * @return 商品信息响应
      */
-    @PostMapping("117488990")
+    @PostMapping("/add")
     @ApiOperation(value = "添加商品信息", notes = "海博新增商品信息回调接口")
     public HBR addGoods(@RequestBody JSONObject HBRequest) {
         log.info("海博新增商品{}",HBRequest);

+ 2 - 2
yami-shop-platform/src/main/resources/application.yml

@@ -1,8 +1,8 @@
 spring:
   # 环境 dev|prod|docker quartz定时任务
   profiles:
-#    active: dev
-    active: prod
+    active: dev
+#    active: prod
   #文件上传设置
   servlet:
 

+ 22 - 0
yami-shop-service/src/main/java/com/yami/shop/dao/CategoryProdHbMapper.java

@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2018-2999 广州亚米信息科技有限公司 All rights reserved.
+ *
+ * https://www.gz-yami.com/
+ *
+ * 未经允许,不可做商业用途!
+ *
+ * 版权所有,侵权必究!
+ */
+
+package com.yami.shop.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.yami.shop.bean.model.CategoryProd;
+import com.yami.shop.bean.model.CategoryProdHb;
+import com.yami.shop.common.util.PageParam;
+import org.apache.ibatis.annotations.Param;
+
+public interface CategoryProdHbMapper extends BaseMapper<CategoryProdHb> {
+	IPage<CategoryProdHb> pageByCode(PageParam<CategoryProdHb> page, @Param("categoryProd")CategoryProdHb categoryProd);
+}

+ 7 - 0
yami-shop-service/src/main/java/com/yami/shop/dao/CategoryProdMapper.java

@@ -12,6 +12,8 @@ package com.yami.shop.dao;
 
 import java.util.List;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.yami.shop.common.util.PageParam;
 import org.apache.ibatis.annotations.Param;
 
 import com.yami.shop.bean.model.CategoryProd;
@@ -24,4 +26,9 @@ public interface CategoryProdMapper extends BaseMapper<CategoryProd> {
 	void deleteByCategoryId(Long categoryId);
 
 	void deleteByProdId(Long prodId);
+
+	/**
+     * 通过code查询分类绑定商品
+     */
+    IPage<CategoryProd> pageByCode(PageParam<CategoryProd> page, @Param("categoryProd") CategoryProd categoryProd);
 }

+ 24 - 0
yami-shop-service/src/main/java/com/yami/shop/service/CategoryProdHbService.java

@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2018-2999 广州亚米信息科技有限公司 All rights reserved.
+ *
+ * https://www.gz-yami.com/
+ *
+ * 未经允许,不可做商业用途!
+ *
+ * 版权所有,侵权必究!
+ */
+
+package com.yami.shop.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.yami.shop.bean.model.CategoryProdHb;
+import com.yami.shop.common.util.PageParam;
+
+public interface CategoryProdHbService extends IService<CategoryProdHb> {
+
+    /**
+     * 通过code查询分类绑定商品
+     */
+    IPage<CategoryProdHb> pageByCode(CategoryProdHb categoryProd, PageParam<CategoryProdHb> page);
+}

+ 22 - 0
yami-shop-service/src/main/java/com/yami/shop/service/CategoryProdService.java

@@ -10,8 +10,11 @@
 
 package com.yami.shop.service;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.yami.shop.bean.model.CategoryProd;
+import com.yami.shop.bean.param.CategoryProductDTO;
+import com.yami.shop.common.util.PageParam;
 
 /**
  *
@@ -19,4 +22,23 @@ import com.yami.shop.bean.model.CategoryProd;
  */
 public interface CategoryProdService extends IService<CategoryProd> {
 
+    /**
+     * 通过code查询分类绑定商品
+     * @param categoryProd 查询参数
+     * @return 分类绑定商品
+     */
+    IPage<CategoryProd> pageByCode(CategoryProd categoryProd, PageParam<CategoryProd> page);
+
+
+    /**
+     * 绑定分类商品
+     * @param categoryProductDTO 分类商品参数
+     */
+    void categoryProduct(CategoryProductDTO categoryProductDTO);
+
+    /**
+     * 取消绑定分类商品
+     * @param categoryProductDTO 分类商品参数
+     */
+    void cancelCategoryProduct(CategoryProductDTO categoryProductDTO);
 }

+ 0 - 6
yami-shop-service/src/main/java/com/yami/shop/service/IShopCategoryService.java

@@ -44,10 +44,4 @@ public interface IShopCategoryService extends IService<ShopCategory> {
      */
     IPage<Category> listByParentIdAndShopId(Long parentId, Long shopId, Integer current, Integer size);
 
-    /**
-     * 绑定分类商品
-     * @param categoryProductDTO 分类商品参数
-     */
-    void categoryProduct(CategoryProductDTO categoryProductDTO);
-
 }

+ 1 - 5
yami-shop-service/src/main/java/com/yami/shop/service/hb/IHBGoodsService.java

@@ -23,11 +23,7 @@ public interface IHBGoodsService {
      * @return 商品信息响应
      */
     HBR addHBGoods(JSONObject hbRequest);
-    /**
-     * 修改商品信息
-     * @param hbRequest 海博传入参数
-     */
-    HBR updateGoods(JSONObject hbRequest);
+
     /**
      * 修改商品状态信息
      * @param hbRequest 海博传入参数

+ 12 - 31
yami-shop-service/src/main/java/com/yami/shop/service/hb/impl/HBGoodsService.java

@@ -45,7 +45,7 @@ public class HBGoodsService implements IHBGoodsService {
 
     private final FrontCategoryMapper frontCategoryMapper;
     private final ShopCategoryMapper shopCategoryMapper;
-    private final CategoryProdMapper categoryProdMapper;
+    private final CategoryProdHbMapper categoryProdHbMapper;
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -163,26 +163,12 @@ public class HBGoodsService implements IHBGoodsService {
         return HBR.success();
     }
 
-    @Override
-    public HBR updateGoods(JSONObject hbRequest) {
-        try {
-            String bodyStr = hbRequest.getString("body");
-            log.info("商品,body:{}", bodyStr);
-            JSONObject bodyJson = JSON.parseObject(bodyStr); // 使用Fastjson的解析方法
-            String outStationNo = bodyJson.getString("outStationNo");
-        } catch (Exception e) {
-            log.error("商品失败:{}", e.getMessage(), e);
-            return HBR.error("未知异常");
-
-        }
-        return HBR.success();
-    }
 
     @Override
     public HBR updateGoodsStatus(JSONObject hbRequest) {
         try {
             JSONObject bodyStr = hbRequest.getJSONObject("body");
-            log.info("商品,body:{}", bodyStr);
+            log.info("商品可售状态,body:{}", bodyStr);
 
             JSONArray data = bodyStr.getJSONArray("data");// 使用Fastjson的解析方法
             String selfSkuStatus = getSelfSkuStatus(data);
@@ -206,10 +192,10 @@ public class HBGoodsService implements IHBGoodsService {
                         .eq(ShopSku::getShopId, shopDetail.getShopId()));
 
                 //处理门店-分类管理
-                List<CategoryProd> categoryProds = categoryProdMapper.selectList(new LambdaQueryWrapper<CategoryProd>()
-                        .eq(CategoryProd::getProdId, sku.getProdId())
-                        .eq(CategoryProd::getIsDelete, 0));
-                for (CategoryProd categoryProd : categoryProds) {
+                List<CategoryProdHb> categoryProds = categoryProdHbMapper.selectList(new LambdaQueryWrapper<CategoryProdHb>()
+                        .eq(CategoryProdHb::getProdId, sku.getProdId())
+                        .eq(CategoryProdHb::getIsDelete, 0));
+                for (CategoryProdHb categoryProd : categoryProds) {
                     FrontCategory frontCategory = frontCategoryMapper.selectOne(new LambdaQueryWrapper<FrontCategory>()
                             .eq(FrontCategory::getCode, categoryProd.getCode()));
                     addShopCategory(frontCategory, shopDetail.getShopId(), shopDetail.getHbStationId());
@@ -617,10 +603,6 @@ public class HBGoodsService implements IHBGoodsService {
             String ztFrontCategoryCodeLevel = jsonObject.getString("ztFrontCategoryCodeLevel2");
             if (StringUtils.isEmpty(ztFrontCategoryCodeLevel)) {
                 ztFrontCategoryCodeLevel = jsonObject.getString("ztFrontCategoryCode");
-//            } else {
-//                //如果是二级,一级对应商品不存在也需要添加
-//                addCategoryProd(spuId, ztFrontCategoryCodeLevel);
-//                ztFrontCategoryCodeLevel = jsonObject.getString("ztFrontCategoryCode");
             }
             addCategoryProd(spuId, ztFrontCategoryCodeLevel);
 
@@ -629,17 +611,16 @@ public class HBGoodsService implements IHBGoodsService {
     }
 
     private void addCategoryProd(Long spuId, String ztFrontCategoryCodeLevel) {
-        CategoryProd categoryProd = new CategoryProd();
+        CategoryProdHb categoryProd = new CategoryProdHb();
         categoryProd.setCode(ztFrontCategoryCodeLevel);
         categoryProd.setProdId(spuId);
         categoryProd.setIsDelete(0);
-        CategoryProd integer = categoryProdMapper.selectOne(new LambdaQueryWrapper<CategoryProd>()
-                .eq(CategoryProd::getProdId, spuId)
-                .eq(CategoryProd::getIsDelete, 0)
-                .eq(CategoryProd::getCode, ztFrontCategoryCodeLevel));
+        CategoryProdHb integer = categoryProdHbMapper.selectOne(new LambdaQueryWrapper<CategoryProdHb>()
+                .eq(CategoryProdHb::getProdId, spuId)
+                .eq(CategoryProdHb::getIsDelete, 0)
+                .eq(CategoryProdHb::getCode, ztFrontCategoryCodeLevel));
         if (integer == null) {
-            categoryProdMapper.insert(categoryProd);
-
+            categoryProdHbMapper.insert(categoryProd);
         }
         //门店分类处理
         List<ShopSku> shopCategoryList = shopSkuMapper.selectList(new LambdaQueryWrapper<ShopSku>()

+ 25 - 0
yami-shop-service/src/main/java/com/yami/shop/service/impl/CategoryProdHbServiceImpl.java

@@ -0,0 +1,25 @@
+
+package com.yami.shop.service.impl;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.yami.shop.bean.model.CategoryProdHb;
+import com.yami.shop.common.util.PageParam;
+import com.yami.shop.dao.CategoryProdHbMapper;
+import com.yami.shop.service.CategoryProdHbService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+
+@Service
+public class CategoryProdHbServiceImpl extends ServiceImpl<CategoryProdHbMapper, CategoryProdHb> implements CategoryProdHbService {
+
+    @Autowired
+    private CategoryProdHbMapper categoryPropHbMapper;
+
+    @Override
+    public IPage<CategoryProdHb> pageByCode(CategoryProdHb categoryProd, PageParam<CategoryProdHb> page) {
+        return categoryPropHbMapper.pageByCode(page, categoryProd);
+    }
+
+}

+ 82 - 4
yami-shop-service/src/main/java/com/yami/shop/service/impl/CategoryProdServiceImpl.java

@@ -1,16 +1,23 @@
 
 package com.yami.shop.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
 import com.yami.shop.bean.model.CategoryProd;
+import com.yami.shop.bean.param.CategoryProductDTO;
+import com.yami.shop.common.exception.GlobalException;
+import com.yami.shop.common.util.PageParam;
 import com.yami.shop.dao.CategoryProdMapper;
 import com.yami.shop.service.CategoryProdService;
+import org.apache.commons.lang3.ObjectUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+import java.util.List;
 
 /**
- *
  * Created by lgh on 2018/07/13.
  */
 @Service
@@ -19,4 +26,75 @@ public class CategoryProdServiceImpl extends ServiceImpl<CategoryProdMapper, Cat
     @Autowired
     private CategoryProdMapper categoryPropMapper;
 
+    @Override
+    public IPage<CategoryProd> pageByCode(CategoryProd categoryProd, PageParam<CategoryProd> page) {
+        return categoryPropMapper.pageByCode(page, categoryProd);
+    }
+
+
+    @Override
+    public void categoryProduct(CategoryProductDTO categoryProductDTO) {
+        List<Long> prodIdList = categoryProductDTO.getProdIdList();
+        if (ObjectUtils.isEmpty(prodIdList)) {
+            new GlobalException("新增商品为空!请选择商品");
+        }
+        for (Long aLong : prodIdList) {
+
+            Integer integer = categoryPropMapper.selectCount(new LambdaQueryWrapper<CategoryProd>().eq(CategoryProd::getProdId, aLong)
+                    .eq(CategoryProd::getIsDelete, 0)
+                    .eq(CategoryProd::getShopId, categoryProductDTO.getShopId())
+                    .eq(CategoryProd::getCode, categoryProductDTO.getCode()));
+
+            if (integer > 0) {
+                new GlobalException("该门店分类对应商品ID=" + aLong + " 已存在!请勿重复添加");
+            }
+            CategoryProd categoryProd = new CategoryProd();
+            categoryProd.setCategoryId(categoryProductDTO.getCategoryId());
+            categoryProd.setProdId(aLong);
+            categoryProd.setShopId(categoryProductDTO.getShopId());
+            categoryProd.setCode(categoryProductDTO.getCode());
+            categoryProd.setIsDelete(0);
+            categoryProd.setCreateTime(new Date());
+            categoryPropMapper.insert(categoryProd);
+
+            //查看父类绑定商品是否存在不存在添加
+            Integer integer1 = categoryPropMapper.selectCount(new LambdaQueryWrapper<CategoryProd>()
+                    .eq(CategoryProd::getCode, categoryProductDTO.getParentCode())
+                    .eq(CategoryProd::getIsDelete, 0));
+            if (integer1 == 0) {
+                CategoryProd categoryProdParent = new CategoryProd();
+                categoryProdParent.setCategoryId(categoryProductDTO.getCategoryId());
+                categoryProdParent.setProdId(aLong);
+                categoryProdParent.setShopId(categoryProductDTO.getShopId());
+                categoryProdParent.setCode(categoryProductDTO.getParentCode());
+                categoryProdParent.setIsDelete(0);
+                categoryProdParent.setCreateTime(new Date());
+                categoryPropMapper.insert(categoryProdParent);
+            }
+
+        }
+    }
+
+    @Override
+    public void cancelCategoryProduct(CategoryProductDTO categoryProductDTO) {
+        List<Long> prodIdList = categoryProductDTO.getProdIdList();
+        if (ObjectUtils.isEmpty(prodIdList)) {
+            new GlobalException("取消商品为空!请选择商品");
+        }
+
+        for (Long aLong : prodIdList) {
+
+            CategoryProd categoryProd = categoryPropMapper.selectOne(new LambdaQueryWrapper<CategoryProd>().eq(CategoryProd::getProdId, aLong)
+                    .eq(CategoryProd::getIsDelete, 0)
+                    .eq(CategoryProd::getShopId, categoryProductDTO.getShopId())
+                    .eq(CategoryProd::getCode, categoryProductDTO.getCode()));
+
+            if (ObjectUtils.isEmpty(categoryProd)) {
+                new GlobalException("该门店分类对应商品ID=" + aLong + " 不存在!请勿重复取消");
+            }
+            categoryProd.setIsDelete(1);
+            categoryPropMapper.deleteById(categoryProd);
+        }
+
+    }
 }

+ 0 - 27
yami-shop-service/src/main/java/com/yami/shop/service/impl/ShopCategoryServiceImpl.java

@@ -186,33 +186,6 @@ public class ShopCategoryServiceImpl extends ServiceImpl<ShopCategoryMapper, Sho
         return res;
     }
 
-    @Override
-    public void categoryProduct(CategoryProductDTO categoryProductDTO) {
-        List<Long> prodIdList = categoryProductDTO.getProdIdList();
-        if (ObjectUtils.isEmpty(prodIdList)) {
-            new GlobalException("新增商品为空!请选择商品");
-        }
-        for (Long aLong : prodIdList) {
-
-            Integer integer = categoryProdMapper.selectCount(new LambdaQueryWrapper<CategoryProd>().eq(CategoryProd::getProdId, aLong)
-                    .eq(CategoryProd::getIsDelete, 0)
-                    .eq(CategoryProd::getShopId, categoryProductDTO.getShopId())
-                    .eq(CategoryProd::getCode, categoryProductDTO.getCode()));
-
-            if (integer > 0) {
-                new GlobalException("该门店分类对应商品ID="+aLong+" 已存在!请勿重复添加");
-            }
-            CategoryProd categoryProd = new CategoryProd();
-            categoryProd.setCategoryId(categoryProductDTO.getCategoryId());
-            categoryProd.setProdId(aLong);
-            categoryProd.setShopId(categoryProductDTO.getShopId());
-            categoryProd.setCode(categoryProductDTO.getCode());
-            categoryProd.setIsDelete(0);
-            categoryProd.setCreateTime(new Date());
-            categoryProdMapper.insert(categoryProd);
-
-        }
-    }
 
     /**
      * 添加对应的二级和三级类目

+ 21 - 0
yami-shop-service/src/main/resources/mapper/CategoryProdHbMapper.xml

@@ -0,0 +1,21 @@
+<?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.yami.shop.dao.CategoryProdHbMapper">
+
+
+    <select id="pageByCode" resultType="com.yami.shop.bean.model.CategoryProdHb">
+        select cp.*, p.prod_name as prodName, p.status
+        from tz_category_prod_hb cp
+        join tz_prod p on cp.prod_id = p.prod_id
+        where p.is_delete = 0 and cp.is_delete = 0
+        <if test="categoryProd.code != null">
+            and cp.code = #{categoryProd.code}
+        </if>
+        <if test="categoryProd.prodName != null">
+            and p.prod_name like concat('%',#{categoryProd.prodName},'%')
+        </if>
+        order by cp.id desc
+    </select>
+
+
+</mapper>

+ 27 - 14
yami-shop-service/src/main/resources/mapper/CategoryProdMapper.xml

@@ -1,21 +1,34 @@
 <?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.yami.shop.dao.CategoryProdMapper">
-  <resultMap id="BaseResultMap" type="com.yami.shop.bean.model.CategoryProd">
-    <!--
-      WARNING - @mbg.generated
-    -->
-    <id column="id" jdbcType="BIGINT" property="id" />
-    <result column="category_id" jdbcType="BIGINT" property="categoryId" />
-    <result column="prop_id" jdbcType="BIGINT" property="propId" />
-  </resultMap>
 
+    <delete id="deleteByCategoryId">
+        delete
+        from tz_category_prod
+        where category_id = #{categoryId}
+    </delete>
 
-  <delete id="deleteByCategoryId">
-  	delete from tz_category_prod where category_id = #{categoryId}
-  </delete>
+    <delete id="deleteByProdId">
+        delete
+        from tz_category_prod
+        where prod_id = #{prodId}
+    </delete>
+
+    <select id="pageByCode" resultType="com.yami.shop.bean.model.CategoryProd">
+        select cp.*, p.prod_name as prodName, p.status
+        from tz_category_prod cp
+        join tz_prod p on cp.prod_id = p.prod_id
+        where p.is_delete = 0 and cp.is_delete = 0
+        <if test="categoryProd.code != null">
+            and cp.code = #{categoryProd.code}
+        </if>
+        <if test="categoryProd.shopId != null">
+            and cp.shop_id = #{categoryProd.shopId}
+        </if>
+        <if test="categoryProd.prodName != null">
+            and p.prod_name like concat('%',#{categoryProd.prodName},'%')
+        </if>
+        order by cp.id desc
+    </select>
 
-  <delete id="deleteByProdId">
-  	delete from tz_category_prod where prod_id = #{prodId}
-  </delete>
 </mapper>

+ 1 - 1
yami-shop-service/src/main/resources/mapper/PointsRecordMapper.xml

@@ -62,7 +62,7 @@
         select id,user_id,channel_id,order_number,
                code,parent_code,points,variable_points,points_type,points_audit,expiry_date,creation_date,currently_available_points,points_id,
                CASE
-               WHEN expiry_date > NOW() THEN 1
+               WHEN expiry_date >= NOW() THEN 1
                ELSE 2 END AS expiryStatus
         from tz_points_record where order_number = #{orderNumber} and points_type =#{pointsType} order by  expiry_date desc
     </select>

+ 27 - 6
yami-shop-service/src/main/resources/mapper/UserMapper.xml

@@ -107,12 +107,33 @@
     <select id="enterpriseUserList" resultType="com.yami.shop.bean.vo.EnterpriseUserVo">
         SELECT a.user_id,a.`status`,a.real_name,a.user_mobile,a.channel_id,
         (SELECT channel_name FROM tz_channel WHERE id= a.channel_id) channelName,
-        IFNULL((SELECT SUM(points) FROM tz_points_recharge WHERE user_id=a.user_id),0) total,
-        IFNULL((SELECT SUM(points) FROM tz_points_recharge WHERE user_id=a.user_id and recharge_status=1),0) available,
-        IFNULL((SELECT SUM(points) FROM tz_points_recharge WHERE user_id=a.user_id and recharge_status=2),0) expired,
-        (SELECT(IFNULL((SELECT SUM(points) FROM tz_points_record WHERE user_id = a.user_id AND points_type = 2 AND
-        points_audit IN (2,3)), 0)-
-        IFNULL((SELECT SUM(points) FROM tz_points_record WHERE user_id = a.user_id AND points_type = 3), 0))) used
+        IFNULL((SELECT SUM(points) FROM tz_points_recharge WHERE user_id=a.user_id),0) total, -- 总积分
+
+        IFNULL(( select (
+        SUM(CASE WHEN points_type = 1 OR points_type = 3 THEN points ELSE 0 END) -- 充值和退款的总积分
+        -
+        GREATEST(
+        SUM( CASE WHEN expiry_date &lt;= NOW() THEN
+        CASE WHEN points_type = 1 OR points_type = 3 THEN points
+        WHEN points_type = 2 THEN -variable_points
+        ELSE 0 END
+        ELSE 0 END ), 0) -- 所以情况的过期积分
+        -
+        SUM(CASE WHEN points_type = 2 THEN variable_points ELSE 0 END) -- 下单的所有积分  未使用 -过期的 = 可用的
+        )  from tz_points_record where user_id =  a.user_id  and channel_id = a.channel_id ),0) available, -- 当前可用积分
+
+        IFNULL(( select  GREATEST(
+        SUM(
+        CASE WHEN expiry_date &lt;= NOW() THEN
+        CASE  WHEN points_type = 1 OR points_type = 3 THEN points
+        WHEN points_type = 2 THEN -variable_points
+        ELSE 0 END
+        ELSE 0 END ), 0 ) from tz_points_record where user_id =  a.user_id  and channel_id = a.channel_id),0) expired, -- 已过期积分
+
+        IFNULL((select  (
+        SUM(CASE WHEN points_type = 2 THEN variable_points ELSE 0 END)
+        -
+        SUM(CASE WHEN points_type = 3 THEN points ELSE 0 END))  from tz_points_record 	where user_id =  a.user_id  and channel_id = a.channel_id),0) used -- 已消耗积分
         FROM tz_user a
         <where>
             a.channel_id in(SELECT id FROM tz_channel)

+ 24 - 0
yami-shop-user/yami-shop-user-comment/src/main/java/com/yami/shop/user/comment/service/impl/UserScoreDetailServiceImpl.java

@@ -202,6 +202,30 @@ public class UserScoreDetailServiceImpl extends ServiceImpl<UserScoreDetailMappe
                                     pointsRecord.getVariablePoints() : "0"));
                     break;
                 case 3:
+                    if (isExpiredToday(pointsRecord.getExpiryDate())&&pointsRecord.getPointsAudit()!=3) {
+                        PointsRecord expiredRecord = new PointsRecord();
+                        // 复制关键属性(根据实际属性补充)
+                        expiredRecord.setId(pointsRecord.getId()); // 若ID唯一需注意业务逻辑
+                        expiredRecord.setCreationDate(pointsRecord.getCreationDate());
+                        expiredRecord.setPointsType(pointsRecord.getPointsType());
+                        expiredRecord.setPoints(pointsRecord.getPoints());
+                        expiredRecord.setVariablePoints(pointsRecord.getVariablePoints());
+                        expiredRecord.setExpiryDate(pointsRecord.getExpiryDate());
+                        expiredRecord.setCurrentlyAvailablePoints(pointsRecord.getCurrentlyAvailablePoints());
+
+                        // 设置复制对象的显示属性
+                        expiredRecord.setCreationDateStr(pointsRecord.getCreationDateStr()); // 复用已格式化的日期
+                        expiredRecord.setPointsTypeStr("过期扣减"); // 示例:区分类型
+                        if (pointsRecord.getPointsAudit()==1){
+                            expiredRecord.setVariablePointsStr("-" + pointsRecord.getPoints()); // 示例:显示过期数量
+                        } else if (pointsRecord.getPointsAudit()==2) {
+                            expiredRecord.setVariablePointsStr("-" + (pointsRecord.getPoints().intValue()-pointsRecord.getVariablePoints().intValue())); // 示例:显示过期数量
+                        }
+
+                        // 设置原对象为过期记录
+                        expiredRecord.setPointsTypeStr("过期");
+                        recordsToAdd.add(expiredRecord); // 添加复制对象
+                    }
                     pointsRecord.setPointsTypeStr("退款");
                     mark = "+";
                     pointsRecord.setVariablePointsStr(mark + pointsRecord.getPoints());