管理员通过后台,在订单管理页面实现手动录入订单的功能。

main
zhangshengli 4 months ago
parent 77b4e8ad22
commit d0f2a9f976

@ -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
*
* <p>
* 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<OrderGoodsDto> goods = orderInfo.getGoods();
if (ObjectUtil.isNotEmpty(goods)) {
goods.forEach(s -> {
MtOrderGoods bean = BeanUtil.toBean(s, MtOrderGoods.class);
mtOrderGoodsMapper.insert(bean);
});
}
return getSuccessResult(true);
}
}

Loading…
Cancel
Save