-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
280 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
server/src/main/java/com/cloudshare/server/order/controller/ProductController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.cloudshare.server.order.controller; | ||
|
||
import com.cloudshare.server.order.model.Product; | ||
import com.cloudshare.server.order.service.ProductService; | ||
import com.cloudshare.web.response.Response; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @author novo | ||
* @since 2023/11/6 | ||
*/ | ||
@RestController | ||
@RequestMapping("/product") | ||
public class ProductController { | ||
|
||
private final ProductService productService; | ||
|
||
public ProductController(ProductService productService) { | ||
this.productService = productService; | ||
} | ||
|
||
@GetMapping("/list") | ||
public Response<List<Product>> list() { | ||
List<Product> resp = productService.list(); | ||
return Response.success(resp); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
server/src/main/java/com/cloudshare/server/order/enums/PayStateEnum.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.cloudshare.server.order.enums; | ||
|
||
/** | ||
* @author novo | ||
* @since 2023-09-20 | ||
*/ | ||
public enum PayStateEnum { | ||
|
||
NEW, | ||
|
||
PAID, | ||
|
||
CANCEL, | ||
|
||
; | ||
} |
12 changes: 12 additions & 0 deletions
12
server/src/main/java/com/cloudshare/server/order/enums/PayType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.cloudshare.server.order.enums; | ||
|
||
public enum PayType { | ||
|
||
WECHAT, | ||
|
||
ALI_PAY_PC, | ||
|
||
BANK, | ||
|
||
; | ||
} |
91 changes: 91 additions & 0 deletions
91
server/src/main/java/com/cloudshare/server/order/model/Order.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package com.cloudshare.server.order.model; | ||
|
||
import com.cloudshare.server.common.BaseModel; | ||
import com.cloudshare.server.order.enums.PayStateEnum; | ||
import com.cloudshare.server.order.enums.PayType; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import org.hibernate.annotations.Comment; | ||
|
||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import java.math.BigDecimal; | ||
import java.time.LocalDateTime; | ||
|
||
/** | ||
* @author novo | ||
* @since 2023-09-19 | ||
*/ | ||
@Data | ||
@EqualsAndHashCode(callSuper = true) | ||
@Entity(name = "`order`") | ||
public class Order extends BaseModel { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
private Long orderId; | ||
|
||
@Comment("商品标题") | ||
private String productTitle; | ||
|
||
@Comment("商品单价") | ||
private BigDecimal productAmount; | ||
|
||
@Comment("商品快照") | ||
private String productSnapshot; | ||
|
||
@Comment("购买数量") | ||
private Integer buyNum; | ||
|
||
@Comment("订单唯⼀标识") | ||
private String outTradeNo; | ||
|
||
@Comment("NEW未支付订单,PAY已经支付订单,CANCEL超时取消订单") | ||
private PayStateEnum state; | ||
|
||
@Comment("订单完成时间") | ||
private LocalDateTime payTime; | ||
|
||
@Comment("订单总⾦额") | ||
private BigDecimal totalAmount; | ||
|
||
@Comment("订单实际⽀付价格") | ||
private BigDecimal actualPayAmount; | ||
|
||
@Comment("支付类型,微信-银行卡-支付宝") | ||
private PayType payType; | ||
|
||
@Comment("账户名") | ||
private String username; | ||
|
||
private Long accountNo; | ||
|
||
/** | ||
* 发票类型:0->不开发票;1->电子发票;2->纸质发票 | ||
*/ | ||
private String billType; | ||
|
||
/** | ||
* 发票抬头 | ||
*/ | ||
private String billHeader; | ||
|
||
/** | ||
* 发票内容 | ||
*/ | ||
private String billContent; | ||
|
||
/** | ||
* 发票收票人电话 | ||
*/ | ||
private String billReceiverPhone; | ||
|
||
/** | ||
* 发票收票人邮箱 | ||
*/ | ||
private String billReceiverEmail; | ||
} |
41 changes: 41 additions & 0 deletions
41
server/src/main/java/com/cloudshare/server/order/model/Product.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.cloudshare.server.order.model; | ||
|
||
import com.cloudshare.server.common.BaseModel; | ||
import com.cloudshare.server.user.enums.PlanLevel; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import org.hibernate.annotations.Comment; | ||
|
||
import javax.persistence.Entity; | ||
import javax.persistence.EnumType; | ||
import javax.persistence.Enumerated; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import java.math.BigDecimal; | ||
|
||
/** | ||
* @author novo | ||
* @since 2023/11/6 | ||
*/ | ||
@Data | ||
@EqualsAndHashCode(callSuper = true) | ||
@Entity(name = "product") | ||
public class Product extends BaseModel { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@Comment("商品标题") | ||
private String title; | ||
|
||
@Comment("商品详情") | ||
private String detail; | ||
|
||
@Comment("商品价格") | ||
private BigDecimal amount; | ||
|
||
@Enumerated(value = EnumType.STRING) | ||
private PlanLevel plan; | ||
} |
11 changes: 11 additions & 0 deletions
11
server/src/main/java/com/cloudshare/server/order/repository/ProductRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.cloudshare.server.order.repository; | ||
|
||
import com.cloudshare.server.order.model.Product; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
/** | ||
* @author novo | ||
* @since 2023/11/6 | ||
*/ | ||
public interface ProductRepository extends JpaRepository<Product, Long> { | ||
} |
14 changes: 14 additions & 0 deletions
14
server/src/main/java/com/cloudshare/server/order/service/ProductService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.cloudshare.server.order.service; | ||
|
||
import com.cloudshare.server.order.model.Product; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @author novo | ||
* @since 2023/11/6 | ||
*/ | ||
public interface ProductService { | ||
|
||
List<Product> list(); | ||
} |
27 changes: 27 additions & 0 deletions
27
server/src/main/java/com/cloudshare/server/order/service/impl/ProductServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.cloudshare.server.order.service.impl; | ||
|
||
import com.cloudshare.server.order.model.Product; | ||
import com.cloudshare.server.order.repository.ProductRepository; | ||
import com.cloudshare.server.order.service.ProductService; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @author novo | ||
* @since 2023/11/6 | ||
*/ | ||
@Service | ||
public class ProductServiceImpl implements ProductService { | ||
|
||
private final ProductRepository productRepository; | ||
|
||
public ProductServiceImpl(ProductRepository productRepository) { | ||
this.productRepository = productRepository; | ||
} | ||
|
||
@Override | ||
public List<Product> list() { | ||
return productRepository.findAll(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters