| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- package com.izouma.tcg.web.orderInfo;
- import com.izouma.tcg.domain.card.CardBox;
- import com.izouma.tcg.dto.OrderInfoDTO;
- import com.izouma.tcg.enums.OrderStatus;
- import com.izouma.tcg.repo.card.CardBoxRepo;
- import com.izouma.tcg.utils.LogisticsQueryResponse;
- import com.izouma.tcg.web.BaseController;
- import com.izouma.tcg.domain.orderInfo.OrderInfo;
- import com.izouma.tcg.service.orderInfo.OrderInfoService;
- import com.izouma.tcg.dto.PageQuery;
- import com.izouma.tcg.exception.BusinessException;
- import com.izouma.tcg.repo.orderInfo.OrderInfoRepo;
- import com.izouma.tcg.utils.ObjUtils;
- import com.izouma.tcg.utils.excel.ExcelUtils;
- import io.swagger.annotations.ApiModel;
- import io.swagger.annotations.ApiOperation;
- import lombok.AllArgsConstructor;
- import org.apache.commons.beanutils.ConvertUtils;
- import org.springframework.data.domain.Page;
- import org.springframework.security.access.prepost.PreAuthorize;
- import org.springframework.web.bind.annotation.*;
- import javax.print.DocFlavor;
- import javax.servlet.http.HttpServletResponse;
- import javax.transaction.Transaction;
- import java.io.IOException;
- import java.util.Arrays;
- import java.util.List;
- import java.util.Map;
- @RestController
- @RequestMapping("/orderInfo")
- @AllArgsConstructor
- public class OrderInfoController extends BaseController {
- private OrderInfoService orderInfoService;
- private OrderInfoRepo orderInfoRepo;
- private CardBoxRepo cardBoxRepo;
- //@PreAuthorize("hasRole('ADMIN')")
- @PostMapping("/save")
- public OrderInfo save(@RequestBody OrderInfo record) {
- if (record.getId() != null) {
- OrderInfo orig = orderInfoRepo.findById(record.getId()).orElseThrow(new BusinessException("无记录"));
- ObjUtils.merge(orig, record);
- return orderInfoRepo.save(orig);
- }
- return orderInfoRepo.save(record);
- }
- //@PreAuthorize("hasRole('ADMIN')")
- @PostMapping("/all")
- public Page<OrderInfo> all(@RequestBody PageQuery pageQuery) {
- return orderInfoService.all(pageQuery);
- }
- @GetMapping("/get/{id}")
- public OrderInfo get(@PathVariable Long id) {
- OrderInfo orderInfo = orderInfoRepo.findById(id).orElseThrow(new BusinessException("无记录"));
- if (orderInfo.getCardBoxList().size() < 1 & orderInfo.getCardBoxStr() != null) {
- List<Long> boxIds = Arrays
- .asList((Long[]) ConvertUtils.convert(orderInfo.getCardBoxStr().split(","), Long.class));
- List<CardBox> cardBoxList = cardBoxRepo.findAllByIdIn(boxIds);
- orderInfo.setCardBoxList(cardBoxList);
- }
- return orderInfo;
- }
- @PostMapping("/del/{id}")
- public void del(@PathVariable Long id) {
- orderInfoRepo.softDelete(id);
- }
- @GetMapping("/excel")
- @ResponseBody
- public void excel(HttpServletResponse response, PageQuery pageQuery) throws IOException {
- List<OrderInfo> data = all(pageQuery).getContent();
- ExcelUtils.export(response, data);
- }
- @PostMapping("/createOrderInfo")
- @ApiOperation("创建订单")
- public OrderInfo create(String boxIds, Long caseId, String remark, Long userAddressId) {
- return orderInfoService.create(boxIds, caseId, remark, userAddressId);
- }
- @GetMapping("/showPreview")
- @ApiOperation(("展示订单预览"))
- public Map<String, Object> showPreview(String boxIds, Long caseId) {
- return orderInfoService.showPreview(boxIds, caseId);
- }
- @GetMapping("/checkBox")
- @ApiOperation(("展示订单预览"))
- public boolean checkBox(String boxIds, Long caseId) {
- return orderInfoService.checkBox(boxIds, caseId);
- }
- @PostMapping("/pay")
- @ApiOperation("完成支付")
- public void pay(Long orderInfoId, String transactionId) {
- orderInfoService.pay(orderInfoId, transactionId);
- }
- @PostMapping("/cancel")
- @ApiOperation("/取消订单")
- public void cancel(Long orderInfoId) {
- orderInfoService.cancel(orderInfoId);
- }
- @PostMapping("/finish")
- @ApiOperation("/完成订单")
- public void finish(Long orderInfoId, @RequestParam(required = false) String finish) {
- orderInfoService.confirm(orderInfoId, finish);
- }
- @PostMapping("/send")
- @ApiOperation("/订单送货")
- public void send(Long orderInfoId, String logisticNo, String type, String remark) {
- orderInfoService.send(orderInfoId, logisticNo, type, remark);
- }
- @GetMapping("/checkLogistic")
- @ApiOperation("/查询物流")
- public Map<String, Object> checkLogistic(Long orderInfoId) {
- return orderInfoService.checkLogistics(orderInfoId);
- }
- @GetMapping("/showMyOrderInfos")
- @ApiOperation("/展示订单列表")
- public List<OrderInfoDTO> showMyOrderInfos(Long userId, OrderStatus orderStatus, @RequestParam(required = false) Long orderInfoId, @RequestParam(required = false) Long storeId) {
- return orderInfoService.showMyOrderInfos(userId, orderStatus, orderInfoId);
- }
- @PostMapping("/refund")
- @ApiOperation("/展示订单列表")
- public void refund(Long orderInfoId, String remark) {
- orderInfoService.refund(orderInfoId, remark);
- }
- @PostMapping("/afterSale")
- @ApiOperation("/展示订单列表")
- public void afterSale(Long orderInfoId, String remark, List<String> images) {
- orderInfoService.newAfterSale(orderInfoId, remark, images);
- }
- @PostMapping("/remindMy")
- @ApiOperation("/展示订单列表")
- public void remindMy(Long orderInfoId, String remark) {
- }
- @PostMapping("/delete")
- @ApiOperation("/删除完成订单")
- public void delete(Long orderInfoId) {
- orderInfoService.delete(orderInfoId);
- }
- @PostMapping("/saveLogistic")
- @ApiOperation("/发货")
- public void delete(Long id, String logisticNo, @RequestParam(required = false) String logisticType) {
- orderInfoService.saveLogistic(id, logisticNo, logisticType);
- }
- }
|