44 Commits

Author SHA1 Message Date
ec1bc6a156 Merge branch 'test' into prod
# Conflicts:
#	cash-service/market-service/src/main/java/com/czg/service/market/service/impl/MkDistributionUserServiceImpl.java
#	cash-service/market-service/src/main/java/com/czg/service/market/service/impl/MkShareBaseServiceImpl.java
2026-01-31 16:22:16 +08:00
c9a432b786 分销等级配置
优惠券获得方式
2026-01-31 15:50:59 +08:00
0ebe2b1787 绑定问题 2026-01-31 15:39:55 +08:00
9a62fcaddf 邀请人列表 2026-01-31 15:34:33 +08:00
d58b4d9aed 邀请人列表 2026-01-31 15:27:44 +08:00
8dc7f3e8f1 上下级关系4 2026-01-31 15:08:21 +08:00
ab955c6b8a 上下级关系3 2026-01-31 15:05:28 +08:00
76567aef53 上下级关系2 2026-01-31 15:00:46 +08:00
36ab1ae3c2 商户余额更新 2026-01-31 14:52:25 +08:00
d9143f9b82 店铺Id类型转换问题 2026-01-31 14:46:25 +08:00
9c5b8ea53f 分销关系 2026-01-31 14:37:03 +08:00
gong
77334e3e73 暂时不用原生进件 删除定时任务 2026-01-31 14:23:02 +08:00
gong
c9e154299b 当日总销售额不正确问题 2026-01-31 14:14:01 +08:00
gong
0d4b1ace60 统计数据导出 2026-01-31 14:06:23 +08:00
a74e099346 绑定上下级 2026-01-31 11:40:24 +08:00
d6d6477c6d 绑定上下级 2026-01-31 11:34:32 +08:00
e3f58e41ca 邀请时间 2026-01-31 11:09:26 +08:00
c04a5b8fb1 绑定关系 2026-01-31 10:20:48 +08:00
ccc18fc229 分销等级配置
优惠券获得方式
2026-01-31 09:56:29 +08:00
gong
f92a593ff8 单位-分类导出 2026-01-30 18:24:32 +08:00
4a6af60352 分享配置
全民股东群聊配置
2026-01-30 17:02:49 +08:00
f32212928a Merge branch 'test' into prod
# Conflicts:
#	cash-api/order-server/src/main/java/com/czg/controller/pay/OrderPayController.java
2026-01-30 16:02:25 +08:00
gong
c974f9e092 报错 2026-01-30 14:38:31 +08:00
gong
496c931678 商品导出 2026-01-30 14:13:02 +08:00
73929aaac5 轮播图开关
获取地址 环境标识
2026-01-30 09:49:18 +08:00
7d640b4f9c 支付问题 2026-01-29 17:57:18 +08:00
3fd032c1d0 OPTIONS放行 2026-01-29 17:34:31 +08:00
6b0423a2ba saToken认证 2026-01-29 17:24:44 +08:00
9c69c8dcbc OPTIONS请求放行 2026-01-29 17:11:28 +08:00
19ed77b35b 扫码支付方式 2026-01-29 14:47:27 +08:00
6238260b3b 扫码支付方式 2026-01-29 14:47:09 +08:00
bac24f9ba1 去重 2026-01-29 11:22:28 +08:00
6c41777b7c 任务执行 耗时 2026-01-29 10:26:54 +08:00
87e89721d8 Merge remote-tracking branch 'origin/test' into test 2026-01-29 10:14:05 +08:00
2b594193ee 分享领取 2026-01-29 10:13:46 +08:00
gong
d71819bd08 微信进件修改 2026-01-29 09:46:57 +08:00
gong
fcd70b24a8 Merge remote-tracking branch 'origin/test' into test 2026-01-29 09:42:59 +08:00
gong
2d15315b79 商品导出 2026-01-29 09:42:50 +08:00
abcd0fbc7b 不知道 2026-01-28 17:27:54 +08:00
fc8599d36c 空指针 2026-01-28 17:07:50 +08:00
66d3c8ad0b 用户端获取分享的基础配置 2026-01-28 14:40:54 +08:00
abdbe89082 Merge remote-tracking branch 'origin/test' into test 2026-01-28 14:40:06 +08:00
e3887148c1 用户端获取分享的基础配置 2026-01-28 14:39:55 +08:00
d1dd806204 微信 获取token 2026-01-28 09:32:58 +08:00
58 changed files with 1140 additions and 508 deletions

View File

