From 824edc826c92312c150a2f0eea9bdd2bfcb82b2f Mon Sep 17 00:00:00 2001
From: gongzuming <gongzuming>
Date: 星期四, 29 八月 2024 14:28:37 +0800
Subject: [PATCH] 冲突

---
 src/main/java/com/mzl/flower/dto/response/point/CustomerPointDetailDTO.java |   39 +++
 src/main/java/com/mzl/flower/entity/point/CustomerPoint.java                |   10 
 src/main/表设计-二期.xlsx                                                        |    0 
 src/main/java/com/mzl/flower/mapper/point/CustomerPointMapper.java          |   11 +
 src/main/java/com/mzl/flower/dto/response/point/CustomerPointDTO.java       |   32 +++
 src/main/java/com/mzl/flower/service/point/CustomerPointService.java        |  114 +++++++++++
 src/main/java/com/mzl/flower/dto/request/point/QueryPointDetailDTO.java     |   28 ++
 src/main/java/com/mzl/flower/dto/request/point/QueryCustomerPointDTO.java   |   12 +
 src/main/java/com/mzl/flower/service/BaseService.java                       |   10 +
 /dev/null                                                                   |  104 ----------
 src/main/java/com/mzl/flower/dto/request/point/ChangePointDTO.java          |   20 ++
 src/main/java/com/mzl/flower/entity/point/PointGoodsRecord.java             |   50 +++++
 src/main/java/com/mzl/flower/web/point/CustomerPointController.java         |   72 ++++++
 src/main/resources/mapper/point/CustomerPointMapper.xml                     |   50 +++++
 src/main/java/com/mzl/flower/config/PyamentV3Configurer.java                |    2 
 src/main/java/com/mzl/flower/mapper/point/PointGoodsRecordMapper.java       |    9 
 src/main/java/com/mzl/flower/entity/point/CustomerPointDetail.java          |    3 
 17 files changed, 451 insertions(+), 115 deletions(-)

diff --git a/src/main/java/com/mzl/flower/config/PyamentV3Configurer.java b/src/main/java/com/mzl/flower/config/PyamentV3Configurer.java
index f715f67..9de019a 100644
--- a/src/main/java/com/mzl/flower/config/PyamentV3Configurer.java
+++ b/src/main/java/com/mzl/flower/config/PyamentV3Configurer.java
@@ -20,7 +20,7 @@
     public static String merchantId = "1661512517";
 
     /** 商户API私钥路径 */
-    public static String privateKeyPath = "E:\\huamanyuan\\apiclient_key.pem";
+    public static String privateKeyPath = "/opt/pay/wx/v3/apiclient_key.pem";
 
     /** 商户证书序列号 */
     public static String merchantSerialNumber = "37A08A552943EF34883614DBC8DE281598148757";
diff --git a/src/main/java/com/mzl/flower/dto/request/point/ChangePointDTO.java b/src/main/java/com/mzl/flower/dto/request/point/ChangePointDTO.java
new file mode 100644
index 0000000..ba68e70
--- /dev/null
+++ b/src/main/java/com/mzl/flower/dto/request/point/ChangePointDTO.java
@@ -0,0 +1,20 @@
+package com.mzl.flower.dto.request.point;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
+@Data
+public class ChangePointDTO {
+
+    @NotNull(message = "积分不能为空")
+    private Integer point;
+
+    @NotBlank(message = "备注不能为空")
+    private String remarks;
+
+    @NotNull(message = "商户ID不能为空")
+    private Long customerId;
+
+}
diff --git a/src/main/java/com/mzl/flower/dto/request/point/QueryCustomerPointDTO.java b/src/main/java/com/mzl/flower/dto/request/point/QueryCustomerPointDTO.java
new file mode 100644
index 0000000..7cf4cd1
--- /dev/null
+++ b/src/main/java/com/mzl/flower/dto/request/point/QueryCustomerPointDTO.java
@@ -0,0 +1,12 @@
+package com.mzl.flower.dto.request.point;
+
+
+import lombok.Data;
+
+@Data
+public class QueryCustomerPointDTO {
+
+    private String customerName;
+
+    private String customerTel;
+}
diff --git a/src/main/java/com/mzl/flower/dto/request/point/QueryPointDetailDTO.java b/src/main/java/com/mzl/flower/dto/request/point/QueryPointDetailDTO.java
new file mode 100644
index 0000000..1c92bde
--- /dev/null
+++ b/src/main/java/com/mzl/flower/dto/request/point/QueryPointDetailDTO.java
@@ -0,0 +1,28 @@
+package com.mzl.flower.dto.request.point;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.time.LocalDate;
+
+@Data
+public class QueryPointDetailDTO {
+
+    @ApiModelProperty("客户ID")
+    private Long customerId;
+
+    @ApiModelProperty("记录日期")
+    private LocalDate recordDateStart;
+
+    @ApiModelProperty("记录日期")
+    private LocalDate recordDateEnd;
+
+    @ApiModelProperty("积分类型-point_type")
+    private String type;
+
+    @ApiModelProperty("备注")
+    private String remarks;
+
+    @ApiModelProperty(hidden = true)
+    private String userId;
+}
diff --git a/src/main/java/com/mzl/flower/dto/response/point/CustomerPointDTO.java b/src/main/java/com/mzl/flower/dto/response/point/CustomerPointDTO.java
new file mode 100644
index 0000000..5e6c074
--- /dev/null
+++ b/src/main/java/com/mzl/flower/dto/response/point/CustomerPointDTO.java
@@ -0,0 +1,32 @@
+package com.mzl.flower.dto.response.point;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+public class CustomerPointDTO {
+
+    private Long id;
+
+    @ApiModelProperty("用户DI")
+    private String userId;
+
+    @ApiModelProperty("商户ID")
+    private Long customerId;
+
+    @ApiModelProperty("商户名称")
+    private String customerName;
+
+    @ApiModelProperty("商户联系电话")
+    private String customerTel;
+
+    @ApiModelProperty("总积分")
+    private String totalPoint;
+
+    @ApiModelProperty("使用积分")
+    private String usedPoint;
+
+    @ApiModelProperty("过期积分")
+    private String expiredPoint;
+
+}
diff --git a/src/main/java/com/mzl/flower/dto/response/point/CustomerPointDetailDTO.java b/src/main/java/com/mzl/flower/dto/response/point/CustomerPointDetailDTO.java
new file mode 100644
index 0000000..84c5568
--- /dev/null
+++ b/src/main/java/com/mzl/flower/dto/response/point/CustomerPointDetailDTO.java
@@ -0,0 +1,39 @@
+package com.mzl.flower.dto.response.point;
+
+import com.mzl.flower.base.AbstractTransDTO;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.time.LocalDate;
+
+@Data
+public class CustomerPointDetailDTO extends AbstractTransDTO {
+
+    @ApiModelProperty("记录日期")
+    private LocalDate recordDate;
+
+    @ApiModelProperty("用户ID")
+    private String userId;
+
+    @ApiModelProperty("商户ID")
+    private Long customerId;
+
+    @ApiModelProperty("积分变更类型-point_change_type")
+    private String changeType;
+
+    @ApiModelProperty("积分类型-point_type")
+    private String type;
+
+    @ApiModelProperty("积分")
+    private String point;
+
+    @ApiModelProperty("使用积分")
+    private String usePoint;
+
+    @ApiModelProperty("过期积分")
+    private String expiredPoint;
+
+    @ApiModelProperty("积分备注")
+    private String remarks;
+
+}
diff --git a/src/main/java/com/mzl/flower/entity/point/CustomerPoint.java b/src/main/java/com/mzl/flower/entity/point/CustomerPoint.java
index 75710eb..55f9510 100644
--- a/src/main/java/com/mzl/flower/entity/point/CustomerPoint.java
+++ b/src/main/java/com/mzl/flower/entity/point/CustomerPoint.java
@@ -12,18 +12,18 @@
 @TableName("t_customer_point")
 public class CustomerPoint extends BaseAutoEntity {
 
-    @ApiModelProperty("名称")
+    @ApiModelProperty("用户ID")
     private String userId;
 
-    @ApiModelProperty("联系人")
+    @ApiModelProperty("商户ID")
     private Long customerId;
 
     @ApiModelProperty("总积分")
-    private String totalPoint;
+    private Integer totalPoint;
 
     @ApiModelProperty("使用积分")
-    private String usedPoint;
+    private Integer usedPoint;
 
     @ApiModelProperty("过期积分")
-    private String expiredPoint;
+    private Integer expiredPoint;
 }
