From d0f2a9f976b1838ebd7d84b46b4de73069e053f3 Mon Sep 17 00:00:00 2001 From: zhangshengli <18103773227@163.com> Date: Wed, 24 Jul 2024 17:51:21 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E9=80=9A=E8=BF=87?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=EF=BC=8C=E5=9C=A8=E8=AE=A2=E5=8D=95=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E9=A1=B5=E9=9D=A2=E5=AE=9E=E7=8E=B0=E6=89=8B=E5=8A=A8?= =?UTF-8?q?=E5=BD=95=E5=85=A5=E8=AE=A2=E5=8D=95=E7=9A=84=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/BackendOrderController.java | 85 ++++++++++++++++--- 1 file changed, 71 insertions(+), 14 deletions(-) diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendOrderController.java b/fuintBackend/fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendOrderController.java index 5f1ce85..4334e07 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendOrderController.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendOrderController.java @@ -1,25 +1,30 @@ package com.fuint.module.backendApi.controller; +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson2.JSONObject; import com.fuint.common.dto.*; import com.fuint.common.enums.*; import com.fuint.common.param.OrderListParam; import com.fuint.common.service.*; +import com.fuint.common.util.DateUtil; import com.fuint.common.util.TokenUtil; import com.fuint.framework.exception.BusinessCheckException; import com.fuint.framework.pagination.PaginationResponse; import com.fuint.framework.web.BaseController; import com.fuint.framework.web.ResponseObject; -import com.fuint.repository.model.MtSetting; -import com.fuint.repository.model.MtStore; -import com.fuint.repository.model.MtUser; -import com.fuint.repository.model.TAccount; +import com.fuint.repository.mapper.MtOrderGoodsMapper; +import com.fuint.repository.model.*; import com.fuint.utils.StringUtil; import com.fuint.utils.TimeUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; + import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; import java.util.ArrayList; @@ -30,11 +35,11 @@ import java.util.Date; /** * 订单管理controller - * + *

* Created by FSQ * CopyRight https://www.fuint.cn */ -@Api(tags="管理端-订单相关接口") +@Api(tags = "管理端-订单相关接口") @RestController @AllArgsConstructor @RequestMapping(value = "/backendApi/order") @@ -42,7 +47,7 @@ public class BackendOrderController extends BaseController { /** * 订单服务接口 - * */ + */ private OrderService orderService; /** @@ -52,12 +57,14 @@ public class BackendOrderController extends BaseController { /** * 会员服务接口 - * */ + */ private MemberService memberService; + private MtOrderGoodsMapper mtOrderGoodsMapper; + /** * 微信服务接口 - * */ + */ private WeixinService weixinService; /** @@ -67,7 +74,7 @@ public class BackendOrderController extends BaseController { /** * 配置服务接口 - * */ + */ private SettingService settingService; /** @@ -175,9 +182,10 @@ public class BackendOrderController extends BaseController { /** * 获取订单详情 + * * @param request HttpServletRequest对象 * @return - * */ + */ @ApiOperation(value = "获取订单详情") @RequestMapping(value = "/info/{orderId}", method = RequestMethod.GET) @CrossOrigin @@ -223,9 +231,10 @@ public class BackendOrderController extends BaseController { /** * 确认发货 + * * @param request HttpServletRequest对象 * @return - * */ + */ @ApiOperation(value = "确认发货") @RequestMapping(value = "/delivered", method = RequestMethod.POST) @CrossOrigin @@ -280,9 +289,10 @@ public class BackendOrderController extends BaseController { /** * 修改订单 + * * @param request HttpServletRequest对象 * @return - * */ + */ @ApiOperation(value = "修改订单") @RequestMapping(value = "/save", method = RequestMethod.POST) @CrossOrigin @@ -328,9 +338,10 @@ public class BackendOrderController extends BaseController { /** * 验证并核销订单 + * * @param request HttpServletRequest对象 * @return - * */ + */ @ApiOperation(value = "验证并核销订单") @RequestMapping(value = "/verify", method = RequestMethod.POST) @CrossOrigin @@ -366,6 +377,7 @@ public class BackendOrderController extends BaseController { /** * 最新订单列表查询 + * * @param request HttpServletRequest对象 * @return */ @@ -503,4 +515,49 @@ public class BackendOrderController extends BaseController { return getSuccessResult(true); } + + /** + * 新增订单 + * + * @param request HttpServletRequest对象 + * @return + */ + @ApiOperation(value = "新增订单") + @RequestMapping(value = "/saveOrder", method = RequestMethod.POST) + @CrossOrigin + @PreAuthorize("@pms.hasPermission('order:setting')") + @Transactional(rollbackFor = Exception.class) + public ResponseObject saveOrder(HttpServletRequest request, @RequestBody JSONObject param) { + String token = request.getHeader("Access-Token"); + AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token); + if (accountInfo == null) { + return getFailureResult(1001, "请先登录"); + } + UserOrderDto orderInfo = BeanUtil.toBean(param.getJSONObject("orderInfo"), UserOrderDto.class); + OrderUserDto userInfo = orderInfo.getUserInfo(); + orderInfo.setPayType(PayTypeEnum.CASH.getKey()); + orderInfo.setType(OrderTypeEnum.GOOGS.getKey()); + orderInfo.setOrderMode(OrderModeEnum.ONESELF.getKey()); + orderInfo.setOrderSn(IdUtil.fastSimpleUUID()); + orderInfo.setIsVerify(true); + orderInfo.setUsePoint(0); + orderInfo.setPointAmount(BigDecimal.ZERO); + orderInfo.setPayTime(DateUtil.formatDate(new Date(), DateUtil.PATTERN_ISO_DATETIME)); + orderInfo.setPayStatus(PayStatusEnum.SUCCESS.getKey()); + orderInfo.setSettleStatus("A"); + orderInfo.setUserId(userInfo.getId()); + MtOrder mtOrder = BeanUtil.toBean(orderInfo, MtOrder.class); + orderService.save(mtOrder); + List goods = orderInfo.getGoods(); + if (ObjectUtil.isNotEmpty(goods)) { + goods.forEach(s -> { + MtOrderGoods bean = BeanUtil.toBean(s, MtOrderGoods.class); + mtOrderGoodsMapper.insert(bean); + }); + } + return getSuccessResult(true); + + } + + }