抢购物品数据库表里增加当前一页

This commit is contained in:
2026-05-30 11:58:41 +08:00
parent 4fb389ea3a
commit cfcbde95dd
7 changed files with 66 additions and 12 deletions

View File

@@ -71,6 +71,10 @@ public class LbGoods implements Serializable {
@Schema(description = "状态")
private Integer status;
@TableField("current_page")
@Schema(description = "当前页码(同步来源页)")
private Integer currentPage;
@TableField("created_at")
@Schema(description = "创建时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")

View File

@@ -300,6 +300,7 @@ public class LbGoodsServiceImpl extends ServiceImpl<LbGoodsMapper, LbGoods> impl
continue;
}
row.setTenantId(tid);
row.setCurrentPage(page);
applyDefaults(row);
if (row.getCreatedAt() == null) {
row.setCreatedAt(now);
@@ -471,10 +472,10 @@ public class LbGoodsServiceImpl extends ServiceImpl<LbGoodsMapper, LbGoods> impl
entity.setTotalMoney(BigDecimal.ZERO);
}
if (entity.getIsShow() == null) {
entity.setIsShow(1);
entity.setIsShow(-1);
}
if (entity.getStatus() == null) {
entity.setStatus(1);
entity.setStatus(-1);
}
}

View File

@@ -97,10 +97,10 @@ public class LbPurchaseApplyServiceImpl
/** 试用期包含的工作日天数(周一至周五),周六日不计入。 */
private static final int TRIAL_WEEKDAY_COUNT = 3;
/** 同事特权开通提醒中「特权开通日期」包含的工作日天数(与 syncHxrAdminColleagueVip 的 viptime 规则一致)。 */
/** 同事特权开通提醒中「特权开通日期」包含的工作日天数(开通日次日顺延至工作日起算,共 2 个工作日)。 */
private static final int COLLEAGUE_PRIVILEGE_WEEKDAY_COUNT = 2;
private static final String COLLEAGUE_VIP_GROUP_LABEL = "开通特权提醒";
private static final String COLLEAGUE_VIP_GROUP_LABEL = "特权提醒";
private static final String PARSE_SYSTEM_PROMPT = """
你是信息抽取助手。用户会提供一段「进货申请」相关的自然语言订货信息。
@@ -1090,7 +1090,7 @@ public class LbPurchaseApplyServiceImpl
CellStyle groupStyle = createGroupStyle(workbook);
CellStyle dataStyle = createDataStyle(workbook);
String[] headers = {"", "昵称", "手机号", "特权开通日期", "开通日期"};
String[] headers = {"提醒", "昵称", "手机号", "特权开通日期", "开通日期"};
Row headerRow = sheet.createRow(0);
headerRow.setHeightInPoints(22);
for (int i = 0; i < headers.length; i++) {
@@ -1106,12 +1106,12 @@ public class LbPurchaseApplyServiceImpl
createExportCell(row, 1, formatColleagueVipNickname(item), dataStyle);
createExportCell(row, 2, nullToEmpty(item.getColleaguePhone()), dataStyle);
createExportCell(row, 3, formatColleaguePrivilegeRange(item.getApplyDate()), dataStyle);
createExportCell(row, 4, formatActivationDate(item.getApplyDate()), dataStyle);
createExportCell(row, 4, formatColleagueVipActivationDate(item.getApplyDate()), dataStyle);
rowIndex++;
}
int groupEndRow = rowIndex - 1;
Row firstRow = sheet.getRow(groupStartRow);
createExportCell(firstRow, 0, COLLEAGUE_VIP_GROUP_LABEL, groupStyle);
createExportCell(firstRow, 0, "特权开通", groupStyle);
if (groupEndRow > groupStartRow) {
sheet.addMergedRegion(new CellRangeAddress(groupStartRow, groupEndRow, 0, 0));
}
@@ -1119,7 +1119,7 @@ public class LbPurchaseApplyServiceImpl
adjustExportColumnWidths(sheet, headers);
String filename = "开通特权提醒_" + LocalDateTime.now().format(EXPORT_FILENAME_TS) + ".xlsx";
String filename = "特权提醒_" + LocalDateTime.now().format(EXPORT_FILENAME_TS) + ".xlsx";
String encoded = URLEncoder.encode(filename, StandardCharsets.UTF_8).replaceAll("\\+", "%20");
response.setCharacterEncoding(StandardCharsets.UTF_8.name());
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
@@ -1219,12 +1219,42 @@ public class LbPurchaseApplyServiceImpl
return item.getApplyUser() == null ? "" : item.getApplyUser().trim();
}
/** 同事特权「开通日期」:申请日加 1 个自然日,若落在周六日则顺延到下一工作日。 */
private static LocalDate computeColleagueVipActivationDate(LocalDate applyDate) {
if (applyDate == null || applyDate.equals(LocalDate.MIN)) {
return null;
}
return firstWeekdayOnOrAfter(applyDate.plusDays(1));
}
/** 同事特权「特权开通日期」起点:开通日加 1 个自然日,若落在周六日则顺延到下一工作日。 */
private static LocalDate computeColleagueVipPrivilegeStart(LocalDate activationDate) {
if (activationDate == null) {
return null;
}
return firstWeekdayOnOrAfter(activationDate.plusDays(1));
}
private static String formatColleagueVipActivationDate(LocalDate applyDate) {
LocalDate activation = computeColleagueVipActivationDate(applyDate);
if (activation == null) {
return "";
}
return activation.getYear() + "/" + activation.getMonthValue() + "/" + activation.getDayOfMonth();
}
private static String formatColleaguePrivilegeRange(LocalDate applyDate) {
if (applyDate == null) {
return "";
}
LocalDate start = firstWeekdayOnOrAfter(applyDate);
LocalDate activation = computeColleagueVipActivationDate(applyDate);
if (activation == null) {
return "";
}
LocalDate start = computeColleagueVipPrivilegeStart(activation);
LocalDate endDate = endOfInclusiveWeekdaySpan(start, COLLEAGUE_PRIVILEGE_WEEKDAY_COUNT, null);
start = start.minusDays(1);
endDate = endDate.minusDays(1);
return start.format(PRIVILEGE_RANGE_FMT) + "-" + endDate.format(PRIVILEGE_RANGE_FMT);
}

View File

@@ -5,13 +5,14 @@
<insert id="upsertBatch">
INSERT INTO lb_goods (
id, tenant_id, old_id, user_id, title, image, price, total_money,
quantity, seller_id, is_show, status, created_at, updated_at
quantity, seller_id, is_show, status, current_page, created_at, updated_at
) VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.id}, #{item.tenantId}, #{item.oldId}, #{item.userId}, #{item.title},
#{item.image}, #{item.price}, #{item.totalMoney}, #{item.quantity},
#{item.sellerId}, #{item.isShow}, #{item.status}, #{item.createdAt}, #{item.updatedAt}
#{item.sellerId}, #{item.isShow}, #{item.status}, #{item.currentPage},
#{item.createdAt}, #{item.updatedAt}
)
</foreach>
ON DUPLICATE KEY UPDATE
@@ -26,6 +27,7 @@
seller_id = VALUES(seller_id),
is_show = VALUES(is_show),
status = VALUES(status),
current_page = VALUES(current_page),
created_at = VALUES(created_at),
updated_at = VALUES(updated_at)
</insert>

View File

@@ -14,7 +14,8 @@ CREATE TABLE `lb_goods` (
`quantity` VARCHAR(64) DEFAULT NULL COMMENT '数量描述≈6盒',
`seller_id` BIGINT DEFAULT NULL COMMENT '卖家用户ID',
`is_show` TINYINT NOT NULL DEFAULT 1 COMMENT '是否展示0否 1是',
`status` TINYINT NOT NULL DEFAULT 1 COMMENT '状态',
`status` TINYINT NOT NULL DEFAULT -1 COMMENT '状态',
`current_page` INT DEFAULT NULL COMMENT '当前页码(同步来源页)',
`created_at` DATETIME DEFAULT NULL COMMENT '创建时间',
`updated_at` DATETIME DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE,

View File

@@ -0,0 +1,8 @@
-- =============================================================================
-- 升级脚本:为 lb_goods 表增加 current_page 列
-- =============================================================================
SET NAMES utf8mb4;
ALTER TABLE `lb_goods`
ADD COLUMN `current_page` INT NULL DEFAULT NULL COMMENT '当前页码(同步来源页)' AFTER `status`;

View File

@@ -0,0 +1,8 @@
-- =============================================================================
-- 升级脚本lb_goods.status 默认值改为 -1
-- =============================================================================
SET NAMES utf8mb4;
ALTER TABLE `lb_goods`
MODIFY COLUMN `status` TINYINT NOT NULL DEFAULT -1 COMMENT '状态';