请设计并实现一个完整的商品交易系统,具体需求如下
1-系统分为用户和商家两个模块,用户从商家库存里面购买商品,通过用户账户的预存现金账户付款。
2-购买商品流程为,用户下单购买某个的商品,提供商品的sku和数量,相应的用户预存账户里面减掉对应的现金(quantity * price),商家账户里加上对应的现金,并且库存中减掉对应的商品数量
- 创建订单
curl --location --request POST 'http://127.0.0.1:8080/apcapital/mall/v1/order' \
--header 'Content-Type: application/json' \
--data-raw '{
"buyer_id": 1,
"seller_id": 2,
"order_type": "normal",
"remark": "订单备注",
"order_details": [
{
"spu_id": 1,
"sku_id": 1,
"quantity": 2,
"total_price": 100.00,
"discount_price": 90.00,
"pay_price": 90.00
}
]
}'- 提交订单
curl --location --request POST 'http://127.0.0.1:8080/apcapital/mall/v1/order/actions/submit' \
--header 'Content-Type: application/json' \
--data-raw '{
"order_id": "1934632845128577026"
}'3-用户可以通过REST API的形式,向自己的预存账户里面充值,只支持一种货币即可。
curl --location --request POST 'http://127.0.0.1:8080/apcapital/mall/v1/user_account/1/actions/recharge' \
--header 'Content-Type: application/json' \
--data-raw '{
"amount": 1000
}'4-商家可以通过REST API的形式,向库存中添加商品数量。
curl --location --request POST 'http://127.0.0.1:8080/apcapital/mall/v1/sku/1/actions/add_stock' \
--header 'User-Agent: Apifox/1.0.0 (https://apifox.com)' \
--header 'Content-Type: application/json' \
--data-raw '{
"seller_id": 2,
"stock": 10
}'5-商家方有定时job每天进行结算,对库存中卖出的商品价值和商家账户的余额进行匹配
- 手动触发方式
curl --location --request GET 'http://127.0.0.1:8080/apcapital/mall/v1/user_account/actions/check_daily' \要求
1-系统要求使用Java作为开发语言,基于Spring,Spring Boot和Spring Cloud的相关技术栈。
2-系统对外API基于REST API来设计,follow良好的REST API设计规范
3-系统要求是一个完成能本地运行的Spring Boot应用程序
4-核心代码单元测试覆盖率达80%
5-代码具有良好的可配置,可扩展性。
6-如果有DDD开发设计经验,可以根据DDD开发来设计,合理划分Boundary Context和Aggregate Root(Better to Have)