diff --git a/src/main/java/com/mzl/flower/entity/point/CustomerPointDetail.java b/src/main/java/com/mzl/flower/entity/point/CustomerPointDetail.java
index 5825a16..3bd0fae 100644
--- a/src/main/java/com/mzl/flower/entity/point/CustomerPointDetail.java
+++ b/src/main/java/com/mzl/flower/entity/point/CustomerPointDetail.java
@@ -5,6 +5,7 @@
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import java.time.LocalDate;
 import java.util.Date;
 
 
@@ -22,7 +23,7 @@
 public class CustomerPointDetail extends BaseAutoEntity {
 
     @ApiModelProperty("记录日期")
-    private Date recordDate;
+    private LocalDate recordDate;
 
     @ApiModelProperty("用户ID")
     private String userId;
diff --git a/src/main/java/com/mzl/flower/entity/point/PointGoodsRecord.java b/src/main/java/com/mzl/flower/entity/point/PointGoodsRecord.java
new file mode 100644
index 0000000..4421001
--- /dev/null
+++ b/src/main/java/com/mzl/flower/entity/point/PointGoodsRecord.java
@@ -0,0 +1,50 @@
+package com.mzl.flower.entity.point;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.mzl.flower.base.BaseAutoEntity;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+@TableName("t_point_goods_record")
+public class PointGoodsRecord extends BaseAutoEntity {
+
+    @ApiModelProperty(value = "用户ID")
+    private String userId;
+
+    @ApiModelProperty(value = "商户ID")
+    private Long customerId;
+
+    @ApiModelProperty(value = "兑换单号")
+    private String recordNo;
+
+    @ApiModelProperty(value = "兑换码")
+    private String redeemCode;
+
+    @ApiModelProperty(value = "积分商品ID")
+    private Long goodsId;
+
+    @ApiModelProperty(value = "商品名称")
+    private String name;
+
+    @ApiModelProperty(value = "商品描述")
+    private String description;
+
+    @ApiModelProperty(value = "商品封面图")
+    private String cover;
+
+    @ApiModelProperty(value = "商品图片")
+    private String pictures;
+
+    @ApiModelProperty(value = "兑换积分数")
+    private String point;
+
+    @ApiModelProperty(value = "兑换数量")
+    private String num;
+
+    @ApiModelProperty(value = "兑换总积分")
+    private String totalPoint;
+
+    @ApiModelProperty(value = "兑换状态")
+    private String status;
+}
diff --git a/src/main/java/com/mzl/flower/mapper/point/CustomerPointMapper.java b/src/main/java/com/mzl/flower/mapper/point/CustomerPointMapper.java
index 8b62d5d..f8f42fa 100644
--- a/src/main/java/com/mzl/flower/mapper/point/CustomerPointMapper.java
+++ b/src/main/java/com/mzl/flower/mapper/point/CustomerPointMapper.java
@@ -1,11 +1,22 @@
 package com.mzl.flower.mapper.point;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.mzl.flower.dto.request.point.QueryCustomerPointDTO;
+import com.mzl.flower.dto.request.point.QueryPointDetailDTO;
+import com.mzl.flower.dto.response.point.CustomerPointDTO;
+import com.mzl.flower.dto.response.point.CustomerPointDetailDTO;
 import com.mzl.flower.entity.point.CustomerPoint;
 import com.mzl.flower.entity.supplier.Station;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
+
+import java.util.List;
 
 @Repository
 public interface CustomerPointMapper extends BaseMapper<CustomerPoint> {
 
+    List<CustomerPointDTO> queryPage(@Param(value = "dto") QueryCustomerPointDTO dto, Page page);
+
+    List<CustomerPointDetailDTO> queryCustomerDetails(@Param(value = "dto")QueryPointDetailDTO dto, Page page);
 }
diff --git a/src/main/java/com/mzl/flower/mapper/point/PointGoodsRecordMapper.java b/src/main/java/com/mzl/flower/mapper/point/PointGoodsRecordMapper.java
new file mode 100644
index 0000000..f0449c3
--- /dev/null
+++ b/src/main/java/com/mzl/flower/mapper/point/PointGoodsRecordMapper.java
@@ -0,0 +1,9 @@
+package com.mzl.flower.mapper.point;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.mzl.flower.entity.point.CustomerPointDetail;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface PointGoodsRecordMapper extends BaseMapper<CustomerPointDetail> {
+}
diff --git a/src/main/java/com/mzl/flower/service/BaseService.java b/src/main/java/com/mzl/flower/service/BaseService.java
index ac580a1..acd2725 100644
--- a/src/main/java/com/mzl/flower/service/BaseService.java
+++ b/src/main/java/com/mzl/flower/service/BaseService.java
@@ -459,6 +459,16 @@
         return p;
     }
 
