商品导出

This commit is contained in:
gong
2026-01-29 09:42:50 +08:00
parent 66d3c8ad0b
commit 2d15315b79
6 changed files with 354 additions and 33 deletions

View File

@@ -27,6 +27,7 @@ import com.czg.validator.group.InsertGroup;
import com.czg.validator.group.UpdateGroup;
import com.mybatisflex.core.paginate.Page;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -80,6 +81,14 @@ public class ProductController {
return CzgResult.success(map);
}
/**
* 导出商品
*/
@GetMapping("export")
public void exportProduct(ProductDTO param, HttpServletResponse response) {
productService.exportProductList(param, response);
}
/**
* 商品-列表
*/
@@ -91,9 +100,7 @@ public class ProductController {
param.setShopId(shopId);
List<ProductDTO> productList = productService.getProductCacheList(param);
productService.refreshProductStock(param, productList);
productList.forEach(prod -> {
prod.setIsSaleTime(uProductService.calcIsSaleTime(prod.getDays(), prod.getStartTime(), prod.getEndTime()));
});
productList.forEach(prod -> prod.setIsSaleTime(uProductService.calcIsSaleTime(prod.getDays(), prod.getStartTime(), prod.getEndTime())));
return CzgResult.success(productList);
}
@@ -124,9 +131,7 @@ public class ProductController {
dto.setShopId(shopId);
productService.addProduct(dto);
asyncProductToShop(dto.getId());
ThreadUtil.execAsync(() -> {
rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId));
});
ThreadUtil.execAsync(() -> rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId)));
return CzgResult.success();
}
@@ -153,9 +158,7 @@ public class ProductController {
dto.setShopId(shopId);
productService.updateProduct(dto);
asyncProductToShop(dto.getId());
ThreadUtil.execAsync(() -> {
rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId));
});
ThreadUtil.execAsync(() -> rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId)));
return CzgResult.success();
}
@@ -167,9 +170,7 @@ public class ProductController {
Long shopId = StpKit.USER.getShopId();
param.setShopId(shopId);
productService.updateProductStock(param);
ThreadUtil.execAsync(() -> {
rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId));
});
ThreadUtil.execAsync(() -> rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId)));
return CzgResult.success();
}
@@ -188,9 +189,7 @@ public class ProductController {
Long shopId = StpKit.USER.getShopId();
productService.deleteProduct(shopId, id);
asyncProductToShop(id);
ThreadUtil.execAsync(() -> {
rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId));
});
ThreadUtil.execAsync(() -> rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId)));
return CzgResult.success();
}
@@ -205,9 +204,7 @@ public class ProductController {
Long shopId = StpKit.USER.getShopId();
param.setShopId(shopId);
productService.onOffProduct(param);
ThreadUtil.execAsync(() -> {
rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId));
});
ThreadUtil.execAsync(() -> rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId)));
return CzgResult.success();
}
@@ -222,9 +219,7 @@ public class ProductController {
Long shopId = StpKit.USER.getShopId();
param.setShopId(shopId);
productService.markProductIsSoldOut(param);
ThreadUtil.execAsync(() -> {
rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId));
});
ThreadUtil.execAsync(() -> rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId)));
return CzgResult.success();
}
@@ -321,9 +316,7 @@ public class ProductController {
if (shopInfo.getMainId() == null || shopId == shopInfo.getMainId()) {
throw new CzgException("不存在主子店铺关系,无需同步商品信息");
}
ThreadUtil.execAsync(() -> {
shopSyncService.sync(shopInfo.getMainId(), shopId, shopId);
});
ThreadUtil.execAsync(() -> shopSyncService.sync(shopInfo.getMainId(), shopId, shopId));
CzgResult<Void> ret = CzgResult.success();
ret.setMsg("操作成功,数据正在后台同步中...");
return ret;
@@ -331,15 +324,11 @@ public class ProductController {
private void asyncProductToShop(Long id) {
long shopId = StpKit.USER.getShopId(0L);
ThreadUtil.execAsync(() -> {
shopSyncService.syncProductBySourceShop(shopId, id, shopId);
});
ThreadUtil.execAsync(() -> shopSyncService.syncProductBySourceShop(shopId, id, shopId));
}
private void asyncConsProToShop(Long id) {
long shopId = StpKit.USER.getShopId(0L);
ThreadUtil.execAsync(() -> {
shopSyncService.syncConsProBySourceShop(shopId, id, shopId);
});
ThreadUtil.execAsync(() -> shopSyncService.syncConsProBySourceShop(shopId, id, shopId));
}
}