From b2b82c1308fd2cf71e118ab8df8258f8160f010a Mon Sep 17 00:00:00 2001 From: 陶杰 <1378534974@qq.com> Date: 星期四, 29 八月 2024 15:52:17 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master-v2' into master-v2 --- 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/constant/Constants.java | 15 src/main/java/com/mzl/flower/mapper/point/PointGoodsMapper.java | 16 src/main/java/com/mzl/flower/dto/request/point/ChangePointDTO.java | 20 + src/main/表设计.xlsx | 0 src/main/resources/mapper/point/CustomerPointMapper.xml | 50 ++ src/main/java/com/mzl/flower/dto/response/point/PointGoodsListDTO.java | 31 + src/main/java/com/mzl/flower/mapper/point/PointGoodsRecordMapper.java | 9 src/main/java/com/mzl/flower/entity/point/CustomerPointDetail.java | 3 src/main/java/com/mzl/flower/dto/response/point/PointGoodsDTO.java | 12 src/main/java/com/mzl/flower/mapper/point/CustomerPointMapper.java | 11 src/main/resources/mapper/point/PointGoodsMapper.xml | 30 + src/main/java/com/mzl/flower/dto/response/point/CustomerPointDTO.java | 32 + src/main/java/com/mzl/flower/web/point/PointGoodsController.java | 90 +++++ src/main/java/com/mzl/flower/service/point/PointGoodsService.java | 89 +++++ src/main/java/com/mzl/flower/dto/request/point/PointGoodsCreateDTO.java | 28 + 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/dto/request/point/PointGoodsQueryDTO.java | 28 + src/main/java/com/mzl/flower/service/BaseService.java | 10 src/main/java/com/mzl/flower/config/ResourceServerConfig.java | 1 /dev/null | 104 ------ src/main/java/com/mzl/flower/entity/point/PointGoods.java | 33 + src/main/java/com/mzl/flower/web/customer/PointGoodsCustomerController.java | 50 ++ src/main/java/com/mzl/flower/entity/point/PointGoodsRecord.java | 50 ++ src/main/java/com/mzl/flower/web/point/CustomerPointController.java | 72 ++++ src/main/java/com/mzl/flower/config/PyamentV3Configurer.java | 2 src/main/java/com/mzl/flower/entity/customer/Customer.java | 2 src/main/java/com/mzl/flower/dto/request/point/PointGoodsUpdateDTO.java | 11 32 files changed, 887 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/config/ResourceServerConfig.java b/src/main/java/com/mzl/flower/config/ResourceServerConfig.java index c77de72..17cbe9a 100644 --- a/src/main/java/com/mzl/flower/config/ResourceServerConfig.java +++ b/src/main/java/com/mzl/flower/config/ResourceServerConfig.java @@ -51,6 +51,7 @@ .antMatchers("/api/customer/flower/list/view").permitAll() .antMatchers("/api/customer/flower/up/stock").permitAll() .antMatchers("api/pub/customer/home/**").permitAll() + .antMatchers("/api/customer/point/goods/**").permitAll() .antMatchers("/api/upload/oss/file").permitAll() .antMatchers("/api/flower/zone/list").permitAll() .antMatchers("/api/config/content/list/view").permitAll() diff --git a/src/main/java/com/mzl/flower/constant/Constants.java b/src/main/java/com/mzl/flower/constant/Constants.java index d231a55..130e745 100644 --- a/src/main/java/com/mzl/flower/constant/Constants.java +++ b/src/main/java/com/mzl/flower/constant/Constants.java @@ -430,6 +430,21 @@ } } + public enum POINT_GOODS_STATUS { + A("上架"), + I("下架"); + + POINT_GOODS_STATUS(String desc) { + this.desc = desc; + } + + private String desc; + + public String getDesc() { + return desc; + } + } + public enum POINT_GOOD_STATUS { up("上架"), off("下架"); 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/PointGoodsCreateDTO.java b/src/main/java/com/mzl/flower/dto/request/point/PointGoodsCreateDTO.java new file mode 100644 index 0000000..0194aa3 --- /dev/null +++ b/src/main/java/com/mzl/flower/dto/request/point/PointGoodsCreateDTO.java @@ -0,0 +1,28 @@ +package com.mzl.flower.dto.request.point; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +@Data +public class PointGoodsCreateDTO { + @ApiModelProperty(value = "商品名称") + private String name; + + @ApiModelProperty(value = "商品描述") + private String description; + + @ApiModelProperty(value = "库存") + private Integer stock; + + @ApiModelProperty(value = "封面图") + private String cover; + + @ApiModelProperty(value = "商品图片") + private List<String> pictureList; + + @ApiModelProperty(value = "兑换积分") + private Integer point; + +} diff --git a/src/main/java/com/mzl/flower/dto/request/point/PointGoodsQueryDTO.java b/src/main/java/com/mzl/flower/dto/request/point/PointGoodsQueryDTO.java new file mode 100644 index 0000000..ff598cd --- /dev/null +++ b/src/main/java/com/mzl/flower/dto/request/point/PointGoodsQueryDTO.java @@ -0,0 +1,28 @@ +package com.mzl.flower.dto.request.point; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +@Data +public class PointGoodsQueryDTO { + @ApiModelProperty(value = "商品名称") + private String name; + + @ApiModelProperty(value = "状态") + private String status; + + @ApiModelProperty(value = "库存-下限") + private Integer stockLower; + + @ApiModelProperty(value = "库存-上限") + private Integer stockUpper; + + @ApiModelProperty(value = "兑换积分-下限") + private Integer pointLower; + + @ApiModelProperty(value = "兑换积分-上限") + private Integer pointUpper; + +} diff --git a/src/main/java/com/mzl/flower/dto/request/point/PointGoodsUpdateDTO.java b/src/main/java/com/mzl/flower/dto/request/point/PointGoodsUpdateDTO.java new file mode 100644 index 0000000..0e8d586 --- /dev/null +++ b/src/main/java/com/mzl/flower/dto/request/point/PointGoodsUpdateDTO.java @@ -0,0 +1,11 @@ +package com.mzl.flower.dto.request.point; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class PointGoodsUpdateDTO extends PointGoodsCreateDTO{ + @ApiModelProperty(value = "id") + private Long id; + +} 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/dto/response/point/PointGoodsDTO.java b/src/main/java/com/mzl/flower/dto/response/point/PointGoodsDTO.java new file mode 100644 index 0000000..ed93b32 --- /dev/null +++ b/src/main/java/com/mzl/flower/dto/response/point/PointGoodsDTO.java @@ -0,0 +1,12 @@ +package com.mzl.flower.dto.response.point; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +@Data +public class PointGoodsDTO extends PointGoodsListDTO { + @ApiModelProperty(value = "商品图片") + private List<String> pictureList; +} diff --git a/src/main/java/com/mzl/flower/dto/response/point/PointGoodsListDTO.java b/src/main/java/com/mzl/flower/dto/response/point/PointGoodsListDTO.java new file mode 100644 index 0000000..b455255 --- /dev/null +++ b/src/main/java/com/mzl/flower/dto/response/point/PointGoodsListDTO.java @@ -0,0 +1,31 @@ +package com.mzl.flower.dto.response.point; + +import com.mzl.flower.base.AbstractTransDTO; +import com.mzl.flower.base.annotation.DictTrans; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class PointGoodsListDTO extends AbstractTransDTO { + private Long id; + + @ApiModelProperty(value = "商品名称") + private String name; + + @ApiModelProperty(value = "商品描述") + private String description; + + @ApiModelProperty(value = "库存") + private Integer stock; + + @ApiModelProperty(value = "封面图") + private String cover; + + @ApiModelProperty(value = "兑换积分") + private Integer point; + + @ApiModelProperty(value = "状态") + @DictTrans(target = "statusStr", codeType = "POINT_GOODS_STATUS") + private String status; + private String statusStr; +} diff --git a/src/main/java/com/mzl/flower/entity/customer/Customer.java b/src/main/java/com/mzl/flower/entity/customer/Customer.java index 93e71ef..38dd158 100644 --- a/src/main/java/com/mzl/flower/entity/customer/Customer.java +++ b/src/main/java/com/mzl/flower/entity/customer/Customer.java @@ -42,4 +42,6 @@ @ApiModelProperty("店铺简介") private String description; + @ApiModelProperty("等级id") + private Long levelId; } 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/PointGoods.java b/src/main/java/com/mzl/flower/entity/point/PointGoods.java new file mode 100644 index 0000000..5b08efd --- /dev/null +++ b/src/main/java/com/mzl/flower/entity/point/PointGoods.java @@ -0,0 +1,33 @@ +package com.mzl.flower.entity.point; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.mzl.flower.base.BaseAutoEntity; +import lombok.Data; + +@Data +@TableName("t_point_goods") +public class PointGoods extends BaseAutoEntity { + + @TableField("name") + private String name;//商品名称 + + @TableField("description") + private String description;//商品描述 + + @TableField("stock") + private Integer stock;//库存 + + @TableField("cover") + private String cover;//封面图 + + @TableField("pictures") + private String pictures;//商品图片 + + @TableField("point") + private Integer point;//兑换积分 + + @TableField("status") + private String status;//状态 + +} \ No newline at end of file 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/PointGoodsMapper.java b/src/main/java/com/mzl/flower/mapper/point/PointGoodsMapper.java new file mode 100644 index 0000000..8825c9b --- /dev/null +++ b/src/main/java/com/mzl/flower/mapper/point/PointGoodsMapper.java @@ -0,0 +1,16 @@ +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.PointGoodsQueryDTO; +import com.mzl.flower.dto.response.point.PointGoodsListDTO; +import com.mzl.flower.entity.point.PointGoods; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface PointGoodsMapper extends BaseMapper<PointGoods> { + List<PointGoodsListDTO> selectGoodsList(Page page, @Param("condition") PointGoodsQueryDTO dto); +} 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/PointGoodsService.java b/src/main/java/com/mzl/flower/service/point/PointGoodsService.java new file mode 100644 index 0000000..12fb25c --- /dev/null +++ b/src/main/java/com/mzl/flower/service/point/PointGoodsService.java @@ -0,0 +1,89 @@ +package com.mzl.flower.service.point; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +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.request.point.PointGoodsCreateDTO; +import com.mzl.flower.dto.request.point.PointGoodsQueryDTO; +import com.mzl.flower.dto.request.point.PointGoodsUpdateDTO; +import com.mzl.flower.dto.response.point.PointGoodsDTO; +import com.mzl.flower.dto.response.point.PointGoodsListDTO; +import com.mzl.flower.entity.point.PointGoods; +import com.mzl.flower.mapper.point.PointGoodsMapper; +import com.mzl.flower.service.BaseService; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +@Service +@Transactional +public class PointGoodsService extends BaseService { + + @Autowired + private PointGoodsMapper pointGoodsMapper; + + public Long addPointGoods(PointGoodsCreateDTO dto){ + PointGoods p = new PointGoods(); + BeanUtils.copyProperties(dto, p); + p.setPictures(toJSONString(dto.getPictureList())); + p.setStatus(Constants.POINT_GOODS_STATUS.I.name()); + + p.create(SecurityUtils.getUserId()); + pointGoodsMapper.insert(p); + + return p.getId(); + } + + public Long updatePointGoods(PointGoodsUpdateDTO dto){ + PointGoods p = pointGoodsMapper.selectById(dto.getId()); + if(p == null){ + throw new ValidationException("商品未找到"); + } + + BeanUtils.copyProperties(dto, p); + p.setPictures(toJSONString(dto.getPictureList())); + + p.update(SecurityUtils.getUserId()); + pointGoodsMapper.updateById(p); + + return p.getId(); + } + + public void deletePointGoods(Long id){ + pointGoodsMapper.deleteById(id); + } + + public Page<PointGoodsListDTO> selectGoodsList(Page page, PointGoodsQueryDTO dto){ + List<PointGoodsListDTO> ls = pointGoodsMapper.selectGoodsList(page, dto); + + page.setRecords(ls); + return page; + } + + public PointGoodsDTO getGoodsInfo(Long id){ + PointGoods p = pointGoodsMapper.selectById(id); + if(p == null){ + throw new ValidationException("商品未找到"); + } + PointGoodsDTO dto = new PointGoodsDTO(); + BeanUtils.copyProperties(p, dto); + dto.setPictureList(parseArray(p.getPictures(), String.class)); + + return dto; + } + + public void updateStatus(Long id, String status){ + PointGoods p = pointGoodsMapper.selectById(id); + if(p == null){ + throw new ValidationException("商品未找到"); + } + + p.setStatus(status); + p.update(SecurityUtils.getUserId()); + pointGoodsMapper.updateById(p); + } +} 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/customer/PointGoodsCustomerController.java b/src/main/java/com/mzl/flower/web/customer/PointGoodsCustomerController.java new file mode 100644 index 0000000..532a098 --- /dev/null +++ b/src/main/java/com/mzl/flower/web/customer/PointGoodsCustomerController.java @@ -0,0 +1,50 @@ +package com.mzl.flower.web.customer; + +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.constant.Constants; +import com.mzl.flower.dto.request.point.PointGoodsCreateDTO; +import com.mzl.flower.dto.request.point.PointGoodsQueryDTO; +import com.mzl.flower.dto.request.point.PointGoodsUpdateDTO; +import com.mzl.flower.dto.response.point.PointGoodsDTO; +import com.mzl.flower.dto.response.point.PointGoodsListDTO; +import com.mzl.flower.service.point.PointGoodsService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequestMapping("/api/customer/point/goods") +@Api(value = "积分商品-花店", tags = "积分商品-花店") +@Validated +@Slf4j +public class PointGoodsCustomerController extends BaseController { + + @Autowired + private PointGoodsService pointGoodsService; + + @GetMapping("/list") + @ApiOperation(value = "商品列表") + public ResponseEntity<ReturnDataDTO<Page<PointGoodsListDTO>>> selectGoodsList(Page page, PointGoodsQueryDTO dto){ + dto.setStatus(Constants.POINT_GOODS_STATUS.A.name()); + return returnData(R.SUCCESS.getCode(), pointGoodsService.selectGoodsList(page, dto)); + } + + @GetMapping("/list/view") + @ApiOperation(value = "商品详情") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "商品id", required = true, dataType = "Long", paramType = "query") + }) + public ResponseEntity<ReturnDataDTO<PointGoodsDTO>> getGoodsInfo(Long id) { + return returnData(R.SUCCESS.getCode(), pointGoodsService.getGoodsInfo(id)); + } + +} 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/java/com/mzl/flower/web/point/PointGoodsController.java b/src/main/java/com/mzl/flower/web/point/PointGoodsController.java new file mode 100644 index 0000000..97614f8 --- /dev/null +++ b/src/main/java/com/mzl/flower/web/point/PointGoodsController.java @@ -0,0 +1,90 @@ +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.constant.Constants; +import com.mzl.flower.dto.request.point.PointGoodsCreateDTO; +import com.mzl.flower.dto.request.point.PointGoodsQueryDTO; +import com.mzl.flower.dto.request.point.PointGoodsUpdateDTO; +import com.mzl.flower.dto.response.point.PointGoodsDTO; +import com.mzl.flower.dto.response.point.PointGoodsListDTO; +import com.mzl.flower.service.point.PointGoodsService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequestMapping("/api/point/goods") +@Api(value = "积分商品管理-运营端", tags = "积分商品管理-运营端") +@Validated +@Slf4j +public class PointGoodsController extends BaseController { + + @Autowired + private PointGoodsService pointGoodsService; + + @PostMapping("/list/new") + @ApiOperation(value = "新增商品") + public ResponseEntity<ReturnDataDTO> addPointGoods(@RequestBody PointGoodsCreateDTO dto) { + return returnData(R.SUCCESS.getCode(), pointGoodsService.addPointGoods(dto)); + } + + @PostMapping("/list/edit") + @ApiOperation(value = "编辑商品") + public ResponseEntity<ReturnDataDTO> updatePointGoods(@RequestBody PointGoodsUpdateDTO dto) { + return returnData(R.SUCCESS.getCode(), pointGoodsService.updatePointGoods(dto)); + } + + @GetMapping("/list") + @ApiOperation(value = "商品列表") + public ResponseEntity<ReturnDataDTO<Page<PointGoodsListDTO>>> selectGoodsList(Page page, PointGoodsQueryDTO dto){ + return returnData(R.SUCCESS.getCode(), pointGoodsService.selectGoodsList(page, dto)); + } + + @GetMapping("/list/view") + @ApiOperation(value = "商品详情") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "商品id", required = true, dataType = "Long", paramType = "query") + }) + public ResponseEntity<ReturnDataDTO<PointGoodsDTO>> getGoodsInfo(Long id) { + return returnData(R.SUCCESS.getCode(), pointGoodsService.getGoodsInfo(id)); + } + + @GetMapping("/list/delete") + @ApiOperation(value = "商品删除") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "商品id", required = true, dataType = "Long", paramType = "query") + }) + public ResponseEntity<ReturnDataDTO<?>> deletePointGoods(Long id) { + pointGoodsService.deletePointGoods(id); + return returnData(R.SUCCESS.getCode(), null); + } + + @GetMapping("/list/on") + @ApiOperation(value = "商品上架") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "商品id", required = true, dataType = "Long", paramType = "query") + }) + public ResponseEntity<ReturnDataDTO<?>> upGoods(Long id) { + pointGoodsService.updateStatus(id, Constants.POINT_GOODS_STATUS.A.name()); + return returnData(R.SUCCESS.getCode(), null); + } + + @GetMapping("/list/off") + @ApiOperation(value = "商品下架") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "商品id", required = true, dataType = "Long", paramType = "query") + }) + public ResponseEntity<ReturnDataDTO<?>> offGoods(Long id) { + pointGoodsService.updateStatus(id, Constants.POINT_GOODS_STATUS.I.name()); + 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/resources/mapper/point/PointGoodsMapper.xml b/src/main/resources/mapper/point/PointGoodsMapper.xml new file mode 100644 index 0000000..7e1357a --- /dev/null +++ b/src/main/resources/mapper/point/PointGoodsMapper.xml @@ -0,0 +1,30 @@ +<?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.PointGoodsMapper"> + + <select id="selectGoodsList" resultType="com.mzl.flower.dto.response.point.PointGoodsListDTO"> + SELECT p.* + FROM t_point_goods p + WHERE p.deleted = 0 + <if test="condition.name != null and condition.name != ''"> + AND p.name LIKE concat('%', #{condition.name},'%') + </if> + <if test="condition.status != null and condition.status != ''"> + AND p.status = #{condition.status} + </if> + <if test="condition.stockLower != null"> + AND p.stock > #{condition.stockLower} + </if> + <if test="condition.stockUpper != null"> + AND p.stock <= #{condition.stockUpper} + </if> + <if test="condition.pointLower != null"> + AND p.point > #{condition.pointLower} + </if> + <if test="condition.pointUpper != null"> + AND p.point <= #{condition.pointUpper} + </if> + ORDER BY p.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 diff --git "a/src/main/\350\241\250\350\256\276\350\256\241.xlsx" "b/src/main/\350\241\250\350\256\276\350\256\241.xlsx" index 2e1e3ae..341bd45 100644 --- "a/src/main/\350\241\250\350\256\276\350\256\241.xlsx" +++ "b/src/main/\350\241\250\350\256\276\350\256\241.xlsx" Binary files differ -- Gitblit v1.9.3