v3.0.0 springboot3+jdk17版本
This commit is contained in:
1 parent
3aa2c942dc
commit
b3ee447f8e
3676 files changed
+64366
-370384
No files matched your search
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>co.yixiang.boot</groupId>
|
||||
<artifactId>yshop</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>yshop-module-score</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>yshop-module-score-api</module>
|
||||
<module>yshop-module-score-biz</module>
|
||||
</modules>
|
||||
|
||||
<name>${project.artifactId}</name>
|
||||
<description>
|
||||
score 模块
|
||||
</description>
|
||||
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,64 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>yshop-module-score</artifactId>
|
||||
<groupId>co.yixiang.boot</groupId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>yshop-module-score-api</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>${project.artifactId}</name>
|
||||
<description>
|
||||
score 模块 API,暴露给其它模块调用
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>co.yixiang.boot</groupId>
|
||||
<artifactId>yshop-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 参数校验 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- DB 相关 -->
|
||||
<dependency>
|
||||
<groupId>co.yixiang.boot</groupId>
|
||||
<artifactId>yshop-spring-boot-starter-mybatis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 消息队列相关 -->
|
||||
<dependency>
|
||||
<groupId>co.yixiang.boot</groupId>
|
||||
<artifactId>yshop-spring-boot-starter-mq</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- 支付相关 -->
|
||||
<dependency>
|
||||
<groupId>com.egzosn</groupId>
|
||||
<artifactId>pay-java-wx</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.egzosn</groupId>
|
||||
<artifactId>pay-java-ali</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.egzosn</groupId>
|
||||
<artifactId>pay-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.egzosn</groupId>
|
||||
<artifactId>pay-java-web-support</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package co.yixiang.yshop.module.score.enums;
|
||||
|
||||
import co.yixiang.yshop.framework.common.exception.ErrorCode;
|
||||
public interface ErrorCodeConstants {
|
||||
ErrorCode ORDER_NOT_EXISTS = new ErrorCode(1008018000, "积分商城订单不存在");
|
||||
ErrorCode PRODUCT_NOT_EXISTS = new ErrorCode(1008018001, "积分产品不存在");
|
||||
ErrorCode SCORE_NOT = new ErrorCode(1008018002, "积分不足");
|
||||
ErrorCode PRODUCT_NOT_STOCK = new ErrorCode(1008018002, "库存不足");
|
||||
}
|
||||
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package co.yixiang.yshop.module.score.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* @author hupeng
|
||||
* 订单相关枚举
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum OrderStatusEnum {
|
||||
|
||||
STATUS__1(-1,"全部订单"),
|
||||
STATUS_0(0,"待发货"),
|
||||
STATUS_1(1,"待收货"),
|
||||
STATUS_2(2,"已完成"),
|
||||
STATUS_6(6,"已删除");
|
||||
|
||||
|
||||
|
||||
private Integer value;
|
||||
private String desc;
|
||||
|
||||
public static OrderStatusEnum toType(int value) {
|
||||
return Stream.of(OrderStatusEnum.values())
|
||||
.filter(p -> p.value == value)
|
||||
.findAny()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>yshop-module-score</artifactId>
|
||||
<groupId>co.yixiang.boot</groupId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>yshop-module-score-biz</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>${project.artifactId}</name>
|
||||
<description>
|
||||
score 模块
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>co.yixiang.boot</groupId>
|
||||
<artifactId>yshop-module-score-api</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>co.yixiang.boot</groupId>
|
||||
<artifactId>yshop-module-member-biz</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- 业务组件 -->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>co.yixiang.boot</groupId>-->
|
||||
<!-- <artifactId>yshop-spring-boot-starter-biz-operatelog</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>co.yixiang.boot</groupId>
|
||||
<artifactId>yshop-spring-boot-starter-biz-tenant</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Web 相关 -->
|
||||
<dependency>
|
||||
<groupId>co.yixiang.boot</groupId>
|
||||
<artifactId>yshop-spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>co.yixiang.boot</groupId>
|
||||
<artifactId>yshop-spring-boot-starter-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- 消息队列相关 -->
|
||||
<dependency>
|
||||
<groupId>co.yixiang.boot</groupId>
|
||||
<artifactId>yshop-spring-boot-starter-mq</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Test 测试相关 -->
|
||||
<dependency>
|
||||
<groupId>co.yixiang.boot</groupId>
|
||||
<artifactId>yshop-spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- 工具类相关 -->
|
||||
<dependency>
|
||||
<groupId>co.yixiang.boot</groupId>
|
||||
<artifactId>yshop-spring-boot-starter-excel</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
package co.yixiang.yshop.module.score.controller.admin.scoreorder;
|
||||
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import jakarta.validation.constraints.*;
|
||||
import jakarta.validation.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import co.yixiang.yshop.framework.common.pojo.PageResult;
|
||||
import co.yixiang.yshop.framework.common.pojo.CommonResult;
|
||||
import static co.yixiang.yshop.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import co.yixiang.yshop.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import co.yixiang.yshop.module.score.controller.admin.scoreorder.vo.*;
|
||||
import co.yixiang.yshop.module.score.dal.dataobject.scoreorder.ScoreOrderDO;
|
||||
import co.yixiang.yshop.module.score.convert.scoreorder.ScoreOrderConvert;
|
||||
import co.yixiang.yshop.module.score.service.scoreorder.ScoreOrderService;
|
||||
|
||||
@Tag(name = "管理后台 - 积分商城订单")
|
||||
@RestController
|
||||
@RequestMapping("/score/order")
|
||||
@Validated
|
||||
public class ScoreOrderController {
|
||||
|
||||
@Resource
|
||||
private ScoreOrderService orderService;
|
||||
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新积分商城订单")
|
||||
@PreAuthorize("@ss.hasPermission('score:order:update')")
|
||||
public CommonResult<Boolean> updateOrder(@Valid @RequestBody ScoreOrderUpdateReqVO updateReqVO) {
|
||||
orderService.updateOrder(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除积分商城订单")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('score:order:delete')")
|
||||
public CommonResult<Boolean> deleteOrder(@RequestParam("id") Long id) {
|
||||
orderService.deleteOrder(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得积分商城订单")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('score:order:query')")
|
||||
public CommonResult<ScoreOrderRespVO> getOrder(@RequestParam("id") Long id) {
|
||||
return success(orderService.getOrder(id));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得积分商城订单列表")
|
||||
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
|
||||
@PreAuthorize("@ss.hasPermission('score:order:query')")
|
||||
public CommonResult<List<ScoreOrderRespVO>> getOrderList(@RequestParam("ids") Collection<Long> ids) {
|
||||
List<ScoreOrderDO> list = orderService.getOrderList(ids);
|
||||
return success(ScoreOrderConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得积分商城订单分页")
|
||||
@PreAuthorize("@ss.hasPermission('score:order:query')")
|
||||
public CommonResult<PageResult<ScoreOrderRespVO>> getOrderPage(@Valid ScoreOrderPageReqVO pageVO) {
|
||||
return success(orderService.getOrderPage(pageVO));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出积分商城订单 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('score:order:export')")
|
||||
public void exportOrderExcel(@Valid ScoreOrderExportReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<ScoreOrderDO> list = orderService.getOrderList(exportReqVO);
|
||||
// 导出 Excel
|
||||
List<ScoreOrderExcelVO> datas = ScoreOrderConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "积分商城订单.xls", "数据", ScoreOrderExcelVO.class, datas);
|
||||
}
|
||||
|
||||
@GetMapping("/take")
|
||||
@Operation(summary = "收货")
|
||||
@PreAuthorize("@ss.hasPermission('score:order:update')")
|
||||
public CommonResult<Boolean> take(@RequestParam("id") Long id) {
|
||||
orderService.takeOrder(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
package co.yixiang.yshop.module.score.controller.admin.scoreorder.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* 积分商城订单 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Data
|
||||
public class ScoreOrderBaseVO {
|
||||
|
||||
@Schema(description = "用户id", required = true, example = "28397")
|
||||
@NotNull(message = "用户id不能为空")
|
||||
private Long uid;
|
||||
|
||||
@Schema(description = "订单编号", required = true, example = "28397")
|
||||
private String orderId;
|
||||
|
||||
@Schema(description = "商品id", required = true, example = "31639")
|
||||
@NotNull(message = "商品id不能为空")
|
||||
private Long productId;
|
||||
|
||||
@Schema(description = "数量", required = true)
|
||||
@NotNull(message = "数量不能为空")
|
||||
private Integer number;
|
||||
|
||||
@Schema(description = "单个商品积分", required = true)
|
||||
@NotNull(message = "单个商品积分不能为空")
|
||||
private Integer score;
|
||||
|
||||
@Schema(description = "总消耗积分", required = true)
|
||||
@NotNull(message = "总消耗积分不能为空")
|
||||
private Integer totalScore;
|
||||
|
||||
@Schema(description = "下单ip")
|
||||
private String ip;
|
||||
|
||||
@Schema(description = "快递公司编码", required = true)
|
||||
private String expressSn;
|
||||
|
||||
@Schema(description = "快递编号", required = true)
|
||||
@NotNull(message = "快递编号不能为空")
|
||||
private String expressNumber;
|
||||
|
||||
@Schema(description = "快递公司", required = true)
|
||||
@NotNull(message = "快递公司不能为空")
|
||||
private String expressCompany;
|
||||
|
||||
@Schema(description = "收货名称", example = "王五")
|
||||
private String customerName;
|
||||
|
||||
@Schema(description = "收货电话")
|
||||
private String customerPhone;
|
||||
|
||||
@Schema(description = "收货地址")
|
||||
private String customerAddress;
|
||||
|
||||
@Schema(description = "订单状态:0=取消订单,1=正常啊", required = true, example = "1")
|
||||
@NotNull(message = "订单状态:0=取消订单,1=正常啊不能为空")
|
||||
private Boolean status;
|
||||
|
||||
@Schema(description = "已支付:0=否", required = true, example = "12822")
|
||||
@NotNull(message = "已支付:0=否不能为空")
|
||||
private Integer havePaid;
|
||||
|
||||
@Schema(description = "已发货:0=否", required = true)
|
||||
@NotNull(message = "已发货:0=否不能为空")
|
||||
private Integer haveDelivered;
|
||||
|
||||
@Schema(description = "已收货:0=否", required = true)
|
||||
@NotNull(message = "已收货:0=否不能为空")
|
||||
private Integer haveReceived;
|
||||
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package co.yixiang.yshop.module.score.controller.admin.scoreorder.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 积分商城订单创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ScoreOrderCreateReqVO extends ScoreOrderBaseVO {
|
||||
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
package co.yixiang.yshop.module.score.controller.admin.scoreorder.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
|
||||
/**
|
||||
* 积分商城订单 Excel VO
|
||||
*
|
||||
* @author yshop
|
||||
*/
|
||||
@Data
|
||||
public class ScoreOrderExcelVO {
|
||||
|
||||
@ExcelProperty("id")
|
||||
private Long id;
|
||||
|
||||
@ExcelProperty("用户id")
|
||||
private Integer userId;
|
||||
|
||||
@ExcelProperty("商品id")
|
||||
private Integer productId;
|
||||
|
||||
@ExcelProperty("数量")
|
||||
private Integer number;
|
||||
|
||||
@ExcelProperty("单个商品积分")
|
||||
private Integer score;
|
||||
|
||||
@ExcelProperty("总消耗积分")
|
||||
private Integer totalScore;
|
||||
|
||||
@ExcelProperty("下单ip")
|
||||
private String ip;
|
||||
|
||||
@ExcelProperty("快递编号")
|
||||
private String expressNumber;
|
||||
|
||||
@ExcelProperty("快递公司")
|
||||
private String expressCompany;
|
||||
|
||||
@ExcelProperty("收货名称")
|
||||
private String customerName;
|
||||
|
||||
@ExcelProperty("收货电话")
|
||||
private String customerPhone;
|
||||
|
||||
@ExcelProperty("收货地址")
|
||||
private String customerAddress;
|
||||
|
||||
@ExcelProperty("订单状态:0=取消订单,1=正常啊")
|
||||
private Boolean status;
|
||||
|
||||
@ExcelProperty("已支付:0=否")
|
||||
private Integer havePaid;
|
||||
|
||||
@ExcelProperty("已发货:0=否")
|
||||
private Integer haveDelivered;
|
||||
|
||||
@ExcelProperty("已收货:0=否")
|
||||
private Integer haveReceived;
|
||||
|
||||
@ExcelProperty("添加时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
package co.yixiang.yshop.module.score.controller.admin.scoreorder.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import co.yixiang.yshop.framework.common.pojo.PageParam;
|
||||
import java.time.LocalDateTime;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import static co.yixiang.yshop.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 积分商城订单 Excel 导出 Request VO,参数和 ScoreOrderPageReqVO 是一致的")
|
||||
@Data
|
||||
public class ScoreOrderExportReqVO {
|
||||
|
||||
@Schema(description = "用户id", example = "28397")
|
||||
private Integer userId;
|
||||
|
||||
@Schema(description = "商品id", example = "31639")
|
||||
private Integer productId;
|
||||
|
||||
@Schema(description = "数量")
|
||||
private Integer number;
|
||||
|
||||
@Schema(description = "单个商品积分")
|
||||
private Integer score;
|
||||
|
||||
@Schema(description = "总消耗积分")
|
||||
private Integer totalScore;
|
||||
|
||||
@Schema(description = "下单ip")
|
||||
private String ip;
|
||||
|
||||
@Schema(description = "快递编号")
|
||||
private String expressNumber;
|
||||
|
||||
@Schema(description = "快递公司")
|
||||
private String expressCompany;
|
||||
|
||||
@Schema(description = "收货名称", example = "王五")
|
||||
private String customerName;
|
||||
|
||||
@Schema(description = "收货电话")
|
||||
private String customerPhone;
|
||||
|
||||
@Schema(description = "收货地址")
|
||||
private String customerAddress;
|
||||
|
||||
@Schema(description = "订单状态:0=取消订单,1=正常啊", example = "1")
|
||||
private Boolean status;
|
||||
|
||||
@Schema(description = "已支付:0=否", example = "12822")
|
||||
private Integer havePaid;
|
||||
|
||||
@Schema(description = "已发货:0=否")
|
||||
private Integer haveDelivered;
|
||||
|
||||
@Schema(description = "已收货:0=否")
|
||||
private Integer haveReceived;
|
||||
|
||||
@Schema(description = "添加时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
package co.yixiang.yshop.module.score.controller.admin.scoreorder.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import co.yixiang.yshop.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static co.yixiang.yshop.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 积分商城订单分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ScoreOrderPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "用户id", example = "28397")
|
||||
private Long uid;
|
||||
|
||||
@Schema(description = "订单编号", required = true, example = "28397")
|
||||
private String orderId;
|
||||
|
||||
@Schema(description = "商品id", example = "31639")
|
||||
private Long productId;
|
||||
|
||||
@Schema(description = "数量")
|
||||
private Integer number;
|
||||
|
||||
@Schema(description = "单个商品积分")
|
||||
private Integer score;
|
||||
|
||||
@Schema(description = "总消耗积分")
|
||||
private Integer totalScore;
|
||||
|
||||
@Schema(description = "下单ip")
|
||||
private String ip;
|
||||
|
||||
@Schema(description = "快递编号")
|
||||
private String expressNumber;
|
||||
|
||||
@Schema(description = "快递公司")
|
||||
private String expressCompany;
|
||||
|
||||
@Schema(description = "收货名称", example = "王五")
|
||||
private String customerName;
|
||||
|
||||
@Schema(description = "收货电话")
|
||||
private String customerPhone;
|
||||
|
||||
@Schema(description = "收货地址")
|
||||
private String customerAddress;
|
||||
|
||||
@Schema(description = "订单状态:0=取消订单,1=正常啊", example = "1")
|
||||
private Boolean status;
|
||||
|
||||
@Schema(description = "已支付:0=否", example = "12822")
|
||||
private Integer havePaid;
|
||||
|
||||
@Schema(description = "已发货:0=否")
|
||||
private Integer haveDelivered;
|
||||
|
||||
@Schema(description = "已收货:0=否")
|
||||
private Integer haveReceived;
|
||||
|
||||
@Schema(description = "添加时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
// "状态,-1全部 默认为0待发货 1待收货 2已完成"
|
||||
private Integer type;
|
||||
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package co.yixiang.yshop.module.score.controller.admin.scoreorder.vo;
|
||||
|
||||
import co.yixiang.yshop.module.member.controller.admin.user.vo.UserRespVO;
|
||||
import co.yixiang.yshop.module.score.controller.admin.scoreproduct.vo.ScoreProductRespVO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 积分商城订单 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ScoreOrderRespVO extends ScoreOrderBaseVO {
|
||||
|
||||
@Schema(description = "id", required = true, example = "19735")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "添加时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "商品明细")
|
||||
private ScoreProductRespVO scoreProductRespVO;
|
||||
|
||||
@Schema(description = "用户信息", required = true)
|
||||
private UserRespVO userRespVO;
|
||||
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package co.yixiang.yshop.module.score.controller.admin.scoreorder.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 积分商城订单更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ScoreOrderUpdateReqVO extends ScoreOrderBaseVO {
|
||||
|
||||
@Schema(description = "id", required = true, example = "19735")
|
||||
@NotNull(message = "id不能为空")
|
||||
private Long id;
|
||||
|
||||
}
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
package co.yixiang.yshop.module.score.controller.admin.scoreproduct;
|
||||
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import jakarta.validation.constraints.*;
|
||||
import jakarta.validation.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import co.yixiang.yshop.framework.common.pojo.PageResult;
|
||||
import co.yixiang.yshop.framework.common.pojo.CommonResult;
|
||||
import static co.yixiang.yshop.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import co.yixiang.yshop.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import co.yixiang.yshop.module.score.controller.admin.scoreproduct.vo.*;
|
||||
import co.yixiang.yshop.module.score.dal.dataobject.scoreproduct.ScoreProductDO;
|
||||
import co.yixiang.yshop.module.score.convert.scoreproduct.ScoreProductConvert;
|
||||
import co.yixiang.yshop.module.score.service.scoreproduct.ScoreProductService;
|
||||
|
||||
@Tag(name = "管理后台 - 积分产品")
|
||||
@RestController
|
||||
@RequestMapping("/score/product")
|
||||
@Validated
|
||||
public class ScoreProductController {
|
||||
|
||||
@Resource
|
||||
private ScoreProductService productService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建积分产品")
|
||||
@PreAuthorize("@ss.hasPermission('score:product:create')")
|
||||
public CommonResult<Long> createProduct(@Valid @RequestBody ScoreProductCreateReqVO createReqVO) {
|
||||
return success(productService.createProduct(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新积分产品")
|
||||
@PreAuthorize("@ss.hasPermission('score:product:update')")
|
||||
public CommonResult<Boolean> updateProduct(@Valid @RequestBody ScoreProductUpdateReqVO updateReqVO) {
|
||||
productService.updateProduct(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除积分产品")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('score:product:delete')")
|
||||
public CommonResult<Boolean> deleteProduct(@RequestParam("id") Long id) {
|
||||
productService.deleteProduct(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得积分产品")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('score:product:query')")
|
||||
public CommonResult<ScoreProductRespVO> getProduct(@RequestParam("id") Long id) {
|
||||
ScoreProductDO product = productService.getProduct(id);
|
||||
return success(ScoreProductConvert.INSTANCE.convert(product));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得积分产品列表")
|
||||
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
|
||||
@PreAuthorize("@ss.hasPermission('score:product:query')")
|
||||
public CommonResult<List<ScoreProductRespVO>> getProductList(@RequestParam("ids") Collection<Long> ids) {
|
||||
List<ScoreProductDO> list = productService.getProductList(ids);
|
||||
return success(ScoreProductConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得积分产品分页")
|
||||
@PreAuthorize("@ss.hasPermission('score:product:query')")
|
||||
public CommonResult<PageResult<ScoreProductRespVO>> getProductPage(@Valid ScoreProductPageReqVO pageVO) {
|
||||
PageResult<ScoreProductDO> pageResult = productService.getProductPage(pageVO);
|
||||
return success(ScoreProductConvert.INSTANCE.convertPage(pageResult));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出积分产品 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('score:product:export')")
|
||||
public void exportProductExcel(@Valid ScoreProductExportReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<ScoreProductDO> list = productService.getProductList(exportReqVO);
|
||||
// 导出 Excel
|
||||
List<ScoreProductExcelVO> datas = ScoreProductConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "积分产品.xls", "数据", ScoreProductExcelVO.class, datas);
|
||||
}
|
||||
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
package co.yixiang.yshop.module.score.controller.admin.scoreproduct.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* 积分产品 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Data
|
||||
public class ScoreProductBaseVO {
|
||||
|
||||
@Schema(description = "产品标题", required = true)
|
||||
@NotNull(message = "产品标题不能为空")
|
||||
private String title;
|
||||
|
||||
@Schema(description = "主图", required = true)
|
||||
@NotNull(message = "主图不能为空")
|
||||
private String image;
|
||||
|
||||
@Schema(description = "组图", required = true)
|
||||
@NotNull(message = "组图不能为空")
|
||||
private List<String> images;
|
||||
|
||||
@Schema(description = "详情", required = true)
|
||||
@NotNull(message = "详情不能为空")
|
||||
private String desc;
|
||||
|
||||
@Schema(description = "消耗积分", required = true)
|
||||
@NotNull(message = "消耗积分不能为空")
|
||||
private Integer score;
|
||||
|
||||
@Schema(description = "权重", required = true)
|
||||
private Integer weigh;
|
||||
|
||||
@Schema(description = "库存", required = true)
|
||||
@NotNull(message = "库存不能为空")
|
||||
private Integer stock;
|
||||
|
||||
@Schema(description = "销售量", required = true)
|
||||
private Integer sales;
|
||||
|
||||
@Schema(description = "是否上架:0=否,1=是", required = true)
|
||||
private Integer isSwitch;
|
||||
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package co.yixiang.yshop.module.score.controller.admin.scoreproduct.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 积分产品创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ScoreProductCreateReqVO extends ScoreProductBaseVO {
|
||||
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
package co.yixiang.yshop.module.score.controller.admin.scoreproduct.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
|
||||
/**
|
||||
* 积分产品 Excel VO
|
||||
*
|
||||
* @author yshop
|
||||
*/
|
||||
@Data
|
||||
public class ScoreProductExcelVO {
|
||||
|
||||
@ExcelProperty("id")
|
||||
private Long id;
|
||||
|
||||
@ExcelProperty("产品标题")
|
||||
private String title;
|
||||
|
||||
@ExcelProperty("主图")
|
||||
private String image;
|
||||
|
||||
@ExcelProperty("组图")
|
||||
private List<String> images;
|
||||
|
||||
@ExcelProperty("详情")
|
||||
private String desc;
|
||||
|
||||
@ExcelProperty("消耗积分")
|
||||
private Integer score;
|
||||
|
||||
@ExcelProperty("权重")
|
||||
private Integer weigh;
|
||||
|
||||
@ExcelProperty("库存")
|
||||
private Integer stock;
|
||||
|
||||
@ExcelProperty("销售量")
|
||||
private Integer sales;
|
||||
|
||||
@ExcelProperty("是否上架:0=否,1=是")
|
||||
private Integer isSwitch;
|
||||
|
||||
@ExcelProperty("添加时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
package co.yixiang.yshop.module.score.controller.admin.scoreproduct.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import co.yixiang.yshop.framework.common.pojo.PageParam;
|
||||
import java.time.LocalDateTime;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import static co.yixiang.yshop.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 积分产品 Excel 导出 Request VO,参数和 ScoreProductPageReqVO 是一致的")
|
||||
@Data
|
||||
public class ScoreProductExportReqVO {
|
||||
|
||||
@Schema(description = "产品标题")
|
||||
private String title;
|
||||
|
||||
@Schema(description = "主图")
|
||||
private String image;
|
||||
|
||||
@Schema(description = "组图")
|
||||
private String images;
|
||||
|
||||
@Schema(description = "详情")
|
||||
private String desc;
|
||||
|
||||
@Schema(description = "消耗积分")
|
||||
private Integer score;
|
||||
|
||||
@Schema(description = "权重")
|
||||
private Integer weigh;
|
||||
|
||||
@Schema(description = "库存")
|
||||
private Integer stock;
|
||||
|
||||
@Schema(description = "销售量")
|
||||
private Integer sales;
|
||||
|
||||
@Schema(description = "是否上架:0=否,1=是")
|
||||
private Integer isSwitch;
|
||||
|
||||
@Schema(description = "添加时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package co.yixiang.yshop.module.score.controller.admin.scoreproduct.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import co.yixiang.yshop.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static co.yixiang.yshop.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 积分产品分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ScoreProductPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "产品标题")
|
||||
private String title;
|
||||
|
||||
@Schema(description = "主图")
|
||||
private String image;
|
||||
|
||||
@Schema(description = "组图")
|
||||
private List<String> images;
|
||||
|
||||
@Schema(description = "详情")
|
||||
private String desc;
|
||||
|
||||
@Schema(description = "消耗积分")
|
||||
private Integer score;
|
||||
|
||||
@Schema(description = "权重")
|
||||
private Integer weigh;
|
||||
|
||||
@Schema(description = "库存")
|
||||
private Integer stock;
|
||||
|
||||
@Schema(description = "销售量")
|
||||
private Integer sales;
|
||||
|
||||
@Schema(description = "是否上架:0=否,1=是")
|
||||
private Integer isSwitch;
|
||||
|
||||
@Schema(description = "添加时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package co.yixiang.yshop.module.score.controller.admin.scoreproduct.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 积分产品 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ScoreProductRespVO extends ScoreProductBaseVO {
|
||||
|
||||
@Schema(description = "id", required = true, example = "8624")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "添加时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package co.yixiang.yshop.module.score.controller.admin.scoreproduct.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 积分产品更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ScoreProductUpdateReqVO extends ScoreProductBaseVO {
|
||||
|
||||
@Schema(description = "id", required = true, example = "8624")
|
||||
@NotNull(message = "id不能为空")
|
||||
private Long id;
|
||||
|
||||
}
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
package co.yixiang.yshop.module.score.controller.app.order;
|
||||
|
||||
import co.yixiang.yshop.framework.common.pojo.CommonResult;
|
||||
import co.yixiang.yshop.framework.security.core.annotations.PreAuthenticated;
|
||||
import co.yixiang.yshop.module.score.controller.app.order.param.AppScoreOrderParam;
|
||||
import co.yixiang.yshop.module.score.controller.app.order.vo.AppScoreOrderVO;
|
||||
import co.yixiang.yshop.module.score.controller.app.product.param.AppScoreProductQueryParam;
|
||||
import co.yixiang.yshop.module.score.controller.app.product.vo.AppScoreProductVO;
|
||||
import co.yixiang.yshop.module.score.service.scoreorder.AppScoreOrderService;
|
||||
import co.yixiang.yshop.module.score.service.scoreproduct.AppScoreProductService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
import static co.yixiang.yshop.framework.common.pojo.CommonResult.success;
|
||||
import static co.yixiang.yshop.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
@Tag(name = "用户 APP - 积分订单")
|
||||
@RestController
|
||||
@RequestMapping("/score-order")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class AppScoreOrderController {
|
||||
|
||||
private final AppScoreOrderService appScoreOrderService;
|
||||
|
||||
/**
|
||||
* 提交积分订单
|
||||
*/
|
||||
@PreAuthenticated
|
||||
@PostMapping("/submit")
|
||||
@Operation(summary = "提交积分订单")
|
||||
public CommonResult<Boolean> submit(@RequestBody @Valid AppScoreOrderParam appScoreOrderParam){
|
||||
Long uid = getLoginUserId();
|
||||
appScoreOrderService.submit(uid,appScoreOrderParam);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单列表
|
||||
*/
|
||||
@PreAuthenticated
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "订单列表")
|
||||
@Parameters({
|
||||
@Parameter(name = "type", description = "状态,-1全部 默认为0待发货 1待收货 2已完成",
|
||||
required = true, example = "1"),
|
||||
@Parameter(name = "page", description = "页码,默认为1",
|
||||
required = true, example = "1"),
|
||||
@Parameter(name = "limit", description = "页大小,默认为10",
|
||||
required = true, example = "10 ")
|
||||
})
|
||||
public CommonResult<List<AppScoreOrderVO>> orderList(@RequestParam(value = "type", defaultValue = "0") int type,
|
||||
@RequestParam(value = "page", defaultValue = "1") int page,
|
||||
@RequestParam(value = "limit", defaultValue = "10") int limit) {
|
||||
Long uid = getLoginUserId();
|
||||
return success(appScoreOrderService.orderList(uid, type, page, limit));
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单详情
|
||||
*/
|
||||
@PreAuthenticated
|
||||
@GetMapping("/detail")
|
||||
@Operation(summary = "订单详情")
|
||||
@Parameters({
|
||||
@Parameter(name = "id", description = "id",
|
||||
required = true, example = "1")
|
||||
})
|
||||
public CommonResult<AppScoreOrderVO> orderList(@RequestParam(value = "id", defaultValue = "0") Long id) {
|
||||
Long uid = getLoginUserId();
|
||||
return success(appScoreOrderService.orderDetail(uid, id));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 收货
|
||||
*/
|
||||
@PreAuthenticated
|
||||
@GetMapping("/take")
|
||||
@Operation(summary = "收货")
|
||||
public CommonResult<Boolean> take(@RequestParam(value = "id", defaultValue = "0") Long id){
|
||||
Long uid = getLoginUserId();
|
||||
appScoreOrderService.take(uid,id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package co.yixiang.yshop.module.score.controller.app.order.param;
|
||||
|
||||
import co.yixiang.yshop.framework.common.params.QueryParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 积分订单参数对象
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @date 2023-11-30
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "用户 APP - 积分订单参数对象")
|
||||
public class AppScoreOrderParam {
|
||||
|
||||
@Schema(description = "积分商品ID", required = true)
|
||||
@NotBlank(message = "参数有误")
|
||||
private String productId;
|
||||
|
||||
@Schema(description = "地址ID", required = true)
|
||||
@NotBlank(message = "请选择地址")
|
||||
private String addressId;
|
||||
|
||||
@Schema(description = "数量", required = true)
|
||||
private String num;
|
||||
|
||||
|
||||
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
package co.yixiang.yshop.module.score.controller.app.order.vo;
|
||||
|
||||
import co.yixiang.yshop.module.score.controller.app.product.vo.AppScoreProductVO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 积分商城订单 AppScoreOrderVO VO,提供给添加、修改、详细的子 VO 使用
|
||||
*/
|
||||
@Data
|
||||
public class AppScoreOrderVO {
|
||||
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "用户id", required = true, example = "28397")
|
||||
private Long uid;
|
||||
|
||||
@Schema(description = "订单编号", required = true, example = "28397")
|
||||
private String orderId;
|
||||
|
||||
@Schema(description = "商品id", required = true, example = "31639")
|
||||
private Long productId;
|
||||
|
||||
@Schema(description = "数量", required = true)
|
||||
private Integer number;
|
||||
|
||||
@Schema(description = "单个商品积分", required = true)
|
||||
private Integer score;
|
||||
|
||||
@Schema(description = "总消耗积分", required = true)
|
||||
@NotNull(message = "总消耗积分不能为空")
|
||||
private Integer totalScore;
|
||||
|
||||
@Schema(description = "下单ip")
|
||||
private String ip;
|
||||
|
||||
@Schema(description = "快递公司编号", required = true)
|
||||
private String expressSn;
|
||||
|
||||
@Schema(description = "快递编号", required = true)
|
||||
private String expressNumber;
|
||||
|
||||
@Schema(description = "快递公司", required = true)
|
||||
private String expressCompany;
|
||||
|
||||
@Schema(description = "收货名称", example = "王五")
|
||||
private String customerName;
|
||||
|
||||
@Schema(description = "收货电话")
|
||||
private String customerPhone;
|
||||
|
||||
@Schema(description = "收货地址")
|
||||
private String customerAddress;
|
||||
|
||||
@Schema(description = "订单状态:0=取消订单,1=正常啊", required = true, example = "1")
|
||||
private Boolean status;
|
||||
|
||||
@Schema(description = "已支付:0=否", required = true, example = "12822")
|
||||
private Integer havePaid;
|
||||
|
||||
@Schema(description = "已发货:0=否", required = true)
|
||||
private Integer haveDelivered;
|
||||
|
||||
@Schema(description = "已收货:0=否", required = true)
|
||||
private Integer haveReceived;
|
||||
|
||||
@Schema(description = "订单状态字符串", required = true)
|
||||
private String statusText;
|
||||
|
||||
private LocalDateTime createTime;
|
||||
|
||||
private AppScoreProductVO product;
|
||||
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
package co.yixiang.yshop.module.score.controller.app.product;
|
||||
|
||||
import co.yixiang.yshop.framework.common.pojo.CommonResult;
|
||||
import co.yixiang.yshop.module.score.controller.app.product.param.AppScoreProductQueryParam;
|
||||
import co.yixiang.yshop.module.score.controller.app.product.vo.AppScoreProductVO;
|
||||
import co.yixiang.yshop.module.score.service.scoreproduct.AppScoreProductService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static co.yixiang.yshop.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "用户 APP - 积分商品")
|
||||
@RestController
|
||||
@RequestMapping("/score-product")
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class AppScoreProductController {
|
||||
|
||||
private final AppScoreProductService appScoreProductService;
|
||||
|
||||
/**
|
||||
* 获取积分商品列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获取积分商品列表")
|
||||
public CommonResult<List<AppScoreProductVO>> goodsList(AppScoreProductQueryParam productQueryParam){
|
||||
return success(appScoreProductService.getList(productQueryParam.getPage(),productQueryParam.getLimit()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取积分商品详情
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
@Operation(summary = "获取积分商品详情")
|
||||
public CommonResult<AppScoreProductVO> goodsDetail(@RequestParam(value = "id", defaultValue = "0") Long id){
|
||||
return success(appScoreProductService.getDetail(id));
|
||||
}
|
||||
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package co.yixiang.yshop.module.score.controller.app.product.param;
|
||||
|
||||
import co.yixiang.yshop.framework.common.params.QueryParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 商品查询参数对象
|
||||
* </p>
|
||||
*
|
||||
* @author hupeng
|
||||
* @date 2023-11-26
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(description = "用户 APP - 积分商品表查询参数")
|
||||
public class AppScoreProductQueryParam extends QueryParam {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Schema(description = "关键字", required = true)
|
||||
private String keyword;
|
||||
|
||||
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package co.yixiang.yshop.module.score.controller.app.product.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 积分产品 AppScoreProductVO VO
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Data
|
||||
public class AppScoreProductVO {
|
||||
|
||||
@Schema(description = "id", required = true, example = "8624")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "产品标题", required = true)
|
||||
private String title;
|
||||
|
||||
@Schema(description = "主图", required = true)
|
||||
private String image;
|
||||
|
||||
@Schema(description = "组图", required = true)
|
||||
private List<String> images;
|
||||
|
||||
@Schema(description = "详情", required = true)
|
||||
private String desc;
|
||||
|
||||
@Schema(description = "消耗积分", required = true)
|
||||
private Integer score;
|
||||
|
||||
|
||||
@Schema(description = "库存", required = true)
|
||||
private Integer stock;
|
||||
|
||||
@Schema(description = "销售量", required = true)
|
||||
private Integer sales;
|
||||
|
||||
|
||||
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
package co.yixiang.yshop.module.score.convert.scoreorder;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import co.yixiang.yshop.framework.common.pojo.PageResult;
|
||||
|
||||
import co.yixiang.yshop.module.score.controller.app.order.vo.AppScoreOrderVO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
import co.yixiang.yshop.module.score.controller.admin.scoreorder.vo.*;
|
||||
import co.yixiang.yshop.module.score.dal.dataobject.scoreorder.ScoreOrderDO;
|
||||
|
||||
/**
|
||||
* 积分商城订单 Convert
|
||||
*
|
||||
* @author yshop
|
||||
*/
|
||||
@Mapper
|
||||
public interface ScoreOrderConvert {
|
||||
|
||||
ScoreOrderConvert INSTANCE = Mappers.getMapper(ScoreOrderConvert.class);
|
||||
|
||||
ScoreOrderDO convert(ScoreOrderCreateReqVO bean);
|
||||
|
||||
ScoreOrderDO convert(ScoreOrderUpdateReqVO bean);
|
||||
|
||||
ScoreOrderRespVO convert(ScoreOrderDO bean);
|
||||
|
||||
AppScoreOrderVO convert01(ScoreOrderDO bean);
|
||||
|
||||
List<ScoreOrderRespVO> convertList(List<ScoreOrderDO> list);
|
||||
|
||||
List<AppScoreOrderVO> convertList01(List<ScoreOrderDO> list);
|
||||
|
||||
PageResult<ScoreOrderRespVO> convertPage(PageResult<ScoreOrderDO> page);
|
||||
|
||||
List<ScoreOrderExcelVO> convertList02(List<ScoreOrderDO> list);
|
||||
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
package co.yixiang.yshop.module.score.convert.scoreproduct;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import co.yixiang.yshop.framework.common.pojo.PageResult;
|
||||
|
||||
import co.yixiang.yshop.module.score.controller.app.product.vo.AppScoreProductVO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
import co.yixiang.yshop.module.score.controller.admin.scoreproduct.vo.*;
|
||||
import co.yixiang.yshop.module.score.dal.dataobject.scoreproduct.ScoreProductDO;
|
||||
|
||||
/**
|
||||
* 积分产品 Convert
|
||||
*
|
||||
* @author yshop
|
||||
*/
|
||||
@Mapper
|
||||
public interface ScoreProductConvert {
|
||||
|
||||
ScoreProductConvert INSTANCE = Mappers.getMapper(ScoreProductConvert.class);
|
||||
|
||||
ScoreProductDO convert(ScoreProductCreateReqVO bean);
|
||||
|
||||
ScoreProductDO convert(ScoreProductUpdateReqVO bean);
|
||||
|
||||
ScoreProductRespVO convert(ScoreProductDO bean);
|
||||
|
||||
AppScoreProductVO convert01(ScoreProductDO bean);
|
||||
|
||||
List<ScoreProductRespVO> convertList(List<ScoreProductDO> list);
|
||||
|
||||
List<AppScoreProductVO> convertList01(List<ScoreProductDO> list);
|
||||
|
||||
PageResult<ScoreProductRespVO> convertPage(PageResult<ScoreProductDO> page);
|
||||
|
||||
List<ScoreProductExcelVO> convertList02(List<ScoreProductDO> list);
|
||||
|
||||
}
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
package co.yixiang.yshop.module.score.dal.dataobject.scoreorder;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import co.yixiang.yshop.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 积分商城订单 DO
|
||||
*
|
||||
* @author yshop
|
||||
*/
|
||||
@TableName("yshop_score_order")
|
||||
@KeySequence("yshop_score_order_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ScoreOrderDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Long uid;
|
||||
|
||||
/**
|
||||
* 订单编号
|
||||
*/
|
||||
private String orderId;
|
||||
/**
|
||||
* 商品id
|
||||
*/
|
||||
private Long productId;
|
||||
/**
|
||||
* 数量
|
||||
*/
|
||||
private Integer number;
|
||||
/**
|
||||
* 单个商品积分
|
||||
*/
|
||||
private Integer score;
|
||||
/**
|
||||
* 总消耗积分
|
||||
*/
|
||||
private Integer totalScore;
|
||||
/**
|
||||
* 下单ip
|
||||
*/
|
||||
private String ip;
|
||||
|
||||
/**
|
||||
* 快递公司编码
|
||||
*/
|
||||
private String expressSn;
|
||||
/**
|
||||
* 快递编号
|
||||
*/
|
||||
private String expressNumber;
|
||||
/**
|
||||
* 快递公司
|
||||
*/
|
||||
private String expressCompany;
|
||||
/**
|
||||
* 收货名称
|
||||
*/
|
||||
private String customerName;
|
||||
/**
|
||||
* 收货电话
|
||||
*/
|
||||
private String customerPhone;
|
||||
/**
|
||||
* 收货地址
|
||||
*/
|
||||
private String customerAddress;
|
||||
/**
|
||||
* 订单状态:0=取消订单,1=正常啊
|
||||
*/
|
||||
private Boolean status;
|
||||
/**
|
||||
* 已支付:0=否
|
||||
*/
|
||||
private Integer havePaid;
|
||||
/**
|
||||
* 已发货:0=否
|
||||
*/
|
||||
private Integer haveDelivered;
|
||||
/**
|
||||
* 已收货:0=否
|
||||
*/
|
||||
private Integer haveReceived;
|
||||
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
package co.yixiang.yshop.module.score.dal.dataobject.scoreproduct;
|
||||
|
||||
import co.yixiang.yshop.framework.mybatis.core.type.StringListTypeHandler;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import co.yixiang.yshop.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 积分产品 DO
|
||||
*
|
||||
* @author yshop
|
||||
*/
|
||||
@TableName(value = "yshop_score_product",autoResultMap = true)
|
||||
@KeySequence("yshop_score_product_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ScoreProductDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 产品标题
|
||||
*/
|
||||
private String title;
|
||||
/**
|
||||
* 主图
|
||||
*/
|
||||
private String image;
|
||||
/**
|
||||
* 组图
|
||||
*/
|
||||
@TableField(typeHandler = StringListTypeHandler.class)
|
||||
private List<String> images;
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
@TableField(value = "`desc`")
|
||||
private String desc;
|
||||
/**
|
||||
* 消耗积分
|
||||
*/
|
||||
private Integer score;
|
||||
/**
|
||||
* 权重
|
||||
*/
|
||||
private Integer weigh;
|
||||
/**
|
||||
* 库存
|
||||
*/
|
||||
private Integer stock;
|
||||
/**
|
||||
* 销售量
|
||||
*/
|
||||
private Integer sales;
|
||||
/**
|
||||
* 是否上架:0=否,1=是
|
||||
*/
|
||||
private Integer isSwitch;
|
||||
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
package co.yixiang.yshop.module.score.dal.mysql.scoreorder;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import co.yixiang.yshop.framework.common.enums.OrderInfoEnum;
|
||||
import co.yixiang.yshop.framework.common.pojo.PageResult;
|
||||
import co.yixiang.yshop.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import co.yixiang.yshop.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import co.yixiang.yshop.module.score.dal.dataobject.scoreorder.ScoreOrderDO;
|
||||
import co.yixiang.yshop.module.score.enums.OrderStatusEnum;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import co.yixiang.yshop.module.score.controller.admin.scoreorder.vo.*;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
/**
|
||||
* 积分商城订单 Mapper
|
||||
*
|
||||
* @author yshop
|
||||
*/
|
||||
@Mapper
|
||||
public interface ScoreOrderMapper extends BaseMapperX<ScoreOrderDO> {
|
||||
|
||||
default PageResult<ScoreOrderDO> selectPage(ScoreOrderPageReqVO reqVO) {
|
||||
LambdaQueryWrapperX<ScoreOrderDO> wrapper = new LambdaQueryWrapperX();
|
||||
wrapper.eqIfPresent(ScoreOrderDO::getOrderId, reqVO.getOrderId())
|
||||
.likeIfPresent(ScoreOrderDO::getCustomerName, reqVO.getCustomerName())
|
||||
.eqIfPresent(ScoreOrderDO::getCustomerPhone, reqVO.getCustomerPhone())
|
||||
.orderByDesc(ScoreOrderDO::getId);
|
||||
switch (OrderStatusEnum.toType(reqVO.getType())) {
|
||||
case STATUS__1:
|
||||
break;
|
||||
//待发货
|
||||
case STATUS_0:
|
||||
wrapper.eq(ScoreOrderDO::getHavePaid, OrderInfoEnum.PAY_STATUS_1.getValue())
|
||||
.eq(ScoreOrderDO::getHaveDelivered, OrderInfoEnum.STATUS_0.getValue())
|
||||
.eq(ScoreOrderDO::getHaveReceived, OrderInfoEnum.STATUS_0.getValue());
|
||||
break;
|
||||
//待收货
|
||||
case STATUS_1:
|
||||
wrapper.eq(ScoreOrderDO::getHavePaid, OrderInfoEnum.PAY_STATUS_1.getValue())
|
||||
.eq(ScoreOrderDO::getHaveDelivered, OrderInfoEnum.STATUS_1.getValue())
|
||||
.eq(ScoreOrderDO::getHaveReceived, OrderInfoEnum.STATUS_0.getValue());
|
||||
break;
|
||||
//已完成
|
||||
case STATUS_2:
|
||||
wrapper.eq(ScoreOrderDO::getHavePaid, OrderInfoEnum.PAY_STATUS_1.getValue())
|
||||
.eq(ScoreOrderDO::getHaveDelivered, OrderInfoEnum.STATUS_1.getValue())
|
||||
.eq(ScoreOrderDO::getHaveReceived, OrderInfoEnum.STATUS_1.getValue());
|
||||
break;
|
||||
default:
|
||||
}
|
||||
return selectPage(reqVO, wrapper);
|
||||
}
|
||||
|
||||
default List<ScoreOrderDO> selectList(ScoreOrderExportReqVO reqVO) {
|
||||
return selectList(new LambdaQueryWrapperX<ScoreOrderDO>()
|
||||
.eqIfPresent(ScoreOrderDO::getProductId, reqVO.getProductId())
|
||||
.eqIfPresent(ScoreOrderDO::getNumber, reqVO.getNumber())
|
||||
.eqIfPresent(ScoreOrderDO::getScore, reqVO.getScore())
|
||||
.eqIfPresent(ScoreOrderDO::getTotalScore, reqVO.getTotalScore())
|
||||
.eqIfPresent(ScoreOrderDO::getIp, reqVO.getIp())
|
||||
.eqIfPresent(ScoreOrderDO::getExpressNumber, reqVO.getExpressNumber())
|
||||
.eqIfPresent(ScoreOrderDO::getExpressCompany, reqVO.getExpressCompany())
|
||||
.likeIfPresent(ScoreOrderDO::getCustomerName, reqVO.getCustomerName())
|
||||
.eqIfPresent(ScoreOrderDO::getCustomerPhone, reqVO.getCustomerPhone())
|
||||
.eqIfPresent(ScoreOrderDO::getCustomerAddress, reqVO.getCustomerAddress())
|
||||
.eqIfPresent(ScoreOrderDO::getStatus, reqVO.getStatus())
|
||||
.eqIfPresent(ScoreOrderDO::getHavePaid, reqVO.getHavePaid())
|
||||
.eqIfPresent(ScoreOrderDO::getHaveDelivered, reqVO.getHaveDelivered())
|
||||
.eqIfPresent(ScoreOrderDO::getHaveReceived, reqVO.getHaveReceived())
|
||||
.betweenIfPresent(ScoreOrderDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(ScoreOrderDO::getId));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
package co.yixiang.yshop.module.score.dal.mysql.scoreproduct;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import co.yixiang.yshop.framework.common.pojo.PageResult;
|
||||
import co.yixiang.yshop.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import co.yixiang.yshop.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import co.yixiang.yshop.module.score.dal.dataobject.scoreproduct.ScoreProductDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import co.yixiang.yshop.module.score.controller.admin.scoreproduct.vo.*;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
/**
|
||||
* 积分产品 Mapper
|
||||
*
|
||||
* @author yshop
|
||||
*/
|
||||
@Mapper
|
||||
public interface ScoreProductMapper extends BaseMapperX<ScoreProductDO> {
|
||||
|
||||
default PageResult<ScoreProductDO> selectPage(ScoreProductPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<ScoreProductDO>()
|
||||
.eqIfPresent(ScoreProductDO::getTitle, reqVO.getTitle())
|
||||
.eqIfPresent(ScoreProductDO::getImage, reqVO.getImage())
|
||||
.eqIfPresent(ScoreProductDO::getImages, reqVO.getImages())
|
||||
.eqIfPresent(ScoreProductDO::getDesc, reqVO.getDesc())
|
||||
.eqIfPresent(ScoreProductDO::getScore, reqVO.getScore())
|
||||
.eqIfPresent(ScoreProductDO::getWeigh, reqVO.getWeigh())
|
||||
.eqIfPresent(ScoreProductDO::getStock, reqVO.getStock())
|
||||
.eqIfPresent(ScoreProductDO::getSales, reqVO.getSales())
|
||||
.betweenIfPresent(ScoreProductDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(ScoreProductDO::getId));
|
||||
}
|
||||
|
||||
default List<ScoreProductDO> selectList(ScoreProductExportReqVO reqVO) {
|
||||
return selectList(new LambdaQueryWrapperX<ScoreProductDO>()
|
||||
.eqIfPresent(ScoreProductDO::getTitle, reqVO.getTitle())
|
||||
.eqIfPresent(ScoreProductDO::getImage, reqVO.getImage())
|
||||
.eqIfPresent(ScoreProductDO::getImages, reqVO.getImages())
|
||||
.eqIfPresent(ScoreProductDO::getDesc, reqVO.getDesc())
|
||||
.eqIfPresent(ScoreProductDO::getScore, reqVO.getScore())
|
||||
.eqIfPresent(ScoreProductDO::getWeigh, reqVO.getWeigh())
|
||||
.eqIfPresent(ScoreProductDO::getStock, reqVO.getStock())
|
||||
.eqIfPresent(ScoreProductDO::getSales, reqVO.getSales())
|
||||
.betweenIfPresent(ScoreProductDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(ScoreProductDO::getId));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 普通商品 减库存 加销量
|
||||
* @param num
|
||||
* @param productId
|
||||
* @return
|
||||
*/
|
||||
@Update("update yshop_score_product set stock=stock-#{num}, sales=sales+#{num}" +
|
||||
" where id=#{productId} and stock >= #{num}")
|
||||
int decStockIncSales(@Param("num") Integer num, @Param("productId") Long productId);
|
||||
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package co.yixiang.yshop.module.score.service.scoreorder;
|
||||
|
||||
import co.yixiang.yshop.module.score.controller.app.order.param.AppScoreOrderParam;
|
||||
import co.yixiang.yshop.module.score.controller.app.order.vo.AppScoreOrderVO;
|
||||
import co.yixiang.yshop.module.score.dal.dataobject.scoreorder.ScoreOrderDO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 积分商城订单 Service 接口
|
||||
*
|
||||
* @author yshop
|
||||
*/
|
||||
public interface AppScoreOrderService extends IService<ScoreOrderDO> {
|
||||
|
||||
/**
|
||||
* 提交
|
||||
* @param uid
|
||||
* @param appScoreOrderParam
|
||||
*/
|
||||
void submit(Long uid,AppScoreOrderParam appScoreOrderParam);
|
||||
|
||||
/**
|
||||
* 订单列表
|
||||
* @param uid 用户id
|
||||
* @param type
|
||||
* @param page page
|
||||
* @param limit limit
|
||||
* @return list
|
||||
*/
|
||||
List<AppScoreOrderVO> orderList(Long uid, int type, int page, int limit);
|
||||
|
||||
/**
|
||||
* 订单详情
|
||||
* @param uid 用户id
|
||||
* @param id
|
||||
*/
|
||||
AppScoreOrderVO orderDetail(Long uid, Long id);
|
||||
|
||||
/**
|
||||
* 收货
|
||||
* @param uid
|
||||
* @param id
|
||||
*/
|
||||
void take(Long uid, Long id);
|
||||
|
||||
|
||||
}
|
||||
+255
@@ -0,0 +1,255 @@
|
||||
package co.yixiang.yshop.module.score.service.scoreorder;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import co.yixiang.yshop.framework.common.constant.ShopConstants;
|
||||
import co.yixiang.yshop.framework.common.enums.OrderInfoEnum;
|
||||
import co.yixiang.yshop.framework.common.enums.ShopCommonEnum;
|
||||
import co.yixiang.yshop.framework.common.exception.ErrorCode;
|
||||
import co.yixiang.yshop.framework.common.util.servlet.ServletUtils;
|
||||
import co.yixiang.yshop.framework.ip.core.utils.IPUtils;
|
||||
import co.yixiang.yshop.module.member.dal.dataobject.user.MemberUserDO;
|
||||
import co.yixiang.yshop.module.member.dal.dataobject.useraddress.UserAddressDO;
|
||||
import co.yixiang.yshop.module.member.enums.BillDetailEnum;
|
||||
import co.yixiang.yshop.module.member.service.user.MemberUserService;
|
||||
import co.yixiang.yshop.module.member.service.useraddress.AppUserAddressService;
|
||||
import co.yixiang.yshop.module.member.service.userbill.UserBillService;
|
||||
import co.yixiang.yshop.module.score.controller.app.order.param.AppScoreOrderParam;
|
||||
import co.yixiang.yshop.module.score.controller.app.order.vo.AppScoreOrderVO;
|
||||
import co.yixiang.yshop.module.score.convert.scoreorder.ScoreOrderConvert;
|
||||
import co.yixiang.yshop.module.score.dal.dataobject.scoreorder.ScoreOrderDO;
|
||||
import co.yixiang.yshop.module.score.dal.dataobject.scoreproduct.ScoreProductDO;
|
||||
import co.yixiang.yshop.module.score.dal.mysql.scoreorder.ScoreOrderMapper;
|
||||
import co.yixiang.yshop.module.score.dal.mysql.scoreproduct.ScoreProductMapper;
|
||||
import co.yixiang.yshop.module.score.enums.OrderStatusEnum;
|
||||
import co.yixiang.yshop.module.score.service.scoreproduct.AppScoreProductService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.redisson.api.RLock;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static co.yixiang.yshop.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static co.yixiang.yshop.module.member.enums.ErrorCodeConstants.USER_ADDRESS_NOT_EXISTS;
|
||||
import static co.yixiang.yshop.module.score.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 积分商城订单 Service 实现类
|
||||
*
|
||||
* @author yshop
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class AppScoreOrderServiceImpl extends ServiceImpl<ScoreOrderMapper, ScoreOrderDO> implements AppScoreOrderService {
|
||||
|
||||
@Resource
|
||||
private ScoreOrderMapper orderMapper;
|
||||
@Resource
|
||||
private ScoreProductMapper scoreProductMapper;
|
||||
@Resource
|
||||
private AppScoreProductService appScoreProductService;
|
||||
@Resource
|
||||
private MemberUserService userService;
|
||||
@Resource
|
||||
private RedissonClient redissonClient;
|
||||
@Resource
|
||||
private UserBillService billService;
|
||||
@Resource
|
||||
private AppUserAddressService appUserAddressService;
|
||||
|
||||
private static final String STOCK_LOCK_KEY = "score:order:stock:lock";
|
||||
|
||||
|
||||
/**
|
||||
* 提交
|
||||
* @param uid
|
||||
* @param appScoreOrderParam
|
||||
*/
|
||||
@Override
|
||||
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
||||
public void submit(Long uid,AppScoreOrderParam appScoreOrderParam) {
|
||||
ScoreProductDO scoreProductDO = appScoreProductService.getById(appScoreOrderParam.getProductId());
|
||||
if(scoreProductDO == null){
|
||||
throw exception(PRODUCT_NOT_EXISTS);
|
||||
}
|
||||
UserAddressDO userAddressDO = appUserAddressService.getById(appScoreOrderParam.getAddressId());
|
||||
if(userAddressDO == null){
|
||||
throw exception(USER_ADDRESS_NOT_EXISTS);
|
||||
}
|
||||
MemberUserDO memberUserDO = userService.getById(uid);
|
||||
if(scoreProductDO.getStock() <= 0){
|
||||
throw exception(PRODUCT_NOT_STOCK);
|
||||
}
|
||||
if(NumberUtil.compare(memberUserDO.getIntegral().intValue(),scoreProductDO.getScore()) < 0){
|
||||
throw exception(SCORE_NOT);
|
||||
}
|
||||
|
||||
//生成分布式唯一值
|
||||
String orderSn = IdUtil.getSnowflake(0, 0).nextIdStr();
|
||||
ScoreOrderDO scoreOrderDO = ScoreOrderDO.builder()
|
||||
.havePaid(ShopCommonEnum.IS_STATUS_1.getValue())
|
||||
.customerAddress(userAddressDO.getAddress() + userAddressDO.getDetail())
|
||||
.customerName(userAddressDO.getRealName())
|
||||
.customerPhone(userAddressDO.getPhone())
|
||||
.ip(ServletUtils.getClientIP())
|
||||
.orderId(orderSn)
|
||||
.productId(scoreProductDO.getId())
|
||||
.number(Integer.valueOf(appScoreOrderParam.getNum()))
|
||||
.score(scoreProductDO.getScore())
|
||||
.totalScore(scoreProductDO.getScore())
|
||||
.uid(uid)
|
||||
.build();
|
||||
//保存
|
||||
this.save(scoreOrderDO);
|
||||
|
||||
//减去积分
|
||||
userService.decScore(uid,scoreOrderDO.getScore());
|
||||
|
||||
this.deStockIncSale(scoreProductDO.getId(),Integer.valueOf(appScoreOrderParam.getNum()));
|
||||
|
||||
//增加流水
|
||||
billService.expend(uid, "积分兑换",
|
||||
BillDetailEnum.CATEGORY_2.getValue(),
|
||||
BillDetailEnum.TYPE_3.getValue(),
|
||||
scoreProductDO.getScore().doubleValue(), memberUserDO.getIntegral().doubleValue(),
|
||||
scoreProductDO.getScore() + "积分兑换商品");
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 订单列表
|
||||
*
|
||||
* @param uid 用户id
|
||||
* @param type OrderStatusEnum
|
||||
* @param page page
|
||||
* @param limit limit
|
||||
* @return list
|
||||
*/
|
||||
@Override
|
||||
public List<AppScoreOrderVO> orderList(Long uid, int type, int page, int limit) {
|
||||
LambdaQueryWrapper<ScoreOrderDO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ScoreOrderDO::getUid, uid);
|
||||
wrapper.orderByDesc(ScoreOrderDO::getId);
|
||||
switch (OrderStatusEnum.toType(type)) {
|
||||
case STATUS__1:
|
||||
break;
|
||||
//待发货
|
||||
case STATUS_0:
|
||||
wrapper.eq(ScoreOrderDO::getHavePaid, OrderInfoEnum.PAY_STATUS_1.getValue())
|
||||
.eq(ScoreOrderDO::getHaveDelivered, OrderInfoEnum.STATUS_0.getValue())
|
||||
.eq(ScoreOrderDO::getHaveReceived, OrderInfoEnum.STATUS_0.getValue());
|
||||
break;
|
||||
//待收货
|
||||
case STATUS_1:
|
||||
wrapper.eq(ScoreOrderDO::getHavePaid, OrderInfoEnum.PAY_STATUS_1.getValue())
|
||||
.eq(ScoreOrderDO::getHaveDelivered, OrderInfoEnum.STATUS_1.getValue())
|
||||
.eq(ScoreOrderDO::getHaveReceived, OrderInfoEnum.STATUS_0.getValue());
|
||||
break;
|
||||
//已完成
|
||||
case STATUS_2:
|
||||
wrapper.eq(ScoreOrderDO::getHavePaid, OrderInfoEnum.PAY_STATUS_1.getValue())
|
||||
//.eq(ScoreOrderDO::getHaveDelivered, OrderInfoEnum.STATUS_1.getValue())
|
||||
.eq(ScoreOrderDO::getHaveReceived, OrderInfoEnum.STATUS_1.getValue());
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
Page<ScoreOrderDO> pageModel = new Page<>(page, limit);
|
||||
IPage<ScoreOrderDO> pageList = orderMapper.selectPage(pageModel, wrapper);
|
||||
List<AppScoreOrderVO> list = ScoreOrderConvert.INSTANCE.convertList01(pageList.getRecords());
|
||||
|
||||
return list.stream().map(this::handleOrder).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单详情
|
||||
* @param uid 用户id
|
||||
* @param id
|
||||
*/
|
||||
@Override
|
||||
public AppScoreOrderVO orderDetail(Long uid, Long id) {
|
||||
LambdaQueryWrapper<ScoreOrderDO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ScoreOrderDO::getUid, uid).eq(ScoreOrderDO::getId,id);
|
||||
ScoreOrderDO scoreOrderDO = this.getOne(wrapper);
|
||||
|
||||
AppScoreOrderVO appScoreOrderVO = ScoreOrderConvert.INSTANCE.convert01(scoreOrderDO);
|
||||
return this.handleOrder(appScoreOrderVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 收货
|
||||
* @param uid
|
||||
* @param id
|
||||
*/
|
||||
@Override
|
||||
public void take(Long uid, Long id) {
|
||||
LambdaQueryWrapper<ScoreOrderDO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ScoreOrderDO::getUid, uid).eq(ScoreOrderDO::getId,id);
|
||||
ScoreOrderDO scoreOrderDO = this.getOne(wrapper);
|
||||
if(scoreOrderDO == null){
|
||||
throw exception(ORDER_NOT_EXISTS);
|
||||
}
|
||||
scoreOrderDO.setHaveReceived(ShopCommonEnum.DEFAULT_1.getValue());
|
||||
this.updateById(scoreOrderDO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理订单
|
||||
* @param order
|
||||
* @return
|
||||
*/
|
||||
private AppScoreOrderVO handleOrder(AppScoreOrderVO order) {
|
||||
order.setProduct(appScoreProductService.getDetail(order.getProductId()));
|
||||
if (OrderInfoEnum.PAY_STATUS_1.getValue().equals(order.getHavePaid())
|
||||
&& OrderInfoEnum.STATUS_0.getValue().equals(order.getHaveDelivered())
|
||||
&& OrderInfoEnum.STATUS_0.getValue().equals(order.getHaveReceived())) {
|
||||
order.setStatusText("待发货");
|
||||
} else if (OrderInfoEnum.PAY_STATUS_1.getValue().equals(order.getHavePaid())
|
||||
&& OrderInfoEnum.STATUS_1.getValue().equals(order.getHaveDelivered())
|
||||
&& OrderInfoEnum.STATUS_0.getValue().equals(order.getHaveReceived())) {
|
||||
order.setStatusText("待收货");
|
||||
} else if (OrderInfoEnum.PAY_STATUS_1.getValue().equals(order.getHavePaid())
|
||||
&& OrderInfoEnum.STATUS_1.getValue().equals(order.getHaveReceived())) {
|
||||
order.setStatusText("已完成");
|
||||
}
|
||||
return order;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 减库存增加销量
|
||||
*
|
||||
* @param productId 商品id
|
||||
* @param number 商品数量
|
||||
*/
|
||||
private void deStockIncSale(Long productId, Integer number) {
|
||||
|
||||
//对库存加锁
|
||||
RLock lock = redissonClient.getLock(STOCK_LOCK_KEY);
|
||||
if (lock.tryLock()) {
|
||||
try {
|
||||
scoreProductMapper.decStockIncSales(number,productId);
|
||||
}catch (Exception ex) {
|
||||
log.error("[deStockIncSale][执行异常]", ex);
|
||||
throw exception(new ErrorCode(999999,ex.getMessage()));
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
package co.yixiang.yshop.module.score.service.scoreorder;
|
||||
|
||||
import java.util.*;
|
||||
import jakarta.validation.*;
|
||||
import co.yixiang.yshop.module.score.controller.admin.scoreorder.vo.*;
|
||||
import co.yixiang.yshop.module.score.dal.dataobject.scoreorder.ScoreOrderDO;
|
||||
import co.yixiang.yshop.framework.common.pojo.PageResult;
|
||||
|
||||
/**
|
||||
* 积分商城订单 Service 接口
|
||||
*
|
||||
* @author yshop
|
||||
*/
|
||||
public interface ScoreOrderService {
|
||||
|
||||
/**
|
||||
* 创建积分商城订单
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createOrder(@Valid ScoreOrderCreateReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新积分商城订单
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateOrder(@Valid ScoreOrderUpdateReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除积分商城订单
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteOrder(Long id);
|
||||
|
||||
/**
|
||||
* 收货
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void takeOrder(Long id);
|
||||
|
||||
/**
|
||||
* 获得积分商城订单
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 积分商城订单
|
||||
*/
|
||||
ScoreOrderRespVO getOrder(Long id);
|
||||
|
||||
/**
|
||||
* 获得积分商城订单列表
|
||||
*
|
||||
* @param ids 编号
|
||||
* @return 积分商城订单列表
|
||||
*/
|
||||
List<ScoreOrderDO> getOrderList(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得积分商城订单分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 积分商城订单分页
|
||||
*/
|
||||
PageResult<ScoreOrderRespVO> getOrderPage(ScoreOrderPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得积分商城订单列表, 用于 Excel 导出
|
||||
*
|
||||
* @param exportReqVO 查询条件
|
||||
* @return 积分商城订单列表
|
||||
*/
|
||||
List<ScoreOrderDO> getOrderList(ScoreOrderExportReqVO exportReqVO);
|
||||
|
||||
}
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
package co.yixiang.yshop.module.score.service.scoreorder;
|
||||
|
||||
import co.yixiang.yshop.framework.common.enums.ShopCommonEnum;
|
||||
import co.yixiang.yshop.module.member.controller.admin.user.vo.UserRespVO;
|
||||
import co.yixiang.yshop.module.member.convert.user.UserConvert;
|
||||
import co.yixiang.yshop.module.member.dal.dataobject.user.MemberUserDO;
|
||||
import co.yixiang.yshop.module.member.dal.mysql.user.MemberUserMapper;
|
||||
import co.yixiang.yshop.module.score.convert.scoreproduct.ScoreProductConvert;
|
||||
import co.yixiang.yshop.module.score.dal.dataobject.scoreproduct.ScoreProductDO;
|
||||
import co.yixiang.yshop.module.score.dal.mysql.scoreproduct.ScoreProductMapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.*;
|
||||
import co.yixiang.yshop.module.score.controller.admin.scoreorder.vo.*;
|
||||
import co.yixiang.yshop.module.score.dal.dataobject.scoreorder.ScoreOrderDO;
|
||||
import co.yixiang.yshop.framework.common.pojo.PageResult;
|
||||
|
||||
import co.yixiang.yshop.module.score.convert.scoreorder.ScoreOrderConvert;
|
||||
import co.yixiang.yshop.module.score.dal.mysql.scoreorder.ScoreOrderMapper;
|
||||
|
||||
import static co.yixiang.yshop.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static co.yixiang.yshop.module.score.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 积分商城订单 Service 实现类
|
||||
*
|
||||
* @author yshop
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class ScoreOrderServiceImpl implements ScoreOrderService {
|
||||
|
||||
@Resource
|
||||
private ScoreOrderMapper orderMapper;
|
||||
@Resource
|
||||
private ScoreProductMapper scoreProductMapper;
|
||||
@Resource
|
||||
private MemberUserMapper memberUserMapper;
|
||||
|
||||
@Override
|
||||
public Long createOrder(ScoreOrderCreateReqVO createReqVO) {
|
||||
// 插入
|
||||
ScoreOrderDO order = ScoreOrderConvert.INSTANCE.convert(createReqVO);
|
||||
orderMapper.insert(order);
|
||||
// 返回
|
||||
return order.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateOrder(ScoreOrderUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateOrderExists(updateReqVO.getId());
|
||||
// 更新
|
||||
ScoreOrderDO updateObj = ScoreOrderConvert.INSTANCE.convert(updateReqVO);
|
||||
updateObj.setHaveDelivered(ShopCommonEnum.DEFAULT_1.getValue());
|
||||
orderMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteOrder(Long id) {
|
||||
// 校验存在
|
||||
validateOrderExists(id);
|
||||
// 删除
|
||||
orderMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void takeOrder(Long id) {
|
||||
// 校验存在
|
||||
ScoreOrderDO scoreOrderDO = orderMapper.selectById(id);
|
||||
if (scoreOrderDO == null) {
|
||||
throw exception(ORDER_NOT_EXISTS);
|
||||
}
|
||||
scoreOrderDO.setHaveReceived(ShopCommonEnum.DEFAULT_1.getValue());
|
||||
orderMapper.updateById(scoreOrderDO);
|
||||
|
||||
}
|
||||
|
||||
private void validateOrderExists(Long id) {
|
||||
if (orderMapper.selectById(id) == null) {
|
||||
throw exception(ORDER_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScoreOrderRespVO getOrder(Long id) {
|
||||
ScoreOrderDO scoreOrderDO = orderMapper.selectById(id);
|
||||
ScoreOrderRespVO scoreOrderRespVO = ScoreOrderConvert.INSTANCE.convert(scoreOrderDO);
|
||||
ScoreProductDO scoreProductDO = scoreProductMapper.selectById(scoreOrderRespVO.getProductId());
|
||||
scoreOrderRespVO.setScoreProductRespVO(ScoreProductConvert.INSTANCE.convert(scoreProductDO));
|
||||
MemberUserDO memberUserDO = memberUserMapper.selectById(scoreOrderRespVO.getUid());
|
||||
UserRespVO userRespVO = UserConvert.INSTANCE.convert4(memberUserDO);
|
||||
scoreOrderRespVO.setUserRespVO(userRespVO);
|
||||
return scoreOrderRespVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ScoreOrderDO> getOrderList(Collection<Long> ids) {
|
||||
return orderMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ScoreOrderRespVO> getOrderPage(ScoreOrderPageReqVO pageReqVO) {
|
||||
PageResult<ScoreOrderDO> pageResult = orderMapper.selectPage(pageReqVO);
|
||||
PageResult<ScoreOrderRespVO> scoreOrderRespVOPageResult = ScoreOrderConvert.INSTANCE.convertPage(pageResult);
|
||||
for (ScoreOrderRespVO scoreOrderRespVO : scoreOrderRespVOPageResult.getList()) {
|
||||
ScoreProductDO scoreProductDO = scoreProductMapper.selectById(scoreOrderRespVO.getProductId());
|
||||
scoreOrderRespVO.setScoreProductRespVO(ScoreProductConvert.INSTANCE.convert(scoreProductDO));
|
||||
MemberUserDO memberUserDO = memberUserMapper.selectById(scoreOrderRespVO.getUid());
|
||||
UserRespVO userRespVO = UserConvert.INSTANCE.convert4(memberUserDO);
|
||||
scoreOrderRespVO.setUserRespVO(userRespVO);
|
||||
}
|
||||
return scoreOrderRespVOPageResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ScoreOrderDO> getOrderList(ScoreOrderExportReqVO exportReqVO) {
|
||||
return orderMapper.selectList(exportReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package co.yixiang.yshop.module.score.service.scoreproduct;
|
||||
|
||||
import co.yixiang.yshop.module.score.controller.app.product.vo.AppScoreProductVO;
|
||||
import co.yixiang.yshop.module.score.dal.dataobject.scoreproduct.ScoreProductDO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 积分产品 Service 接口
|
||||
*
|
||||
* @author yshop
|
||||
*/
|
||||
public interface AppScoreProductService extends IService<ScoreProductDO> {
|
||||
|
||||
/**
|
||||
* 列表
|
||||
* @param page page
|
||||
* @param limit limit
|
||||
* @return list
|
||||
*/
|
||||
List<AppScoreProductVO> getList(int page, int limit);
|
||||
|
||||
/**
|
||||
* 详情
|
||||
* @param id 产品ID
|
||||
* @return list
|
||||
*/
|
||||
AppScoreProductVO getDetail(Long id);
|
||||
|
||||
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
package co.yixiang.yshop.module.score.service.scoreproduct;
|
||||
|
||||
import co.yixiang.yshop.module.score.controller.app.product.vo.AppScoreProductVO;
|
||||
import co.yixiang.yshop.module.score.convert.scoreproduct.ScoreProductConvert;
|
||||
import co.yixiang.yshop.module.score.dal.dataobject.scoreproduct.ScoreProductDO;
|
||||
import co.yixiang.yshop.module.score.dal.mysql.scoreproduct.ScoreProductMapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 积分产品 Service 实现类
|
||||
*
|
||||
* @author yshop
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class AppScoreProductServiceImpl extends ServiceImpl<ScoreProductMapper,ScoreProductDO> implements AppScoreProductService {
|
||||
|
||||
@Resource
|
||||
private ScoreProductMapper productMapper;
|
||||
|
||||
|
||||
/**
|
||||
* 订单列表
|
||||
* @param page page
|
||||
* @param limit limit
|
||||
* @return list
|
||||
*/
|
||||
@Override
|
||||
public List<AppScoreProductVO> getList(int page, int limit) {
|
||||
LambdaQueryWrapper<ScoreProductDO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.orderByDesc(ScoreProductDO::getWeigh);
|
||||
|
||||
|
||||
Page<ScoreProductDO> pageModel = new Page<>(page, limit);
|
||||
IPage<ScoreProductDO> pageList = productMapper.selectPage(pageModel, wrapper);
|
||||
List<AppScoreProductVO> list = ScoreProductConvert.INSTANCE.convertList01(pageList.getRecords());
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 详情
|
||||
* @param id 产品ID
|
||||
* @return list
|
||||
*/
|
||||
@Override
|
||||
public AppScoreProductVO getDetail(Long id) {
|
||||
ScoreProductDO scoreProductDO = this.getById(id);
|
||||
return ScoreProductConvert.INSTANCE.convert01(scoreProductDO);
|
||||
}
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
package co.yixiang.yshop.module.score.service.scoreproduct;
|
||||
|
||||
import java.util.*;
|
||||
import jakarta.validation.*;
|
||||
import co.yixiang.yshop.module.score.controller.admin.scoreproduct.vo.*;
|
||||
import co.yixiang.yshop.module.score.dal.dataobject.scoreproduct.ScoreProductDO;
|
||||
import co.yixiang.yshop.framework.common.pojo.PageResult;
|
||||
|
||||
/**
|
||||
* 积分产品 Service 接口
|
||||
*
|
||||
* @author yshop
|
||||
*/
|
||||
public interface ScoreProductService {
|
||||
|
||||
/**
|
||||
* 创建积分产品
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createProduct(@Valid ScoreProductCreateReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新积分产品
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateProduct(@Valid ScoreProductUpdateReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除积分产品
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteProduct(Long id);
|
||||
|
||||
/**
|
||||
* 获得积分产品
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 积分产品
|
||||
*/
|
||||
ScoreProductDO getProduct(Long id);
|
||||
|
||||
/**
|
||||
* 获得积分产品列表
|
||||
*
|
||||
* @param ids 编号
|
||||
* @return 积分产品列表
|
||||
*/
|
||||
List<ScoreProductDO> getProductList(Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得积分产品分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 积分产品分页
|
||||
*/
|
||||
PageResult<ScoreProductDO> getProductPage(ScoreProductPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得积分产品列表, 用于 Excel 导出
|
||||
*
|
||||
* @param exportReqVO 查询条件
|
||||
* @return 积分产品列表
|
||||
*/
|
||||
List<ScoreProductDO> getProductList(ScoreProductExportReqVO exportReqVO);
|
||||
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
package co.yixiang.yshop.module.score.service.scoreproduct;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.*;
|
||||
import co.yixiang.yshop.module.score.controller.admin.scoreproduct.vo.*;
|
||||
import co.yixiang.yshop.module.score.dal.dataobject.scoreproduct.ScoreProductDO;
|
||||
import co.yixiang.yshop.framework.common.pojo.PageResult;
|
||||
|
||||
import co.yixiang.yshop.module.score.convert.scoreproduct.ScoreProductConvert;
|
||||
import co.yixiang.yshop.module.score.dal.mysql.scoreproduct.ScoreProductMapper;
|
||||
|
||||
import static co.yixiang.yshop.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static co.yixiang.yshop.module.score.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 积分产品 Service 实现类
|
||||
*
|
||||
* @author yshop
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class ScoreProductServiceImpl implements ScoreProductService {
|
||||
|
||||
@Resource
|
||||
private ScoreProductMapper productMapper;
|
||||
|
||||
@Override
|
||||
public Long createProduct(ScoreProductCreateReqVO createReqVO) {
|
||||
// 插入
|
||||
ScoreProductDO product = ScoreProductConvert.INSTANCE.convert(createReqVO);
|
||||
productMapper.insert(product);
|
||||
// 返回
|
||||
return product.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProduct(ScoreProductUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateProductExists(updateReqVO.getId());
|
||||
// 更新
|
||||
ScoreProductDO updateObj = ScoreProductConvert.INSTANCE.convert(updateReqVO);
|
||||
productMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteProduct(Long id) {
|
||||
// 校验存在
|
||||
validateProductExists(id);
|
||||
// 删除
|
||||
productMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateProductExists(Long id) {
|
||||
if (productMapper.selectById(id) == null) {
|
||||
throw exception(PRODUCT_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScoreProductDO getProduct(Long id) {
|
||||
return productMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ScoreProductDO> getProductList(Collection<Long> ids) {
|
||||
return productMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ScoreProductDO> getProductPage(ScoreProductPageReqVO pageReqVO) {
|
||||
return productMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ScoreProductDO> getProductList(ScoreProductExportReqVO exportReqVO) {
|
||||
return productMapper.selectList(exportReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
<?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="co.yixiang.yshop.module.score.dal.mysql.scoreorder.ScoreOrderMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.yixiang.co/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
</mapper>
|
||||
Reference in new issue
Block a user