This commit is contained in:
Cauchy
2023-10-23 17:41:38 +08:00
parent 3a59fdb860
commit 167d2de1bd
5 changed files with 85 additions and 21 deletions

View File

@@ -351,8 +351,10 @@ public class BuyOrderController {
* 删除 * 删除
*/ */
@RequestMapping("/delete") @RequestMapping("/delete")
public R delete(@RequestBody Integer[] orderIds) { public R delete(@RequestBody List<String> orderSnList) {
buyOrderService.removeByIds(Arrays.asList(orderIds)); QueryWrapper<BuyOrder> queryWrapper = new QueryWrapper<>();
queryWrapper.in("order_sn", orderSnList);
buyOrderService.remove(queryWrapper);
return R.ok(); return R.ok();
} }
@@ -389,6 +391,39 @@ public class BuyOrderController {
return R.ok(); return R.ok();
} }
/**
* app 端 取消订单
*/
// @RequestMapping("/cancelOrder")
// @Transactional
// public R appDelete(@RequestParam("orderSn") String orderSn) {
// QueryWrapper<BuyOrder> qu
//
// //1. 判断订单状态
// BuyOrder byId = buyOrderService.getById(orderId);
// if (byId != null) {
// //2. 判断当前订单是否存在优惠券 进行 回显
// Integer couponId = byId.getCouponId();
// if (couponId != null) {
//
// CouponHistoryEntity byId1 = couponHistoryService.getById(couponId);
// byId1.setUseStatus(0);
// couponHistoryService.updateById(byId1);
// }
// // 库存回滚
// List<BuyOrderDetail> buyOrderDetailEntities = buyOrderDetailService.getBaseMapper().selectList(new QueryWrapper<BuyOrderDetail>()
// .eq("order_id", byId.getOrderId()));
// for (BuyOrderDetail buyOrderDetailEntity : buyOrderDetailEntities) {
// Integer productId = buyOrderDetailEntity.getProductId();
// ShopProduct product = shopProductService.getById(productId);
// product.setProductStock(product.getProductStock() + buyOrderDetailEntity.getQuantity());
// shopProductService.updateById(product);
// }
// buyOrderService.removeById(orderId);
// }
// return R.ok();
// }
/** /**
* 充值专用订单生成接口 * 充值专用订单生成接口

View File

@@ -2,6 +2,7 @@ package com.peanut.modules.book.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.peanut.common.utils.R; import com.peanut.common.utils.R;
import com.peanut.modules.book.entity.BuyOrder; import com.peanut.modules.book.entity.BuyOrder;
import com.peanut.modules.book.entity.BuyOrderProduct; import com.peanut.modules.book.entity.BuyOrderProduct;
@@ -11,14 +12,14 @@ import com.peanut.modules.book.service.BuyOrderService;
import com.peanut.modules.book.service.ExpressCompanyService; import com.peanut.modules.book.service.ExpressCompanyService;
import com.peanut.modules.book.service.ExpressOrderService; import com.peanut.modules.book.service.ExpressOrderService;
import com.peanut.modules.book.vo.ExpressCompanyVo; import com.peanut.modules.book.vo.ExpressCompanyVo;
import com.peanut.modules.book.vo.response.PrintTemplateVo;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList; import java.util.*;
import java.util.List;
/** /**
* @Description: 快递 Controller * @Description: 快递 Controller
@@ -56,25 +57,31 @@ public class ExpressController {
* @return * @return
*/ */
@RequestMapping(path = "/getPrintTemplateList", method = RequestMethod.GET) @RequestMapping(path = "/getPrintTemplateList", method = RequestMethod.GET)
public R getPrintTemplate(String orderSn) { public R getPrintTemplate(@RequestParam(value = "expressOrderSn", required = false) String expressOrderSn,
QueryWrapper<BuyOrder> queryWrapper = new QueryWrapper<>(); @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
queryWrapper.eq("order_sn", orderSn); @RequestParam(value = "currentPage", defaultValue = "1") Integer currentPage) {
BuyOrder buyOrder = buyOrderService.getOne(queryWrapper); Page<ExpressOrder> expressOrderPage = new Page<>(currentPage, pageSize);
QueryWrapper<BuyOrderProduct> buyOrderProductQueryWrapper = new QueryWrapper<>();
buyOrderProductQueryWrapper.eq("order_id", buyOrder.getOrderId());
List<BuyOrderProduct> buyOrderProductList = buyOrderProductService.list(buyOrderProductQueryWrapper);
List<Integer> expressOrderIdList = new ArrayList<>();
for (BuyOrderProduct buyOrderProduct : buyOrderProductList) {
expressOrderIdList.add(buyOrderProduct.getExpressOrderId());
}
QueryWrapper<ExpressOrder> expressOrderQueryWrapper = new QueryWrapper<>(); QueryWrapper<ExpressOrder> expressOrderQueryWrapper = new QueryWrapper<>();
expressOrderQueryWrapper.in("id", expressOrderIdList); if (expressOrderSn != null) {
expressOrderQueryWrapper.select("print_template"); expressOrderQueryWrapper.eq("express_order_sn", expressOrderSn);
List<ExpressOrder> expressOrderList = expressOrderService.list(expressOrderQueryWrapper);
List<String> result = new ArrayList<>();
for (ExpressOrder expressOrder : expressOrderList) {
result.add(expressOrder.getPrintTemplate());
} }
int totalDataSize = expressOrderService.count(expressOrderQueryWrapper);
int totalPage = totalDataSize / pageSize + 1;
Page<ExpressOrder> page = expressOrderService.page(expressOrderPage, expressOrderQueryWrapper);
List<ExpressOrder> expressOrderList = page.getRecords();
List<PrintTemplateVo> data = new ArrayList<>();
for (ExpressOrder expressOrder : expressOrderList) {
PrintTemplateVo vo = new PrintTemplateVo();
vo.setPrintTemplate(expressOrder.getPrintTemplate());
vo.setExpressOrderSn(expressOrder.getExpressOrderSn());
data.add(vo);
}
Map<String, Object> result = new HashMap<>();
result.put("data", data);
result.put("currentPage", currentPage);
result.put("pageSize", pageSize);
result.put("totalDataSize", totalDataSize);
result.put("totalPage", totalPage);
return R.ok().put("result", result); return R.ok().put("result", result);
} }

View File

@@ -405,6 +405,7 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
MyUserEntity user = myUserService.getOne(userEntityQueryWrapper); MyUserEntity user = myUserService.getOne(userEntityQueryWrapper);
if (user != null) { if (user != null) {
UserResponseVo userResponseVo = new UserResponseVo(); UserResponseVo userResponseVo = new UserResponseVo();
userResponseVo.setUserId(user.getId());
userResponseVo.setUserPhone(user.getTel()); userResponseVo.setUserPhone(user.getTel());
if (user.getName() != null) { if (user.getName() != null) {
userResponseVo.setUserName(user.getName()); userResponseVo.setUserName(user.getName());

View File

@@ -0,0 +1,20 @@
package com.peanut.modules.book.vo.response;
import lombok.Data;
/**
* @Description: 面单响应 value object
* @Author: Cauchy
* @CreateTime: 2023/10/23
*/
@Data
public class PrintTemplateVo {
/**
* 快递单号
*/
private String expressOrderSn;
/**
* 面单
*/
private String printTemplate;
}

View File

@@ -9,6 +9,7 @@ import lombok.Data;
*/ */
@Data @Data
public class UserResponseVo { public class UserResponseVo {
private Integer userId;
/** /**
* 用户姓名 * 用户姓名
*/ */