diff --git a/.editorconfig b/.editorconfig
index d1989d440..abd071783 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -1,11 +1,10 @@
root=true
-[*.java]
+[*.{adoc,bat,groovy,html,java,js,jsp,kt,kts,md,properties,py,rb,sh,sql,svg,txt,xml,xsd}]
+charset = utf-8
+
+[*.{groovy,java,kt,kts,xml,xsd}]
indent_style = space
indent_size = 4
continuation_indent_size = 8
-
-[*.xml]
-indent_style = space
-indent_size = 4
-continuation_indent_size = 4
+end_of_line = lf
diff --git a/order/order-application/pom.xml b/order/order-application/pom.xml
index 42d90ee09..2f80d4ffb 100644
--- a/order/order-application/pom.xml
+++ b/order/order-application/pom.xml
@@ -15,89 +15,16 @@
cn.iocoder.mall
- common-framework
+ order-rest
1.0-SNAPSHOT
cn.iocoder.mall
- mall-spring-boot
- 1.0-SNAPSHOT
-
-
- cn.iocoder.mall
- order-service-impl
- 1.0-SNAPSHOT
-
-
- cn.iocoder.mall
- system-sdk
- 1.0-SNAPSHOT
-
-
- cn.iocoder.mall
- user-sdk
+ order-rpc
1.0-SNAPSHOT
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
-
- io.springfox
- springfox-swagger2
-
-
- com.github.xiaoymin
- swagger-bootstrap-ui
-
-
-
-
- com.alibaba.cloud
- spring-cloud-starter-alibaba-sentinel
-
-
-
-
- de.codecentric
- spring-boot-admin-starter-client
-
-
-
- org.springframework.boot
- spring-boot-starter-actuator
-
-
-
- io.micrometer
- micrometer-registry-prometheus
-
-
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
-
diff --git a/order/order-application/src/main/java/cn/iocoder/mall/order/application/OrderApplication.java b/order/order-application/src/main/java/cn/iocoder/mall/order/application/OrderApplication.java
index 6928ec3ff..ed0d910a0 100644
--- a/order/order-application/src/main/java/cn/iocoder/mall/order/application/OrderApplication.java
+++ b/order/order-application/src/main/java/cn/iocoder/mall/order/application/OrderApplication.java
@@ -3,24 +3,35 @@ package cn.iocoder.mall.order.application;
import org.apache.catalina.connector.Connector;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.context.config.ConfigFileApplicationListener;
import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
import org.springframework.context.annotation.Bean;
+/**
+ * @author xiaofeng
+ */
@SpringBootApplication(scanBasePackages = {"cn.iocoder.mall.order"})
public class OrderApplication {
- public static void main(String[] args) {
- SpringApplication.run(OrderApplication.class, args);
- }
+ /**
+ * 设置需要读取的配置文件的名字。 基于 {@link org.springframework.boot.context.config.ConfigFileApplicationListener#CONFIG_NAME_PROPERTY}
+ * 实现。
+ */
+ private static final String CONFIG_NAME_VALUE = "biz,rest,rpc,application";
+ public static void main(String[] args) {
+ // 设置环境变量
+ System.setProperty(ConfigFileApplicationListener.CONFIG_NAME_PROPERTY, CONFIG_NAME_VALUE);
+ SpringApplication.run(OrderApplication.class, args);
+ }
/**
- * 解决异常信息:
- * java.lang.IllegalArgumentException:
- * Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986
+ * 解决异常信息: java.lang.IllegalArgumentException: Invalid character found in the request target.
+ * The valid characters are defined in RFC 7230 and RFC 3986
+ *
* @return
*/
@Bean
@@ -36,5 +47,4 @@ public class OrderApplication {
}
-
-}
\ No newline at end of file
+}
diff --git a/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/admins/AdminOrderReturnController.java b/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/admins/AdminOrderReturnController.java
deleted file mode 100644
index d7591408c..000000000
--- a/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/admins/AdminOrderReturnController.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package cn.iocoder.mall.order.application.controller.admins;
-
-import cn.iocoder.common.framework.util.HttpUtil;
-import cn.iocoder.common.framework.vo.CommonResult;
-import cn.iocoder.mall.order.api.OrderReturnService;
-import cn.iocoder.mall.order.api.bo.OrderReturnListBO;
-import cn.iocoder.mall.order.api.dto.OrderReturnQueryDTO;
-import cn.iocoder.mall.order.application.convert.OrderReturnConvert;
-import cn.iocoder.mall.order.application.po.admin.OrderReturnQueryPO;
-import io.swagger.annotations.Api;
-import org.apache.dubbo.config.annotation.Reference;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-import javax.servlet.http.HttpServletRequest;
-
-/**
- * 订单退货
- *
- * @author Sin
- * @time 2019-05-06 21:31
- */
-@RestController
-@RequestMapping("admins/order_return")
-@Api("订单退货(admins api)")
-public class AdminOrderReturnController {
-
- @Reference(validation = "true", version = "${dubbo.provider.OrderReturnService.version}")
- private OrderReturnService orderReturnService;
-
- @GetMapping("list")
- public CommonResult list(@Validated OrderReturnQueryPO queryPO) {
- OrderReturnQueryDTO queryDTO = OrderReturnConvert.INSTANCE.convert(queryPO);
- return orderReturnService.orderReturnList(queryDTO);
- }
-
- @PostMapping("agree")
- public CommonResult agree(@RequestParam("id") Integer id) {
- return orderReturnService.orderReturnAgree(id);
- }
-
- @PostMapping("refuse")
- public CommonResult refuse(@RequestParam("id") Integer id) {
- return orderReturnService.orderReturnRefuse(id);
- }
-
- @PostMapping("confirm_receipt")
- public CommonResult confirmReceipt(@RequestParam("id") Integer id) {
- return orderReturnService.confirmReceipt(id);
- }
-
- @PostMapping("confirm_refund")
- public CommonResult confirmRefund(HttpServletRequest request, @RequestParam("id") Integer id) {
- String ip = HttpUtil.getIp(request);
- return orderReturnService.refund(id, ip);
- }
-}
diff --git a/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/admins/AdminsOrderController.java b/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/admins/AdminsOrderController.java
deleted file mode 100644
index 7dd025655..000000000
--- a/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/admins/AdminsOrderController.java
+++ /dev/null
@@ -1,101 +0,0 @@
-package cn.iocoder.mall.order.application.controller.admins;
-
-import cn.iocoder.common.framework.vo.CommonResult;
-import cn.iocoder.mall.order.api.OrderService;
-import cn.iocoder.mall.order.api.bo.OrderItemBO;
-import cn.iocoder.mall.order.api.bo.OrderPageBO;
-import cn.iocoder.mall.order.api.bo.OrderRecipientBO;
-import cn.iocoder.mall.order.api.dto.OrderItemUpdateDTO;
-import cn.iocoder.mall.order.api.dto.OrderLogisticsUpdateDTO;
-import cn.iocoder.mall.order.api.dto.OrderQueryDTO;
-import cn.iocoder.mall.order.application.convert.OrderConvertAPP;
-import cn.iocoder.mall.order.application.convert.OrderDeliveryConvert;
-import cn.iocoder.mall.order.application.po.admin.OrderDeliverPO;
-import cn.iocoder.mall.order.application.po.admin.OrderItemUpdatePO;
-import cn.iocoder.mall.order.application.po.admin.OrderLogisticsPO;
-import cn.iocoder.mall.order.application.po.admin.OrderPageQueryPO;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import org.apache.dubbo.config.annotation.Reference;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.List;
-
-/**
- * 订单API(admins)
- *
- * @author Sin
- * @time 2019-03-24 10:22
- */
-@RestController
-@RequestMapping("admins/order")
-@Api(value = "订单 API(admins)")
-public class AdminsOrderController {
-
- @Reference(validation = "true", version = "${dubbo.provider.OrderService.version}")
- private OrderService orderService;
-
- @GetMapping("page")
- @ApiOperation("订单列表")
- public CommonResult getOrderPage(@Validated OrderPageQueryPO orderPageQueryVO) {
- OrderQueryDTO orderQueryDTO = OrderConvertAPP.INSTANCE.convert(orderPageQueryVO);
- return orderService.getOrderPage(orderQueryDTO);
- }
-
- @GetMapping("order_items")
- @ApiOperation("订单列表")
- public CommonResult> getOrderItems(@RequestParam("orderId") Integer orderId) {
- return orderService.getOrderItems(orderId);
- }
-
- @GetMapping("order_recipient_info")
- @ApiOperation("订单收件人信息")
- public CommonResult getOrderRecipientBO(@RequestParam("orderId") Integer orderId) {
- return orderService.getOrderRecipientBO(orderId);
- }
-
- @PostMapping("order_deliver")
- @ApiOperation("订单发货")
- public CommonResult orderDeliver(@RequestBody @Validated OrderDeliverPO orderDeliverPO) {
- return orderService.orderDelivery(OrderDeliveryConvert.INSTANCE.convert(orderDeliverPO));
- }
-
- @PutMapping("update_remark")
- @ApiOperation("更新-更新订单备注")
- public CommonResult updateRemark(@RequestParam("orderId") Integer orderId,
- @RequestParam("remark") String remark) {
- return orderService.updateOrderRemake(orderId, remark);
- }
-
- @PutMapping("cancel_order")
- @ApiOperation("取消订单")
- public CommonResult cancelOrder(
- @RequestParam("orderId") Integer orderId,
- @RequestParam("reasons") Integer reasons,
- @RequestParam(value = "otherReasons", required = false) String otherReasons) {
- return orderService.cancelOrder(orderId, reasons, otherReasons);
- }
-
- @PutMapping("order_item/update_pay_amount")
- @ApiOperation("更新-订单item实付金额")
- public CommonResult updateOrderItemPayAmount(@RequestParam("orderId") Integer orderId,
- @RequestParam("orderItemId") Integer orderItemId,
- @RequestParam("payAmount") Integer payAmount) {
- return orderService.updateOrderItemPayAmount(orderId, orderItemId, payAmount);
- }
-
- @PutMapping("order_item/update")
- @ApiOperation("更新-订单item")
- public CommonResult updateOrderItem(@RequestBody @Validated OrderItemUpdatePO orderItemUpdateVO) {
- OrderItemUpdateDTO dto = OrderConvertAPP.INSTANCE.convert(orderItemUpdateVO);
- return orderService.updateOrderItem(dto);
- }
-
- @PutMapping("logistics/update")
- @ApiOperation("更新-订单物流")
- public CommonResult updateLogistics(@RequestBody @Validated OrderLogisticsPO orderLogisticsVO) {
- OrderLogisticsUpdateDTO dto = OrderConvertAPP.INSTANCE.convert(orderLogisticsVO);
- return orderService.updateLogistics(dto);
- }
-}
diff --git a/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/users/OrderCommentController.java b/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/users/OrderCommentController.java
deleted file mode 100644
index e908c5e16..000000000
--- a/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/users/OrderCommentController.java
+++ /dev/null
@@ -1,78 +0,0 @@
-package cn.iocoder.mall.order.application.controller.users;
-
-import cn.iocoder.common.framework.constant.MallConstants;
-import cn.iocoder.common.framework.vo.CommonResult;
-import cn.iocoder.mall.order.api.OrderCommentReplyService;
-import cn.iocoder.mall.order.api.OrderCommentService;
-import cn.iocoder.mall.order.api.bo.OrderCommentCreateBO;
-import cn.iocoder.mall.order.api.bo.OrderCommentInfoAndMerchantReplyBO;
-import cn.iocoder.mall.order.api.bo.OrderCommentPageBO;
-import cn.iocoder.mall.order.api.bo.OrderCommentStateInfoPageBO;
-import cn.iocoder.mall.order.api.dto.OrderCommentCreateDTO;
-import cn.iocoder.mall.order.api.dto.OrderCommentPageDTO;
-import cn.iocoder.mall.order.api.dto.OrderCommentStateInfoPageDTO;
-import cn.iocoder.mall.user.sdk.annotation.RequiresLogin;
-import cn.iocoder.mall.user.sdk.context.UserSecurityContextHolder;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import org.apache.dubbo.config.annotation.Reference;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-
-import static cn.iocoder.common.framework.vo.CommonResult.success;
-
-/**
- *
- * 订单评论 Api(user)
- *
- * @author wtz
- * @time 2019-05-27 20:46
- */
-@RestController
-@RequestMapping(MallConstants.ROOT_PATH_USER + "/order_comment")
-@Api("用户评论模块")
-public class OrderCommentController {
-
- @Reference(validation = "true", version = "${dubbo.provider.OrderCommentService.version}")
- private OrderCommentService orderCommentService;
-
- @Reference(validation = "true", version = "${dubbo.provider.OrderCommentReplyService.version}")
- private OrderCommentReplyService orderCommentReplyService;
-
-
- @PostMapping("create_order_comment")
- //@RequiresLogin
- @ApiOperation(value = "创建订单评论")
- public CommonResult createOrderComment(@RequestBody @Validated OrderCommentCreateDTO orderCommentCreateDTO) {
- Integer userId = UserSecurityContextHolder.getContext().getUserId();
- orderCommentCreateDTO.setUserId(userId);
- return success(orderCommentService.createOrderComment(orderCommentCreateDTO));
- }
-
- @GetMapping("order_comment_page")
- @ApiOperation(value = "获取评论分页")
- public CommonResult getOrderCommentPage(@Validated OrderCommentPageDTO orderCommentPageDTO){
- return success(orderCommentService.getOrderCommentPage(orderCommentPageDTO));
- }
-
- @GetMapping("order_comment_info_merchant_reply")
- @ApiOperation(value = "获取评论和商家回复")
- public CommonResult geOrderCommentInfoAndMerchantReply(@RequestParam("commentId") Integer commentId){
- OrderCommentInfoAndMerchantReplyBO orderCommentInfoAndMerchantReplyBO=new OrderCommentInfoAndMerchantReplyBO();
- orderCommentInfoAndMerchantReplyBO.setOrderCommentInfoBO(orderCommentService.getOrderCommentInfo(commentId));
- orderCommentInfoAndMerchantReplyBO.setOrderCommentMerchantReplyBOS(orderCommentReplyService.getOrderCommentMerchantReply(commentId));
- return success(orderCommentInfoAndMerchantReplyBO);
- }
-
- @GetMapping
- //@RequiresLogin
- @ApiOperation(value = "获取订单评论状态分页")
- public CommonResult getOrderCommentStateInfoPage(@Validated OrderCommentStateInfoPageDTO orderCommentStateInfoPageDTO){
- //Integer userId = UserSecurityContextHolder.getContext().getUserId();
- //orderCommentStateInfoPageDTO.setUserId(userId);
- return success(orderCommentService.getOrderCommentStateInfoPage(orderCommentStateInfoPageDTO));
- }
-
-
-}
diff --git a/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/users/OrderCommentReplyController.java b/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/users/OrderCommentReplyController.java
deleted file mode 100644
index 37c147b65..000000000
--- a/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/users/OrderCommentReplyController.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package cn.iocoder.mall.order.application.controller.users;
-
-import cn.iocoder.common.framework.constant.MallConstants;
-import cn.iocoder.common.framework.vo.CommonResult;
-import cn.iocoder.mall.order.api.OrderCommentReplyService;
-import cn.iocoder.mall.order.api.bo.OrderCommentReplyCreateBO;
-import cn.iocoder.mall.order.api.bo.OrderCommentReplyPageBO;
-import cn.iocoder.mall.order.api.dto.OrderCommentReplyCreateDTO;
-import cn.iocoder.mall.order.api.dto.OrderCommentReplyPageDTO;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import org.apache.dubbo.config.annotation.Reference;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-import static cn.iocoder.common.framework.vo.CommonResult.success;
-
-
-/**
- *
- * 评论回复模块 Api(user)
- *
- * @author wtz
- * @time 2019-05-31 18:00
- */
-@RestController
-@RequestMapping(MallConstants.ROOT_PATH_USER + "/order_comment_reply")
-@Api("用户评论回复模块 ")
-public class OrderCommentReplyController {
-
- @Reference(validation = "true", version = "${dubbo.provider.OrderCommentService.version}")
- private OrderCommentReplyService orderCommentReplyService;
-
- @PostMapping("create_order_comment_reply")
- //@RequiresLogin
- @ApiOperation(value = "创建订单回复")
- public CommonResult createOrderCommentReply(@RequestBody @Validated OrderCommentReplyCreateDTO orderCommentReplyCreateDTO){
- return success(orderCommentReplyService.createOrderCommentReply(orderCommentReplyCreateDTO));
- }
-
- @GetMapping("order_comment_reply_page")
- //@RequiresLogin
- @ApiOperation(value = "分页获取评论回复")
- public CommonResult getOrderCommentReplyPage(@Validated OrderCommentReplyPageDTO orderCommentReplyCreateDTO){
- return success(orderCommentReplyService.getOrderCommentReplyPage(orderCommentReplyCreateDTO));
- }
-}
diff --git a/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/users/OrderController.java b/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/users/OrderController.java
deleted file mode 100644
index 2d53ae44d..000000000
--- a/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/users/OrderController.java
+++ /dev/null
@@ -1,152 +0,0 @@
-package cn.iocoder.mall.order.application.controller.users;
-
-import cn.iocoder.common.framework.util.HttpUtil;
-import cn.iocoder.common.framework.util.ServiceExceptionUtil;
-import cn.iocoder.common.framework.vo.CommonResult;
-import cn.iocoder.mall.system.api.DataDictService;
-import cn.iocoder.mall.system.api.bo.datadict.DataDictBO;
-import cn.iocoder.mall.order.api.CartService;
-import cn.iocoder.mall.order.api.OrderService;
-import cn.iocoder.mall.order.api.bo.*;
-import cn.iocoder.mall.order.api.constant.DictKeyConstants;
-import cn.iocoder.mall.order.api.constant.OrderErrorCodeEnum;
-import cn.iocoder.mall.order.api.dto.CalcOrderPriceDTO;
-import cn.iocoder.mall.order.api.dto.OrderCreateDTO;
-import cn.iocoder.mall.order.api.dto.OrderQueryDTO;
-import cn.iocoder.mall.order.application.convert.CartConvert;
-import cn.iocoder.mall.order.application.convert.OrderConvertAPP;
-import cn.iocoder.mall.order.application.po.user.OrderCreatePO;
-import cn.iocoder.mall.order.application.vo.UsersOrderConfirmCreateVO;
-import cn.iocoder.mall.promotion.api.CouponService;
-import cn.iocoder.mall.promotion.api.bo.CouponCardAvailableBO;
-import cn.iocoder.mall.user.sdk.annotation.RequiresLogin;
-import cn.iocoder.mall.user.sdk.context.UserSecurityContextHolder;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import org.apache.dubbo.config.annotation.Reference;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-
-import javax.servlet.http.HttpServletRequest;
-import java.util.Collections;
-import java.util.List;
-import java.util.stream.Collectors;
-
-import static cn.iocoder.common.framework.vo.CommonResult.success;
-
-/**
- * 订单API(users)
- *
- * @author Sin
- * @time 2019-03-24 11:24
- */
-@RestController
-@RequestMapping("users/order")
-@Api(description = "用户订单") // TODO FROM 芋艿 to 小范,description 已经废弃啦
-public class OrderController {
-
- @Reference(validation = "true", version = "${dubbo.provider.OrderReturnService.version}")
- private OrderService orderService;
-
- @Reference(validation = "true", version = "${dubbo.provider.CartService.version}")
- private CartService cartService;
-
- @Reference(validation = "true", version = "${dubbo.consumer.DataDictService.version}")
- private DataDictService dataDictService;
-
- @Reference(validation = "true", version = "${dubbo.consumer.CouponService.version}")
- private CouponService couponService;
-
- @GetMapping("order_page")
- @RequiresLogin
- @ApiOperation("订单分页")
- public CommonResult getOrderPage(@Validated OrderQueryDTO orderQueryDTO) {
- Integer userId = UserSecurityContextHolder.getContext().getUserId();
- orderQueryDTO.setUserId(userId);
- return orderService.getOrderPage(orderQueryDTO);
- }
-
- @PostMapping("create_order")
- @RequiresLogin
- @ApiOperation("创建订单")
- public CommonResult createOrder(@RequestBody @Validated OrderCreatePO orderCreatePO,
- HttpServletRequest request) {
- Integer userId = UserSecurityContextHolder.getContext().getUserId();
- OrderCreateDTO orderCreateDTO = OrderConvertAPP.INSTANCE.convert(orderCreatePO);
- orderCreateDTO.setUserId(userId).setIp(HttpUtil.getIp(request));
- return orderService.createOrder(orderCreateDTO);
- }
-
- @PostMapping("create_order_from_cart")
- @RequiresLogin
- @ApiOperation("创建订单购物车")
- public CommonResult createOrderFromCart(@RequestParam("userAddressId") Integer userAddressId,
- @RequestParam(value = "couponCardId", required = false) Integer couponCardId,
- @RequestParam(value = "remark", required = false) String remark,
- HttpServletRequest request) {
- Integer userId = UserSecurityContextHolder.getContext().getUserId();
- // 获得购物车中选中的商品
- List cartItems = cartService.list(userId, true);
- if (cartItems.isEmpty()) {
- return ServiceExceptionUtil.error(OrderErrorCodeEnum.ORDER_CREATE_CART_IS_EMPTY.getCode());
- }
- // 创建 OrderCreateDTO 对象
- OrderCreateDTO orderCreateDTO = OrderConvertAPP.INSTANCE.createOrderCreateDTO(userId, userAddressId,
- remark, HttpUtil.getIp(request),
- cartItems, couponCardId);
- // 创建订单
- CommonResult createResult = orderService.createOrder(orderCreateDTO);
- if (createResult.isError()) {
- return CommonResult.error(createResult);
- }
- // 清空购物车 // TODO 芋艿,需要标记删除的原因,即结果为创建为某个订单。
- cartService.deleteList(userId, cartItems.stream().map(CartItemBO::getSkuId).collect(Collectors.toList()));
- // 返回结果
- return createResult;
- }
-
- @GetMapping("confirm_create_order")
- @RequiresLogin
- @ApiOperation("确认创建订单")
- public CommonResult getConfirmCreateOrder(@RequestParam("skuId") Integer skuId,
- @RequestParam("quantity") Integer quantity,
- @RequestParam(value = "couponCardId", required = false) Integer couponCardId) {
- Integer userId = UserSecurityContextHolder.getContext().getUserId();
- // 创建 CalcOrderPriceDTO 对象,并执行价格计算
- CalcOrderPriceDTO calcOrderPriceDTO = new CalcOrderPriceDTO()
- .setUserId(userId)
- .setItems(Collections.singletonList(new CalcOrderPriceDTO.Item(skuId, quantity, true)))
- .setCouponCardId(couponCardId);
- CalcOrderPriceBO calcOrderPrice = cartService.calcOrderPrice(calcOrderPriceDTO);
- // 获得优惠劵
- List couponCards = couponService.getCouponCardList(userId,
- CartConvert.INSTANCE.convertList(calcOrderPrice.getItemGroups()));
- // 执行数据拼装
- return success(CartConvert.INSTANCE.convert(calcOrderPrice).setCouponCards(couponCards));
- }
-
- @PostMapping("confirm_receiving")
- @RequiresLogin
- @ApiOperation("确认收货")
- public CommonResult confirmReceiving(@RequestParam("orderId") Integer orderId) {
- Integer userId = UserSecurityContextHolder.getContext().getUserId();
- return orderService.confirmReceiving(userId, orderId);
- }
-
- @GetMapping("info")
- @RequiresLogin
- @ApiOperation("订单详情")
- public CommonResult orderInfo(@RequestParam("orderId") Integer orderId) {
- Integer userId = UserSecurityContextHolder.getContext().getUserId();
- CommonResult commonResult = orderService.info(userId, orderId);
-
- OrderInfoBO orderInfoBO = commonResult.getData();
- if (orderInfoBO != null) {
- CommonResult dictResult = dataDictService
- .getDataDict(DictKeyConstants.ORDER_STATUS, orderInfoBO.getStatus());
- orderInfoBO.setStatusText(dictResult.getData().getDisplayName());
- }
- return commonResult;
- }
-
-}
diff --git a/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/users/OrderLogisticsController.java b/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/users/OrderLogisticsController.java
deleted file mode 100644
index 918b92ac2..000000000
--- a/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/users/OrderLogisticsController.java
+++ /dev/null
@@ -1,85 +0,0 @@
-package cn.iocoder.mall.order.application.controller.users;
-
-import cn.iocoder.common.framework.util.ServiceExceptionUtil;
-import cn.iocoder.common.framework.vo.CommonResult;
-import cn.iocoder.mall.system.api.DataDictService;
-import cn.iocoder.mall.system.api.bo.datadict.DataDictBO;
-import cn.iocoder.mall.order.api.OrderLogisticsService;
-import cn.iocoder.mall.order.api.bo.OrderLogisticsInfoBO;
-import cn.iocoder.mall.order.api.bo.OrderLogisticsInfoWithOrderBO;
-import cn.iocoder.mall.order.api.constant.DictKeyConstants;
-import cn.iocoder.mall.order.api.constant.OrderErrorCodeEnum;
-import cn.iocoder.mall.user.sdk.context.UserSecurityContextHolder;
-import org.apache.dubbo.config.annotation.Reference;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.util.CollectionUtils;
-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 java.util.Map;
-import java.util.Set;
-import java.util.stream.Collectors;
-
-/**
- * 订单物流 controller
- *
- * @author Sin
- * @time 2019-04-12 22:24
- */
-@RestController
-@RequestMapping("users/order_logistics")
-@Api(description = "订单物流信息")
-public class OrderLogisticsController {
-
- @Reference(validation = "true", version = "${dubbo.provider.OrderLogisticsService.version}")
- private OrderLogisticsService orderLogisticsService;
-
- @Reference(validation = "true", version = "${dubbo.consumer.DataDictService.version}")
- private DataDictService dataDictService;
-
- @GetMapping("info")
- @ApiOperation("物流详细 - 物流通用")
- public CommonResult logistics(@RequestParam("logisticsId") Integer logisticsId) {
- return orderLogisticsService.getLogisticsInfo(logisticsId);
- }
-
- @GetMapping("info_order")
- @ApiOperation("物流详细 - 返回订单所关联的所有物流信息(订单用的)")
- public CommonResult logisticsInfoWithOrder(@RequestParam("orderId") Integer orderId) {
- Integer userId = UserSecurityContextHolder.getContext().getUserId();
- CommonResult commonResult = orderLogisticsService.getOrderLogisticsInfo(userId, orderId);
- if (commonResult.isSuccess()) {
- OrderLogisticsInfoWithOrderBO orderLogisticsInfoBO = commonResult.getData();
- List logisticsList = orderLogisticsInfoBO.getLogistics();
-
- // 获取字典值
- Set dictValues = logisticsList.stream().map(o -> o.getLogistics()).collect(Collectors.toSet());
- if (!CollectionUtils.isEmpty(dictValues)) {
- CommonResult> dictResult = dataDictService
- .getDataDictList(DictKeyConstants.ORDER_LOGISTICS_COMPANY, dictValues);
-
- if (dictResult.isError()) {
- // 错误情况
- return ServiceExceptionUtil.error(OrderErrorCodeEnum.DICT_SERVER_INVOKING_FAIL.getCode());
- }
-
- // 转换结果字典值
- Map dataDictBOMap = dictResult.getData()
- .stream().collect(Collectors.toMap(o -> o.getValue(), o -> o));
-
- logisticsList.stream().map(o -> {
- String dicValue = o.getLogistics().toString();
- if (dataDictBOMap.containsKey(dicValue)) {
- o.setLogisticsText(dataDictBOMap.get(dicValue).getDisplayName());
- }
- return o;
- }).collect(Collectors.toList());
- }
- }
- return commonResult;
- }
-}
diff --git a/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/users/OrderReturnController.java b/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/users/OrderReturnController.java
deleted file mode 100644
index ff5503dbc..000000000
--- a/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/users/OrderReturnController.java
+++ /dev/null
@@ -1,65 +0,0 @@
-package cn.iocoder.mall.order.application.controller.users;
-
-import cn.iocoder.common.framework.vo.CommonResult;
-import cn.iocoder.mall.system.api.DataDictService;
-import cn.iocoder.mall.system.api.bo.datadict.DataDictBO;
-import cn.iocoder.mall.order.api.OrderReturnService;
-import cn.iocoder.mall.order.api.bo.OrderReturnInfoBO;
-import cn.iocoder.mall.order.api.constant.DictKeyConstants;
-import cn.iocoder.mall.order.api.dto.OrderReturnApplyDTO;
-import cn.iocoder.mall.order.application.convert.OrderReturnConvert;
-import cn.iocoder.mall.order.application.po.user.OrderReturnApplyPO;
-import org.apache.dubbo.config.annotation.Reference;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.List;
-
-/**
- * 订单退款/售后流程
- *
- * @author Sin
- * @time 2019-04-25 22:04
- */
-@RestController
-@RequestMapping("users/order_return")
-public class OrderReturnController {
-
- @Reference(validation = "true", version = "${dubbo.provider.OrderReturnService.version}")
- private OrderReturnService orderReturnService;
-
- @Reference(validation = "true", version = "${dubbo.consumer.DataDictService.version}")
- private DataDictService dataDictService;
-
- @GetMapping("reason")
- @ApiOperation("原因")
- public CommonResult> orderReturnReason() {
- return dataDictService.getDataDict(DictKeyConstants.ORDER_RETURN_REASON);
- }
-
- @PostMapping("apply")
- @ApiOperation("订单售后")
- public CommonResult orderReturnApply(@RequestBody OrderReturnApplyPO orderReturnApplyPO) {
- OrderReturnApplyDTO applyDTO = OrderReturnConvert.INSTANCE.convert(orderReturnApplyPO);
- return orderReturnService.orderReturnApply(applyDTO);
- }
-
- @GetMapping("info")
- @ApiOperation("订单售后详细")
- public CommonResult orderApplyInfo(@RequestParam("orderId") Integer orderId) {
- CommonResult commonResult = orderReturnService.orderApplyInfo(orderId);
-
- // 转换 字典值
- if (commonResult.isSuccess()) {
- CommonResult dataDictResult = dataDictService.getDataDict(
- DictKeyConstants.ORDER_RETURN_SERVICE_TYPE,
- commonResult.getData().getReturnInfo().getServiceType());
-
- if (dataDictResult.isSuccess()) {
- commonResult.getData().getReturnInfo().setServiceTypeText(dataDictResult.getData().getDisplayName());
- }
- }
-
- return commonResult;
- }
-}
diff --git a/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/users/UsersCartController.java b/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/users/UsersCartController.java
deleted file mode 100644
index 5e021055c..000000000
--- a/order/order-application/src/main/java/cn/iocoder/mall/order/application/controller/users/UsersCartController.java
+++ /dev/null
@@ -1,143 +0,0 @@
-package cn.iocoder.mall.order.application.controller.users;
-
-import cn.iocoder.common.framework.vo.CommonResult;
-import cn.iocoder.mall.order.api.CartService;
-import cn.iocoder.mall.order.api.OrderService;
-import cn.iocoder.mall.order.api.bo.CalcOrderPriceBO;
-import cn.iocoder.mall.order.api.bo.CalcSkuPriceBO;
-import cn.iocoder.mall.order.api.bo.CartItemBO;
-import cn.iocoder.mall.order.api.dto.CalcOrderPriceDTO;
-import cn.iocoder.mall.order.application.convert.CartConvert;
-import cn.iocoder.mall.order.application.vo.UsersCalcSkuPriceVO;
-import cn.iocoder.mall.order.application.vo.UsersCartDetailVO;
-import cn.iocoder.mall.order.application.vo.UsersOrderConfirmCreateVO;
-import cn.iocoder.mall.promotion.api.CouponService;
-import cn.iocoder.mall.promotion.api.bo.CouponCardAvailableBO;
-import cn.iocoder.mall.user.sdk.context.UserSecurityContextHolder;
-import org.apache.dubbo.config.annotation.Reference;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-import static cn.iocoder.common.framework.vo.CommonResult.success;
-
-@RestController
-@RequestMapping("users/cart")
-public class UsersCartController {
-
- @Reference(validation = "true", version = "${dubbo.provider.CartService.version}")
- private CartService cartService;
-
- @Reference(validation = "true", version = "${dubbo.provider.OrderService.version}")
- private OrderService orderService;
-
- @Reference(validation = "true", version = "${dubbo.consumer.CouponService.version}")
- private CouponService couponService;
-
- @PostMapping("add")
- public CommonResult add(@RequestParam("skuId") Integer skuId,
- @RequestParam("quantity") Integer quantity) {
- // 添加到购物车
- cartService.add(UserSecurityContextHolder.getContext().getUserId(), skuId, quantity);
- // 获得目前购物车商品总数量
- return success(cartService.count(UserSecurityContextHolder.getContext().getUserId()));
- }
-
- @PostMapping("update_quantity")
- public CommonResult updateQuantity(@RequestParam("skuId") Integer skuId, // TODO 芋艿,先暂用这个 VO 。等促销活动出来后,做调整
- @RequestParam("quantity") Integer quantity) {
- // 添加到购物车
- cartService.updateQuantity(UserSecurityContextHolder.getContext().getUserId(),
- skuId, quantity);
- // 获得目前购物车明细
- return getCartDetail();
- }
-
- @PostMapping("update_selected")
- public CommonResult updateSelected(@RequestParam("skuIds") Set skuIds, // TODO 芋艿,先暂用这个 VO 。等促销活动出来后,做调整
- @RequestParam("selected") Boolean selected) {
- // 添加到购物车
- cartService.updateSelected(UserSecurityContextHolder.getContext().getUserId(), skuIds, selected);
- // 获得目前购物车明细
- return getCartDetail();
- }
-
- @GetMapping("count")
- public CommonResult count() {
- return success(cartService.count(UserSecurityContextHolder.getContext().getUserId()));
- }
-
- @GetMapping("/list")
- public CommonResult list() { // TODO 芋艿,先暂用这个 VO 。等促销活动出来后,做调整
- return getCartDetail();
- }
-
- private CommonResult getCartDetail() {
- // 获得购物车中选中的
- List cartItems = cartService.list(UserSecurityContextHolder.getContext().getUserId(), null);
- // 购物车为空时,构造空的 UsersOrderConfirmCreateVO 返回
- if (cartItems.isEmpty()) {
- UsersCartDetailVO result = new UsersCartDetailVO();
- result.setItemGroups(Collections.emptyList());
- result.setFee(new UsersCartDetailVO.Fee(0, 0, 0, 0));
- return success(result);
- }
- // 计算商品价格
- CalcOrderPriceBO calcOrder = list0(cartItems, null);
- // 执行数据拼装
- return success(CartConvert.INSTANCE.convert2(calcOrder));
- }
-
- @GetMapping("/confirm_create_order")
- public CommonResult getConfirmCreateOrder(@RequestParam(value = "couponCardId", required = false) Integer couponCardId) {
- Integer userId = UserSecurityContextHolder.getContext().getUserId();
- // 获得购物车中选中的
- List cartItems = cartService.list(userId, true);
- // 购物车为空时,构造空的 UsersOrderConfirmCreateVO 返回
- if (cartItems.isEmpty()) {
- UsersOrderConfirmCreateVO result = new UsersOrderConfirmCreateVO();
- result.setItemGroups(Collections.emptyList());
- result.setFee(new UsersOrderConfirmCreateVO.Fee(0, 0, 0, 0));
- return success(result);
- }
- // 计算商品价格
- CalcOrderPriceBO calcOrderPrice = list0(cartItems, couponCardId);
- // 获得优惠劵
- List couponCards = couponService.getCouponCardList(userId,
- CartConvert.INSTANCE.convertList(calcOrderPrice.getItemGroups()));
- // 执行数据拼装
- return success(CartConvert.INSTANCE.convert(calcOrderPrice).setCouponCards(couponCards));
- }
-
- private CalcOrderPriceBO list0(List cartItems, Integer couponCardId) {
- // 创建计算的 DTO
- CalcOrderPriceDTO calcOrderPriceDTO = new CalcOrderPriceDTO()
- .setUserId(UserSecurityContextHolder.getContext().getUserId())
- .setItems(new ArrayList<>(cartItems.size()))
- .setCouponCardId(couponCardId);
- for (CartItemBO item : cartItems) {
- calcOrderPriceDTO.getItems().add(new CalcOrderPriceDTO.Item(item.getSkuId(), item.getQuantity(), item.getSelected()));
- }
- // 执行计算
- return cartService.calcOrderPrice(calcOrderPriceDTO);
- }
-
- @GetMapping("/calc_sku_price")
- public CommonResult calcSkuPrice(@RequestParam("skuId") Integer skuId) {
- // 计算 sku 的价格
- CalcSkuPriceBO calcSkuPrice = cartService.calcSkuPrice(skuId);
- return success(CartConvert.INSTANCE.convert2(calcSkuPrice));
- }
-
- public CommonResult