|  |  |  | 
|---|
|  |  |  | 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) { | 
|---|
|  |  |  | if(dto.getPoint()<=0){ | 
|---|
|  |  |  | throw new ValidationException("赠送积分必须大于0"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | customerPointService.giveawayPoint(dto); | 
|---|
|  |  |  | return returnData(R.SUCCESS.getCode(),null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/deduction") | 
|---|
|  |  |  | @ApiOperation(value = "管理端-积分扣除", notes = "管理端-积分扣除") | 
|---|
|  |  |  | public ResponseEntity<ReturnDataDTO> deductionPoint(@Validated @RequestBody ChangePointDTO dto) { | 
|---|
|  |  |  | if(dto.getPoint()<=0){ | 
|---|
|  |  |  | throw new ValidationException("扣除积分必须大于0"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 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)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|