Pārlūkot izejas kodu

feat: 添加下单接口

pangqijun 3 mēneši atpakaļ
vecāks
revīzija
a2730d2cb8
22 mainītis faili ar 613 papildinājumiem un 33 dzēšanām
  1. 2 1
      src/main/java/org/springblade/common/enums/OrderTypeEnum.java
  2. 2 2
      src/main/java/org/springblade/modules/api/controller/ApiGoodsController.java
  3. 9 0
      src/main/java/org/springblade/modules/api/request/SubmitOrderRequest.java
  4. 1 3
      src/main/java/org/springblade/modules/api/service/SubmitOrderService.java
  5. 0 6
      src/main/java/org/springblade/modules/api/service/impl/GrouponOrderServiceImpl.java
  6. 3 0
      src/main/java/org/springblade/modules/business/entity/FacilityCargoWay.java
  7. 2 1
      src/main/java/org/springblade/modules/business/mapper/FacilityMapper.java
  8. 3 2
      src/main/java/org/springblade/modules/business/mapper/FacilityMapper.xml
  9. 2 1
      src/main/java/org/springblade/modules/business/service/IFacilityService.java
  10. 2 1
      src/main/java/org/springblade/modules/business/service/impl/FacilityServiceImpl.java
  11. 129 0
      src/main/java/org/springblade/modules/finance/controller/OrderGoodsController.java
  12. 34 0
      src/main/java/org/springblade/modules/finance/dto/OrderGoodsDTO.java
  13. 98 0
      src/main/java/org/springblade/modules/finance/entity/OrderGoods.java
  14. 42 0
      src/main/java/org/springblade/modules/finance/mapper/OrderGoodsMapper.java
  15. 34 0
      src/main/java/org/springblade/modules/finance/mapper/OrderGoodsMapper.xml
  16. 41 0
      src/main/java/org/springblade/modules/finance/service/IOrderGoodsService.java
  17. 111 0
      src/main/java/org/springblade/modules/finance/service/impl/OrderGoodsServiceImpl.java
  18. 36 0
      src/main/java/org/springblade/modules/finance/vo/OrderGoodsVO.java
  19. 49 0
      src/main/java/org/springblade/modules/finance/wrapper/OrderGoodsWrapper.java
  20. 3 0
      src/main/java/org/springblade/modules/mall/vo/GoodsInfoVO.java
  21. 10 0
      src/main/java/sql/ordergoods.menu.mysql
  22. 0 16
      src/main/resources/templates/controller.java.vm

+ 2 - 1
src/main/java/org/springblade/common/enums/OrderTypeEnum.java