+    protected Customer getCustomer(Long id){
+        Customer p = customerMapper.selectById(id);
+
+        if(p == null){
+            throw new ValidationException("商户不存在");
+        }
+
+        return p;
+    }
+
     public Partner getCurrentPartner(){
         String userId = SecurityUtils.getUserId();
         Partner p = partnerMapper.selectOne(new QueryWrapper<Partner>()
diff --git a/src/main/java/com/mzl/flower/service/point/CustomerPointDetailService.java b/src/main/java/com/mzl/flower/service/point/CustomerPointDetailService.java
deleted file mode 100644
index 3641135..0000000
--- a/src/main/java/com/mzl/flower/service/point/CustomerPointDetailService.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.mzl.flower.service.point;
-
-
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.mzl.flower.dto.request.point.CustomerPointDetailDTO;
-import com.mzl.flower.dto.request.point.CustomerPointDetailQueryDTO;
-import com.mzl.flower.dto.response.point.CustomerPointDetailVO;
-import com.mzl.flower.entity.point.CustomerPointDetail;
-
-
-public interface CustomerPointDetailService extends IService<CustomerPointDetail> {
-
-    void save(CustomerPointDetailDTO customerPointDetailDTO);
-
-    void update(CustomerPointDetailDTO customerPointDetailDTO);
-
-    void delete(Long id);
-
-    Page<CustomerPointDetailVO> queryPage(CustomerPointDetailQueryDTO customerPointDetailQueryDTO, Page page);
-}
diff --git a/src/main/java/com/mzl/flower/service/point/CustomerPointService.java b/src/main/java/com/mzl/flower/service/point/CustomerPointService.java
index 2e5c744..6353061 100644
--- a/src/main/java/com/mzl/flower/service/point/CustomerPointService.java
+++ b/src/main/java/com/mzl/flower/service/point/CustomerPointService.java
@@ -1,9 +1,121 @@
 package com.mzl.flower.service.point;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.mzl.flower.config.security.SecurityUtils;
+import com.mzl.flower.dto.request.point.ChangePointDTO;
+import com.mzl.flower.dto.request.point.QueryCustomerPointDTO;
+import com.mzl.flower.dto.request.point.QueryPointDetailDTO;
+import com.mzl.flower.dto.response.point.CustomerPointDTO;
+import com.mzl.flower.dto.response.point.CustomerPointDetailDTO;
+import com.mzl.flower.entity.customer.Customer;
+import com.mzl.flower.entity.point.CustomerPoint;
+import com.mzl.flower.entity.point.CustomerPointDetail;
+import com.mzl.flower.mapper.point.CustomerPointDetailMapper;
+import com.mzl.flower.mapper.point.CustomerPointMapper;
+import com.mzl.flower.service.BaseService;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.time.LocalDate;
+import java.util.List;
+
+import com.mzl.flower.constant.Constants.*;
+
 @Service
 @Transactional
-public class CustomerPointService {
+public class CustomerPointService extends BaseService {
+
+    private final CustomerPointMapper customerPointMapper;
+
+    private final CustomerPointDetailMapper customerPointDetailMapper;
+
+
+    public CustomerPointService(CustomerPointMapper customerPointMapper, CustomerPointDetailMapper customerPointDetailMapper) {
+        this.customerPointMapper = customerPointMapper;
+        this.customerPointDetailMapper = customerPointDetailMapper;
+    }
+
+    public Page<CustomerPointDTO> queryPage(QueryCustomerPointDTO dto, Page page) {
+        List<CustomerPointDTO> list = customerPointMapper.queryPage(dto, page);
+        page.setRecords(list);
+        return page;
+    }
+
+    public  Page<CustomerPointDetailDTO> queryCustomerDetails(QueryPointDetailDTO dto, Page page) {
+        List<CustomerPointDetailDTO> list = customerPointMapper.queryCustomerDetails(dto, page);
+        page.setRecords(list);
+
+        return page;
+    }
+
+    public void giveawayPoint(ChangePointDTO dto) {
+        CustomerPointDetail detail = new CustomerPointDetail();
+        Customer customer = getCustomer(dto.getCustomerId());
+        detail.setCustomerId(customer.getId());
+        detail.setUserId(customer.getUserId());
+        detail.setPoint(dto.getPoint());
+        detail.setRemarks(dto.getRemarks());
+        detail.setRecordDate(LocalDate.now());
+        detail.setChangeType(POINT_CHANGE_TYPE.add.name());
+        detail.setType(POINT_TYPE.giveaway.name());
+        detail.create(SecurityUtils.getUserId());
+        customerPointDetailMapper.insert(detail);
+
+        //更新汇总表
+        updateCustomerPoint(detail);
+    }
+
+    public void updateCustomerPoint(CustomerPointDetail detail) {
+        CustomerPoint point = customerPointMapper.selectOne(new LambdaQueryWrapper<CustomerPoint>()
+                .eq(CustomerPoint::getCustomerId, detail.getCustomerId()));
+        boolean isAdd = false;
+        if(point == null){
+            isAdd = true;
+            point = new CustomerPoint();
+            point.setCustomerId(detail.getCustomerId());
+            point.setUserId(detail.getUserId());
+            point.setTotalPoint(0);
+            point.setUsedPoint(0);
+            point.setExpiredPoint(0);
+            point.create(SecurityUtils.getUserId());
+        }
+
+        if(POINT_CHANGE_TYPE.add.name().equals(detail.getChangeType())){
+            point.setTotalPoint(point.getTotalPoint() + detail.getPoint());
+            point.setUsedPoint(point.getUsedPoint() + detail.getUsePoint());
+            point.setExpiredPoint(point.getExpiredPoint() + detail.getExpiredPoint());
+        }else if(POINT_CHANGE_TYPE.reduce.name().equals(detail.getChangeType())){
+//            if(point.getTotalPoint()!= null && point.getTotalPoint()!=0 && point.getTotalPoint()>= detail.getPoint()){
+//                point.setTotalPoint(point.getTotalPoint() - detail.getPoint());
+//            }else{
+//                //积分不足,直接清0
+//                point.setTotalPoint(0);
+//            }
+            point.setTotalPoint(point.getTotalPoint() - detail.getPoint());
+        }
+        if(isAdd){
+            customerPointMapper.insert(point);
+        }else{
+            customerPointMapper.updateById(point);
+        }
+
+    }
+
+    public void deductionPoint(ChangePointDTO dto) {
+        CustomerPointDetail detail = new CustomerPointDetail();
+        Customer customer = getCustomer(dto.getCustomerId());
+        detail.setCustomerId(customer.getId());
+        detail.setUserId(customer.getUserId());
+        detail.setPoint(dto.getPoint());
+        detail.setRemarks(dto.getRemarks());
+        detail.setRecordDate(LocalDate.now());
+        detail.setChangeType(POINT_CHANGE_TYPE.reduce.name());
+        detail.setType(POINT_TYPE.deduction.name());
+        detail.create(SecurityUtils.getUserId());
+        customerPointDetailMapper.insert(detail);
+
+        //更新汇总表
+        updateCustomerPoint(detail);
+    }
 }
diff --git a/src/main/java/com/mzl/flower/service/point/PointGoodService.java b/src/main/java/com/mzl/flower/service/point/PointGoodService.java
deleted file mode 100644
index 65a60f9..0000000
--- a/src/main/java/com/mzl/flower/service/point/PointGoodService.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.mzl.flower.service.point;
-
-
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.mzl.flower.dto.BatchDTO;
-import com.mzl.flower.dto.request.menber.MemberDTO;
-import com.mzl.flower.dto.request.point.PointGoodDTO;
-import com.mzl.flower.dto.request.point.PointGoodQueryDTO;
-import com.mzl.flower.dto.response.content.AnnouncementDTO;
-import com.mzl.flower.dto.response.point.PointGoodVO;
-import com.mzl.flower.entity.menber.Member;
-import com.mzl.flower.entity.point.PointGood;
-
-
-public interface PointGoodService extends IService<PointGood> {
-
-    void save(PointGoodDTO pointGoodDTO);
-
-    void update(PointGoodDTO pointGoodDTO);
-    void batchDelete(BatchDTO batchDTO);
-
-    void batchPublish(BatchDTO batchDTO);
-
-    void batchOff(BatchDTO batchDTO);
-
-    void delete(Long id);
-
-    void copy(Long id);
-
-    void changeStatus(Long id);
-
-    PointGoodVO detail(Long id);
-
-    Page<PointGoodVO> queryPage(PointGoodQueryDTO pointGoodQueryDTO,Page page);
-}
diff --git a/src/main/java/com/mzl/flower/service/point/impl/CustomerPointDetailServiceImpl.java b/src/main/java/com/mzl/flower/service/point/impl/CustomerPointDetailServiceImpl.java
deleted file mode 100644
index c33236b..0000000
--- a/src/main/java/com/mzl/flower/service/point/impl/CustomerPointDetailServiceImpl.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package com.mzl.flower.service.point.impl;
-
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.mzl.flower.config.exception.ValidationException;
-import com.mzl.flower.config.security.SecurityUtils;
-import com.mzl.flower.dto.request.point.CustomerPointDetailDTO;
-import com.mzl.flower.dto.request.point.CustomerPointDetailQueryDTO;
-import com.mzl.flower.dto.response.point.CustomerPointDetailVO;
-import com.mzl.flower.entity.point.CustomerPointDetail;
-import com.mzl.flower.mapper.point.CustomerPointDetailMapper;
-import com.mzl.flower.service.point.CustomerPointDetailService;
-import lombok.RequiredArgsConstructor;
-import org.springframework.beans.BeanUtils;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.util.List;
-
-/**
- * @author fanghaowei
- * @version version2.0
- * @className MemberServiceImpl
- * @date 2024/8/26
- * @description 积分记录
- */
-@Service
-@Transactional
-@RequiredArgsConstructor
-public class CustomerPointDetailServiceImpl extends ServiceImpl<CustomerPointDetailMapper, CustomerPointDetail> implements CustomerPointDetailService {
-
-    private final CustomerPointDetailMapper customerPointDetailMapper;
-
-    @Override
-    public void save(CustomerPointDetailDTO customerPointDetailDTO) {
-        if (customerPointDetailDTO.getId() != null) {
-            throw new ValidationException("id必须为空");
-        }
-        CustomerPointDetail customerPointDetail = new CustomerPointDetail();
-        BeanUtils.copyProperties(customerPointDetailDTO, customerPointDetail);
-        customerPointDetail.create(SecurityUtils.getUserId());
-        customerPointDetailMapper.insert(customerPointDetail);
-    }
-
-    @Override
-    public void update(CustomerPointDetailDTO customerPointDetailDTO) {
-        if (customerPointDetailDTO.getId() == null || customerPointDetailDTO.getId() == 0) {
-            throw new ValidationException("id不能为空");
-        }
-        CustomerPointDetail customerPointDetail = customerPointDetailMapper.selectById(customerPointDetailDTO.getId());
-        if (customerPointDetail == null) {
-            throw new ValidationException("找不到id为" + customerPointDetail.getId() + "的积分记录");
-        }
-        BeanUtils.copyProperties(customerPointDetailDTO, customerPointDetail, "id", "createTime", "createBy", "deleted", "status");
-        customerPointDetail.update(SecurityUtils.getUserId());
-        customerPointDetailMapper.updateById(customerPointDetail);
-    }
-
-
-    @Override
-    public void delete(Long id) {
-        CustomerPointDetail customerPointDetail = customerPointDetailMapper.selectById(id);
-        if (customerPointDetail == null) {
-            throw new ValidationException("找不到id为" + id + "的积分记录");
-        }
-        customerPointDetailMapper.deleteById(id);
-
-    }
-
-    @Override
-    public Page<CustomerPointDetailVO> queryPage(CustomerPointDetailQueryDTO customerPointDetailQueryDTO, Page page) {
-        List<CustomerPointDetailVO> list = customerPointDetailMapper.queryPage(customerPointDetailQueryDTO, page);
-        page.setRecords(list);
-        return page;
-    }
-}
diff --git a/src/main/java/com/mzl/flower/service/point/impl/PointGoodServiceImpl.java b/src/main/java/com/mzl/flower/service/point/impl/PointGoodServiceImpl.java
deleted file mode 100644
index 47b9113..0000000
--- a/src/main/java/com/mzl/flower/service/point/impl/PointGoodServiceImpl.java
+++ /dev/null
@@ -1,163 +0,0 @@
-package com.mzl.flower.service.point.impl;
-
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.mzl.flower.config.exception.ValidationException;
-import com.mzl.flower.config.security.SecurityUtils;
-import com.mzl.flower.constant.Constants;
-import com.mzl.flower.dto.BatchDTO;
-import com.mzl.flower.dto.request.menber.MemberDTO;
-import com.mzl.flower.dto.request.point.PointGoodDTO;
-import com.mzl.flower.dto.request.point.PointGoodQueryDTO;
-import com.mzl.flower.dto.response.content.AnnouncementDTO;
-import com.mzl.flower.dto.response.point.PointGoodVO;
-import com.mzl.flower.entity.content.Announcement;
-import com.mzl.flower.entity.menber.Member;
-import com.mzl.flower.entity.point.PointGood;
-import com.mzl.flower.mapper.member.MemberMapper;
-import com.mzl.flower.mapper.point.PointGoodMapper;
-import com.mzl.flower.service.menber.MemberService;
-import com.mzl.flower.service.point.PointGoodService;
-import lombok.RequiredArgsConstructor;
-import org.springframework.beans.BeanUtils;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.util.ObjectUtils;
-import org.springframework.util.StringUtils;
-
-import java.time.LocalDate;
-import java.util.List;
-
-/**
- * @author fanghaowei
- * @version version2.0
- * @className MemberServiceImpl
- * @date 2024/8/26
- * @description 会员管理功能逻辑层
- */
-@Service
-@Transactional
-@RequiredArgsConstructor
-public class PointGoodServiceImpl extends ServiceImpl<PointGoodMapper, PointGood> implements PointGoodService {
-
-    private final PointGoodMapper pointGoodMapper;
-
-    @Override
-    public void save(PointGoodDTO pointGoodDTO) {
-        if (pointGoodDTO.getId() != null) {
-            throw new ValidationException("id必须为空");
-        }
-        if (pointGoodDTO.getStock() < 0) {
-            throw new ValidationException("库存不能小于0");
-        }
-        if (pointGoodDTO.getPoint() < 0) {
-            throw new ValidationException("积分不能小于0");
-        }
-        PointGood pointGood = new PointGood();
-        BeanUtils.copyProperties(pointGoodDTO, pointGood);
-        pointGood.setStatus(Constants.POINT_GOOD_STATUS.off.name());
-        pointGood.create(SecurityUtils.getUserId());
-        pointGoodMapper.insert(pointGood);
-    }
-
-    @Override
-    public void update(PointGoodDTO pointGoodDTO) {
-        if (pointGoodDTO.getId() == null || pointGoodDTO.getId() == 0) {
-            throw new ValidationException("id不能为空");
-        }
-        if (pointGoodDTO.getStock() < 0) {
-            throw new ValidationException("库存不能小于0");
-        }
-        if (pointGoodDTO.getPoint() < 0) {
-            throw new ValidationException("积分不能小于0");
-        }
-        PointGood pointGood = pointGoodMapper.selectById(pointGoodDTO.getId());
-        if (pointGood == null) {
-            throw new ValidationException("找不到id为" + pointGood.getId() + "的商品");
-        }
-        BeanUtils.copyProperties(pointGoodDTO, pointGood, "id", "createTime", "createBy", "deleted", "status");
-        pointGood.update(SecurityUtils.getUserId());
-        pointGoodMapper.updateById(pointGood);
-    }
-
-    @Override
-    public void batchDelete(BatchDTO batchDTO) {
-        pointGoodMapper.deleteBatchIds(batchDTO.getIds());
-    }
-
-    @Override
-    public void batchPublish(BatchDTO batchDTO) {
-        List<PointGood> list = pointGoodMapper.selectList(new LambdaQueryWrapper<PointGood>().in(PointGood::getId, batchDTO.getIds()));
-        for (PointGood pointGood : list) {
-            pointGood.setStatus(Constants.POINT_GOOD_STATUS.up.name());
-            pointGoodMapper.updateById(pointGood);
-        }
-    }
-
-    @Override
-    public void batchOff(BatchDTO batchDTO) {
-        List<PointGood> list = pointGoodMapper.selectList(new LambdaQueryWrapper<PointGood>().in(PointGood::getId, batchDTO.getIds()));
-        for (PointGood pointGood : list) {
-            pointGood.setStatus(Constants.POINT_GOOD_STATUS.off.name());
-            pointGoodMapper.updateById(pointGood);
-        }
-    }
-
-    @Override
-    public void delete(Long id) {
-        PointGood pointGood = pointGoodMapper.selectById(id);
-        if (pointGood == null) {
-            throw new ValidationException("找不到id为" + id + "的商品");
-        }
-        pointGoodMapper.deleteById(id);
-
-    }
-
-    @Override
-    public void copy(Long id) {
-        PointGood pointGoodTmp = pointGoodMapper.selectById(id);
-        if (pointGoodTmp == null) {
-            throw new ValidationException("找不到id为" + id + "的商品");
-        }
-        PointGood pointGood = new PointGood();
-        BeanUtils.copyProperties(pointGoodTmp, pointGood,"id","createTime", "createBy", "deleted", "status");
-        pointGood.setStatus(Constants.POINT_GOOD_STATUS.off.name());
-        pointGood.create(SecurityUtils.getUserId());
-        pointGoodMapper.deleteById(id);
-
-    }
-
-    @Override
-    public void changeStatus(Long id) {
-        PointGood pointGood = pointGoodMapper.selectById(id);
-        if (pointGood == null) {
-            throw new ValidationException("找不到id为" + id + "的商品");
-        }
-        if (Constants.COMMON_PUBLISH_STATUS.published.name().equals(pointGood.getStatus())) {
-            pointGood.setStatus(Constants.COMMON_PUBLISH_STATUS.unpublished.name());
-        } else {
-            pointGood.setStatus(Constants.COMMON_PUBLISH_STATUS.published.name());
-        }
-        pointGoodMapper.updateById(pointGood);
-
-    }
-
-    @Override
-    public PointGoodVO detail(Long id) {
-        PointGood pointGood = pointGoodMapper.selectById(id);
-        if (pointGood == null) {
-            return null;
-        }
-        PointGoodVO vo = new PointGoodVO();
-        BeanUtils.copyProperties(pointGood, vo);
-        return vo;
-    }
-
-    @Override
-    public Page<PointGoodVO> queryPage(PointGoodQueryDTO pointGoodQueryDTO, Page page) {
-        List<PointGoodVO> list = pointGoodMapper.queryPage(pointGoodQueryDTO, page);
-        page.setRecords(list);
-        return page;
-    }
-}
diff --git a/src/main/java/com/mzl/flower/web/point/CustomerPointController.java b/src/main/java/com/mzl/flower/web/point/CustomerPointController.java
index 3664ad8..342d05d 100644
--- a/src/main/java/com/mzl/flower/web/point/CustomerPointController.java
+++ b/src/main/java/com/mzl/flower/web/point/CustomerPointController.java
@@ -1,16 +1,82 @@
 package com.mzl.flower.web.point;
 
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.mzl.flower.base.BaseController;
+import com.mzl.flower.base.R;
+import com.mzl.flower.base.ReturnDataDTO;
+import com.mzl.flower.config.security.SecurityUtils;
+import com.mzl.flower.dto.request.point.ChangePointDTO;
+import com.mzl.flower.dto.request.point.QueryCustomerPointDTO;
+import com.mzl.flower.dto.request.point.QueryPointDetailDTO;
+import com.mzl.flower.dto.request.supplier.UpdateSupplierDTO;
+import com.mzl.flower.dto.response.content.AdvertisementDTO;
+import com.mzl.flower.dto.response.point.CustomerPointDTO;
+import com.mzl.flower.dto.response.point.CustomerPointDetailDTO;
+import com.mzl.flower.service.point.CustomerPointService;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.ResponseEntity;
 import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.ValidationException;
+import javax.validation.constraints.NotNull;
+import java.util.List;
 
 @RestController
 @RequestMapping("/api/customer/point")
 @Api(value = "会员积分", tags = "会员积分")
 @Validated
 @Slf4j
-public class CustomerPointController {
+public class CustomerPointController extends BaseController {
+
+
+    private final CustomerPointService customerPointService;
+
+    public CustomerPointController(CustomerPointService customerPointService) {
+        this.customerPointService = customerPointService;
+    }
+
+
+    @GetMapping("/page/list")
+    @ApiOperation(value = "管理端-积分详细记录列表", notes = "管理端-商户积分详细记录列表")
+    public ResponseEntity<ReturnDataDTO<Page<CustomerPointDetailDTO>>> queryCustomerDetails(QueryPointDetailDTO dto, Page page) {
+        if(dto.getCustomerId() == null || dto.getCustomerId() == 0){
+            throw new ValidationException("商户ID不能为空");
+        }
+        return returnData(R.SUCCESS.getCode(),customerPointService.queryCustomerDetails(dto, page));
+    }
+
+
+    @GetMapping("/page")
+    @ApiOperation(value = "管理端-积分查询", notes = "用户端-积分查询")
+    public ResponseEntity<ReturnDataDTO<Page<CustomerPointDTO>>> queryPage(QueryCustomerPointDTO dto, Page page)  {
+        return returnData(R.SUCCESS.getCode(), customerPointService.queryPage(dto, page));
+    }
+
+    @PostMapping("/giveaway")
+    @ApiOperation(value = "管理端-积分赠送", notes = "管理端-积分赠送")
+    public ResponseEntity<ReturnDataDTO> giveawayPoint(@Validated @RequestBody ChangePointDTO dto) {
+        customerPointService.giveawayPoint(dto);
+        return returnData(R.SUCCESS.getCode(),null);
+    }
+
+    @PostMapping("/deduction")
+    @ApiOperation(value = "管理端-积分扣除", notes = "管理端-积分扣除")
+    public ResponseEntity<ReturnDataDTO> deductionPoint(@Validated @RequestBody ChangePointDTO dto) {
+        customerPointService.deductionPoint(dto);
+        return returnData(R.SUCCESS.getCode(),null);
+    }
+
+
+
+    @GetMapping("/list")
+    @ApiOperation(value = "用户端-积分列表(花店积分列表)", notes = "管理端-积分列表(花店积分列表)")
+    public ResponseEntity<ReturnDataDTO<Page<CustomerPointDetailDTO>>> myPointDetails(QueryPointDetailDTO dto, Page page) {
+        dto.setUserId(SecurityUtils.getUserId());
+        return returnData(R.SUCCESS.getCode(),customerPointService.queryCustomerDetails(dto, page));
+    }
+
 }
diff --git a/src/main/java/com/mzl/flower/web/point/CustomerPointDetailController.java b/src/main/java/com/mzl/flower/web/point/CustomerPointDetailController.java
deleted file mode 100644
index 73bcba0..0000000
--- a/src/main/java/com/mzl/flower/web/point/CustomerPointDetailController.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package com.mzl.flower.web.point;
-
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.mzl.flower.base.BaseController;
-import com.mzl.flower.base.R;
-import com.mzl.flower.base.ReturnDataDTO;
-import com.mzl.flower.dto.request.point.CustomerPointDetailDTO;
-import com.mzl.flower.dto.request.point.CustomerPointDetailQueryDTO;
-import com.mzl.flower.dto.response.point.CustomerPointDetailVO;
-import com.mzl.flower.service.point.CustomerPointDetailService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.http.ResponseEntity;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-import javax.validation.constraints.NotNull;
-
-@RestController
-@RequestMapping("/api/customer")
-@Api(value = "用户积分记录", tags = "用户积分记录")
-@Validated
-@Slf4j
-@RequiredArgsConstructor
-public class CustomerPointDetailController extends BaseController {
-
-    private final CustomerPointDetailService customerPointDetailService;
-
-
-    @PostMapping("/point/save")
-    @ApiOperation(value = "新增", notes = "新增")
-    public ResponseEntity<ReturnDataDTO> save(@Validated @RequestBody CustomerPointDetailDTO customerPointDetailDTO) {
-        customerPointDetailService.save(customerPointDetailDTO);
-        return returnData(R.SUCCESS.getCode(), null);
-    }
-
-    @PostMapping("/point/update")
-    @ApiOperation(value = "修改", notes = "修改")
-    public ResponseEntity<ReturnDataDTO> update(@Validated @RequestBody CustomerPointDetailDTO customerPointDetailDTO) {
-        customerPointDetailService.update(customerPointDetailDTO);
-        return returnData(R.SUCCESS.getCode(), null);
-    }
-
-
-    @GetMapping("/point/delete")
-    @ApiOperation(value = "删除", notes = "删除")
-    public ResponseEntity<ReturnDataDTO> delete(@NotNull(message = "id不能为空") Long id) {
-        customerPointDetailService.delete(id);
-        return returnData(R.SUCCESS.getCode(), null);
-    }
-
-
-    @GetMapping("/point/page")
-    @ApiOperation(value = "查询-分页", notes = "查询-分页")
-    public ResponseEntity<ReturnDataDTO<Page<CustomerPointDetailVO>>> queryPage(CustomerPointDetailQueryDTO dto, Page page) {
-        return returnData(R.SUCCESS.getCode(), customerPointDetailService.queryPage(dto, page));
-    }
-
-
-}
diff --git a/src/main/java/com/mzl/flower/web/point/PointGoodController.java b/src/main/java/com/mzl/flower/web/point/PointGoodController.java
deleted file mode 100644
index b51adf5..0000000
--- a/src/main/java/com/mzl/flower/web/point/PointGoodController.java
+++ /dev/null
@@ -1,104 +0,0 @@
-package com.mzl.flower.web.point;
-
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.mzl.flower.base.BaseController;
-import com.mzl.flower.base.R;
-import com.mzl.flower.base.ReturnDataDTO;
-import com.mzl.flower.dto.BatchDTO;
-import com.mzl.flower.dto.request.point.PointGoodDTO;
-import com.mzl.flower.dto.request.point.PointGoodQueryDTO;
-import com.mzl.flower.dto.response.point.PointGoodVO;
-import com.mzl.flower.service.point.PointGoodService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.http.ResponseEntity;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-import javax.validation.constraints.NotNull;
-
-@RestController
-@RequestMapping("/api/point")
-@Api(value = "积分商品管理", tags = "积分商品管理")
-@Validated
-@Slf4j
-@RequiredArgsConstructor
-public class PointGoodController extends BaseController {
-
-
-    private final PointGoodService pointGoodService;
-
-
-
-    @PostMapping("/good/save")
-    @ApiOperation(value = "新增", notes = "新增")
-    public ResponseEntity<ReturnDataDTO> save(@Validated @RequestBody PointGoodDTO pointGoodDTO) {
-        pointGoodService.save(pointGoodDTO);
-        return returnData(R.SUCCESS.getCode(),null);
-    }
-
-    @PostMapping("/good/update")
-    @ApiOperation(value = "修改", notes = "修改")
-    public ResponseEntity<ReturnDataDTO> update(@Validated @RequestBody PointGoodDTO pointGoodDTO) {
-        pointGoodService.update(pointGoodDTO);
-        return returnData(R.SUCCESS.getCode(),null);
-    }
-
-    @PostMapping("/good/delete/batch")
-    @ApiOperation(value = "批量删除", notes = "批量删除")
-    public ResponseEntity<ReturnDataDTO> batchDelete(@Validated @RequestBody BatchDTO dto) {
-        pointGoodService.batchDelete(dto);
-        return returnData(R.SUCCESS.getCode(),null);
-    }
-
-    @PostMapping("/good/publish/batch")
-    @ApiOperation(value = "批量上架", notes = "批量上架")
-    public ResponseEntity<ReturnDataDTO> batchPublish(@Validated @RequestBody BatchDTO dto) {
-        pointGoodService.batchPublish(dto);
-        return returnData(R.SUCCESS.getCode(),null);
-    }
-
-    @PostMapping("/good/off/batch")
-    @ApiOperation(value = "批量下架", notes = "批量下架")
-    public ResponseEntity<ReturnDataDTO> batchoff(@Validated @RequestBody BatchDTO dto) {
-        pointGoodService.batchOff(dto);
-        return returnData(R.SUCCESS.getCode(),null);
-    }
-
-
-    @GetMapping("/good/delete")
-    @ApiOperation(value = "删除", notes = "删除")
-    public ResponseEntity<ReturnDataDTO> delete(@NotNull(message = "id不能为空") Long id) {
-        pointGoodService.delete(id);
-        return returnData(R.SUCCESS.getCode(),null);
-    }
-
-
-    @GetMapping("/good/copy")
-    @ApiOperation(value = "复制", notes = "复制")
-    public ResponseEntity<ReturnDataDTO> copy(@NotNull(message = "id不能为空") Long id) {
-        pointGoodService.delete(id);
-        return returnData(R.SUCCESS.getCode(), null);
-    }
-
-    @GetMapping("/good/view")
-    @ApiOperation(value = "详情", notes = "详情")
-    public ResponseEntity<ReturnDataDTO<PointGoodVO>> detail(@NotNull(message = "id不能为空") Long id) {
-        return returnData(R.SUCCESS.getCode(),pointGoodService.detail(id));
-    }
-
-    @GetMapping("/good/page")
-    @ApiOperation(value = "查询-分页", notes = "查询-分页")
-    public ResponseEntity<ReturnDataDTO<Page<PointGoodVO>>> queryPage(PointGoodQueryDTO dto, Page page) {
-        return returnData(R.SUCCESS.getCode(), pointGoodService.queryPage(dto,page));
-    }
-
-    @GetMapping("/good/changeStatus")
-    @ApiOperation(value = "修改上架下架状态", notes = "修改上架下架状态")
-    public ResponseEntity<ReturnDataDTO> changeStatus(@NotNull(message = "id不能为空") Long id) {
-        pointGoodService.changeStatus(id);
-        return returnData(R.SUCCESS.getCode(), null);
-    }
-}
diff --git a/src/main/resources/mapper/point/CustomerPointMapper.xml b/src/main/resources/mapper/point/CustomerPointMapper.xml
new file mode 100644
index 0000000..b89823a
--- /dev/null
+++ b/src/main/resources/mapper/point/CustomerPointMapper.xml
@@ -0,0 +1,50 @@
+<?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.mzl.flower.mapper.point.CustomerPointMapper">
+    <select id="queryPage" resultType="com.mzl.flower.dto.response.point.CustomerPointDTO">
+        SELECT
+            p.*,
+            c.`name` as customerName,
+            t.tel as customerTel
+        FROM
+            t_customer_point p
+                LEFT JOIN t_customer_info c ON c.id = p.customer_id
+                LEFT JOIN t_user t on p.user_id = t.id
+        WHERE
+            p.deleted = 0
+          <if test="dto.customerName!= null and dto.customerName != ''">
+              AND c.`name` LIKE CONCAT('%',#{dto.customerName},'%')
+          </if>
+        <if test="dto.customerTel!= null and dto.customerTel != ''">
+            and t.tel like CONCAT('%',#{dto.customerTel},'%')
+        </if>
+         order by p.create_time desc
+
+    </select>
+    <select id="queryCustomerDetails" resultType="com.mzl.flower.dto.response.point.CustomerPointDetailDTO">
+        SELECT * from t_customer_point_detail t where t.deleted= 0
+        <if test="dto.customerId!= null and dto.customerId != 0">
+            and t.customer_id = #{dto.customerId}
+        </if>
+        <if test="dto.userId!= null and dto.userId != 0">
+            and t.user_id = #{dto.userId}
+        </if>
+        <if test="dto.recordDateStart!=null ">
+            <![CDATA[
+               AND t.record_date >= #{dto.createDateBegin}
+            ]]>
+        </if>
+        <if test="dto.recordDateEnd!=null ">
+            <![CDATA[
+               AND t.record_date <= #{dto.createDateEnd}
+            ]]>
+        </if>
+        <if test="dto.type!=null and dto.type != null">
+            and t.type = #{dto.type}
+        </if>
+        <if test="dto.remarks!=null and dto.remarks != null">
+            and t.remarks like CONCAT('%',#{dto.remarks},'%')
+        </if>
+        order by t.create_time desc
+    </select>
+</mapper>
\ No newline at end of file
diff --git "a/src/main/\350\241\250\350\256\276\350\256\241-\344\272\214\346\234\237.xlsx" "b/src/main/\350\241\250\350\256\276\350\256\241-\344\272\214\346\234\237.xlsx"
index 7841603..50c991e 100644
--- "a/src/main/\350\241\250\350\256\276\350\256\241-\344\272\214\346\234\237.xlsx"
+++ "b/src/main/\350\241\250\350\256\276\350\256\241-\344\272\214\346\234\237.xlsx"
Binary files differ

--
Gitblit v1.9.3