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