diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/StoreOrderController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/StoreOrderController.java index dba06bf35..c62b0b5cd 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/StoreOrderController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/StoreOrderController.java @@ -7,14 +7,8 @@ import com.ruoyi.common.core.domain.R; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.SecurityUtils; -import com.ruoyi.web.controller.xkt.vo.order.StoreOrderAddReqVO; -import com.ruoyi.web.controller.xkt.vo.order.StoreOrderPayReqVO; -import com.ruoyi.web.controller.xkt.vo.order.StoreOrderPayRespVO; -import com.ruoyi.web.controller.xkt.vo.order.StoreOrderUpdateReqVO; -import com.ruoyi.xkt.dto.order.StoreOrderAddDTO; -import com.ruoyi.xkt.dto.order.StoreOrderAddResult; -import com.ruoyi.xkt.dto.order.StoreOrderInfo; -import com.ruoyi.xkt.dto.order.StoreOrderUpdateDTO; +import com.ruoyi.web.controller.xkt.vo.order.*; +import com.ruoyi.xkt.dto.order.*; import com.ruoyi.xkt.enums.EPayChannel; import com.ruoyi.xkt.enums.EPayPage; import com.ruoyi.xkt.manager.PaymentManager; @@ -24,10 +18,7 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.validation.Valid; import java.util.List; @@ -57,7 +48,7 @@ public class StoreOrderController extends XktBaseController { StoreOrderAddResult result = storeOrderService.createOrder(dto, vo.getBeginPay(), EPayChannel.of(vo.getPayChannel()), EPayPage.of(vo.getPayFrom())); //返回信息 - StoreOrderPayRespVO respVO = new StoreOrderPayRespVO(result.getOrderInfo().getOrder().getId(), + StoreOrderPayRespVO respVO = new StoreOrderPayRespVO(result.getOrderExt().getOrder().getId(), result.getPayRtnStr()); return success(respVO); } @@ -65,11 +56,11 @@ public class StoreOrderController extends XktBaseController { @PreAuthorize("@ss.hasPermi('system:order:add')") @Log(title = "订单", businessType = BusinessType.UPDATE) @ApiOperation("修改订单") - @PostMapping("modify") - public R modify(@Valid @RequestBody StoreOrderUpdateReqVO vo) { + @PutMapping("edit") + public R edit(@Valid @RequestBody StoreOrderUpdateReqVO vo) { StoreOrderUpdateDTO dto = BeanUtil.toBean(vo, StoreOrderUpdateDTO.class); dto.setOrderUserId(SecurityUtils.getUserId()); - StoreOrderInfo result = storeOrderService.modifyOrder(dto); + StoreOrderExt result = storeOrderService.modifyOrder(dto); return success(result.getOrder().getId()); } @@ -80,13 +71,22 @@ public class StoreOrderController extends XktBaseController { public R pay(@Valid @RequestBody StoreOrderPayReqVO vo) { PaymentManager paymentManager = getPaymentManager(EPayChannel.of(vo.getPayChannel())); //订单支付状态->支付中 - StoreOrderInfo storeOrderInfo = storeOrderService.preparePayOrder(vo.getStoreOrderId()); + StoreOrderExt orderExt = storeOrderService.preparePayOrder(vo.getStoreOrderId()); //调用支付 - String rtnStr = paymentManager.payOrder(storeOrderInfo, EPayPage.of(vo.getPayFrom())); + String rtnStr = paymentManager.payOrder(orderExt, EPayPage.of(vo.getPayFrom())); StoreOrderPayRespVO respVO = new StoreOrderPayRespVO(vo.getStoreOrderId(), rtnStr); return success(respVO); } + @PreAuthorize("@ss.hasPermi('system:order:query')") + @ApiOperation(value = "订单详情") + @GetMapping(value = "/{id}") + public R getInfo(@PathVariable("id") Long id) { + StoreOrderInfoDTO infoDTO = storeOrderService.getInfo(id); + //TODO 非下单人,非所属档口不允许查询 + return success(BeanUtil.toBean(infoDTO, StoreOrderInfoVO.class)); + } + /** * 根据支付渠道匹配支付类 * diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/order/StoreOrderInfoVO.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/order/StoreOrderInfoVO.java new file mode 100644 index 000000000..aa9f48974 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/xkt/vo/order/StoreOrderInfoVO.java @@ -0,0 +1,399 @@ +package com.ruoyi.web.controller.xkt.vo.order; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * @author liangyq + * @date 2025-04-11 13:43 + */ +@ApiModel("订单信息") +@Data +public class StoreOrderInfoVO { + /** + * 订单ID + */ + @ApiModelProperty(value = "订单ID") + private Long id; + /** + * 档口ID + */ + @ApiModelProperty(value = "档口ID") + private Long storeId; + /** + * 下单用户ID + */ + @ApiModelProperty(value = "下单用户ID") + private Long orderUserId; + /** + * 订单号 + */ + @ApiModelProperty(value = "订单号") + private String orderNo; + /** + * 订单类型[1:销售订单 2:退货订单] + */ + @ApiModelProperty(value = "订单类型[1:销售订单 2:退货订单]") + private Integer orderType; + /** + * 订单状态(1开头为销售订单状态,2开头为退货订单状态)[10:已取消 11:待付款 12:待发货 13:已发货 14:已完成 21:售后中 22:售后拒绝 23:平台介入 24:售后完成] + */ + @ApiModelProperty(value = "订单状态(1开头为销售订单状态,2开头为退货订单状态)[10:已取消 11:待付款 12:待发货 13:已发货 14:已完成 21:售后中 22:售后拒绝 23:平台介入 24:售后完成]") + private Integer orderStatus; + /** + * 支付状态[1:初始 2:支付中 3:已支付] + */ + @ApiModelProperty(value = "支付状态[1:初始 2:支付中 3:已支付]") + private Integer payStatus; + /** + * 订单备注 + */ + @ApiModelProperty(value = "订单备注") + private String orderRemark; + /** + * 商品数量 + */ + @ApiModelProperty(value = "商品数量") + private Integer goodsQuantity; + /** + * 商品金额 + */ + @ApiModelProperty(value = "商品金额") + private BigDecimal goodsAmount; + /** + * 快递费 + */ + @ApiModelProperty(value = "快递费") + private BigDecimal expressFee; + /** + * 总金额(商品金额+快递费) + */ + @ApiModelProperty(value = "总金额") + private BigDecimal totalAmount; + /** + * 实际总金额(总金额-支付渠道服务费) + */ + @ApiModelProperty(value = "实际总金额") + private BigDecimal realTotalAmount; + /** + * 退货原订单ID + */ + @ApiModelProperty(value = "退货原订单ID") + private Long refundOrderId; + /** + * 退货原因 + */ + @ApiModelProperty(value = "退货原因") + private Integer refundReasonCode; + /** + * 退货拒绝原因 + */ + @ApiModelProperty(value = "退货拒绝原因") + private String refundRejectReason; + /** + * 物流ID + */ + @ApiModelProperty(value = "物流ID") + private Long expressId; + /** + * 发货人-名称 + */ + @ApiModelProperty(value = "发货人-名称") + private String originContactName; + /** + * 发货人-电话 + */ + @ApiModelProperty(value = "发货人-电话") + private String originContactPhoneNumber; + /** + * 发货人-省编码 + */ + @ApiModelProperty(value = "发货人-省编码") + private String originProvinceCode; + /** + * 发货人-市编码 + */ + @ApiModelProperty(value = "发货人-市编码") + private String originCityCode; + /** + * 发货人-区县编码 + */ + @ApiModelProperty(value = "发货人-区县编码") + private String originCountyCode; + /** + * 发货人-详细地址 + */ + @ApiModelProperty(value = "发货人-详细地址") + private String originDetailAddress; + /** + * 收货人-名称 + */ + @ApiModelProperty(value = "收货人-名称") + private String destinationContactName; + /** + * 收货人-电话 + */ + @ApiModelProperty(value = "收货人-电话") + private String destinationContactPhoneNumber; + /** + * 收货人-省编码 + */ + @ApiModelProperty(value = "收货人-省编码") + private String destinationProvinceCode; + /** + * 收货人-市编码 + */ + @ApiModelProperty(value = "收货人-市编码") + private String destinationCityCode; + /** + * 收货人-区县编码 + */ + @ApiModelProperty(value = "收货人-区县编码") + private String destinationCountyCode; + /** + * 收货人-详细地址 + */ + @ApiModelProperty(value = "收货人-详细地址") + private String destinationDetailAddress; + /** + * 发货方式[1:货其再发 2:有货先发] + */ + @ApiModelProperty(value = "发货方式[1:货其再发 2:有货先发]") + private Integer deliveryType; + /** + * 最晚发货时间 + */ + @ApiModelProperty(value = "最晚发货时间") + private Date deliveryEndTime; + /** + * 自动完成时间 + */ + @ApiModelProperty(value = "自动完成时间") + private Date autoEndTime; + /** + * 凭证日期 + */ + @ApiModelProperty(value = "凭证日期") + private Date voucherDate; + /** + * 删除标志(0代表存在 2代表删除) + */ + @ApiModelProperty(value = "删除标志(0代表存在 2代表删除)") + private String delFlag; + /** + * 创建者 + */ + @ApiModelProperty(value = "创建者") + private String createBy; + /** + * 创建时间 + */ + @ApiModelProperty(value = "创建时间") + private Date createTime; + /** + * 更新者 + */ + @ApiModelProperty(value = "更新者") + private String updateBy; + /** + * 更新时间 + */ + @ApiModelProperty(value = "更新时间") + private Date updateTime; + + @ApiModelProperty(value = "快递名") + private String expressName; + + @ApiModelProperty(value = "发货人-省名称") + private String originProvinceName; + + @ApiModelProperty(value = "发货人-市名称") + private String originCityName; + + @ApiModelProperty(value = "发货人-区县名称") + private String originCountyName; + + @ApiModelProperty(value = "收货人-省名称") + private String destinationProvinceName; + + @ApiModelProperty(value = "收货人-市名称") + private String destinationCityName; + + @ApiModelProperty(value = "收货人-区县名称") + private String destinationCountyName; + + @ApiModelProperty(value = "订单明细") + private List orderDetails; + + + @ApiModel + @Data + public static class Detail { + /** + * 订单明细ID + */ + @ApiModelProperty(value = "订单明细ID") + private Long id; + /** + * 订单ID + */ + @ApiModelProperty(value = "订单ID") + private Long storeOrderId; + /** + * 商品颜色尺码ID + */ + @ApiModelProperty(value = "商品颜色尺码ID") + private Long storeProdColorSizeId; + /** + * 商品ID + */ + @ApiModelProperty(value = "商品ID") + private Long storeProdId; + /** + * 订单明细状态(同订单状态)[10:已取消 11:待付款 12:待发货 13:已发货 14:已完成 21:售后中 22:售后拒绝 23:平台介入 24:售后完成] + */ + @ApiModelProperty(value = "订单明细状态(同订单状态)[10:已取消 11:待付款 12:待发货 13:已发货 14:已完成 21:售后中 22:售后拒绝 23:平台介入 24:售后完成]") + private Integer detailStatus; + /** + * 支付状态[1:初始 2:支付中 3:已支付] + */ + @ApiModelProperty(value = "支付状态[1:初始 2:支付中 3:已支付]") + private Integer payStatus; + /** + * 物流ID + */ + @ApiModelProperty(value = "物流ID") + private Long expressId; + /** + * 物流类型[1:平台物流 2:档口物流] + */ + @ApiModelProperty(value = "物流类型[1:平台物流 2:档口物流]") + private Integer expressType; + /** + * 物流状态[1:初始 2:下单中 3:已下单 4:取消中 5:已揽件 6:拦截中 99:已结束] + */ + @ApiModelProperty(value = "物流状态[1:初始 2:下单中 3:已下单 4:取消中 5:已揽件 6:拦截中 99:已结束]") + private Integer expressStatus; + /** + * 物流请求单号 + */ + @ApiModelProperty(value = "物流请求单号") + private String expressReqNo; + /** + * 物流运单号(快递单号),档口/用户自己填写时可能存在多个,使用“,”分割 + */ + @ApiModelProperty(value = "物流运单号(快递单号),档口/用户自己填写时可能存在多个,使用“,”分割") + private String expressWaybillNo; + /** + * 商品单价 + */ + @ApiModelProperty(value = "商品单价") + private BigDecimal goodsPrice; + /** + * 商品数量 + */ + @ApiModelProperty(value = "商品数量") + private Integer goodsQuantity; + /** + * 商品金额(商品单价*商品数量) + */ + @ApiModelProperty(value = "商品金额") + private BigDecimal goodsAmount; + /** + * 快递费 + */ + @ApiModelProperty(value = "快递费") + private BigDecimal expressFee; + /** + * 总金额(商品金额+快递费) + */ + @ApiModelProperty(value = "总金额") + private BigDecimal totalAmount; + /** + * 实际总金额(总金额-支付渠道服务费) + */ + @ApiModelProperty(value = "实际总金额") + private BigDecimal realTotalAmount; + /** + * 退货原订单明细ID + */ + @ApiModelProperty(value = "退货原订单明细ID") + private Long refundOrderDetailId; + /** + * 退货原因 + */ + @ApiModelProperty(value = "退货原因") + private Integer refundReasonCode; + /** + * 退货拒绝原因 + */ + @ApiModelProperty(value = "退货拒绝原因") + private String refundRejectReason; + /** + * 删除标志(0代表存在 2代表删除) + */ + @ApiModelProperty(value = "删除标志(0代表存在 2代表删除)") + private String delFlag; + /** + * 创建者 + */ + @ApiModelProperty(value = "创建者") + private String createBy; + /** + * 创建时间 + */ + @ApiModelProperty(value = "创建时间") + private Date createTime; + /** + * 更新者 + */ + @ApiModelProperty(value = "更新者") + private String updateBy; + /** + * 更新时间 + */ + @ApiModelProperty(value = "更新时间") + private Date updateTime; + + @ApiModelProperty(value = "档口商品名称") + private String prodName; + + @ApiModelProperty(value = "商品货号") + private String prodArtNum; + + @ApiModelProperty(value = "商品标题") + private String prodTitle; + + @ApiModelProperty(value = "档口颜色ID") + private Long storeColorId; + + @ApiModelProperty(value = "颜色名称") + private String colorName; + + @ApiModelProperty(value = "商品尺码") + private Integer size; + + @ApiModelProperty(value = "档口商品文件") + private List fileList; + } + + @Data + @ApiModel(value = "档口商品文件") + public static class StoreProdFileVO { + @ApiModelProperty(value = "文件名称") + private String fileName; + @ApiModelProperty(value = "文件路径") + private String fileUrl; + @ApiModelProperty(value = "文件大小") + private BigDecimal fileSize; + @ApiModelProperty(value = "文件类型 1商品主图 2商品主图视频 3下载图片包") + private Integer fileType; + @ApiModelProperty(value = "排序") + private Integer orderNum; + } +} diff --git a/xkt/src/main/java/com/ruoyi/xkt/dto/order/StoreOrderAddResult.java b/xkt/src/main/java/com/ruoyi/xkt/dto/order/StoreOrderAddResult.java index 8505fce66..ec529ce54 100644 --- a/xkt/src/main/java/com/ruoyi/xkt/dto/order/StoreOrderAddResult.java +++ b/xkt/src/main/java/com/ruoyi/xkt/dto/order/StoreOrderAddResult.java @@ -15,7 +15,7 @@ public class StoreOrderAddResult { /** * 订单信息 */ - private StoreOrderInfo orderInfo; + private StoreOrderExt orderExt; /** * 三方支付返回信息 */ diff --git a/xkt/src/main/java/com/ruoyi/xkt/dto/order/StoreOrderDetailInfoDTO.java b/xkt/src/main/java/com/ruoyi/xkt/dto/order/StoreOrderDetailInfoDTO.java index 1ea7d07e0..f101bde0d 100644 --- a/xkt/src/main/java/com/ruoyi/xkt/dto/order/StoreOrderDetailInfoDTO.java +++ b/xkt/src/main/java/com/ruoyi/xkt/dto/order/StoreOrderDetailInfoDTO.java @@ -1,9 +1,12 @@ package com.ruoyi.xkt.dto.order; +import com.ruoyi.xkt.dto.storeProductFile.StoreProdFileResDTO; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; +import java.util.List; + /** * @author liangyq * @date 2025-04-02 22:39 @@ -13,4 +16,17 @@ import lombok.ToString; @ToString(callSuper = true) public class StoreOrderDetailInfoDTO extends StoreOrderDetailDTO { + private String prodName; + + private String prodArtNum; + + private String prodTitle; + + private Long storeColorId; + + private String colorName; + + private Integer size; + + private List fileList; } diff --git a/xkt/src/main/java/com/ruoyi/xkt/dto/order/StoreOrderInfo.java b/xkt/src/main/java/com/ruoyi/xkt/dto/order/StoreOrderExt.java similarity index 93% rename from xkt/src/main/java/com/ruoyi/xkt/dto/order/StoreOrderInfo.java rename to xkt/src/main/java/com/ruoyi/xkt/dto/order/StoreOrderExt.java index 0343b8319..133500585 100644 --- a/xkt/src/main/java/com/ruoyi/xkt/dto/order/StoreOrderInfo.java +++ b/xkt/src/main/java/com/ruoyi/xkt/dto/order/StoreOrderExt.java @@ -15,7 +15,7 @@ import java.util.List; @Data @AllArgsConstructor @NoArgsConstructor -public class StoreOrderInfo { +public class StoreOrderExt { private StoreOrder order; diff --git a/xkt/src/main/java/com/ruoyi/xkt/dto/order/StoreOrderInfoDTO.java b/xkt/src/main/java/com/ruoyi/xkt/dto/order/StoreOrderInfoDTO.java index 1b7213f2d..b78b7d507 100644 --- a/xkt/src/main/java/com/ruoyi/xkt/dto/order/StoreOrderInfoDTO.java +++ b/xkt/src/main/java/com/ruoyi/xkt/dto/order/StoreOrderInfoDTO.java @@ -15,5 +15,19 @@ import java.util.List; @ToString(callSuper = true) public class StoreOrderInfoDTO extends StoreOrderDTO { - private List detailList; + private String expressName; + + private String originProvinceName; + + private String originCityName; + + private String originCountyName; + + private String destinationProvinceName; + + private String destinationCityName; + + private String destinationCountyName; + + private List orderDetails; } diff --git a/xkt/src/main/java/com/ruoyi/xkt/dto/order/StoreOrderUpdateDTO.java b/xkt/src/main/java/com/ruoyi/xkt/dto/order/StoreOrderUpdateDTO.java index 7f22d958f..4b7b7980f 100644 --- a/xkt/src/main/java/com/ruoyi/xkt/dto/order/StoreOrderUpdateDTO.java +++ b/xkt/src/main/java/com/ruoyi/xkt/dto/order/StoreOrderUpdateDTO.java @@ -11,7 +11,7 @@ import lombok.ToString; @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class StoreOrderUpdateDTO extends StoreOrderAddDTO{ +public class StoreOrderUpdateDTO extends StoreOrderAddDTO { /** * 订单ID */ diff --git a/xkt/src/main/java/com/ruoyi/xkt/manager/PaymentManager.java b/xkt/src/main/java/com/ruoyi/xkt/manager/PaymentManager.java index 007fbf08a..31835f92b 100644 --- a/xkt/src/main/java/com/ruoyi/xkt/manager/PaymentManager.java +++ b/xkt/src/main/java/com/ruoyi/xkt/manager/PaymentManager.java @@ -1,6 +1,6 @@ package com.ruoyi.xkt.manager; -import com.ruoyi.xkt.dto.order.StoreOrderInfo; +import com.ruoyi.xkt.dto.order.StoreOrderExt; import com.ruoyi.xkt.enums.EPayChannel; import com.ruoyi.xkt.enums.EPayPage; @@ -23,6 +23,6 @@ public interface PaymentManager { * @param payFrom * @return 跳转页面数据/签名字符串/支付跳转链接/预支付交易会话标识(根据支付渠道&支付来源确定) */ - String payOrder(StoreOrderInfo order, EPayPage payFrom); + String payOrder(StoreOrderExt order, EPayPage payFrom); } diff --git a/xkt/src/main/java/com/ruoyi/xkt/manager/impl/AliPaymentMangerImpl.java b/xkt/src/main/java/com/ruoyi/xkt/manager/impl/AliPaymentMangerImpl.java index be90db924..a0371a600 100644 --- a/xkt/src/main/java/com/ruoyi/xkt/manager/impl/AliPaymentMangerImpl.java +++ b/xkt/src/main/java/com/ruoyi/xkt/manager/impl/AliPaymentMangerImpl.java @@ -8,7 +8,7 @@ import com.alipay.api.request.AlipayTradePagePayRequest; import com.alipay.api.request.AlipayTradeWapPayRequest; import com.ruoyi.common.exception.ServiceException; import com.ruoyi.xkt.dto.finance.AlipayReqDTO; -import com.ruoyi.xkt.dto.order.StoreOrderInfo; +import com.ruoyi.xkt.dto.order.StoreOrderExt; import com.ruoyi.xkt.enums.EPayChannel; import com.ruoyi.xkt.enums.EPayPage; import com.ruoyi.xkt.enums.EPayStatus; @@ -77,16 +77,16 @@ public class AliPaymentMangerImpl implements PaymentManager { } @Override - public String payOrder(StoreOrderInfo orderInfo, EPayPage payFrom) { - Assert.notNull(orderInfo); + public String payOrder(StoreOrderExt orderExt, EPayPage payFrom) { + Assert.notNull(orderExt); Assert.notNull(payFrom); - if (!EPayStatus.PAYING.getValue().equals(orderInfo.getOrder().getPayStatus())) { - throw new ServiceException("订单[" + orderInfo.getOrder().getOrderNo() + "]支付状态异常"); + if (!EPayStatus.PAYING.getValue().equals(orderExt.getOrder().getPayStatus())) { + throw new ServiceException("订单[" + orderExt.getOrder().getOrderNo() + "]支付状态异常"); } AlipayReqDTO reqDTO = new AlipayReqDTO(); - reqDTO.setOutTradeNo(orderInfo.getOrder().getOrderNo()); - reqDTO.setTotalAmount(orderInfo.getOrder().getTotalAmount().toPlainString()); - reqDTO.setSubject("代发订单" + orderInfo.getOrder().getOrderNo()); + reqDTO.setOutTradeNo(orderExt.getOrder().getOrderNo()); + reqDTO.setTotalAmount(orderExt.getOrder().getTotalAmount().toPlainString()); + reqDTO.setSubject("代发订单" + orderExt.getOrder().getOrderNo()); reqDTO.setProductCode(PAY_PRODUCT_CODE); //这个是固定的 String reqStr = JSON.toJSONString(reqDTO); AlipayClient alipayClient = new DefaultAlipayClient(gatewayUrl, appId, privateKey, DEFAULT_FORMAT, charset, diff --git a/xkt/src/main/java/com/ruoyi/xkt/mapper/StoreColorMapper.java b/xkt/src/main/java/com/ruoyi/xkt/mapper/StoreColorMapper.java index 600201bda..ec0e04991 100644 --- a/xkt/src/main/java/com/ruoyi/xkt/mapper/StoreColorMapper.java +++ b/xkt/src/main/java/com/ruoyi/xkt/mapper/StoreColorMapper.java @@ -3,6 +3,7 @@ package com.ruoyi.xkt.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.xkt.domain.StoreColor; import com.ruoyi.xkt.dto.storeColor.StoreColorDTO; +import org.springframework.stereotype.Repository; import java.util.List; @@ -12,6 +13,7 @@ import java.util.List; * @author ruoyi * @date 2025-03-26 */ +@Repository public interface StoreColorMapper extends BaseMapper { /** * 查询档口所有颜色 diff --git a/xkt/src/main/java/com/ruoyi/xkt/mapper/StoreProductFileMapper.java b/xkt/src/main/java/com/ruoyi/xkt/mapper/StoreProductFileMapper.java index 82f52bcde..a55c52353 100644 --- a/xkt/src/main/java/com/ruoyi/xkt/mapper/StoreProductFileMapper.java +++ b/xkt/src/main/java/com/ruoyi/xkt/mapper/StoreProductFileMapper.java @@ -6,6 +6,7 @@ import com.ruoyi.xkt.dto.storeProductFile.StoreProdFilePicSpaceResDTO; import com.ruoyi.xkt.dto.storeProductFile.StoreProdFileResDTO; import com.ruoyi.xkt.dto.storeProductFile.StoreProdMainPicDTO; import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Repository; import java.util.List; @@ -15,6 +16,7 @@ import java.util.List; * @author ruoyi * @date 2025-03-26 */ +@Repository public interface StoreProductFileMapper extends BaseMapper { /** * 查询档口商品文件 diff --git a/xkt/src/main/java/com/ruoyi/xkt/service/IExpressService.java b/xkt/src/main/java/com/ruoyi/xkt/service/IExpressService.java index c8da13312..0cf538286 100644 --- a/xkt/src/main/java/com/ruoyi/xkt/service/IExpressService.java +++ b/xkt/src/main/java/com/ruoyi/xkt/service/IExpressService.java @@ -1,8 +1,13 @@ package com.ruoyi.xkt.service; +import com.ruoyi.xkt.domain.Express; import com.ruoyi.xkt.domain.ExpressFeeConfig; +import com.ruoyi.xkt.domain.ExpressRegion; import com.ruoyi.xkt.dto.express.ExpressContactDTO; +import java.util.Collection; +import java.util.List; + /** * @author liangyq * @date 2025-04-03 13:35 @@ -16,6 +21,14 @@ public interface IExpressService { */ void checkExpress(Long expressId); + /** + * 获取物流 + * + * @param expressId + * @return + */ + Express getById(Long expressId); + /** * 获取快递费配置 * @@ -34,4 +47,12 @@ public interface IExpressService { * @return */ ExpressContactDTO getStoreContact(Long storeId); + + /** + * 获取行政区划 + * + * @param regionCodes + * @return + */ + List listRegionByCode(Collection regionCodes); } diff --git a/xkt/src/main/java/com/ruoyi/xkt/service/IFinanceBillService.java b/xkt/src/main/java/com/ruoyi/xkt/service/IFinanceBillService.java index dd89cd9dd..70aaa241d 100644 --- a/xkt/src/main/java/com/ruoyi/xkt/service/IFinanceBillService.java +++ b/xkt/src/main/java/com/ruoyi/xkt/service/IFinanceBillService.java @@ -1,7 +1,7 @@ package com.ruoyi.xkt.service; import com.ruoyi.xkt.dto.finance.FinanceBillInfo; -import com.ruoyi.xkt.dto.order.StoreOrderInfo; +import com.ruoyi.xkt.dto.order.StoreOrderExt; import com.ruoyi.xkt.enums.EPayChannel; /** @@ -12,10 +12,10 @@ public interface IFinanceBillService { /** * 根据订单创建收款单 * - * @param orderInfo + * @param orderExt * @param payId * @param payChannel * @return */ - FinanceBillInfo createCollectionBillAfterOrderPaid(StoreOrderInfo orderInfo, Long payId, EPayChannel payChannel); + FinanceBillInfo createCollectionBillAfterOrderPaid(StoreOrderExt orderExt, Long payId, EPayChannel payChannel); } diff --git a/xkt/src/main/java/com/ruoyi/xkt/service/IStoreOrderService.java b/xkt/src/main/java/com/ruoyi/xkt/service/IStoreOrderService.java index d52fd84e7..e9037bcb6 100644 --- a/xkt/src/main/java/com/ruoyi/xkt/service/IStoreOrderService.java +++ b/xkt/src/main/java/com/ruoyi/xkt/service/IStoreOrderService.java @@ -1,10 +1,7 @@ package com.ruoyi.xkt.service; import com.ruoyi.xkt.domain.StoreOrder; -import com.ruoyi.xkt.dto.order.StoreOrderAddDTO; -import com.ruoyi.xkt.dto.order.StoreOrderAddResult; -import com.ruoyi.xkt.dto.order.StoreOrderInfo; -import com.ruoyi.xkt.dto.order.StoreOrderUpdateDTO; +import com.ruoyi.xkt.dto.order.*; import com.ruoyi.xkt.enums.EPayChannel; import com.ruoyi.xkt.enums.EPayPage; @@ -33,7 +30,7 @@ public interface IStoreOrderService { * @param storeOrderUpdateDTO * @return */ - StoreOrderInfo modifyOrder(StoreOrderUpdateDTO storeOrderUpdateDTO); + StoreOrderExt modifyOrder(StoreOrderUpdateDTO storeOrderUpdateDTO); /** * 通过订单号获取订单 @@ -43,12 +40,20 @@ public interface IStoreOrderService { */ StoreOrder getByOrderNo(String orderNo); + /** + * 获取订单详情 + * + * @param storeOrderId + * @return + */ + StoreOrderInfoDTO getInfo(Long storeOrderId); + /** * 准备支付订单 * * @param storeOrderId */ - StoreOrderInfo preparePayOrder(Long storeOrderId); + StoreOrderExt preparePayOrder(Long storeOrderId); /** * 订单支付成果 @@ -59,5 +64,5 @@ public interface IStoreOrderService { * @param realTotalAmount * @return */ - StoreOrderInfo paySuccess(Long storeOrderId, BigDecimal totalAmount, BigDecimal realTotalAmount); + StoreOrderExt paySuccess(Long storeOrderId, BigDecimal totalAmount, BigDecimal realTotalAmount); } diff --git a/xkt/src/main/java/com/ruoyi/xkt/service/impl/AlipayCallbackServiceImpl.java b/xkt/src/main/java/com/ruoyi/xkt/service/impl/AlipayCallbackServiceImpl.java index 7de42ef31..9fcffa248 100644 --- a/xkt/src/main/java/com/ruoyi/xkt/service/impl/AlipayCallbackServiceImpl.java +++ b/xkt/src/main/java/com/ruoyi/xkt/service/impl/AlipayCallbackServiceImpl.java @@ -3,7 +3,7 @@ package com.ruoyi.xkt.service.impl; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.ruoyi.xkt.domain.AlipayCallback; import com.ruoyi.xkt.domain.StoreOrder; -import com.ruoyi.xkt.dto.order.StoreOrderInfo; +import com.ruoyi.xkt.dto.order.StoreOrderExt; import com.ruoyi.xkt.enums.EPayChannel; import com.ruoyi.xkt.enums.EProcessStatus; import com.ruoyi.xkt.mapper.AlipayCallbackMapper; @@ -53,9 +53,9 @@ public class AlipayCallbackServiceImpl implements IAlipayCallbackService { //更新订单状态 StoreOrder order = storeOrderService.getByOrderNo(info.getOutTradeNo()); Assert.notNull(order); - StoreOrderInfo orderInfo = storeOrderService.paySuccess(order.getId(), info.getTotalAmount(), + StoreOrderExt orderExt = storeOrderService.paySuccess(order.getId(), info.getTotalAmount(), info.getReceiptAmount()); //创建收款单 - financeBillService.createCollectionBillAfterOrderPaid(orderInfo, info.getId(), EPayChannel.ALI_PAY); + financeBillService.createCollectionBillAfterOrderPaid(orderExt, info.getId(), EPayChannel.ALI_PAY); } } diff --git a/xkt/src/main/java/com/ruoyi/xkt/service/impl/ExpressServiceImpl.java b/xkt/src/main/java/com/ruoyi/xkt/service/impl/ExpressServiceImpl.java index c194c7a39..52764471c 100644 --- a/xkt/src/main/java/com/ruoyi/xkt/service/impl/ExpressServiceImpl.java +++ b/xkt/src/main/java/com/ruoyi/xkt/service/impl/ExpressServiceImpl.java @@ -1,23 +1,24 @@ package com.ruoyi.xkt.service.impl; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.ListUtil; import cn.hutool.core.lang.Assert; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.ruoyi.common.utils.bean.BeanValidators; import com.ruoyi.xkt.domain.Express; import com.ruoyi.xkt.domain.ExpressFeeConfig; +import com.ruoyi.xkt.domain.ExpressRegion; import com.ruoyi.xkt.domain.Store; import com.ruoyi.xkt.dto.express.ExpressContactDTO; -import com.ruoyi.xkt.mapper.ExpressFeeConfigMapper; -import com.ruoyi.xkt.mapper.ExpressMapper; -import com.ruoyi.xkt.mapper.StoreMapper; -import com.ruoyi.xkt.mapper.StoreOrderExpressTrackMapper; +import com.ruoyi.xkt.mapper.*; import com.ruoyi.xkt.service.IExpressService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import java.util.Arrays; +import java.util.Collection; +import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -42,6 +43,8 @@ public class ExpressServiceImpl implements IExpressService { @Autowired private StoreOrderExpressTrackMapper storeOrderExpressTrackMapper; @Autowired + private ExpressRegionMapper expressRegionMapper; + @Autowired private StoreMapper storeMapper; @Override @@ -52,6 +55,11 @@ public class ExpressServiceImpl implements IExpressService { Assert.isTrue(express.getSystemDeliverAccess(), "快递不可用"); } + @Override + public Express getById(Long expressId) { + return expressMapper.selectById(expressId); + } + @Override public ExpressFeeConfig getExpressFeeConfig(Long expressId, String provinceCode, String cityCode, String countyCode) { @@ -60,8 +68,8 @@ public class ExpressServiceImpl implements IExpressService { Assert.notEmpty(cityCode); Assert.notEmpty(countyCode); Map map = expressFeeConfigMapper.selectList(Wrappers.lambdaQuery(ExpressFeeConfig.class) - .eq(ExpressFeeConfig::getExpressId, expressId) - .in(ExpressFeeConfig::getRegionCode, Arrays.asList(provinceCode, cityCode, countyCode))) + .eq(ExpressFeeConfig::getExpressId, expressId) + .in(ExpressFeeConfig::getRegionCode, Arrays.asList(provinceCode, cityCode, countyCode))) .stream() //过滤掉已被删除的配置 .filter(BeanValidators::exists) @@ -98,4 +106,13 @@ public class ExpressServiceImpl implements IExpressService { expressContactDTO.setContactPhoneNumber(store.getContactPhone()); return expressContactDTO; } + + @Override + public List listRegionByCode(Collection regionCodes) { + if (CollUtil.isEmpty(regionCodes)) { + return ListUtil.empty(); + } + return expressRegionMapper.selectList(Wrappers.lambdaQuery(ExpressRegion.class) + .in(ExpressRegion::getRegionCode, regionCodes)); + } } diff --git a/xkt/src/main/java/com/ruoyi/xkt/service/impl/FinanceBillServiceImpl.java b/xkt/src/main/java/com/ruoyi/xkt/service/impl/FinanceBillServiceImpl.java index 6de32ee7f..2ac3d20d8 100644 --- a/xkt/src/main/java/com/ruoyi/xkt/service/impl/FinanceBillServiceImpl.java +++ b/xkt/src/main/java/com/ruoyi/xkt/service/impl/FinanceBillServiceImpl.java @@ -7,7 +7,7 @@ import com.ruoyi.xkt.domain.FinanceBillDetail; import com.ruoyi.xkt.domain.StoreOrderDetail; import com.ruoyi.xkt.dto.finance.FinanceBillInfo; import com.ruoyi.xkt.dto.finance.TransInfo; -import com.ruoyi.xkt.dto.order.StoreOrderInfo; +import com.ruoyi.xkt.dto.order.StoreOrderExt; import com.ruoyi.xkt.enums.*; import com.ruoyi.xkt.mapper.FinanceBillDetailMapper; import com.ruoyi.xkt.mapper.FinanceBillMapper; @@ -41,9 +41,9 @@ public class FinanceBillServiceImpl implements IFinanceBillService { @Transactional @Override - public FinanceBillInfo createCollectionBillAfterOrderPaid(StoreOrderInfo orderInfo, Long payId, + public FinanceBillInfo createCollectionBillAfterOrderPaid(StoreOrderExt orderExt, Long payId, EPayChannel payChannel) { - Assert.notNull(orderInfo); + Assert.notNull(orderExt); Assert.notNull(payId); Assert.notNull(payChannel); //获取平台内部账户并加锁 @@ -55,19 +55,19 @@ public class FinanceBillServiceImpl implements IFinanceBillService { bill.setSrcType(EFinBillSrcType.STORE_ORDER_PAID.getValue()); bill.setSrcId(payId); bill.setRelType(EFinBillRelType.STORE_ORDER.getValue()); - bill.setRelId(orderInfo.getOrder().getId()); + bill.setRelId(orderExt.getOrder().getId()); //支付渠道+回调ID构成业务唯一键,防止重复创建收款单 String businessUniqueKey = payChannel.getPrefix() + payId; bill.setBusinessUniqueKey(businessUniqueKey); bill.setInputInternalAccountId(Constants.PLATFORM_INTERNAL_ACCOUNT_ID); bill.setInputExternalAccountId(payChannel.getPlatformExternalAccountId()); - bill.setBusinessAmount(orderInfo.getOrder().getTotalAmount()); - bill.setTransAmount(orderInfo.getOrder().getRealTotalAmount()); + bill.setBusinessAmount(orderExt.getOrder().getTotalAmount()); + bill.setTransAmount(orderExt.getOrder().getRealTotalAmount()); bill.setVersion(0L); bill.setDelFlag(Constants.UNDELETED); financeBillMapper.insert(bill); - List billDetails = new ArrayList<>(orderInfo.getOrderDetails().size()); - for (StoreOrderDetail orderDetail : orderInfo.getOrderDetails()) { + List billDetails = new ArrayList<>(orderExt.getOrderDetails().size()); + for (StoreOrderDetail orderDetail : orderExt.getOrderDetails()) { FinanceBillDetail billDetail = new FinanceBillDetail(); billDetail.setFinanceBillId(bill.getId()); billDetail.setRelType(EFinBillDetailRelType.STORE_ORDER_DETAIL.getValue()); diff --git a/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreOrderServiceImpl.java b/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreOrderServiceImpl.java index 98b722bba..c4362b37a 100644 --- a/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreOrderServiceImpl.java +++ b/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreOrderServiceImpl.java @@ -1,5 +1,6 @@ package com.ruoyi.xkt.service.impl; +import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.lang.Assert; @@ -27,6 +28,7 @@ import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; import java.util.*; +import java.util.function.Function; import java.util.stream.Collectors; /** @@ -47,6 +49,10 @@ public class StoreOrderServiceImpl implements IStoreOrderService { @Autowired private StoreProductColorPriceMapper storeProductColorPriceMapper; @Autowired + private StoreColorMapper storeColorMapper; + @Autowired + private StoreProductFileMapper storeProductFileMapper; + @Autowired private IExpressService expressService; @Autowired private IOperationRecordService operationRecordService; @@ -165,19 +171,19 @@ public class StoreOrderServiceImpl implements IStoreOrderService { //操作记录 addOperationRecords(orderId, EOrderAction.INSERT, orderDetailIdList, EOrderAction.INSERT, orderUserId, new Date()); - StoreOrderInfo orderInfo = new StoreOrderInfo(order, orderDetailList); + StoreOrderExt orderExt = new StoreOrderExt(order, orderDetailList); String rtnStr = null; if (beginPay) { //发起支付 PaymentManager paymentManager = getPaymentManager(payChannel); - rtnStr = paymentManager.payOrder(orderInfo, payPage); + rtnStr = paymentManager.payOrder(orderExt, payPage); } - return new StoreOrderAddResult(orderInfo, rtnStr); + return new StoreOrderAddResult(orderExt, rtnStr); } @Transactional @Override - public StoreOrderInfo modifyOrder(StoreOrderUpdateDTO storeOrderUpdateDTO) { + public StoreOrderExt modifyOrder(StoreOrderUpdateDTO storeOrderUpdateDTO) { //原订单 StoreOrder order = storeOrderMapper.selectById(storeOrderUpdateDTO.getId()); if (!BeanValidators.exists(order)) { @@ -291,7 +297,7 @@ public class StoreOrderServiceImpl implements IStoreOrderService { //操作记录 addOperationRecords(orderId, EOrderAction.UPDATE, orderDetailIdList, EOrderAction.INSERT, orderUserId, new Date()); - return new StoreOrderInfo(order, orderDetailList); + return new StoreOrderExt(order, orderDetailList); } @Override @@ -301,9 +307,68 @@ public class StoreOrderServiceImpl implements IStoreOrderService { .eq(StoreOrder::getOrderNo, orderNo)); } + @Override + public StoreOrderInfoDTO getInfo(Long storeOrderId) { + StoreOrder order = storeOrderMapper.selectById(storeOrderId); + if (order == null) { + return null; + } + List details = storeOrderDetailMapper.selectList(Wrappers.lambdaQuery(StoreOrderDetail.class) + .eq(StoreOrderDetail::getStoreOrderId, storeOrderId) + .eq(SimpleEntity::getDelFlag, Constants.UNDELETED)); + StoreOrderInfoDTO orderInfo = BeanUtil.toBean(order, StoreOrderInfoDTO.class); + List detailInfos = BeanUtil.copyToList(details, + StoreOrderDetailInfoDTO.class); + orderInfo.setOrderDetails(detailInfos); + //物流信息 + Express express = expressService.getById(order.getExpressId()); + orderInfo.setExpressName(Optional.ofNullable(express).map(Express::getExpressName).orElse(null)); + Map regionNameMap = expressService.listRegionByCode(Arrays + .asList(order.getDestinationProvinceCode(), order.getDestinationCityCode(), + order.getDestinationCountyCode(), order.getOriginProvinceCode(), + order.getOriginCityCode(), order.getOriginCountyCode())) + .stream() + .collect(Collectors.toMap(ExpressRegion::getRegionCode, ExpressRegion::getRegionName)); + orderInfo.setDestinationProvinceName(regionNameMap.get(orderInfo.getDestinationProvinceCode())); + orderInfo.setDestinationCityName(regionNameMap.get(orderInfo.getDestinationCityCode())); + orderInfo.setDestinationCountyName(regionNameMap.get(orderInfo.getDestinationCountyCode())); + orderInfo.setOriginProvinceName(regionNameMap.get(orderInfo.getOriginProvinceCode())); + orderInfo.setOriginCityName(regionNameMap.get(orderInfo.getOriginCityCode())); + orderInfo.setOriginCountyName(regionNameMap.get(orderInfo.getOriginCountyCode())); + //商品信息 + Set spcsIds = detailInfos.stream().map(StoreOrderDetailDTO::getStoreProdColorSizeId) + .collect(Collectors.toSet()); + List spcsList = storeProductColorSizeMapper.selectByIds(spcsIds); + Map spcsMap = spcsList.stream() + .collect(Collectors.toMap(StoreProductColorSize::getId, Function.identity())); + Set scIds = spcsList.stream().map(StoreProductColorSize::getStoreColorId).collect(Collectors.toSet()); + Map scMap = storeColorMapper.selectByIds(scIds).stream() + .collect(Collectors.toMap(StoreColor::getId, Function.identity())); + Set pIds = spcsList.stream().map(StoreProductColorSize::getStoreProdId).collect(Collectors.toSet()); + Map storeProductMap = storeProductMapper.selectByIds(pIds).stream() + .collect(Collectors.toMap(StoreProduct::getId, Function.identity())); + for (StoreOrderDetailInfoDTO detailInfo : detailInfos) { + StoreProductColorSize spcs = spcsMap.get(detailInfo.getStoreProdColorSizeId()); + if (spcs != null) { + detailInfo.setSize(spcs.getSize()); + detailInfo.setStoreColorId(spcs.getStoreColorId()); + detailInfo.setColorName(Optional.ofNullable(scMap.get(spcs.getStoreColorId())) + .map(StoreColor::getColorName).orElse(null)); + StoreProduct sp = storeProductMap.get(spcs.getStoreProdId()); + if (sp != null) { + detailInfo.setProdName(sp.getProdName()); + detailInfo.setProdArtNum(sp.getProdArtNum()); + detailInfo.setProdTitle(sp.getProdTitle()); + } + detailInfo.setFileList(storeProductFileMapper.selectListByStoreProdId(spcs.getStoreProdId())); + } + } + return orderInfo; + } + @Transactional @Override - public StoreOrderInfo preparePayOrder(Long storeOrderId) { + public StoreOrderExt preparePayOrder(Long storeOrderId) { Assert.notNull(storeOrderId); StoreOrder order = storeOrderMapper.selectById(storeOrderId); Assert.isTrue(EOrderType.SALES_ORDER.getValue().equals(order.getOrderType()), @@ -327,12 +392,12 @@ public class StoreOrderServiceImpl implements IStoreOrderService { throw new ServiceException(Constants.VERSION_LOCK_ERROR_COMMON_MSG); } } - return new StoreOrderInfo(order, orderDetails); + return new StoreOrderExt(order, orderDetails); } @Transactional @Override - public StoreOrderInfo paySuccess(Long storeOrderId, BigDecimal totalAmount, BigDecimal realTotalAmount) { + public StoreOrderExt paySuccess(Long storeOrderId, BigDecimal totalAmount, BigDecimal realTotalAmount) { Assert.notNull(storeOrderId); StoreOrder order = storeOrderMapper.selectById(storeOrderId); Assert.isTrue(EOrderType.SALES_ORDER.getValue().equals(order.getOrderType()), @@ -379,7 +444,7 @@ public class StoreOrderServiceImpl implements IStoreOrderService { //操作记录 addOperationRecords(storeOrderId, EOrderAction.PAY, orderDetailIdList, EOrderAction.PAY, null, new Date()); - return new StoreOrderInfo(order, orderDetails); + return new StoreOrderExt(order, orderDetails); } private void checkPreparePayStatus(Integer payStatus) {