refactor project

This commit is contained in:
Cauchy
2023-10-19 15:04:31 +08:00
parent 19a2ef58a9
commit 1994ba60ae
35 changed files with 274 additions and 226 deletions

View File

@@ -79,15 +79,15 @@ public class BuyOrderController {
private SysConfigService sysConfigService;
/**
* 列表
* 订单列表
*
* @param params
* @return
* @throws Exception
*/
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params) throws Exception {
if ("all".equals(params.get("orderStatus"))) {
params.remove("orderStatus");
}
PageUtils page = buyOrderService.queryPage(params);
PageUtils page = buyOrderService.list(params);
return R.ok().put("page", page);
}
@@ -108,7 +108,7 @@ public class BuyOrderController {
for (BuyOrderDetail buyOrderDetail : buyOrderDetails) {
Integer productId = buyOrderDetail.getProductId();
int quantity = buyOrderDetail.getQuantity();
ShopProductEntity product = shopProductService.getById(productId);
ShopProduct product = shopProductService.getById(productId);
BigDecimal price = getRealPrice(product);
if (!handleStock(buyOrderDetail, product)) {
return R.error(500, "库存不足");
@@ -137,7 +137,8 @@ public class BuyOrderController {
vo = userAddressService.getAddressName(vo, userAddress.getRegionCode());
buyOrder.setProvince(vo.getProvince());
buyOrder.setCity(vo.getCity());
buyOrder.setDistrict(vo.getCity());
buyOrder.setDistrict(vo.getCounty());
buyOrder.setAddress(vo.getDetailAddress());
buyOrderService.save(buyOrder);
for (BuyOrderDetail buyOrderDetail : buyOrderDetails) {
@@ -187,7 +188,7 @@ public class BuyOrderController {
List<ProductRequestVo> products = vo.getProducts();
BigDecimal totalWeight = new BigDecimal(0);
for (ProductRequestVo product : products) {
ShopProductEntity shopProduct = shopProductService.getById(product.getProductId());
ShopProduct shopProduct = shopProductService.getById(product.getProductId());
BigDecimal weight = BigDecimal.valueOf(Double.valueOf(shopProduct.getWeight()) / 1000.0);
totalWeight = totalWeight.add(weight.multiply(new BigDecimal(product.getQuantity())));
}
@@ -204,7 +205,7 @@ public class BuyOrderController {
*/
@RequestMapping("/getMyOrderList")
public R getMyOrderList(@RequestParam Map<String, Object> params) {
PageUtils page = buyOrderService.queryPage1(params);
PageUtils page = buyOrderService.getMyOrderList(params);
return R.ok().put("page", page);
}
@@ -251,7 +252,7 @@ public class BuyOrderController {
.eq("order_id", byId.getOrderId()));
for (BuyOrderDetail buyOrderDetailEntity : buyOrderDetailEntities) {
Integer productId = buyOrderDetailEntity.getProductId();
ShopProductEntity product = shopProductService.getById(productId);
ShopProduct product = shopProductService.getById(productId);
product.setProductStock(product.getProductStock() + buyOrderDetailEntity.getQuantity());
shopProductService.updateById(product);
}
@@ -319,7 +320,7 @@ public class BuyOrderController {
List<BuyOrderDetail> buyOrderDetailList = buyOrderDetailService.list(queryWrapper);
for (BuyOrderDetail buyOrderDetail : buyOrderDetailList) {
ShopProductEntity prod = shopProductService.getById(buyOrderDetail.getProductId());
ShopProduct prod = shopProductService.getById(buyOrderDetail.getProductId());
if (prod != null) {
buyOrderDetail.setImage(prod.getProductImages());
}
@@ -392,10 +393,10 @@ public class BuyOrderController {
* @param buyOrderDetailId 订单详情列表
* @return R
*/
@RequestMapping(value = "/createSplitPackages", method = RequestMethod.POST)
public R createSplitPackageOrder(@RequestParam("expressCompanyCode") String expressCompanyCode,
@RequestBody List<Integer> buyOrderDetailId) throws Exception {
buyOrderService.createSplitPackageOrder(expressCompanyCode, buyOrderDetailId);
@RequestMapping(value = "/delivery", method = RequestMethod.POST)
public R delivery(@RequestParam("expressCompanyCode") String expressCompanyCode,
@RequestBody List<Integer> buyOrderDetailId) throws Exception {
buyOrderService.delivery(expressCompanyCode, buyOrderDetailId);
return R.ok();
}
@@ -406,7 +407,7 @@ public class BuyOrderController {
* @param product 商品信息
* @return 商品实际价格
*/
private BigDecimal getRealPrice(ShopProductEntity product) {
private BigDecimal getRealPrice(ShopProduct product) {
BigDecimal activityPrice = product.getActivityPrice();
return (activityPrice == null || activityPrice.equals(BigDecimal.ZERO)) ? product.getPrice() : activityPrice;
}
@@ -418,7 +419,7 @@ public class BuyOrderController {
* @param product
* @return
*/
private boolean handleStock(BuyOrderDetail buyOrderDetail, ShopProductEntity product) {
private boolean handleStock(BuyOrderDetail buyOrderDetail, ShopProduct product) {
int quantity = buyOrderDetail.getQuantity();
if (product.getProductStock() - quantity < 0) {
return false;