before test

This commit is contained in:
Cauchy
2023-10-25 13:47:06 +08:00
parent 86027f543c
commit 7792024b15
6 changed files with 39 additions and 32 deletions

View File

@@ -19,17 +19,14 @@ public class Constants {
*/ */
public static final String ORDER_STATUS_SHIPPED = "2"; public static final String ORDER_STATUS_SHIPPED = "2";
/** /**
* 订单状态 - 已发货 * 订单状态 - 已完成
*/ */
public static final String ORDER_STATUS_FINISHED = "3"; public static final String ORDER_STATUS_FINISHED = "3";
/** /**
* 订单状态 - 交易失败 * 订单状态 - 交易失败
*/ */
public static final String ORDER_STATUS_FAIL = "4"; public static final String ORDER_STATUS_FAIL = "4";
/**
* 订单状态 - 已部分发货
*/
public static final String ORDER_STATUS_PART_SHIPPED = "5";
/** /**
* 订单状态 - 全部 * 订单状态 - 全部
*/ */

View File

@@ -89,9 +89,9 @@ public class BuyOrderController {
@Autowired @Autowired
private CountyService countyService; private CountyService countyService;
@RequestMapping(value = "/decomposeShipment", method = RequestMethod.GET) @RequestMapping(value = "/decomposeShipment", method = RequestMethod.POST)
public R decomposeShipment(@RequestParam("userId") Integer userId) { public R decomposeShipment(@RequestBody BuyOrderListRequestVo requestVo) {
Map<Integer, List<String>> result = buyOrderService.decomposeShipment(userId); Map<String, Object> result = buyOrderService.decomposeShipment(requestVo);
return R.ok().put("result", result); return R.ok().put("result", result);
} }

View File

@@ -10,11 +10,9 @@ 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 com.peanut.modules.book.vo.response.PrintTemplateVo;
import io.swagger.models.auth.In;
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.*;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@@ -83,11 +81,11 @@ public class ExpressController {
return R.ok().put("result", result); return R.ok().put("result", result);
} }
@RequestMapping(value = "/printTemplate", method = RequestMethod.GET) @RequestMapping(value = "/printTemplate", method = RequestMethod.POST)
public R printTemplate(@RequestParam("expressOrderId") Integer expressOrderId) { public R printTemplate(@RequestBody List<Integer> expressOrderIdList) {
UpdateWrapper<ExpressOrder> updateWrapper = new UpdateWrapper<>(); UpdateWrapper<ExpressOrder> updateWrapper = new UpdateWrapper<>();
updateWrapper.set("template_printed", 1); updateWrapper.set("template_printed", 1);
updateWrapper.eq("id", expressOrderId); updateWrapper.in("id", expressOrderIdList);
expressOrderService.update(updateWrapper); expressOrderService.update(updateWrapper);
return R.ok(); return R.ok();
} }

View File

@@ -40,7 +40,7 @@ public interface BuyOrderService extends IService<BuyOrder> {
* @param requestVo * @param requestVo
* @return * @return
*/ */
Map<String,Object> orderList(BuyOrderListRequestVo requestVo); Map<String, Object> orderList(BuyOrderListRequestVo requestVo);
/** /**
* 订单拆分发货 * 订单拆分发货
@@ -52,7 +52,7 @@ public interface BuyOrderService extends IService<BuyOrder> {
BuyOrderResponseVo orderDetail(String orderSn); BuyOrderResponseVo orderDetail(String orderSn);
Map<Integer, List<String>> decomposeShipment(Integer userId); Map<String, Object> decomposeShipment(BuyOrderListRequestVo requestVo);
} }

View File

@@ -236,24 +236,35 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
return userOrderVoList; return userOrderVoList;
} }
public Map<Integer, List<String>> decomposeShipment(Integer userId) { @Override
public Map<String, Object> decomposeShipment(BuyOrderListRequestVo requestVo) {
Page<BuyOrder> buyOrderPage = new Page<>();
List<BuyOrderResponseVo> data = new ArrayList<>();
BuyOrder requestBuyOrder = getById(requestVo.getOrderId());
Integer addressId = requestBuyOrder.getAddressId();
Integer userId = requestBuyOrder.getUserId();
QueryWrapper<BuyOrder> queryWrapper = new QueryWrapper<>(); QueryWrapper<BuyOrder> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("del_flag", 0); queryWrapper.eq("del_flag", 0);
queryWrapper.eq("order_status",1); queryWrapper.eq("order_status", Constants.ORDER_STATUS_TO_BE_SHIPPED);
queryWrapper.eq("userId", userId); queryWrapper.eq("user_id", userId);
queryWrapper.eq("address_id", addressId);
queryWrapper.eq("address_modified", 0); queryWrapper.eq("address_modified", 0);
List<BuyOrder> buyOrderList = list(queryWrapper); Integer totalSize = count(queryWrapper);
Map<Integer, List<String>> result = new HashMap<>(); Integer totalPage = totalSize / requestVo.getPageSize() + 1;
Page<BuyOrder> page = page(buyOrderPage, queryWrapper);
List<BuyOrder> buyOrderList = page.getRecords();
for (BuyOrder buyOrder : buyOrderList) { for (BuyOrder buyOrder : buyOrderList) {
if (result.containsKey(buyOrder.getAddressId())) { BuyOrderResponseVo responseVo = setBuyOrderInfo(buyOrder);
List<String> orderSnList = result.get(buyOrder.getAddressId()); data.add(responseVo);
orderSnList.add(buyOrder.getOrderSn());
} else {
List<String> orderSnList = new ArrayList<>();
result.put(buyOrder.getAddressId(), orderSnList);
}
} }
Map<String, Object> result = new HashMap<>();
result.put("totalDataSize", totalSize);
result.put("totalPage", totalPage);
result.put("data", data);
result.put("currentPage", requestVo.getPageIndex());
result.put("pageSize", requestVo.getPageSize());
return result; return result;
} }
/** /**
@@ -413,12 +424,9 @@ public class BuyOrderServiceImpl extends ServiceImpl<BuyOrderDao, BuyOrder> impl
int count = buyOrderProductService.count(buyOrderProductQueryWrapper); int count = buyOrderProductService.count(buyOrderProductQueryWrapper);
if (count == 0) { if (count == 0) {
buyorder.setOrderStatus(Constants.ORDER_STATUS_SHIPPED); buyorder.setOrderStatus(Constants.ORDER_STATUS_SHIPPED);
} else {
buyorder.setOrderStatus(Constants.ORDER_STATUS_PART_SHIPPED);
} }
} }
updateBatchById(buyOrderList); updateBatchById(buyOrderList);
} }
@Override @Override

View File

@@ -11,6 +11,10 @@ import java.util.Date;
*/ */
@Data @Data
public class BuyOrderListRequestVo { public class BuyOrderListRequestVo {
/**
* id
*/
private Integer orderId;
/** /**
* 页号 * 页号
*/ */