@@ -8,10 +8,11 @@ import com.czg.account.vo.HandoverProductListVo;
import com.czg.account.vo.HandoverTotalVo;
import com.czg.annotation.SaAdminCheckPermission;
import com.czg.constants.SystemConstants;
import com.czg.excel.ExcelExportUtil;
import com.czg.log.annotation.OperationLog;
import com.czg.resp.CzgResult;
import com.mybatisflex.core.paginate.Page;
import com.pig4cloud.plugin.excel.annotation.ResponseExcel;
import jakarta.servlet.http.HttpServletResponse;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
@@ -62,12 +63,12 @@ public class HandoverRecordController {
*
* @param id 交班记录ID
*/
@ResponseExcel(name = "交班售出商品明细")
@GetMapping("/export/{id}")
@OperationLog("交班记录-导出")
@SaAdminCheckPermission(parentName = "交班记录", value = "handoverRecord:export", name = "交班记录-导出")
public List<HandoverProductListVo> export(@PathVariable Long id) {
return handoverRecordService.getHandoverProductListById(id);
public void export(@PathVariable Long id, HttpServletResponse response) {
List<HandoverProductListVo> list = handoverRecordService.getHandoverProductListById(id);
ExcelExportUtil.exportToResponse(list, HandoverProductListVo.class, "交班售出商品明细", response);
}
/**

View File

@@ -41,7 +41,7 @@ public class ADisGroupController {
if (share == null) {
return CzgResult.success(mkDistributionGroupService.save(group));
} else {
return CzgResult.success(mkDistributionGroupService.updateById(group, false));
return CzgResult.success(mkDistributionGroupService.updateById(group));
}
}
}

View File

@@ -41,6 +41,7 @@ public class AShareBaseController {
if (share == null) {
return CzgResult.success(mkShareBaseService.save(shareBase));
} else {
shareBase.setCreateTime(share.getCreateTime());
return CzgResult.success(mkShareBaseService.updateById(shareBase, false));
}
}

View File

@@ -2,6 +2,7 @@ package com.czg.controller.user;
import com.czg.market.dto.MkCarouselDTO;
import com.czg.market.entity.MkCarousel;
import com.czg.market.entity.MkShareBase;
import com.czg.market.service.MkCarouselService;
import com.czg.market.service.MkShareBaseService;
import com.czg.resp.CzgResult;
@@ -34,6 +35,7 @@ public class UCarouselController {
@GetMapping("/carousel")
public CzgResult<List<MkCarousel>> getCarousels(MkCarouselDTO carouselDTO) {
carouselDTO.setShopId(StpKit.USER.getShopId());
carouselDTO.setIsEnabled(1);
return CzgResult.success(mkCarouselService.getCarousels(carouselDTO));
}
@@ -48,6 +50,13 @@ public class UCarouselController {
public record ShareClaim(String tagType, Long shopId, Long fromUserId, Long toUserId) {
}
/**
* 分享 基础配置
*/
@GetMapping("/share")
public CzgResult<MkShareBase> share(@RequestParam Long shopId) {
return CzgResult.success(mkShareBaseService.getShareBase(shopId));
}
/**
* 分享 领取触发

View File

@@ -1,5 +1,6 @@
package com.czg.controller.admin;
import com.czg.excel.ExcelExportUtil;
import com.czg.log.annotation.OperationLog;
import com.czg.order.entity.ShopProdStatistic;
import com.czg.order.param.SaleSummaryCountParam;
@@ -7,8 +8,8 @@ import com.czg.order.service.ShopProdStatisticService;
import com.czg.order.vo.SaleSummaryCountVo;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import com.pig4cloud.plugin.excel.annotation.ResponseExcel;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
@@ -59,13 +60,12 @@ public class SaleSummaryController {
return CzgResult.success(list);
}
@ResponseExcel(name = "销售统计明细")
@GetMapping("/export")
public List<ShopProdStatistic> summaryExport(SaleSummaryCountParam param) {
public void summaryExport(SaleSummaryCountParam param, HttpServletResponse response) {
if (param.getShopId() == null) {
param.setShopId(StpKit.USER.getShopId());
}
return prodStatisticService.getArchiveTradeData(param);
ExcelExportUtil.exportToResponse(prodStatisticService.getArchiveTradeData(param), ShopProdStatistic.class, "销售统计明细", response);
}
}

View File

@@ -1,7 +1,6 @@
package com.czg.controller.admin;
import com.czg.handel.ExcelMergeHandler;
import com.czg.handel.TableRefundCellHandel;
import com.czg.excel.ExcelExportUtil;
import com.czg.log.annotation.OperationLog;
import com.czg.order.entity.ShopTableOrderStatistic;
import com.czg.order.param.DataSummaryTradeParam;
@@ -11,8 +10,8 @@ import com.czg.order.service.TableSummaryService;
import com.czg.order.vo.TableSummaryExportVo;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import com.pig4cloud.plugin.excel.annotation.ResponseExcel;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
@@ -54,15 +53,14 @@ public class TableSummaryController {
/**
* 导出
*/
@ResponseExcel(name = "台桌统计", writeHandler = {ExcelMergeHandler.class, TableRefundCellHandel.class})
@GetMapping("export")
@OperationLog("导出")
//@SaAdminCheckPermission("tableSummary:export")
public List<TableSummaryExportVo> summaryExport(TableSummaryParam param) {
public void summaryExport(TableSummaryParam param, HttpServletResponse response) {
if (param.getShopId() == null) {
param.setShopId(StpKit.USER.getShopId());
}
return tableSummaryService.summaryExportList(param);
tableSummaryService.summaryExportList(param, response);
}
}

View File

@@ -20,6 +20,7 @@ import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -44,6 +45,8 @@ public class OrderPayController {
private OrderInfoService orderInfoService;
@DubboReference
private SysParamsService paramsService;
@Value("${spring.profiles.active}")
private String env;
@PostMapping("/creditPay")
@Debounce(value = "#payParam.checkOrderPay.orderId")
@@ -154,6 +157,7 @@ public class OrderPayController {
AssertUtil.isNull(shopId, "店铺id不能为空");
AssertUtil.isNull(checkOrderPay, "订单信息不能为空");
Map<String, Object> map = new HashMap<>();
map.put("env", env);
map.put("shopId", shopId);
map.put("orderId", checkOrderPay.getOrderId());
map.put("payAmount", checkOrderPay.getOrderAmount());
@@ -177,9 +181,9 @@ public class OrderPayController {
@PostMapping("/shopPayApi/js2Pay")
@Debounce(value = "#payParam.checkOrderPay.orderId")
public CzgResult<Map<String, Object>> js2PayOrder(HttpServletRequest request, @RequestBody OrderPayParamDTO payParam) {
if ("alipay".equals(payParam.getPayType())) {
if ("ALIPAY".equals(payParam.getPayType())) {
payParam.setPayType(PayCst.Type.ALIPAY);
} else if ("wechatPay".equals(payParam.getPayType())) {
} else if ("WECHAT".equals(payParam.getPayType())) {
payParam.setPayType(PayCst.Type.WECHAT);
} else {
throw new CzgException(payParam.getPayType() + "支付方式错误");

View File

@@ -1,151 +0,0 @@
package com.czg.handel;
import cn.idev.excel.metadata.Head;
import cn.idev.excel.metadata.data.WriteCellData;
import cn.idev.excel.write.handler.CellWriteHandler;
import cn.idev.excel.write.metadata.holder.WriteSheetHolder;
import cn.idev.excel.write.metadata.holder.WriteTableHolder;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import java.util.List;
/**
* @author tankaikai
* @since 2025-04-01 18:41
*/
public class ExcelMergeHandler implements CellWriteHandler {
// 要合并的列索引数组
private int[] mergeColumnIndex = {0, 1, 2, 3, 8, 9};
// 合并开始的行索引
private int mergeRowIndex = 1;
public ExcelMergeHandler() {
}
/**
* 构造函数
*
* @param mergeRowIndex 合并开始的行索引
* @param mergeColumnIndex 要合并的列索引数组
*/
public ExcelMergeHandler(int mergeRowIndex, int[] mergeColumnIndex) {
this.mergeRowIndex = mergeRowIndex;
this.mergeColumnIndex = mergeColumnIndex;
}
@Override
public void afterCellDispose(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, List<WriteCellData<?>> cellDataList, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) {
// 当前行索引
int curRowIndex = cell.getRowIndex();
// 当前列索引
int curColIndex = cell.getColumnIndex();
// 如果当前行大于合并开始行且当前列在需要合并的列中
if (curRowIndex > mergeRowIndex && isMergeColumn(curColIndex)) {
// 进行合并操作
mergeWithPrevRow(writeSheetHolder, cell, curRowIndex, curColIndex);
}
}
/**
* 检查当前列是否在需要合并的列中
*
* @param curColIndex 当前列索引
* @return 如果是需要合并的列返回true否则返回false
*/
private boolean isMergeColumn(int curColIndex) {
for (int columnIndex : mergeColumnIndex) {
if (curColIndex == columnIndex) {
return true;
}
}
return false;
}
/**
* 当前单元格向上合并
*
* @param writeSheetHolder 当前工作表持有者
* @param cell 当前单元格
* @param curRowIndex 当前行索引
* @param curColIndex 当前列索引
*/
private void mergeWithPrevRow(WriteSheetHolder writeSheetHolder, Cell cell, int curRowIndex, int curColIndex) {
// 获取当前单元格的数据
Object curData = getCellData(cell);
// 获取前一个单元格的数据
Cell preCell = cell.getSheet().getRow(curRowIndex - 1).getCell(curColIndex);
Object preData = getCellData(preCell);
// 判断当前单元格和前一个单元格的数据以及主键是否相同
if (curData.equals(preData) && isSamePrimaryKey(cell, curRowIndex)) {
// 获取工作表
Sheet sheet = writeSheetHolder.getSheet();
// 合并单元格
mergeCells(sheet, curRowIndex, curColIndex);
CellStyle style = preCell.getCellStyle();
// 设置水平居中
style.setAlignment(HorizontalAlignment.CENTER);
// 设置垂直居中
style.setVerticalAlignment(VerticalAlignment.CENTER);
preCell.setCellStyle(style);
}
}
/**
* 获取单元格的数据
*
* @param cell 单元格
* @return 单元格数据
*/
private Object getCellData(Cell cell) {
return cell.getCellType() == CellType.STRING ? cell.getStringCellValue() : cell.getNumericCellValue();
}
/**
* 判断当前单元格和前一个单元格的主键是否相同
*
* @param cell 当前单元格
* @param curRowIndex 当前行索引
* @return 如果主键相同返回true否则返回false
*/
private boolean isSamePrimaryKey(Cell cell, int curRowIndex) {
String currentPrimaryKey = cell.getRow().getCell(0).getStringCellValue();
String previousPrimaryKey = cell.getSheet().getRow(curRowIndex - 1).getCell(0).getStringCellValue();
return currentPrimaryKey.equals(previousPrimaryKey);
}
/**
* 合并单元格
*
* @param sheet 工作表
* @param curRowIndex 当前行索引
* @param curColIndex 当前列索引
*/
private void mergeCells(Sheet sheet, int curRowIndex, int curColIndex) {
// 获取已合并的区域
List<CellRangeAddress> mergeRegions = sheet.getMergedRegions();
boolean isMerged = false;
// 检查前一个单元格是否已经被合并
for (int i = 0; i < mergeRegions.size() && !isMerged; i++) {
CellRangeAddress cellRangeAddr = mergeRegions.get(i);
if (cellRangeAddr.isInRange(curRowIndex - 1, curColIndex)) {
sheet.removeMergedRegion(i);
cellRangeAddr.setLastRow(curRowIndex);
sheet.addMergedRegion(cellRangeAddr);
isMerged = true;
}
}
// 如果前一个单元格未被合并,则新增合并区域
if (!isMerged) {
CellRangeAddress cellRangeAddress = new CellRangeAddress(curRowIndex - 1, curRowIndex, curColIndex, curColIndex);
sheet.addMergedRegion(cellRangeAddress);
}
}
}

View File

@@ -1,55 +0,0 @@
package com.czg.handel;
import cn.hutool.core.util.ArrayUtil;
import cn.idev.excel.metadata.Head;
import cn.idev.excel.metadata.data.WriteCellData;
import cn.idev.excel.write.handler.CellWriteHandler;
import cn.idev.excel.write.metadata.holder.WriteSheetHolder;
import cn.idev.excel.write.metadata.holder.WriteTableHolder;
import org.apache.poi.ss.usermodel.*;
import java.util.List;
/**
* 台桌统计退单单元格处理器
*
* @author tankaikai
* @since 2025-04-02 09:50
*/
public class TableRefundCellHandel implements CellWriteHandler {
// 要处理的列索引数组
private int[] yellowColumnIndex = {10, 11};
public TableRefundCellHandel() {
}
@Override
public void afterCellDispose(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, List<WriteCellData<?>> cellDataList, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) {
// 当前行索引
int curRowIndex = cell.getRowIndex();
// 当前列索引
int curColIndex = cell.getColumnIndex();
if (curRowIndex == 0) {
return;
}
// 如果是指定要处理的列,则要进行加黄操作
if (ArrayUtil.contains(yellowColumnIndex, curColIndex)) {
Cell preCell = cell.getSheet().getRow(curRowIndex - 1).getCell(curColIndex);
if (preCell.getCellType() == CellType.NUMERIC) {
if (preCell.getNumericCellValue() < 0) {
//System.out.println("设置黄色背景:" + curRowIndex + "行," + curColIndex + "列" + preCell.getNumericCellValue());
CellStyle style = preCell.getSheet().getWorkbook().createCellStyle();
style.cloneStyleFrom(preCell.getCellStyle());
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
style.setFillForegroundColor(IndexedColors.YELLOW.getIndex());
// 设置水平居中
style.setAlignment(HorizontalAlignment.CENTER);
// 设置垂直居中
style.setVerticalAlignment(VerticalAlignment.CENTER);
preCell.setCellStyle(style);
}
}
}
}
}

View File

@@ -14,7 +14,6 @@ import com.czg.service.order.service.ShopDirectMerchantService;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.List;
@@ -32,13 +31,15 @@ public class EntryManagerTask {
@Resource
private ShopMerchantService shopMerchantService;
// TODO 暂时不用原生进件,使用第三方进件
//每10分钟查一次
@Scheduled(cron = "0 0/10 * * * ? ")
// @Scheduled(cron = "0 0/10 * * * ? ")
public void run() {
log.info("进件查询,定时任务执行");
long start = System.currentTimeMillis();
entryManager(null);
log.info("进件查询,定时任务执行完毕,耗时:{}ms", start - System.currentTimeMillis());
// log.info("进件查询,定时任务执行");
// long start = System.currentTimeMillis();
// entryManager(null);
// log.info("进件查询,定时任务执行完毕,耗时:{}ms", System.currentTimeMillis() - start);
}
/**

View File

@@ -17,6 +17,7 @@ import java.util.List;
/**
* 统计任务
*
* @author Administrator
*/
@Component
@@ -43,7 +44,7 @@ public class StatisticTask {
// 获取前一天
LocalDate yesterday = LocalDate.now().minusDays(1);
baseStatistic(yesterday);
log.info("统计数据,定时任务执行完毕,耗时:{}ms", start - System.currentTimeMillis());
log.info("统计数据,定时任务执行完毕,耗时:{}ms", System.currentTimeMillis() - start);
}

View File

@@ -52,10 +52,6 @@
<artifactId>cash-common-service</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.pig4cloud.excel</groupId>
<artifactId>excel-spring-boot-starter</artifactId>
</dependency>
</dependencies>
<build>

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.*;
@@ -71,15 +72,23 @@ public class ProductController {
public CzgResult<Map<String, Object>> getProductPage(ProductDTO param) {
Page<ProductDTO> data = productService.getProductPage(param);
Map<String, Object> map = JSONObject.parseObject(JSONObject.toJSONString(data), Map.class);
if(data.getRecords() != null){
if (data.getRecords() != null && !data.getRecords().isEmpty()) {
ProductDTO first = data.getRecords().getFirst();
map.put("warnLine", first.getWarnLine());
}else {
} else {
map.put("warnLine", 0);
}
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));
}
}

View File

@@ -13,6 +13,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 lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -36,14 +37,19 @@ public class ShopProdCategoryController {
@Resource
private ShopSyncService shopSyncService;
/**
* 分页
*/
@GetMapping("page")
@OperationLog("商品分类-分页")
//@SaAdminCheckPermission("shopProdCategory:page")
public CzgResult<Page<ShopProdCategoryDTO>> getShopProdCategoryPage(ShopProdCategoryDTO param) {
Page<ShopProdCategoryDTO> data = shopProdCategoryService.getShopProdCategoryPage(param);
return CzgResult.success(data);
}
/**
* 列表
*/
@GetMapping("list")
@OperationLog("商品分类-列表")
//@SaAdminCheckPermission("shopProdCategory:list")
@@ -52,6 +58,18 @@ public class ShopProdCategoryController {
return CzgResult.success(data);
}
/**
* 导出
*/
@GetMapping("/export")
@OperationLog("商品分类-导出")
public void exportShopProdCategory(ShopProdCategoryDTO param, HttpServletResponse response) {
shopProdCategoryService.exportShopProdCategory(param, response);
}
/**
* 详情
*/
@GetMapping("{id}")
@OperationLog("商品分类-详情")
//@SaAdminCheckPermission("shopProdCategory:info")
@@ -61,6 +79,9 @@ public class ShopProdCategoryController {
return CzgResult.success(data);
}
/**
* 新增
*/
@PostMapping
@OperationLog("商品分类-新增")
//@SaAdminCheckPermission("shopProdCategory:add")
@@ -70,6 +91,9 @@ public class ShopProdCategoryController {
return CzgResult.success();
}
/**
* 修改
*/
@PutMapping
@OperationLog("商品分类-修改")
//@SaAdminCheckPermission("shopProdCategory:update")
@@ -79,6 +103,9 @@ public class ShopProdCategoryController {
return CzgResult.success();
}
/**
* 删除
*/
@DeleteMapping("{id}")
@OperationLog("商品分类-删除")
//@SaAdminCheckPermission("shopProdCategory:delete")
@@ -89,6 +116,9 @@ public class ShopProdCategoryController {
return CzgResult.success();
}
/**
* 禁用
*/
@PostMapping("disable/{id}")
@OperationLog("商品分类-禁用")
//@SaAdminCheckPermission("shopProdCategory:able")
@@ -100,6 +130,9 @@ public class ShopProdCategoryController {
return CzgResult.success();
}
/**
* 启用
*/
@PostMapping("enable/{id}")
@OperationLog("商品分类-启用")
//@SaAdminCheckPermission("shopProdCategory:able")

View File

@@ -13,6 +13,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 lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -21,7 +22,7 @@ import java.util.List;
/**
* 商品单位
* 管理端/商品单位
*
* @author Tankaikai tankaikai@aliyun.com
* @since 1.0 2025-02-10
@@ -36,7 +37,9 @@ public class ShopProdUnitController {
@Resource
private ShopSyncService shopSyncService;
/**
* 分页
*/
@GetMapping("page")
@OperationLog("商品单位-分页")
//@SaAdminCheckPermission("shopProdUnit:page")
@@ -45,6 +48,9 @@ public class ShopProdUnitController {
return CzgResult.success(data);
}
/**
* 列表
*/
@GetMapping("list")
@OperationLog("商品单位-列表")
//@SaAdminCheckPermission("shopProdUnit:list")
@@ -53,6 +59,18 @@ public class ShopProdUnitController {
return CzgResult.success(data);
}
/**
* 导出
*/
@GetMapping("/export")
@OperationLog("商品单位-导出")
public void exportProduct(ShopProdUnitDTO param, HttpServletResponse response) {
shopProdUnitService.exportShopProdUnit(param, response);
}
/**
* 详情
*/
@GetMapping("{id}")
@OperationLog("商品单位-详情")
//@SaAdminCheckPermission("shopProdUnit:info")
@@ -62,6 +80,9 @@ public class ShopProdUnitController {
return CzgResult.success(data);
}
/**
* 新增
*/
@PostMapping
@OperationLog("商品单位-新增")
//@SaAdminCheckPermission("shopProdUnit:add")
@@ -71,6 +92,9 @@ public class ShopProdUnitController {
return CzgResult.success();
}
/**
* 修改
*/
@PutMapping
@OperationLog("商品单位-修改")
//@SaAdminCheckPermission("shopProdUnit:update")
@@ -80,6 +104,9 @@ public class ShopProdUnitController {
return CzgResult.success();
}
/**
* 删除
*/
@DeleteMapping("{id}")
@OperationLog("商品单位-删除")
//@SaAdminCheckPermission("shopProdUnit:delete")
@@ -90,6 +117,9 @@ public class ShopProdUnitController {
return CzgResult.success();
}
/**
* 禁用
*/
@PostMapping("disable/{id}")
@OperationLog("商品单位-禁用")
//@SaAdminCheckPermission("shopProdUnit:able")
@@ -101,6 +131,9 @@ public class ShopProdUnitController {
return CzgResult.success();
}
/**
* 启用
*/
@PostMapping("enable/{id}")
@OperationLog("商品单位-启用")
//@SaAdminCheckPermission("shopProdUnit:able")

View File

@@ -1,6 +1,5 @@
package com.czg.config;
import cn.dev33.satoken.application.ApplicationInfo;
import cn.dev33.satoken.config.SaTokenConfig;
import cn.dev33.satoken.context.SaHolder;
import cn.dev33.satoken.interceptor.SaInterceptor;
@@ -58,14 +57,17 @@ public class SaTokenConfigure implements WebMvcConfigurer {
public void addInterceptors(InterceptorRegistry registry) {
// 注册路由拦截器,自定义认证规则
registry.addInterceptor(new SaInterceptor(handler -> {
log.info(SaHolder.getRequest().getRequestPath());
// 重置根路径防止satoken切割根路径导致匹配不到路径
ApplicationInfo.routePrefix = "";
log.info("{}: {}", SaHolder.getRequest().getMethod(), SaHolder.getRequest().getRequestPath());
if ("OPTIONS".equalsIgnoreCase(SaHolder.getRequest().getMethod())) {
SaRouter.back();
return;
}
SaRouter
.match(r -> "OPTIONS".equalsIgnoreCase(SaHolder.getRequest().getMethod()))
.stop()
// 完全开放的路径(不需要任何认证)
.match("/user/login", "/user/geo/**", "/user/home/**",
"/user/dict/**", "/user/openId","/admin/auth/**",
"/user/dict/**", "/user/openId", "/admin/auth/**",
"/admin/shopMsgPush/subscribe/**",
"/admin/coupon/grant",
"/pay/**",

View File

@@ -30,10 +30,7 @@
<groupId>com.mybatis-flex</groupId>
<artifactId>mybatis-flex-processor</artifactId>
</dependency>
<dependency>
<groupId>com.pig4cloud.excel</groupId>
<artifactId>excel-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>

View File

@@ -11,7 +11,7 @@ import java.math.BigDecimal;
@Data
public class ShopInfoEditDTO {
@NotNull(message = "id不为空")
private Integer id;
private Long id;
private String code;

View File

@@ -1,6 +1,5 @@
package com.czg.account.entity;
import com.alibaba.fastjson2.annotation.JSONField;
import com.czg.utils.CzgRandomUtils;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
@@ -152,22 +151,6 @@ public class ShopUser implements Serializable {
private LocalDateTime nextDeliverTime;
// 是否分销员
private String distributionShops;
/**
* 上级分销员id
*/
private Long parentUserId;
/**
* 上上级分销员id
*/
private Long gradeUserId;
/**
* 一级分销收入
*/
private BigDecimal oneIncome;
/**
* 二级分销收入
*/
private BigDecimal twoIncome;
private String memberCircleName;
private Integer memberCircleReward;
@@ -179,8 +162,6 @@ public class ShopUser implements Serializable {
private Integer discount;
@Column(ignore = true)
private Integer isMemberPrice;
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime inviteTime;
/**
* 添加或更新分销店铺若shopId已存在无论后缀则替换为新的id_后缀否则插入

View File

@@ -5,7 +5,6 @@ import com.czg.account.entity.ShopInfo;
import com.czg.exception.CzgException;
import com.mybatisflex.core.service.IService;
import java.io.Serializable;
import java.util.List;
/**
@@ -16,7 +15,7 @@ import java.util.List;
*/
public interface ShopConfigService extends IService<ShopConfig> {
ShopInfo getShopInfoAndConfig(Serializable id) throws CzgException;
ShopInfo getShopInfoAndConfig(Long id) throws CzgException;
void editStatusByShopIdList(Long mainShopId, Integer isEnable, boolean onyUpValid, String name, String useShopType, List<Long> shopIdList);

View File

@@ -1,10 +1,9 @@
package com.czg.account.vo;
import cn.idev.excel.annotation.ExcelIgnore;
import cn.idev.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.fastjson2.annotation.JSONField;
import com.pig4cloud.plugin.excel.annotation.ExcelLine;
import lombok.Data;
import java.io.Serial;
@@ -26,7 +25,6 @@ public class HandoverProductListVo implements Serializable {
/**
* 导入时候回显行号
*/
@ExcelLine
@ExcelIgnore
@JSONField(serialize = false)
private Long lineNum;

View File

@@ -1,16 +1,17 @@
package com.czg.market.dto;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import com.alibaba.fastjson2.annotation.JSONField;
import jakarta.validation.constraints.*;
import lombok.experimental.Accessors;
import java.io.Serial;
import jakarta.validation.constraints.DecimalMin;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 分销员等级配置 实体类。
@@ -50,12 +51,7 @@ public class MkDistributionLevelConfigDTO implements Serializable {
* 一级分销比例
*/
@NotNull(message = "一级分销比例不为空")
private BigDecimal levelOneCommission;
/**
* 二级分销比例
*/
private BigDecimal levelTwoCommission;
private BigDecimal commission;
}

View File

@@ -0,0 +1,75 @@
package com.czg.market.entity;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.io.Serial;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 全民股东邀请关系 实体类。
*
* @author ww
* @since 2026-01-31
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table("mk_distribution_invite")
public class MkDistributionInvite implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
@Id(keyType = KeyType.Auto)
private Long id;
/**
* 店铺Id
*/
private Long shopId;
/**
* 用户Id
*/
private Long userId;
/**
* 用户Id
*/
private Long shopUserId;
/**
* 邀请人ID mk_distribution_user.id
*/
private Long parentUserId;
/**
* 邀请人上级ID mk_distribution_user.id
*/
private Long gradeUserId;
/**
* 一级分润
*/
private BigDecimal oneIncome;
/**
* 二级分润
*/
private BigDecimal twoIncome;
/**
* 邀请时间
*/
private LocalDateTime inviteTime;
}

View File

@@ -1,5 +1,6 @@
package com.czg.market.entity;
import com.czg.market.dto.ShopCouponDTO;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.Table;
@@ -57,6 +58,11 @@ public class MkShareBase implements Serializable {
* 分享人奖励的优惠券ID关联优惠券表
*/
private Long sharerCouponId;
/**
* 分享人奖励的优惠券信息
*/
@Column(ignore = true)
private ShopCouponDTO sharerCoupon;
/**
* 分享人奖励的优惠券名称
*/

View File

@@ -0,0 +1,15 @@
package com.czg.market.service;
import com.mybatisflex.core.service.IService;
import com.czg.market.entity.MkDistributionInvite;
/**
* 全民股东邀请关系 服务层。
*
* @author ww
* @since 2026-01-31
*/
public interface MkDistributionInviteService extends IService<MkDistributionInvite> {
MkDistributionInvite getByShopIdAndShopUserId(Long shopId, Long shopUserId);
}

View File

@@ -1,8 +1,8 @@
package com.czg.order.entity;
import cn.idev.excel.annotation.ExcelIgnore;
import cn.idev.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
@@ -59,42 +59,42 @@ public class ShopProdStatistic implements Serializable {
* 销售数量
*/
@ExcelProperty("销量")
@ColumnWidth(5)
@ColumnWidth(15)
private BigDecimal saleCount;
/**
* 销售金额
*/
@ExcelProperty("销售金额")
@ColumnWidth(7)
@ColumnWidth(15)
private BigDecimal saleAmount;
/**
* 退单量
*/
@ExcelProperty("退单量")
@ColumnWidth(5)
@ColumnWidth(15)
private BigDecimal refundCount;
/**
* 退单金额
*/
@ExcelProperty("退款金额")
@ColumnWidth(7)
@ColumnWidth(15)
private BigDecimal refundAmount;
/**
* 实际销售数量(过滤掉退单后的数量)
*/
@ExcelProperty("实际销量")
@ColumnWidth(5)
@ColumnWidth(15)
private BigDecimal validSaleCount;
/**
* 实际销售金额(过滤掉退单后的金额)
*/
@ExcelProperty("实际销售额")
@ColumnWidth(7)
@ColumnWidth(15)
private BigDecimal validSaleAmount;
/**

View File

@@ -2,6 +2,7 @@ package com.czg.order.service;
import com.czg.order.param.TableSummaryParam;
import com.czg.order.vo.TableSummaryExportVo;
import jakarta.servlet.http.HttpServletResponse;
import java.util.List;
@@ -14,7 +15,7 @@ import java.util.List;
public interface TableSummaryService {
List<TableSummaryExportVo> summaryExportList(TableSummaryParam param);
void summaryExportList(TableSummaryParam param, HttpServletResponse response);
}

View File

@@ -1,10 +1,9 @@
package com.czg.order.vo;
import cn.idev.excel.annotation.ExcelIgnore;
import cn.idev.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.fastjson2.annotation.JSONField;
import com.pig4cloud.plugin.excel.annotation.ExcelLine;
import lombok.Data;
import java.io.Serial;
@@ -25,7 +24,6 @@ public class TableSummaryExportVo implements Serializable {
/**
* 导入时候回显行号
*/
@ExcelLine
@ExcelIgnore
@JSONField(serialize = false)
private Long lineNum;
@@ -36,18 +34,20 @@ public class TableSummaryExportVo implements Serializable {
private String tableConcatDate;
@ExcelIgnore
private String tableCode;
/**
* 台桌
*/
@ExcelProperty("台桌")
@ColumnWidth(10)
private String tableName;
/**
* 日期
*/
@ExcelProperty("日期")
@ColumnWidth(10)
@ColumnWidth(15)
private String createDate;
/**
* 台桌
*/
@ExcelProperty("台桌")
@ColumnWidth(13)
private String tableName;
/**
* 商品分类
*/

View File

@@ -0,0 +1,20 @@
package com.czg.product.dto;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
/**
* @author yjjie
* @date 2026/1/30 18:15
*/
@Data
public class ProductCategoryExportDTO {
@ExcelProperty("分类名称")
private String name;
@ExcelProperty("简称")
private String shortName;
}

View File

@@ -0,0 +1,104 @@
package com.czg.product.dto;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalTime;
/**
* 商品导出
* @author yjjie
* @date 2026/1/28 14:30
*/
@Data
public class ProductExportDTO {
@ExcelProperty("商品名称")
@ColumnWidth(20)
private String name;
@ExcelProperty("商品分类")
@ColumnWidth(15)
private String categoryName;
@ExcelProperty("条码")
@ColumnWidth(20)
private String barCode;
@ExcelProperty("商品规格")
@ColumnWidth(20)
private String specFullName;
@ExcelProperty("售价")
@ColumnWidth(10)
private BigDecimal price;
@ExcelProperty("会员价")
@ColumnWidth(10)
private BigDecimal memberPrice;
@ExcelProperty("成本价")
@ColumnWidth(10)
private BigDecimal costPrice;
@ExcelProperty("商品单位")
@ColumnWidth(10)
private String unitName;
/**
* 商品类型 single-单规格商品 sku-多规格商品 package-套餐商品 weight-称重商品 coupon-团购券
*/
@ExcelProperty("商品类型")
@ColumnWidth(15)
private String type;
/**
* 可用开始时间
*/
@ExcelProperty("可用开始时间")
@ColumnWidth(16)
private LocalTime startTime;
/**
* 可用结束时间
*/
@ExcelProperty("可用结束时间")
@ColumnWidth(16)
private LocalTime endTime;
/**
* 商品级库存数量
*/
@ExcelProperty("库存数量")
@ColumnWidth(10)
private Integer stockNumber;
/**
* 是否上架
*/
@ExcelIgnore
private Integer isSale;
@ExcelProperty("是否上架")
@ColumnWidth(10)
private String isSaleRemark;
public String getType() {
return switch (type) {
case "single" -> "单规格商品";
case "sku" -> "多规格商品";
case "package" -> "套餐商品";
case "weight" -> "称重商品";
case "coupon" -> "团购券";
case null, default -> "未知类型";
};
}
public String getIsSaleRemark() {
return switch (isSale) {
case 0 -> "下架";
case 1 -> "上架";
case null, default -> "未知状态";
};
}
}

View File

@@ -0,0 +1,101 @@
package com.czg.product.dto;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import lombok.Data;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
/**
* 套餐商品导出
* @author yjjie
* @date 2026/1/30 10:26
*/
@Data
@Accessors(chain = true)
public class ProductPackageExportDTO {
@ExcelProperty("套餐名称")
@ColumnWidth(20)
private String name;
@ExcelProperty("套餐分类")
@ColumnWidth(15)
private String categoryName;
@ExcelProperty("售价")
@ColumnWidth(10)
private BigDecimal price;
@ExcelProperty("会员价")
@ColumnWidth(10)
private BigDecimal memberPrice;
/**
* 商品类型 single-单规格商品 sku-多规格商品 package-套餐商品 weight-称重商品 coupon-团购券
*/
@ExcelIgnore()
private String type;
/**
* 套餐类型 0 固定套餐 1可选套餐
*/
@ExcelIgnore
private Integer groupType;
@ExcelProperty("套餐类型")
@ColumnWidth(15)
private String groupTypeRemark;
@ExcelProperty("组名称")
@ColumnWidth(15)
private String groupTitleName;
@ExcelProperty("商品名称")
@ColumnWidth(21)
private String groupProductName;
@ExcelProperty("商品单位")
@ColumnWidth(10)
private String unitName;
@ExcelProperty("套餐内选择数量")
@ColumnWidth(10)
private String groupProductNumber;
/**
* 商品级库存数量
*/
@ExcelProperty("库存数量")
@ColumnWidth(10)
private Integer stockNumber;
/**
* 是否上架
*/
@ExcelIgnore
private Integer isSale;
@ExcelProperty("是否上架")
@ColumnWidth(10)
private String isSaleRemark;
public String getGroupTypeRemark() {
if (!"package".equals(type)) {
return "";
}
return switch (groupType) {
case 0 -> "固定套餐";
case 1 -> "可选套餐";
case null, default -> "未知类型";
};
}
public String getIsSaleRemark() {
return switch (isSale) {
case 0 -> "下架";
case 1 -> "上架";
case null, default -> "未知状态";
};
}
}

View File

@@ -0,0 +1,40 @@
package com.czg.product.dto;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
/**
* 商品单位导出
* @author yjjie
* @date 2026/1/30 17:51
*/
@Data
public class ProductUnitExportDTO {
@ExcelProperty("单位名称")
private String name;
/**
* 单位类型 number-计数 weight-记重
*/
@ExcelIgnore
private String unitType;
@ExcelProperty("单位类型")
private String unitTypeRemark;
/**
* 单位来源 1-系统预设 0-商家创建
*/
@ExcelIgnore
private Integer isSystem;
@ExcelProperty("单位来源")
private String isSystemRemark;
public String getUnitTypeRemark() {
return "number".equals(unitType) ? "计数" : "记重";
}
public String getIsSystemRemark() {
return isSystem == 1 ? "系统预设" : "商家创建";
}
}

View File

@@ -1,13 +1,13 @@
package com.czg.product.service;
import com.czg.product.dto.ProductDTO;
import com.czg.product.dto.RelatedProductDTO;
import com.czg.product.entity.Product;
import com.czg.product.entity.ProductStockFlow;
import com.czg.product.param.*;
import com.czg.product.vo.ProductStatisticsVo;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.service.IService;
import jakarta.servlet.http.HttpServletResponse;
import java.util.List;
@@ -34,6 +34,8 @@ public interface ProductService extends IService<Product> {
*/
List<ProductDTO> getProductList(ProductDTO param);
void exportProductList(ProductDTO param, HttpServletResponse response);
/**
* 从缓存里面获取商品列表
*

View File

@@ -4,6 +4,7 @@ import com.czg.product.dto.ShopProdCategoryDTO;
import com.czg.product.entity.ShopProdCategory;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.service.IService;
import jakarta.servlet.http.HttpServletResponse;
import java.util.List;
@@ -30,6 +31,8 @@ public interface ShopProdCategoryService extends IService<ShopProdCategory> {
*/
List<ShopProdCategoryDTO> getShopProdCategoryList(ShopProdCategoryDTO param);
void exportShopProdCategory(ShopProdCategoryDTO param, HttpServletResponse response);
/**
* 获取店铺商品分类详情
* @param id id

View File

@@ -4,6 +4,7 @@ import com.czg.product.dto.ShopProdUnitDTO;
import com.czg.product.entity.ShopProdUnit;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.service.IService;
import jakarta.servlet.http.HttpServletResponse;
import java.util.List;
@@ -31,6 +32,8 @@ public interface ShopProdUnitService extends IService<ShopProdUnit> {
*/
List<ShopProdUnitDTO> getShopProdUnitList(ShopProdUnitDTO param);
void exportShopProdUnit(ShopProdUnitDTO param, HttpServletResponse response);
/**
* 获取商品单位详情
*

View File

@@ -1,8 +1,14 @@
package com.czg.excel;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.write.builder.ExcelWriterBuilder;
import com.alibaba.excel.write.builder.ExcelWriterSheetBuilder;
import com.alibaba.excel.write.handler.SheetWriteHandler;
import com.alibaba.excel.write.merge.OnceAbsoluteMergeStrategy;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
@@ -21,6 +27,7 @@ import java.util.List;
/**
* EasyExcel导出工具类
*
* @author yjjie
* @date 2026/1/28 10:48
*/
@@ -29,14 +36,18 @@ public class ExcelExportUtil {
private static final ExcelExportConfig DEFAULT_CONFIG = new ExcelExportConfig();
public static OnceAbsoluteMergeStrategy createMergeStrategy(int firstRow, int lastRow, int firstCol, int lastCol) {
return new OnceAbsoluteMergeStrategy(firstRow, lastRow, firstCol, lastCol);
}
/**
* 导出Excel到HttpServletResponse
*
* @param data 数据列表
* @param clazz 数据类型
* @param data 数据列表
* @param clazz 数据类型
* @param fileName 文件名(不含扩展名)
* @param response HttpServletResponse
* @param <T> 数据类型
* @param <T> 数据类型
*/
public static <T> void exportToResponse(List<T> data, Class<T> clazz,
String fileName, HttpServletResponse response) {
@@ -46,12 +57,12 @@ public class ExcelExportUtil {
/**
* 导出Excel到HttpServletResponse自定义配置
*
* @param data 数据列表
* @param clazz 数据类型
* @param data 数据列表
* @param clazz 数据类型
* @param fileName 文件名(不含扩展名)
* @param config 配置信息
* @param config 配置信息
* @param response HttpServletResponse
* @param <T> 数据类型
* @param <T> 数据类型
*/
public static <T> void exportToResponse(List<T> data, Class<T> clazz,
String fileName, ExcelExportConfig config,
@@ -81,10 +92,10 @@ public class ExcelExportUtil {
/**
* 导出Excel到文件
*
* @param data 数据列表
* @param clazz 数据类型
* @param data 数据列表
* @param clazz 数据类型
* @param filePath 文件路径
* @param <T> 数据类型
* @param <T> 数据类型
*/
public static <T> void exportToFile(List<T> data, Class<T> clazz, String filePath) {
exportToFile(data, clazz, filePath, DEFAULT_CONFIG);
@@ -93,11 +104,11 @@ public class ExcelExportUtil {
/**
* 导出Excel到文件自定义配置
*
* @param data 数据列表
* @param clazz 数据类型
* @param data 数据列表
* @param clazz 数据类型
* @param filePath 文件路径
* @param config 配置信息
* @param <T> 数据类型
* @param config 配置信息
* @param <T> 数据类型
*/
public static <T> void exportToFile(List<T> data, Class<T> clazz,
String filePath, ExcelExportConfig config) {
@@ -119,11 +130,11 @@ public class ExcelExportUtil {
/**
* 带样式的Excel导出到Response
*
* @param data 数据列表
* @param clazz 数据类型
* @param data 数据列表
* @param clazz 数据类型
* @param fileName 文件名
* @param response HttpServletResponse
* @param <T> 数据类型
* @param <T> 数据类型
*/
public static <T> void exportWithStyleToResponse(List<T> data, Class<T> clazz,
String fileName, HttpServletResponse response) {
@@ -157,11 +168,11 @@ public class ExcelExportUtil {
* 大数据量分批导出(避免内存溢出)
*
* @param dataSupplier 数据提供者(分页获取数据)
* @param clazz 数据类型
* @param fileName 文件名
* @param response HttpServletResponse
* @param batchSize 每批大小
* @param <T> 数据类型
* @param clazz 数据类型
* @param fileName 文件名
* @param response HttpServletResponse
* @param batchSize 每批大小
* @param <T> 数据类型
*/
public static <T> void exportBigDataToResponse(DataSupplier<T> dataSupplier,
Class<T> clazz, String fileName,
@@ -244,4 +255,70 @@ public class ExcelExportUtil {
}
return count;
}
/**
* 带合并单元格的导出到Response
* 多sheet导出到response
*
* @param sheetDataList 数据列表
* @param fileName 文件名
* @param response HttpServletResponse
*/
public static void exportMultipleSheetsToResponse(List<SheetData> sheetDataList,
String fileName,
HttpServletResponse response) {
if (CollectionUtil.isEmpty(sheetDataList)) {
throw new CzgException("数据列表不能为空");
}
setResponseHeader(response, fileName, DEFAULT_CONFIG);
try (OutputStream outputStream = response.getOutputStream()) {
// 创建样式策略
WriteCellStyle headStyle = new WriteCellStyle();
headStyle.setHorizontalAlignment(HorizontalAlignment.LEFT);
headStyle.setVerticalAlignment(VerticalAlignment.CENTER);
WriteCellStyle contentStyle = new WriteCellStyle();
contentStyle.setHorizontalAlignment(HorizontalAlignment.LEFT);
contentStyle.setVerticalAlignment(VerticalAlignment.CENTER);
HorizontalCellStyleStrategy styleStrategy = new HorizontalCellStyleStrategy(headStyle, contentStyle);
// 创建ExcelWriter
ExcelWriterBuilder builder = EasyExcel.write(outputStream)
.autoCloseStream(true)
.registerConverter(new LocalTimeConverter())
.registerWriteHandler(styleStrategy);
ExcelWriter excelWriter = builder.build();
// 逐个写入sheet
for (int i = 0; i < sheetDataList.size(); i++) {
SheetData sheetData = sheetDataList.get(i);
String sheetName = StrUtil.isNotBlank(sheetData.getSheetName())
? sheetData.getSheetName()
: DEFAULT_CONFIG.getDefaultSheetName() + (i + 1);
ExcelWriterSheetBuilder sheetBuilder = EasyExcel.writerSheet(sheetName);
// 注册该sheet的合并处理器
if (sheetData.getHandlers() != null && !sheetData.getHandlers().isEmpty()) {
for (SheetWriteHandler handler : sheetData.getHandlers()) {
sheetBuilder.registerWriteHandler(handler);
}
}
WriteSheet writeSheet = sheetBuilder.head(sheetData.getClazz()).build();
excelWriter.write(sheetData.getData(), writeSheet);
}
excelWriter.finish();
log.info("多sheet商品Excel导出成功文件名{},共{}个sheet", fileName, sheetDataList.size());
} catch (IOException e) {
log.error("多sheet商品Excel导出失败", e);
throw new CzgException("Excel导出失败", e);
}
}
}

View File

@@ -0,0 +1,47 @@
package com.czg.excel;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
/**
* @author yjjie
* @date 2026/1/28 16:16
*/
public class LocalTimeConverter implements Converter<LocalTime> {
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("HH:mm:ss");
@Override
public Class<LocalTime> supportJavaTypeKey() {
return LocalTime.class;
}
@Override
public CellDataTypeEnum supportExcelTypeKey() {
return CellDataTypeEnum.STRING;
}
@Override
public LocalTime convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
String stringValue = cellData.getStringValue();
if (stringValue == null || stringValue.trim().isEmpty()) {
return null;
}
return LocalTime.parse(stringValue, FORMATTER);
}
@Override
public WriteCellData<?> convertToExcelData(LocalTime value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
if (value == null) {
return new WriteCellData<>("");
}
return new WriteCellData<>(value.format(FORMATTER));
}
}

View File

@@ -0,0 +1,21 @@
package com.czg.excel;
import com.alibaba.excel.write.handler.SheetWriteHandler;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
/**
* 多sheet导出数据封装类
* @author yjjie
* @date 2026/1/30 10:53
*/
@Data
@Accessors(chain = true)
public class SheetData {
private List<?> data;
private Class<?> clazz;
private String sheetName;
private List<SheetWriteHandler> handlers;
}

View File

@@ -250,13 +250,6 @@
<artifactId>spring-data-redis</artifactId>
<version>${spring-data-redis.version}</version>
</dependency>
<!-- excel 导入导出工具类https://github.com/pig-mesh/excel-spring-boot-starter -->
<!-- 参考文档https://www.yuque.com/pig4cloud/excel -->
<dependency>
<groupId>com.pig4cloud.excel</groupId>
<artifactId>excel-spring-boot-starter</artifactId>
<version>3.4.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.netty/netty-all -->
<dependency>

View File

@@ -313,8 +313,8 @@ public class WechatEntryManager {
bizStoreInfo.setBizStoreName(baseInfo.getShortName());
bizStoreInfo.setBizAddressCode(storeInfo.getMercAreaCode());
bizStoreInfo.setBizStoreAddress(storeInfo.getBusinessAddress());
bizStoreInfo.setStoreEntrancePic(storeInfo.getDoorPic().getWechatId());
bizStoreInfo.setIndoorPic(storeInfo.getInsidePic().getWechatId());
bizStoreInfo.setStoreEntrancePic(List.of(storeInfo.getDoorPic().getWechatId()));
bizStoreInfo.setIndoorPic(List.of(storeInfo.getInsidePic().getWechatId()));
salesInfo.setBizStoreInfo(bizStoreInfo);
WechatEntryMiniProgramReqDto miniProgramInfo = new WechatEntryMiniProgramReqDto();
miniProgramInfo.setMiniProgramAppid("wxd88fffa983758a30");

View File

@@ -55,8 +55,8 @@ public class WechatEntryStoreInfoReqDto {
* 2、请填写通过图片上传API预先上传图片生成好的MediaID。
*/
@JSONField(name = "store_entrance_pic")
// private List<String> storeEntrancePic;
private String storeEntrancePic;
private List<String> storeEntrancePic;
// private String storeEntrancePic;
/**
* 【必填】
@@ -65,8 +65,8 @@ public class WechatEntryStoreInfoReqDto {
* 2、请填写通过图片上传API预先上传图片生成好的MediaID。
*/
@JSONField(name = "indoor_pic")
// private List<String> indoorPic;
private String indoorPic;
private List<String> indoorPic;
// private String indoorPic;
/**
* 【选填】

View File

@@ -1,11 +1,11 @@
package com.czg.service.account.service.impl;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSONObject;
import com.czg.account.service.GeoService;
import com.czg.exception.CzgException;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestClient;
@@ -49,7 +49,7 @@ public class GeoServiceImpl implements GeoService {
param.put("key", "7a7f2e4790ea222660a027352ee3af39");
param.put("keywords", keywords);
param.put("subdistrict", "1");
if (StringUtils.isNotBlank(subdistrict)) {
if (StrUtil.isNotBlank(subdistrict)) {
param.put("subdistrict", "2");
}
param.put("extensions", "base");

View File

@@ -14,7 +14,6 @@ import jakarta.annotation.Resource;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.cache.annotation.Cacheable;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@@ -37,7 +36,7 @@ public class ShopConfigServiceImpl extends ServiceImpl<ShopConfigMapper, ShopCon
@Override
@Cacheable(cacheNames = "shopInfo",key = "#id")
public ShopInfo getShopInfoAndConfig(Serializable id) throws CzgException {
public ShopInfo getShopInfoAndConfig(Long id) throws CzgException {
ShopInfo shopInfo = shopInfoMapper.selectOneById(id);
if (shopInfo == null) {
throw new CzgException("店铺不存在");

View File

@@ -83,7 +83,7 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
@Override
public ShopInfo getById(Serializable id) throws CzgException {
return shopConfigService.getShopInfoAndConfig(id);
return shopConfigService.getShopInfoAndConfig((Long) id);
}
@Override
@@ -459,7 +459,7 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
@Override
public BigDecimal updateAmount(Long id, BigDecimal amount) {
ShopInfo shopInfo = getShopInfo(id);
if (shopInfo.getAmount() == null || shopInfo.getAmount().compareTo(BigDecimal.ZERO) <= 0) {
if (shopInfo.getAmount().add(amount).compareTo(BigDecimal.ZERO) < 0) {
throw new CzgException("更新失败");
}
boolean flag = mapper.updateAmount(id, amount);

View File

@@ -7,13 +7,13 @@ import com.czg.config.RedisCst;
import com.czg.exception.CzgException;
import com.czg.sa.StpKit;
import com.czg.service.RedisService;
import com.czg.utils.CzgRandomUtils;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.czg.account.entity.ShopSong;
import com.czg.account.service.ShopSongService;
import com.czg.service.account.mapper.ShopSongMapper;
import jakarta.annotation.Resource;
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.stereotype.Service;
/**
@@ -23,7 +23,7 @@ import org.springframework.stereotype.Service;
* @since 2025-03-01
*/
@Service
public class ShopSongServiceImpl extends ServiceImpl<ShopSongMapper, ShopSong> implements ShopSongService{
public class ShopSongServiceImpl extends ServiceImpl<ShopSongMapper, ShopSong> implements ShopSongService {
@Resource
private RedisService redisService;
@@ -49,18 +49,12 @@ public class ShopSongServiceImpl extends ServiceImpl<ShopSongMapper, ShopSong> i
public String getSongUrl(Long shopId) {
String code;
String key = RedisCst.getSongUrlKey(shopId);
if(redisService.hasKey(key)){
if (redisService.hasKey(key)) {
code = (String) redisService.get(key);
}else {
code = RandomStringUtils.randomAlphanumeric(12);
} else {
code = CzgRandomUtils.randomString(12);
redisService.set(key, code);
}
return code;
}
public static void main(String[] args) {
String string = RandomStringUtils.randomAlphanumeric(12);
System.out.println(string);
}
}

View File

@@ -18,7 +18,7 @@
and amount - #{money} >= 0
</update>
<update id="updateOneOrTwoAmount">
update tb_shop_user
update mk_distribution_invite
<set>
<if test="isOne != null and isOne == 1">
one_income = one_income + #{amount}
@@ -27,7 +27,7 @@
two_income = two_income + #{amount}
</if>
</set>
where id = #{shopUserId}
where shop_user_id = #{shopUserId} and shop_id = #{shopId}
</update>
@@ -256,10 +256,10 @@
</select>
<select id="getInviteUser" resultType="com.czg.market.vo.InviteUserVO">
SELECT
invite.id AS shopUserId,
invite.head_img AS headImg,
invite.nick_name AS shopUserName,
invite.phone AS shopUserPhone,
u.id AS shopUserId,
u.head_img AS headImg,
u.nick_name AS shopUserName,
u.phone AS shopUserPhone,
invite.one_income AS oneIncome,
invite.invite_time AS inviteTime,
dist.total_income AS totalIncome,
@@ -269,12 +269,14 @@
dist.status AS status,
dist.distribution_level_id AS levelId,
dist.distribution_level_name AS levelName,
invite.distribution_shops AS distributionShops
FROM tb_shop_user invite
left join mk_distribution_user dist on invite.id = dist.id and dist.shop_id = #{shopId}
WHERE invite.`parent_user_id` = #{distributionUserId}
u.distribution_shops AS distributionShops
FROM mk_distribution_invite invite
left join tb_shop_user u on invite.shop_user_id = u.id
left join mk_distribution_user dist on invite.shop_user_id = dist.id
WHERE invite.`parent_user_id` = #{distributionUserId} and invite.shop_id = #{shopId}
<if test="distributionLevelId != null">and dist.distribution_level_id = #{distributionLevelId}</if>
<if test="shopUserId != null">and invite.id = #{shopUserId}</if>
GROUP BY invite.id
ORDER BY invite.`invite_time` DESC
</select>
</mapper>

View File

@@ -0,0 +1,14 @@
package com.czg.service.market.mapper;
import com.mybatisflex.core.BaseMapper;
import com.czg.market.entity.MkDistributionInvite;
/**
* 全民股东邀请关系 映射层。
*
* @author ww
* @since 2026-01-31
*/
public interface MkDistributionInviteMapper extends BaseMapper<MkDistributionInvite> {
}

View File

@@ -36,9 +36,11 @@ public class MkCarouselServiceImpl extends ServiceImpl<MkCarouselMapper, MkCarou
}
List<MkCarousel> list = list(queryWrapper);
list.forEach(mkCarousel -> {
MiniAppPages miniAppPages = miniAppPageService.getById(mkCarousel.getJumpPageId());
if (miniAppPages != null) {
mkCarousel.setJumpPagePath(miniAppPages.getPath());
if (mkCarousel.getJumpPageId() != null) {
MiniAppPages miniAppPages = miniAppPageService.getById(mkCarousel.getJumpPageId());
if (miniAppPages != null) {
mkCarousel.setJumpPagePath(miniAppPages.getPath());
}
}
});
return list;

View File

@@ -0,0 +1,22 @@
package com.czg.service.market.service.impl;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.czg.market.entity.MkDistributionInvite;
import com.czg.market.service.MkDistributionInviteService;
import com.czg.service.market.mapper.MkDistributionInviteMapper;
import org.springframework.stereotype.Service;
/**
* 全民股东邀请关系 服务层实现。
*
* @author ww
* @since 2026-01-31
*/
@Service
public class MkDistributionInviteServiceImpl extends ServiceImpl<MkDistributionInviteMapper, MkDistributionInvite> implements MkDistributionInviteService{
@Override
public MkDistributionInvite getByShopIdAndShopUserId(Long shopId, Long shopUserId) {
return getOne(query().eq(MkDistributionInvite::getShopId, shopId).eq(MkDistributionInvite::getShopUserId, shopUserId));
}
}

View File

@@ -76,6 +76,8 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
@Resource
private MkDistributionDeliverService distributionDeliverService;
@Resource
private MkDistributionInviteService distributionInviteService;
@Resource
private AppWxServiceImpl appWxService;
@DubboReference
private ShopUserService shopUserService;
@@ -148,9 +150,9 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
AssertUtil.isNull(shopUser, "店铺用户不存在");
UserInfo userInfo = userInfoService.getById(shopUser.getUserId());
result.put("cashOutAmount", userInfo.getDistributionAmount() == null ? 0.0 : userInfo.getDistributionAmount());
if (shopUser.getParentUserId() != null) {
MkDistributionUser mkDistributionUser = getMkDistributionUserByIdAndShopId(shopUser.getParentUserId(), shopId);
MkDistributionInvite invite = distributionInviteService.getByShopIdAndShopUserId(shopId, shopUser.getId());
if (invite != null && invite.getParentUserId() != null) {
MkDistributionUser mkDistributionUser = getMkDistributionUserByIdAndShopId(invite.getParentUserId(), shopId);
AssertUtil.isNull(mkDistributionUser, "上级分销员不存在");
ShopUser shopUserParent = shopUserService.getById(mkDistributionUser.getId());
result.put("parentName", shopUserParent.getNickName());
@@ -234,8 +236,9 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
public void bindInviteUser(MkDistributionUserDTO param) throws CzgException, ValidateException {
ShopUser shopUser = shopUserService.getById(param.getId());
AssertUtil.isNull(shopUser, "店铺用户不存在");
if (shopUser.getParentUserId() != null) {
throw new CzgException("店铺用户已绑定分销员");
MkDistributionInvite shopUserInvite = distributionInviteService.getByShopIdAndShopUserId(param.getShopId(), shopUser.getId());
if (shopUserInvite != null && shopUserInvite.getParentUserId() != null) {
throw new CzgException("店铺用户已存在上级");
}
MkDistributionUser parent = getOne(QueryWrapper.create().eq(MkDistributionUser::getInviteCode, param.getInviteCode()));
AssertUtil.isNull(parent, "邀请人不存在");
@@ -250,28 +253,28 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
}
ShopUser parentShopUser = shopUserService.getById(parent.getId());
AssertUtil.isNull(parentShopUser, "邀请人不存在");
MkDistributionInvite parentShopUserInvite = distributionInviteService.getByShopIdAndShopUserId(param.getShopId(), parentShopUser.getId());
if (parentShopUserInvite != null && parentShopUserInvite.getParentUserId() != null && parentShopUserInvite.getParentUserId().equals(shopUser.getId())) {
throw new CzgException("存在绑定关系,不可绑定");
}
if (parentShopUserInvite != null && parentShopUserInvite.getGradeUserId() != null && parentShopUserInvite.getGradeUserId().equals(shopUser.getId())) {
throw new CzgException("存在绑定关系,不可绑定");
}
if (parentShopUser.getParentUserId() != null && parentShopUser.getParentUserId().equals(shopUser.getId())) {
throw new CzgException("存在绑定关系,不可绑定");
}
if (parentShopUser.getGradeUserId() != null && parentShopUser.getGradeUserId().equals(shopUser.getId())) {
throw new CzgException("存在绑定关系,不可绑定");
}
//更新自己的上级
shopUser.setParentUserId(parentShopUser.getId());
shopUser.setGradeUserId(parentShopUser.getParentUserId());
//更新自己的下级 的上级的上级 为自己的上级
ShopUser upShopUser1 = new ShopUser();
upShopUser1.setParentUserId(parentShopUser.getId());
upShopUser1.setGradeUserId(parentShopUser.getParentUserId());
shopUserService.update(upShopUser1, QueryWrapper.create().eq(ShopUser::getId, shopUser.getId()));
if (shopUser.getParentUserId() != null) {
MkDistributionInvite newShopUserInvite = new MkDistributionInvite();
newShopUserInvite.setShopId(param.getShopId());
newShopUserInvite.setUserId(shopUser.getUserId());
newShopUserInvite.setShopUserId(shopUser.getId());
newShopUserInvite.setParentUserId(parentShopUser.getId());
newShopUserInvite.setGradeUserId(parentShopUserInvite == null ? null : parentShopUserInvite.getParentUserId());
newShopUserInvite.setInviteTime(LocalDateTime.now());
distributionInviteService.save(newShopUserInvite);
if (parentShopUserInvite != null && parentShopUserInvite.getParentUserId() != null) {
//更新自己的下级 的上级的上级 为自己的上级
ShopUser upShopUser = new ShopUser();
upShopUser.setGradeUserId(shopUser.getParentUserId());
shopUserService.update(upShopUser, QueryWrapper.create().eq(ShopUser::getParentUserId, shopUser.getId()));
MkDistributionInvite childShopUserInvite = new MkDistributionInvite();
childShopUserInvite.setGradeUserId(parentShopUser.getId());
distributionInviteService.update(childShopUserInvite, QueryWrapper.create().eq(MkDistributionInvite::getParentUserId, shopUser.getId()));
}
MkDistributionUser newDistributionUser = new MkDistributionUser();
@@ -318,16 +321,14 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
@Override
@GlobalTransactional
public void bindInviteUser(Long fromUserId, Long toUserId, Long shopId) throws CzgException, ValidateException {
ShopUser shopUser = shopUserService.getById(fromUserId);
ShopUser shopUser = shopUserService.getById(toUserId);
AssertUtil.isNull(shopUser, "店铺用户不存在");
if (shopUser.getParentUserId() != null) {
throw new CzgException("店铺用户已绑定上级");
MkDistributionInvite shopUserInvite = distributionInviteService.getByShopIdAndShopUserId(shopId, shopUser.getId());
if (shopUserInvite != null && shopUserInvite.getParentUserId() != null) {
throw new CzgException("店铺用户已存在上级");
}
MkDistributionUser parent = getOne(QueryWrapper.create().eq(MkDistributionUser::getId, toUserId));
MkDistributionUser parent = getOne(QueryWrapper.create().eq(MkDistributionUser::getId, fromUserId).eq(MkDistributionUser::getShopId, shopId));
AssertUtil.isNull(parent, "邀请人不存在");
if (!parent.getShopId().equals(shopId)) {
throw new CzgException("邀请人不是本店铺的分销员");
}
if (parent.getId().equals(shopUser.getId())) {
throw new CzgException("不能绑定自己为上级");
}
@@ -337,27 +338,28 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
ShopUser parentShopUser = shopUserService.getById(parent.getId());
AssertUtil.isNull(parentShopUser, "邀请人不存在");
if (parentShopUser.getParentUserId() != null && parentShopUser.getParentUserId().equals(shopUser.getId())) {
MkDistributionInvite parentShopUserInvite = distributionInviteService.getByShopIdAndShopUserId(shopId, parentShopUser.getId());
if (parentShopUserInvite != null && parentShopUserInvite.getParentUserId() != null && parentShopUserInvite.getParentUserId().equals(shopUser.getId())) {
throw new CzgException("存在绑定关系,不可绑定");
}
if (parentShopUser.getGradeUserId() != null && parentShopUser.getGradeUserId().equals(shopUser.getId())) {
if (parentShopUserInvite != null && parentShopUserInvite.getGradeUserId() != null && parentShopUserInvite.getGradeUserId().equals(shopUser.getId())) {
throw new CzgException("存在绑定关系,不可绑定");
}
//更新自己的上级
shopUser.setParentUserId(parentShopUser.getId());
shopUser.setGradeUserId(parentShopUser.getParentUserId());
//更新自己的下级 的上级的上级 为自己的上级
ShopUser upShopUser1 = new ShopUser();
upShopUser1.setParentUserId(parentShopUser.getId());
upShopUser1.setGradeUserId(parentShopUser.getParentUserId());
shopUserService.update(upShopUser1, QueryWrapper.create().eq(ShopUser::getId, shopUser.getId()));
if (shopUser.getParentUserId() != null) {
MkDistributionInvite newShopUserInvite = new MkDistributionInvite();
newShopUserInvite.setShopId(shopId);
newShopUserInvite.setUserId(shopUser.getUserId());
newShopUserInvite.setShopUserId(shopUser.getId());
newShopUserInvite.setParentUserId(parentShopUser.getId());
newShopUserInvite.setGradeUserId(parentShopUserInvite == null ? null : parentShopUserInvite.getParentUserId());
newShopUserInvite.setInviteTime(LocalDateTime.now());
distributionInviteService.save(newShopUserInvite);
if (parentShopUserInvite != null && parentShopUserInvite.getParentUserId() != null) {
//更新自己的下级 的上级的上级 为自己的上级
ShopUser upShopUser = new ShopUser();
upShopUser.setGradeUserId(shopUser.getParentUserId());
shopUserService.update(upShopUser, QueryWrapper.create().eq(ShopUser::getParentUserId, shopUser.getId()));
MkDistributionInvite childShopUserInvite = new MkDistributionInvite();
childShopUserInvite.setGradeUserId(parentShopUser.getId());
distributionInviteService.update(childShopUserInvite, QueryWrapper.create().eq(MkDistributionInvite::getParentUserId, shopUser.getId()));
}
MkDistributionUser newDistributionUser = new MkDistributionUser();
@@ -405,8 +407,9 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
public void costUpgradeLevelBefore(Long userId, Long shopId) {
ShopUser shopUser = shopUserService.getShopUserInfo(shopId, userId);
costUpgradeLevel(shopUser.getId(), shopId);
if (shopUser.getParentUserId() != null) {
costUpgradeLevel(shopUser.getParentUserId(), shopId);
MkDistributionInvite shopUserInvite = distributionInviteService.getByShopIdAndShopUserId(shopId, shopUser.getId());
if (shopUserInvite != null && shopUserInvite.getParentUserId() != null) {
costUpgradeLevel(shopUserInvite.getParentUserId(), shopId);
}
}
@@ -773,18 +776,19 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
AssertUtil.isTrue(config.getIsEnable() != 1, "分销未开启");
// 产生消费的用户
ShopUser curUser = shopUserService.getShopUserInfo(shopId, sourceUserId);
if (curUser == null || curUser.getParentUserId() == null) {
MkDistributionInvite sourceInviteUser = distributionInviteService.getByShopIdAndShopUserId(shopId, curUser.getId());
if (sourceInviteUser.getParentUserId() == null) {
return;
}
log.info("开始分销, 当前来源用户: {}, shopId: {}, 邀请人id: {}", sourceUserId, shopId, curUser.getParentUserId());
log.info("开始分销, 当前来源用户: {}, shopId: {}, 邀请人id: {}", sourceUserId, shopId, sourceInviteUser.getParentUserId());
MkDistributionUser distributionUser = getMkDistributionUserByIdAndShopId(curUser.getParentUserId(), shopId);
MkDistributionUser distributionUser = getMkDistributionUserByIdAndShopId(sourceInviteUser.getParentUserId(), shopId);
MkDistributionLevelConfig level = levelConfigService.getById(distributionUser.getDistributionLevelId());
deepReward(curUser, level.getCommission(), config, distributionUser,
amount, sourceId, type, orderNo, 1);
if (curUser.getGradeUserId() != null) {
MkDistributionUser parentDis = getMkDistributionUserByIdAndShopId(curUser.getGradeUserId(), shopId);
if (sourceInviteUser.getGradeUserId() != null) {
MkDistributionUser parentDis = getMkDistributionUserByIdAndShopId(sourceInviteUser.getGradeUserId(), shopId);
MkDistributionLevelConfig parentDisLevel = levelConfigService.getById(parentDis.getDistributionLevelId());
deepReward(curUser, parentDisLevel.getCommission().subtract(level.getCommission()), config, parentDis,
amount, sourceId, type, orderNo, 2);

View File

@@ -39,6 +39,7 @@ public class MkShareBaseServiceImpl extends ServiceImpl<MkShareBaseMapper, MkSha
ShopCouponDTO sharerCoupon = shopCouponService.getCouponById(shareBase.getSharerCouponId());
if (sharerCoupon != null) {
shareBase.setSharerCouponName(sharerCoupon.getTitle());
shareBase.setSharerCoupon(sharerCoupon);
}
}
if (shareBase.getSharedUserCouponId() != null) {
@@ -61,10 +62,12 @@ public class MkShareBaseServiceImpl extends ServiceImpl<MkShareBaseMapper, MkSha
}
//绑定上下级
if (StrUtil.isNotBlank(inviteCode)) {
FunUtils.asyncSafeRunVoid(() -> distributionUserService.bindInviteUser(fromUserId, toUserId, shopId));
FunUtils.safeRunVoid(() -> {
distributionUserService.bindInviteUser(fromUserId, toUserId, shopId);
}, "shareClaim绑定上下级");
}
MkShareBase shareBase = getById(shopId);
if (shareBase == null || shareBase.getIsEnabled().equals(1) || StrUtil.isBlank(shareBase.getRewardSharePages())) {
if (shareBase == null || !shareBase.getIsEnabled().equals(1) || StrUtil.isBlank(shareBase.getRewardSharePages())) {
return;
}
if (!shareBase.getRewardSharePages().contains(tagType)) {
@@ -81,6 +84,13 @@ public class MkShareBaseServiceImpl extends ServiceImpl<MkShareBaseMapper, MkSha
.eq(MkShopCouponRecord::getSource, "邀请获得"));
grant = !exists;
}
if (grant) {
grant = !mkShopCouponRecordService.exists(query()
.eq(MkShopCouponRecord::getShopId, shopId)
.eq(MkShopCouponRecord::getShopUserId, fromUserId)
.eq(MkShopCouponRecord::getSourceFlowId, toUserId)
.eq(MkShopCouponRecord::getSource, "邀请获得"));
}
if (grant) {
MkShopCouponGiftDTO giftDTO = new MkShopCouponGiftDTO();
giftDTO.setShopId(shopId)

View File

@@ -67,12 +67,14 @@ public class MkShopCouponRecordServiceImpl extends ServiceImpl<MkShopCouponRecor
private ShopCouponMapper couponService;
private static final List<String> TARGET_KEY = Arrays.asList("消费赠券", "充值赠券", "管理员赠送", "兑换码兑换", "群聊发放", "生日赠券",
"购买会员赠券", "短信发放", "公众号发放", "用户弹窗领取", "积分兑换");
"购买会员赠券", "短信发放", "公众号发放", "用户弹窗领取", "积分兑换", "参与分享获得", "邀请获得");
private static final Map<String, String> SOURCE_TO_CATEGORY = Map.ofEntries(
Map.entry("用户弹窗领取", "用户领取"),
Map.entry("兑换码兑换", "用户领取"),
Map.entry("积分兑换", "用户领取"),
Map.entry("参与分享获得", "分享获得"),
Map.entry("邀请获得", "分享获得"),
Map.entry("群聊发放", "群聊发放"),
Map.entry("短信发放", "推广发放"),
Map.entry("公众号发放", "推广发放"),

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.czg.service.market.mapper.MkDistributionInviteMapper">
</mapper>

View File

@@ -65,8 +65,10 @@
<select id="getOrderConsumeAmountByList" resultType="java.math.BigDecimal">
SELECT IFNULL(SUM(ord.pay_amount), 0) AS totalAmount
FROM tb_shop_user invite
INNER JOIN tb_order_info ord ON invite.user_id = ord.user_id
FROM mk_distribution_invite invite
INNER JOIN tb_shop_user su on invite.shop_user_id = su.id
INNER JOIN tb_order_info ord ON su.user_id = ord.user_id
and invite.shop_id = #{shopId}
AND ord.shop_id = #{shopId}
AND ord.STATUS = 'done'
AND ord.pay_type NOT IN ('vip_pay', 'credit_pay')

View File

@@ -1,18 +1,21 @@
package com.czg.service.order.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.alibaba.excel.write.handler.SheetWriteHandler;
import com.czg.excel.ExcelExportUtil;
import com.czg.excel.SheetData;
import com.czg.order.param.TableSummaryParam;
import com.czg.order.service.TableSummaryService;
import com.czg.order.vo.TableSummaryExportVo;
import com.czg.service.order.mapper.ShopTableOrderStatisticMapper;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
@@ -27,9 +30,8 @@ public class TableSummaryServiceImpl implements TableSummaryService {
@Resource
private ShopTableOrderStatisticMapper shopTableOrderStatisticMapper;
@Override
public List<TableSummaryExportVo> summaryExportList(TableSummaryParam param) {
public void summaryExportList(TableSummaryParam param, HttpServletResponse response) {
if (param.getBeginDate() == null && param.getEndDate() == null) {
// 获取当前日期
LocalDate currentDate = LocalDate.now();
@@ -46,49 +48,103 @@ public class TableSummaryServiceImpl implements TableSummaryService {
param.setBeginDate(formattedStartDate + " 00:00:00");
param.setEndDate(formattedEndDate + " 23:59:59");
}
List<TableSummaryExportVo> list = shopTableOrderStatisticMapper.findSummaryExportList(param);
if (CollUtil.isEmpty(list)) {
return List.of();
ExcelExportUtil.exportToResponse(new ArrayList<>(), TableSummaryExportVo.class, "台桌统计", response);
return;
}
record TableSummary(String tableKey, BigDecimal totalSales, Map<Long, BigDecimal> productSales) {}
Map<String, TableSummary> summaryMap = list.stream()
// === Step 1: 按日期计算 当日总销售额 ===
Map<String, BigDecimal> dailyTotalMap = list.stream()
.collect(Collectors.groupingBy(
vo -> vo.getTableCode() + "_" + vo.getCreateDate(),
Collectors.collectingAndThen(
Collectors.toList(),
vos -> {
String tableKey = vos.getFirst().getTableCode() + "_" + vos.getFirst().getCreateDate();
BigDecimal totalSales = vos.stream()
.map(TableSummaryExportVo::getAmount)
.reduce(BigDecimal.ZERO, BigDecimal::add);
Map<Long, BigDecimal> productSales = vos.stream()
.collect(Collectors.groupingBy(
TableSummaryExportVo::getProductId,
Collectors.reducing(
BigDecimal.ZERO,
TableSummaryExportVo::getAmount,
BigDecimal::add
)
));
return new TableSummary(tableKey, totalSales, productSales);
}
)
TableSummaryExportVo::getCreateDate,
Collectors.reducing(BigDecimal.ZERO, TableSummaryExportVo::getAmount, BigDecimal::add)
));
list.forEach(vo -> {
TableSummary summary = summaryMap.get(vo.getTableConcatDate());
if (summary != null) {
vo.setTotalSalesAmount(summary.totalSales());
vo.setSalesAmount(summary.productSales().getOrDefault(vo.getProductId(), BigDecimal.ZERO));
}
});
// 追加个空行用于处理表格样式
TableSummaryExportVo nullVo = new TableSummaryExportVo();
list.add(nullVo);
return list;
// === Step 2: 按 台桌+日期 计算 每台桌当日销售额 ===
Map<String, BigDecimal> tableDailyTotalMap = list.stream()
.collect(Collectors.groupingBy(
vo -> vo.getTableCode() + "_" + vo.getCreateDate(),
Collectors.reducing(BigDecimal.ZERO, TableSummaryExportVo::getAmount, BigDecimal::add)
));
// === Step 3: 回填字段 ===
for (TableSummaryExportVo vo : list) {
String dateKey = vo.getCreateDate();
String tableDateKey = vo.getTableCode() + "_" + dateKey;
// 设置“总销售额” = 该台桌当天总销售额
vo.setSalesAmount(tableDailyTotalMap.getOrDefault(tableDateKey, BigDecimal.ZERO));
// 设置“当日总销售额” = 当天所有台桌总和
vo.setTotalSalesAmount(dailyTotalMap.getOrDefault(dateKey, BigDecimal.ZERO));
}
// === Step 4: 导出 ===
List<SheetWriteHandler> strategies = calculateMergeCells(list);
ExcelExportUtil.exportMultipleSheetsToResponse(
List.of(new SheetData()
.setData(list)
.setSheetName("台桌统计")
.setHandlers(strategies)
.setClazz(TableSummaryExportVo.class)),
"台桌统计",
response);
}
}
/**
* 计算需要合并的单元格信息
*/
private List<SheetWriteHandler> calculateMergeCells(List<TableSummaryExportVo> list) {
List<SheetWriteHandler> mergeInfos = new ArrayList<>();
if (CollUtil.isEmpty(list)) {
return mergeInfos;
}
// 按日期分组(用于合并“日期”和“当日总销售额”列)
Map<String, List<TableSummaryExportVo>> byDate = list.stream()
.collect(Collectors.groupingBy(TableSummaryExportVo::getCreateDate));
int currentRow = 1; // Excel 数据从第1行开始第0行为标题
// 按日期排序
List<String> sortedDates = byDate.keySet().stream().sorted().toList();
for (String date : sortedDates) {
List<TableSummaryExportVo> dateGroup = byDate.get(date);
int dateSize = dateGroup.size();
// 合并“日期”列第0列和“当日总销售额”列第9列
if (dateSize > 1) {
mergeInfos.add(ExcelExportUtil.createMergeStrategy(currentRow, currentRow + dateSize - 1, 0, 0));
mergeInfos.add(ExcelExportUtil.createMergeStrategy(currentRow, currentRow + dateSize - 1, 9, 9));
}
// 在日期组内,按台桌分组(用于合并“台桌”和“总销售额”列)
Map<String, List<TableSummaryExportVo>> byTable = dateGroup.stream()
.collect(Collectors.groupingBy(TableSummaryExportVo::getTableName));
int tableStartRow = currentRow;
List<String> sortedTables = byTable.keySet().stream().sorted().toList();
for (String table : sortedTables) {
List<TableSummaryExportVo> tableGroup = byTable.get(table);
int tableSize = tableGroup.size();
// 合并“台桌”列第1列和“总销售额”列第8列
if (tableSize > 1) {
mergeInfos.add(ExcelExportUtil.createMergeStrategy(tableStartRow, tableStartRow + tableSize - 1, 1, 1));
mergeInfos.add(ExcelExportUtil.createMergeStrategy(tableStartRow, tableStartRow + tableSize - 1, 8, 8));
}
tableStartRow += tableSize;
}
currentRow += dateSize;
}
return mergeInfos;
}
}

View File

@@ -5,17 +5,22 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.write.handler.SheetWriteHandler;
import com.alibaba.excel.write.merge.OnceAbsoluteMergeStrategy;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONWriter;
import com.czg.constant.CacheConstant;
import com.czg.constants.SystemConstants;
import com.czg.excel.ExcelExportUtil;
import com.czg.excel.SheetData;
import com.czg.exception.CzgException;
import com.czg.product.dto.*;
import com.czg.product.entity.*;
import com.czg.product.enums.*;
import com.czg.product.param.*;
import com.czg.product.service.*;
import com.czg.product.vo.ProductGroupVo;
import com.czg.product.vo.ProductStatisticsVo;
import com.czg.sa.StpKit;
import com.czg.service.RedisService;
@@ -30,6 +35,7 @@ import com.mybatisflex.core.update.UpdateChain;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
@@ -43,6 +49,7 @@ import java.time.LocalDate;
import java.time.LocalTime;
import java.time.format.TextStyle;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
import static com.czg.constant.CacheConstant.ADMIN_CLIENT_PRODUCT_LIST;
@@ -65,7 +72,6 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
private final ProdSkuMapper prodSkuMapper;
private final ProdConsRelationMapper prodConsRelationMapper;
private final ConsInfoMapper consInfoMapper;
private final ConsStockFlowMapper consStockFlowMapper;
private final ProductStockFlowMapper productStockFlowMapper;
private final ProductStockFlowService productStockFlowService;
private final ConsStockFlowService consStockFlowService;
@@ -138,6 +144,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
private void buildProductExtInfo(List<ProductDTO> records) {
records.forEach(record -> {
record.setIsSaleTime(calcIsSaleTime(record.getDays(), record.getStartTime(), record.getEndTime()));
record.setProGroupVo(JSONArray.parseArray(record.getGroupSnap().toString(), ProductGroupVo.class));
List<ProdSkuDTO> skuList = prodSkuMapper.selectListByQueryAs(query().eq(ProdSku::getProductId, record.getId()).eq(ProdSku::getIsDel, SystemConstants.OneZero.ZERO), ProdSkuDTO.class);
if (CollUtil.isNotEmpty(skuList)) {
Optional<BigDecimal> lowPriceIsPresent = skuList.stream().map(obj -> NumberUtil.nullToZero(obj.getSalePrice())).min(BigDecimal::compareTo);
@@ -175,6 +182,154 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
return records;
}
@Override
public void exportProductList(ProductDTO param, HttpServletResponse response) {
// 1. 查询并构建完整数据
QueryWrapper queryWrapper = buildFullQueryWrapper(param);
List<ProductDTO> records = super.listAs(queryWrapper, ProductDTO.class);
buildProductExtInfo(records);
// 2. 分别处理普通商品和套餐商品
SheetData normalSheet = buildNormalProductSheet(records);
SheetData packageSheet = buildPackageProductSheet(records);
// 3. 导出
List<SheetData> dataList = List.of(normalSheet, packageSheet);
ExcelExportUtil.exportMultipleSheetsToResponse(dataList, "商品列表", response);
}
// -----------------------------
// 普通商品处理
// -----------------------------
private SheetData buildNormalProductSheet(List<ProductDTO> records) {
List<SheetWriteHandler> handlers = new ArrayList<>();
List<ProductExportDTO> dataList = new ArrayList<>();
for (ProductDTO dto : records) {
if ("package".equals(dto.getType())) continue; // 跳过套餐
int firstRow = dataList.size() + 1;
if (dto.getSkuList() != null && !dto.getSkuList().isEmpty()) {
for (ProdSkuDTO sku : dto.getSkuList()) {
ProductExportDTO exportDto = new ProductExportDTO();
BeanUtil.copyProperties(dto, exportDto);
exportDto.setSpecFullName(sku.getSpecInfo());
exportDto.setPrice(sku.getSalePrice());
exportDto.setMemberPrice(sku.getMemberPrice());
exportDto.setIsSale(sku.getIsGrounding());
exportDto.setBarCode(sku.getBarCode());
exportDto.setCostPrice(sku.getCostPrice());
dataList.add(exportDto);
}
int skuCount = dto.getSkuList().size();
if (skuCount > 1) {
mergeColumns(handlers, firstRow, firstRow + skuCount - 1,
0, 1, 7, 8, 9, 10, 11); // 多列合并
}
} else {
dataList.add(BeanUtil.copyProperties(dto, ProductExportDTO.class));
}
}
return new SheetData()
.setSheetName("普通商品")
.setData(dataList)
.setClazz(ProductExportDTO.class)
.setHandlers(handlers);
}
// -----------------------------
// 套餐商品处理
// -----------------------------
private SheetData buildPackageProductSheet(List<ProductDTO> records) {
List<SheetWriteHandler> handlers = new ArrayList<>();
List<ProductPackageExportDTO> dataList = new ArrayList<>();
for (ProductDTO exportDTO : records) {
if (!"package".equals(exportDTO.getType())) continue;
if (exportDTO.getProGroupVo() == null || exportDTO.getProGroupVo().isEmpty()) {
dataList.add(BeanUtil.copyProperties(exportDTO, ProductPackageExportDTO.class));
continue;
}
int sheetFirstRow = dataList.size() + 1;
boolean needOuterMerge = exportDTO.getProGroupVo().size() > 1;
for (ProductGroupVo proGroupDTO : exportDTO.getProGroupVo()) {
int groupFirstRow = dataList.size() + 1;
List<ProductGroupVo.Food> goods = proGroupDTO.getGoods();
int groupSize = goods.size();
// 添加每条商品记录
for (ProductGroupVo.Food good : goods) {
ProductPackageExportDTO pkgDto = new ProductPackageExportDTO()
.setName(exportDTO.getName())
.setCategoryName(exportDTO.getCategoryName())
.setUnitName(exportDTO.getUnitName())
.setPrice(getMainSkuPrice(exportDTO))
.setMemberPrice(getMainSkuMemberPrice(exportDTO))
.setType(exportDTO.getType())
.setGroupType(exportDTO.getGroupType())
.setStockNumber(exportDTO.getStockNumber())
.setIsSale(getMainSkuIsSale(exportDTO))
.setGroupTitleName(proGroupDTO.getTitle())
.setGroupProductNumber(Optional.ofNullable(proGroupDTO.getNumber()).map(String::valueOf).orElse(""))
.setGroupProductName(good.getProName() + "-" + good.getSkuName());
dataList.add(pkgDto);
}
// 组内合并:如果该组有多个商品
if (groupSize > 1) {
needOuterMerge = true;
mergeColumns(handlers, groupFirstRow, groupFirstRow + groupSize - 1, 5, 8);
}
}
// 外层合并:整个套餐的信息(名称、分类等)
if (needOuterMerge) {
int lastRow = dataList.size();
mergeColumns(handlers, sheetFirstRow, lastRow, 0, 1, 2, 3, 4);
}
}
return new SheetData()
.setSheetName("套餐商品")
.setData(dataList)
.setClazz(ProductPackageExportDTO.class)
.setHandlers(handlers);
}
// -----------------------------
// 辅助方法:提取主 SKU 信息(避免重复 getFirst()
// -----------------------------
private BigDecimal getMainSkuPrice(ProductDTO dto) {
return dto.getSkuList().isEmpty() ? null : dto.getSkuList().getFirst().getSalePrice();
}
private BigDecimal getMainSkuMemberPrice(ProductDTO dto) {
return dto.getSkuList().isEmpty() ? null : dto.getSkuList().getFirst().getMemberPrice();
}
private Integer getMainSkuIsSale(ProductDTO dto) {
return dto.getSkuList().isEmpty() ? null : dto.getSkuList().getFirst().getIsSale();
}
// -----------------------------
// 合并工具方法:支持多列合并
// -----------------------------
private void mergeColumns(List<SheetWriteHandler> handlers, int firstRow, int lastRow, int... columns) {
for (int col : columns) {
addMergeHandler(handlers, firstRow, lastRow, col, col);
}
}
private void addMergeHandler(List<SheetWriteHandler> handlers, int firstRow, int lastRow, int firstCol, int lastCol) {
handlers.add(ExcelExportUtil.createMergeStrategy(firstRow, lastRow, firstCol, lastCol));
}
@Override
public List<ProductDTO> getProductCacheList(ProductDTO param) {
Long shopId = param.getShopId();
@@ -555,7 +710,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
String type = param.getType();
Long id = param.getId();
Integer isSale = param.getIsSale();
String sensitiveOperation = "";
String sensitiveOperation;
if (isSale == 1) {
sensitiveOperation = "上架";
} else {

View File

@@ -3,7 +3,9 @@ package com.czg.service.product.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import com.czg.constants.SystemConstants;
import com.czg.excel.ExcelExportUtil;
import com.czg.exception.CzgException;
import com.czg.product.dto.ProductCategoryExportDTO;
import com.czg.product.dto.ShopProdCategoryDTO;
import com.czg.product.entity.ShopProdCategory;
import com.czg.product.service.ProductService;
@@ -16,6 +18,7 @@ import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.update.UpdateChain;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
@@ -62,6 +65,14 @@ public class ShopProdCategoryServiceImpl extends ServiceImpl<ShopProdCategoryMap
return super.listAs(queryWrapper, ShopProdCategoryDTO.class);
}
@Override
public void exportShopProdCategory(ShopProdCategoryDTO param, HttpServletResponse response) {
QueryWrapper queryWrapper = buildQueryWrapper(param);
queryWrapper.eq(ShopProdCategory::getStatus, SystemConstants.OneZero.ONE);
List<ProductCategoryExportDTO> exportList = listAs(queryWrapper, ProductCategoryExportDTO.class);
ExcelExportUtil.exportToResponse(exportList, ProductCategoryExportDTO.class, "商品分类列表", response);
}
@Override
public ShopProdCategoryDTO getShopProdCategoryById(Long id) {
Long shopId = StpKit.USER.getShopId(0L);

View File

@@ -3,7 +3,9 @@ package com.czg.service.product.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import com.czg.constants.SystemConstants;
import com.czg.excel.ExcelExportUtil;
import com.czg.exception.CzgException;
import com.czg.product.dto.ProductUnitExportDTO;
import com.czg.product.dto.ShopProdUnitDTO;
import com.czg.product.entity.ShopProdUnit;
import com.czg.product.enums.UnitTypeEnum;
@@ -15,6 +17,7 @@ import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.update.UpdateChain;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Service;
import java.util.List;
@@ -59,6 +62,14 @@ public class ShopProdUnitServiceImpl extends ServiceImpl<ShopProdUnitMapper, Sho
return super.listAs(queryWrapper, ShopProdUnitDTO.class);
}
@Override
public void exportShopProdUnit(ShopProdUnitDTO param, HttpServletResponse response) {
QueryWrapper queryWrapper = buildQueryWrapper(param);
queryWrapper.eq(ShopProdUnit::getStatus,SystemConstants.OneZero.ONE);
List<ProductUnitExportDTO> unitExportDTOList = listAs(queryWrapper, ProductUnitExportDTO.class);
ExcelExportUtil.exportToResponse(unitExportDTOList, ProductUnitExportDTO.class, "单位列表", response);
}
@Override
public ShopProdUnitDTO getShopProdUnitById(Long id) {
Long shopId = StpKit.USER.getShopId(0L);