@@ -8,7 +8,8 @@ import org.springblade.core.log.exception.ServiceException;
  */
 @Getter
 public enum OrderTypeEnum {
-	NORMAL("拼团订单", 1, "grouponOrderServiceImpl");
+	NORMAL("拼团订单", 1, "grouponOrderServiceImpl"),
+	GOODS("商品订单", 2, "grouponOrderServiceImpl");
 
 	private String name;
 	private Integer value;

+ 2 - 2
src/main/java/org/springblade/modules/api/controller/ApiGoodsController.java

@@ -100,8 +100,8 @@ public class ApiGoodsController extends BladeController {
     @GetMapping("/goods/byDeviceId")
     @ApiOperationSupport(order = 3)
     @ApiOperation(value = "查询设备商品")
-    public R<List<GoodsInfo>> getByDeviceId(Long deviceId) {
-        List<GoodsInfo> goods = iFacilityService.getGoods(deviceId);
+    public R<List<GoodsInfoVO>> getByDeviceId(Long deviceId) {
+        List<GoodsInfoVO> goods = iFacilityService.getGoods(deviceId);
         return R.data(goods);
     }
 

+ 9 - 0
src/main/java/org/springblade/modules/api/request/SubmitOrderRequest.java

@@ -87,4 +87,13 @@ public class SubmitOrderRequest implements Serializable {
 	@ApiModelProperty(value = "自提点ID")
 	private Long selfTakeId;
 
+	@ApiModelProperty(value = "设备id")
+	private Long deviceId;
+
+	@ApiModelProperty(value = "门店id")
+	private Long shopId;
+
+	@ApiModelProperty(value = "货道id")
+	private Long cargoWayId;
+
 }

+ 1 - 3
src/main/java/org/springblade/modules/api/service/SubmitOrderService.java

@@ -23,9 +23,7 @@ public interface SubmitOrderService {
      */
     String submitOrder(SubmitOrderRequest request);
 
-    void confirmOrder(String pickupCode, Long userId);
-
-    List<OrderGrouponGoods> getGroupGoodsList(Long orderId);
+    default void confirmOrder(String pickupCode, Long userId) {};
 
     /**
      * 支付成功后处理操作,默认不处理,各实现类可自行实现覆盖

+ 0 - 6
src/main/java/org/springblade/modules/api/service/impl/GrouponOrderServiceImpl.java

@@ -176,12 +176,6 @@ public class GrouponOrderServiceImpl implements SubmitOrderService {
         messageService.sendMessage(order.getUserId(), "提货成功", order.getOrderNo());
     }
 
-    @Override
-    public List<OrderGrouponGoods> getGroupGoodsList(Long orderId) {
-        return orderGrouponGoodsService.list(Wrappers.lambdaQuery(OrderGrouponGoods.class)
-                .eq(OrderGrouponGoods::getOrderId, orderId));
-    }
-
     /**
      * 校验商品
      * @param map

+ 3 - 0
src/main/java/org/springblade/modules/business/entity/FacilityCargoWay.java

@@ -79,4 +79,7 @@ public class FacilityCargoWay extends BaseEntity {
     @ApiModelProperty(name = "货道总交易金额")
     private BigDecimal totalAmount;
 
+    public Double getDiscount() {
+        return discount == null ? 0.0 : discount;
+    }
 }

+ 2 - 1
src/main/java/org/springblade/modules/business/mapper/FacilityMapper.java

@@ -21,6 +21,7 @@ import org.springblade.modules.business.vo.FacilityVO;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.springblade.modules.mall.entity.GoodsInfo;
+import org.springblade.modules.mall.vo.GoodsInfoVO;
 
 import java.util.List;
 
@@ -41,5 +42,5 @@ public interface FacilityMapper extends BaseMapper<Facility> {
 	 */
 	List<FacilityVO> selectFacilityPage(IPage page, FacilityVO facility);
 
-    List<GoodsInfo> selectGoods(Long deviceId);
+    List<GoodsInfoVO> selectGoods(Long deviceId);
 }

+ 3 - 2
src/main/java/org/springblade/modules/business/mapper/FacilityMapper.xml

@@ -25,14 +25,15 @@
     <select id="selectFacilityPage" resultMap="facilityResultMap">
         select * from t_facility where is_delete = 0
     </select>
-    <select id="selectGoods" resultType="org.springblade.modules.mall.entity.GoodsInfo">
+    <select id="selectGoods" resultType="org.springblade.modules.mall.vo.GoodsInfoVO">
         SELECT
             gi.id,
             gi.goods_name,
             gi.goods_cover,
             fcw.goods_store totalStock,
             fcw.discount,
-            fcw.sale_price
+            fcw.sale_price,
+            fcw.id cargoWayId
         FROM
             t_facility_cargo_way fcw
                 JOIN t_goods_info gi ON fcw.goods_id = gi.id

+ 2 - 1
src/main/java/org/springblade/modules/business/service/IFacilityService.java

@@ -21,6 +21,7 @@ import org.springblade.modules.business.vo.FacilityVO;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.springblade.modules.mall.entity.GoodsInfo;
+import org.springblade.modules.mall.vo.GoodsInfoVO;
 
 import java.util.List;
 
@@ -46,5 +47,5 @@ public interface IFacilityService extends IService<Facility> {
 	 * @param deviceId 设备id
 	 * @return 商品列表
 	 */
-    List<GoodsInfo> getGoods(Long deviceId);
+    List<GoodsInfoVO> getGoods(Long deviceId);
 }

+ 2 - 1
src/main/java/org/springblade/modules/business/service/impl/FacilityServiceImpl.java

@@ -22,6 +22,7 @@ import org.springblade.modules.business.mapper.FacilityMapper;
 import org.springblade.modules.business.service.IFacilityService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springblade.modules.mall.entity.GoodsInfo;
+import org.springblade.modules.mall.vo.GoodsInfoVO;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 
@@ -42,7 +43,7 @@ public class FacilityServiceImpl extends ServiceImpl<FacilityMapper, Facility> i
 	}
 
 	@Override
-	public List<GoodsInfo> getGoods(Long deviceId) {
+	public List<GoodsInfoVO> getGoods(Long deviceId) {
 		return baseMapper.selectGoods(deviceId);
 	}
 

+ 129 - 0
src/main/java/org/springblade/modules/finance/controller/OrderGoodsController.java

@@ -0,0 +1,129 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.finance.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import lombok.AllArgsConstructor;
+import javax.validation.Valid;
+
+import org.springblade.core.mp.support.Condition;
+import org.springblade.core.mp.support.Query;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.Func;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.RequestParam;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.springblade.modules.finance.entity.OrderGoods;
+import org.springblade.modules.finance.vo.OrderGoodsVO;
+import org.springblade.modules.finance.wrapper.OrderGoodsWrapper;
+import org.springblade.modules.finance.service.IOrderGoodsService;
+import org.springblade.core.boot.ctrl.BladeController;
+
+/**
+ * 商品订单表 控制器
+ *
+ * @author BladeX
+ * @since 2024-07-17
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("finance/ordergoods")
+@Api(value = "商品订单表", tags = "商品订单表接口")
+public class OrderGoodsController extends BladeController {
+
+	private final IOrderGoodsService orderGoodsService;
+
+	/**
+	 * 详情
+	 */
+	@GetMapping("/detail")
+	@ApiOperationSupport(order = 1)
+	@ApiOperation(value = "详情", notes = "传入orderGoods")
+	public R<OrderGoodsVO> detail(OrderGoods orderGoods) {
+		OrderGoods detail = orderGoodsService.getOne(Condition.getQueryWrapper(orderGoods));
+		return R.data(OrderGoodsWrapper.build().entityVO(detail));
+	}
+
+	/**
+	 * 分页 商品订单表
+	 */
+	@GetMapping("/list")
+	@ApiOperationSupport(order = 2)
+	@ApiOperation(value = "分页", notes = "传入orderGoods")
+	public R<IPage<OrderGoodsVO>> list(OrderGoods orderGoods, Query query) {
+		IPage<OrderGoods> pages = orderGoodsService.page(Condition.getPage(query), Condition.getQueryWrapper(orderGoods));
+		return R.data(OrderGoodsWrapper.build().pageVO(pages));
+	}
+
+
+	/**
+	 * 自定义分页 商品订单表
+	 */
+	@GetMapping("/page")
+	@ApiOperationSupport(order = 3)
+	@ApiOperation(value = "分页", notes = "传入orderGoods")
+	public R<IPage<OrderGoodsVO>> page(OrderGoodsVO orderGoods, Query query) {
+		IPage<OrderGoodsVO> pages = orderGoodsService.selectOrderGoodsPage(Condition.getPage(query), orderGoods);
+		return R.data(pages);
+	}
+
+	/**
+	 * 新增 商品订单表
+	 */
+	@PostMapping("/save")
+	@ApiOperationSupport(order = 4)
+	@ApiOperation(value = "新增", notes = "传入orderGoods")
+	public R save(@Valid @RequestBody OrderGoods orderGoods) {
+		return R.status(orderGoodsService.save(orderGoods));
+	}
+
+	/**
+	 * 修改 商品订单表
+	 */
+	@PostMapping("/update")
+	@ApiOperationSupport(order = 5)
+	@ApiOperation(value = "修改", notes = "传入orderGoods")
+	public R update(@Valid @RequestBody OrderGoods orderGoods) {
+		return R.status(orderGoodsService.updateById(orderGoods));
+	}
+
+	/**
+	 * 新增或修改 商品订单表
+	 */
+	@PostMapping("/submit")
+	@ApiOperationSupport(order = 6)
+	@ApiOperation(value = "新增或修改", notes = "传入orderGoods")
+	public R submit(@Valid @RequestBody OrderGoods orderGoods) {
+		return R.status(orderGoodsService.saveOrUpdate(orderGoods));
+	}
+
+	
+	/**
+	 * 删除 商品订单表
+	 */
+	@PostMapping("/remove")
+	@ApiOperationSupport(order = 7)
+	@ApiOperation(value = "逻辑删除", notes = "传入ids")
+	public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
+		return R.status(orderGoodsService.removeByIds(Func.toLongList(ids)));
+	}
+
+	
+}

+ 34 - 0
src/main/java/org/springblade/modules/finance/dto/OrderGoodsDTO.java

@@ -0,0 +1,34 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.finance.dto;
+
+import org.springblade.modules.finance.entity.OrderGoods;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 商品订单表数据传输对象实体类
+ *
+ * @author BladeX
+ * @since 2024-07-17
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class OrderGoodsDTO extends OrderGoods {
+	private static final long serialVersionUID = 1L;
+
+}

+ 98 - 0
src/main/java/org/springblade/modules/finance/entity/OrderGoods.java

@@ -0,0 +1,98 @@
+package org.springblade.modules.finance.entity;
+
+import java.math.BigDecimal;
+import org.springblade.common.base.BaseEntity;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.time.LocalDateTime;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * 商品订单表实体类
+ *
+ * @author zzyd
+ * @since 2024-07-17
+ */
+@Data
+@TableName("t_order_goods")
+@EqualsAndHashCode(callSuper = true)
+@ApiModel(value = "OrderGoods对象", description = "商品订单表")
+public class OrderGoods extends BaseEntity {
+
+	private static final long serialVersionUID = 1L;
+
+	/**
+	* 订单id
+	*/
+	@ApiModelProperty(value = "订单id")
+	private Long orderId;
+	/**
+	* 商品id
+	*/
+	@ApiModelProperty(value = "商品id")
+	private Long goodsId;
+	/**
+	* 商品数量
+	*/
+	@ApiModelProperty(value = "商品数量")
+	private Integer goodsNum;
+	/**
+	* 商品名称
+	*/
+	@ApiModelProperty(value = "商品名称")
+	private String goodsName;
+	/**
+	* 商品价格
+	*/
+	@ApiModelProperty(value = "商品价格")
+	private BigDecimal goodsPrice;
+	/**
+	* 商品图片
+	*/
+	@ApiModelProperty(value = "商品图片")
+	private String goodsImage;
+	/**
+	* 商品编号
+	*/
+	@ApiModelProperty(value = "商品编号")
+	private String goodsNo;
+	/**
+	* 门店id
+	*/
+	@ApiModelProperty(value = "门店id")
+	private Long shopId;
+	/**
+	* 门店名称
+	*/
+	@ApiModelProperty(value = "门店名称")
+	private String storeName;
+	/**
+	* 设备id
+	*/
+	@ApiModelProperty(value = "设备id")
+	private Long deviceId;
+	/**
+	* 商家id
+	*/
+	@ApiModelProperty(value = "商家id")
+	private Long merchantId;
+	/**
+	* 用户id
+	*/
+	@ApiModelProperty(value = "用户id")
+	private Long userId;
+	/**
+	* 货道id
+	*/
+	@ApiModelProperty(value = "货道id")
+	private Long cargoWayId;
+	/**
+	* 出货时间
+	*/
+	@ApiModelProperty(value = "出货时间")
+	private LocalDateTime shippingTime;
+
+
+}

+ 42 - 0
src/main/java/org/springblade/modules/finance/mapper/OrderGoodsMapper.java

@@ -0,0 +1,42 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.finance.mapper;
+
+import org.springblade.modules.finance.entity.OrderGoods;
+import org.springblade.modules.finance.vo.OrderGoodsVO;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import java.util.List;
+
+/**
+ * 商品订单表 Mapper 接口
+ *
+ * @author BladeX
+ * @since 2024-07-17
+ */
+public interface OrderGoodsMapper extends BaseMapper<OrderGoods> {
+
+	/**
+	 * 自定义分页
+	 *
+	 * @param page
+	 * @param orderGoods
+	 * @return
+	 */
+	List<OrderGoodsVO> selectOrderGoodsPage(IPage page, OrderGoodsVO orderGoods);
+
+}

+ 34 - 0
src/main/java/org/springblade/modules/finance/mapper/OrderGoodsMapper.xml

@@ -0,0 +1,34 @@
+<?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="org.springblade.modules.finance.mapper.OrderGoodsMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="orderGoodsResultMap" type="org.springblade.modules.finance.entity.OrderGoods">
+        <result column="id" property="id"/>
+        <result column="is_delete" property="isDelete"/>
+        <result column="create_user_id" property="createUserId"/>
+        <result column="create_time" property="createTime"/>
+        <result column="update_user_id" property="updateUserId"/>
+        <result column="update_time" property="updateTime"/>
+        <result column="order_id" property="orderId"/>
+        <result column="goods_id" property="goodsId"/>
+        <result column="goods_num" property="goodsNum"/>
+        <result column="goods_name" property="goodsName"/>
+        <result column="goods_price" property="goodsPrice"/>
+        <result column="goods_image" property="goodsImage"/>
+        <result column="goods_no" property="goodsNo"/>
+        <result column="shop_id" property="shopId"/>
+        <result column="store_name" property="storeName"/>
+        <result column="device_id" property="deviceId"/>
+        <result column="merchant_id" property="merchantId"/>
+        <result column="user_id" property="userId"/>
+        <result column="cargo_way_id" property="cargoWayId"/>
+        <result column="shipping_time" property="shippingTime"/>
+    </resultMap>
+
+
+    <select id="selectOrderGoodsPage" resultMap="orderGoodsResultMap">
+        select * from t_order_goods where is_delete = 0
+    </select>
+
+</mapper>

+ 41 - 0
src/main/java/org/springblade/modules/finance/service/IOrderGoodsService.java

@@ -0,0 +1,41 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.finance.service;
+
+import org.springblade.modules.finance.entity.OrderGoods;
+import org.springblade.modules.finance.vo.OrderGoodsVO;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+
+/**
+ * 商品订单表 服务类
+ *
+ * @author BladeX
+ * @since 2024-07-17
+ */
+public interface IOrderGoodsService extends IService<OrderGoods> {
+
+	/**
+	 * 自定义分页
+	 *
+	 * @param page
+	 * @param orderGoods
+	 * @return
+	 */
+	IPage<OrderGoodsVO> selectOrderGoodsPage(IPage<OrderGoodsVO> page, OrderGoodsVO orderGoods);
+
+}

+ 111 - 0
src/main/java/org/springblade/modules/finance/service/impl/OrderGoodsServiceImpl.java

@@ -0,0 +1,111 @@
+package org.springblade.modules.finance.service.impl;
+
+import cn.hutool.core.lang.Assert;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import lombok.AllArgsConstructor;
+import org.springblade.modules.api.request.SubmitOrderRequest;
+import org.springblade.modules.api.service.SubmitOrderService;
+import org.springblade.modules.business.entity.FacilityCargoWay;
+import org.springblade.modules.business.entity.Shop;
+import org.springblade.modules.business.service.IFacilityCargoWayService;
+import org.springblade.modules.business.service.IShopService;
+import org.springblade.modules.finance.entity.Order;
+import org.springblade.modules.finance.entity.OrderGoods;
+import org.springblade.modules.finance.service.IOrderService;
+import org.springblade.modules.finance.vo.OrderGoodsVO;
+import org.springblade.modules.finance.mapper.OrderGoodsMapper;
+import org.springblade.modules.finance.service.IOrderGoodsService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springblade.modules.mall.entity.GoodsInfo;
+import org.springblade.modules.mall.service.IGoodsInfoService;
+import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.math.BigDecimal;
+
+/**
+ * 商品订单表 服务实现类
+ *
+ * @author BladeX
+ * @since 2024-07-17
+ */
+@AllArgsConstructor
+@Service
+public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper, OrderGoods> implements IOrderGoodsService, SubmitOrderService {
+
+	private final IOrderService iOrderService;
+	private final IGoodsInfoService iGoodsInfoService;
+	private final IFacilityCargoWayService iFacilityCargoWayService;
+	private final IShopService iShopService;
+
+	@Override
+	public IPage<OrderGoodsVO> selectOrderGoodsPage(IPage<OrderGoodsVO> page, OrderGoodsVO orderGoods) {
+		return page.setRecords(baseMapper.selectOrderGoodsPage(page, orderGoods));
+	}
+
+	@Transactional
+	@Override
+	public String submitOrder(SubmitOrderRequest request) {
+		GoodsInfo goods = iGoodsInfoService.getById(request.getGoodsInfoId());
+		Assert.notNull(goods, "商品信息不存在");
+		FacilityCargoWay cargoWay = iFacilityCargoWayService.getById(request.getCargoWayId());
+		Assert.notNull(cargoWay, "货道信息不存在");
+		Shop shop = iShopService.getById(request.getShopId());
+		Assert.notNull(shop, "门店信息不存在");
+
+		// 订单初始化
+		Order order = iOrderService.init();
+		order.setOrderType(request.getOrderType());
+		order.setOrderType(request.getOrderType());
+		order.setSource(request.getOrderSource());
+		order.setUserId(request.getUserId());
+		// 订单总金额
+		order.setTotalAmount(cargoWay.getSalePrice().multiply(BigDecimal.valueOf(request.getGoodsNum())));
+		// 实付金额
+		BigDecimal payAmount = cargoWay.getSalePrice().multiply(BigDecimal.valueOf(cargoWay.getDiscount())).multiply(BigDecimal.valueOf(request.getGoodsNum()));
+		order.setPaymentAmount(payAmount);
+		order.setDiscountAmount(order.getTotalAmount().subtract(order.getPaymentAmount()));
+		iOrderService.save(order);
+
+		OrderGoods orderGoods = new OrderGoods();
+		orderGoods.setOrderId(order.getId());
+		orderGoods.setGoodsNum(request.getGoodsNum());
+		orderGoods.setDeviceId(request.getDeviceId());
+		orderGoods.setGoodsName(goods.getGoodsName());
+		orderGoods.setCargoWayId(request.getCargoWayId());
+		orderGoods.setGoodsNo(goods.getGoodsNo());
+		orderGoods.setGoodsImage(goods.getGoodsCover());
+		orderGoods.setGoodsId(request.getGoodsInfoId());
+		orderGoods.setGoodsPrice(cargoWay.getSalePrice());
+		orderGoods.setMerchantId(shop.getMerchantId());
+		orderGoods.setShopId(request.getShopId());
+		orderGoods.setUserId(request.getUserId());
+		baseMapper.insert(orderGoods);
+
+		// 扣减货道库存
+		cargoWay.setGoodsStore(cargoWay.getGoodsStore() - request.getGoodsNum());
+		iFacilityCargoWayService.updateById(cargoWay);
+		return order.getOrderNo();
+	}
+
+
+	@Override
+	public void releaseGoodsStock(Order order) {
+		OrderGoods orderGoods = baseMapper.selectOne(Wrappers.lambdaQuery(OrderGoods.class).eq(OrderGoods::getOrderId, order.getId()));
+		// 更新货道库存
+		FacilityCargoWay cargoWay = iFacilityCargoWayService.getById(orderGoods.getCargoWayId());
+		cargoWay.setGoodsStore(cargoWay.getGoodsStore() + orderGoods.getGoodsNum());
+		iFacilityCargoWayService.updateById(cargoWay);
+	}
+
+	@Override
+	public void paySuccessAfter(Order order) {
+		OrderGoods orderGoods = baseMapper.selectOne(Wrappers.lambdaQuery(OrderGoods.class).eq(OrderGoods::getOrderId, order.getId()));
+		// 更新货道销售信息
+		FacilityCargoWay cargoWay = iFacilityCargoWayService.getById(orderGoods.getCargoWayId());
+		cargoWay.setTotalTrade(cargoWay.getTotalTrade() + orderGoods.getGoodsNum());
+		cargoWay.setTotalAmount(cargoWay.getTotalAmount().add(order.getPaymentAmount()));
+		iFacilityCargoWayService.updateById(cargoWay);
+	}
+}

+ 36 - 0
src/main/java/org/springblade/modules/finance/vo/OrderGoodsVO.java

@@ -0,0 +1,36 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.finance.vo;
+
+import org.springblade.modules.finance.entity.OrderGoods;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import io.swagger.annotations.ApiModel;
+
+/**
+ * 商品订单表视图实体类
+ *
+ * @author BladeX
+ * @since 2024-07-17
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ApiModel(value = "OrderGoodsVO对象", description = "商品订单表")
+public class OrderGoodsVO extends OrderGoods {
+	private static final long serialVersionUID = 1L;
+
+}

+ 49 - 0
src/main/java/org/springblade/modules/finance/wrapper/OrderGoodsWrapper.java

@@ -0,0 +1,49 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.modules.finance.wrapper;
+
+import org.springblade.core.mp.support.BaseEntityWrapper;
+import org.springblade.core.tool.utils.BeanUtil;
+import org.springblade.modules.finance.entity.OrderGoods;
+import org.springblade.modules.finance.vo.OrderGoodsVO;
+import java.util.Objects;
+
+/**
+ * 商品订单表包装类,返回视图层所需的字段
+ *
+ * @author BladeX
+ * @since 2024-07-17
+ */
+public class OrderGoodsWrapper extends BaseEntityWrapper<OrderGoods, OrderGoodsVO>  {
+
+	public static OrderGoodsWrapper build() {
+		return new OrderGoodsWrapper();
+ 	}
+
+	@Override
+	public OrderGoodsVO entityVO(OrderGoods orderGoods) {
+		OrderGoodsVO orderGoodsVO = Objects.requireNonNull(BeanUtil.copy(orderGoods, OrderGoodsVO.class));
+
+		//User createUser = UserCache.getUser(orderGoods.getCreateUser());
+		//User updateUser = UserCache.getUser(orderGoods.getUpdateUser());
+		//orderGoodsVO.setCreateUserName(createUser.getName());
+		//orderGoodsVO.setUpdateUserName(updateUser.getName());
+
+		return orderGoodsVO;
+	}
+
+}

+ 3 - 0
src/main/java/org/springblade/modules/mall/vo/GoodsInfoVO.java

@@ -51,6 +51,9 @@ public class GoodsInfoVO extends GoodsInfo {
 
 	private BigDecimal grouponPrice;
 
+	@ApiModelProperty(value = "货道id")
+	private Long cargoWayId;
+
 	public String getAuditStatusDesc() {
 		return AuditStatusEnum.getNameByValue(this.getAuditStatus());
 	}

+ 10 - 0
src/main/java/sql/ordergoods.menu.mysql

@@ -0,0 +1,10 @@
+INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
+VALUES ('1813427754432028679', 1123598815738675201, 'ordergoods', '商品订单表', 'menu', '/finance/ordergoods', NULL, 1, 1, 0, 1, NULL, 0);
+INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
+VALUES ('1813427754432028680', '1813427754432028679', 'ordergoods_add', '新增', 'add', '/finance/ordergoods/add', 'plus', 1, 2, 1, 1, NULL, 0);
+INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
+VALUES ('1813427754432028681', '1813427754432028679', 'ordergoods_edit', '修改', 'edit', '/finance/ordergoods/edit', 'form', 2, 2, 2, 1, NULL, 0);
+INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
+VALUES ('1813427754432028682', '1813427754432028679', 'ordergoods_delete', '删除', 'delete', '/api/finance/ordergoods/remove', 'delete', 3, 2, 3, 1, NULL, 0);
+INSERT INTO `blade_menu`(`id`, `parent_id`, `code`, `name`, `alias`, `path`, `source`, `sort`, `category`, `action`, `is_open`, `remark`, `is_deleted`)
+VALUES ('1813427754432028683', '1813427754432028679', 'ordergoods_view', '查看', 'view', '/finance/ordergoods/view', 'file-text', 4, 2, 2, 1, NULL, 0);

+ 0 - 16
src/main/resources/templates/controller.java.vm

@@ -1,19 +1,3 @@
-/*
- *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
- *
- *  Redistribution and use in source and binary forms, with or without
- *  modification, are permitted provided that the following conditions are met:
- *
- *  Redistributions of source code must retain the above copyright notice,
- *  this list of conditions and the following disclaimer.
- *  Redistributions in binary form must reproduce the above copyright
- *  notice, this list of conditions and the following disclaimer in the
- *  documentation and/or other materials provided with the distribution.
- *  Neither the name of the dreamlu.net developer nor the names of its
- *  contributors may be used to endorse or promote products derived from
- *  this software without specific prior written permission.
- *  Author: Chill 庄骞 (smallchill@163.com)
- */
 package $!{package.Controller};
 
 import io.swagger.annotations.Api;