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"; 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; } 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; } 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; } 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; } 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; } 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; } 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; 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; } 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); } 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> { } 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>() src/main/java/com/mzl/flower/service/point/CustomerPointDetailService.java
文件已删除 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); } } src/main/java/com/mzl/flower/service/point/PointGoodService.java
文件已删除 src/main/java/com/mzl/flower/service/point/impl/CustomerPointDetailServiceImpl.java
文件已删除 src/main/java/com/mzl/flower/service/point/impl/PointGoodServiceImpl.java
文件已删除 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)); } } src/main/java/com/mzl/flower/web/point/CustomerPointDetailController.java
文件已删除 src/main/java/com/mzl/flower/web/point/PointGoodController.java
文件已删除 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> src/main/表设计-二期.xlsxBinary files differ