抢单历史记录
This commit is contained in:
@@ -62,6 +62,7 @@ public class MybatisPlusConfig {
|
|||||||
ignoreTables.add("ai_prompts"); // AI 提示词全局配置,表无 tenant_id 字段
|
ignoreTables.add("ai_prompts"); // AI 提示词全局配置,表无 tenant_id 字段
|
||||||
ignoreTables.add("lb_third_integration_config"); // 每租户一条,按 tenant_id 显式查询,不走插件自动拼接
|
ignoreTables.add("lb_third_integration_config"); // 每租户一条,按 tenant_id 显式查询,不走插件自动拼接
|
||||||
ignoreTables.add("lb_buy_account"); // 抢单账号跨租户管理;分页/批量抢单按记录 tenant_id 业务处理
|
ignoreTables.add("lb_buy_account"); // 抢单账号跨租户管理;分页/批量抢单按记录 tenant_id 业务处理
|
||||||
|
ignoreTables.add("lb_buy_account_history"); // 抢单历史跨租户查询;按记录 tenant_id 业务过滤
|
||||||
|
|
||||||
return new TenantLineHandler() {
|
return new TenantLineHandler() {
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,86 @@
|
|||||||
|
package com.rj.controller;
|
||||||
|
|
||||||
|
import com.rj.entity.LbBuyAccountHistory;
|
||||||
|
import com.rj.service.ILbBuyAccountHistoryService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/lbBuyAccountHistory")
|
||||||
|
@Tag(name = "LB抢单历史", description = "lb_buy_account_history 增删改查与分页")
|
||||||
|
public class LbBuyAccountHistoryController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ILbBuyAccountHistoryService lbBuyAccountHistoryService;
|
||||||
|
|
||||||
|
@PostMapping("/add")
|
||||||
|
@Operation(summary = "新增")
|
||||||
|
public ResponseEntity<Map<String, Object>> add(
|
||||||
|
@Parameter(description = "实体(id 为空时自动生成 UUID)", required = true)
|
||||||
|
@RequestBody LbBuyAccountHistory entity) {
|
||||||
|
Map<String, Object> result = lbBuyAccountHistoryService.add(entity);
|
||||||
|
Boolean success = (Boolean) result.get("success");
|
||||||
|
if (success != null && success) {
|
||||||
|
return ResponseEntity.ok(result);
|
||||||
|
}
|
||||||
|
return ResponseEntity.badRequest().body(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/update")
|
||||||
|
@Operation(summary = "编辑")
|
||||||
|
public ResponseEntity<Map<String, Object>> update(
|
||||||
|
@Parameter(description = "实体", required = true) @RequestBody LbBuyAccountHistory entity) {
|
||||||
|
Map<String, Object> result = lbBuyAccountHistoryService.update(entity);
|
||||||
|
Boolean success = (Boolean) result.get("success");
|
||||||
|
if (success != null && success) {
|
||||||
|
return ResponseEntity.ok(result);
|
||||||
|
}
|
||||||
|
return ResponseEntity.badRequest().body(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete/{id}")
|
||||||
|
@Operation(summary = "删除")
|
||||||
|
public ResponseEntity<Map<String, Object>> delete(
|
||||||
|
@Parameter(description = "主键ID(UUID)", required = true) @PathVariable String id) {
|
||||||
|
Map<String, Object> result = lbBuyAccountHistoryService.deleteById(id);
|
||||||
|
Boolean success = (Boolean) result.get("success");
|
||||||
|
if (success != null && success) {
|
||||||
|
return ResponseEntity.ok(result);
|
||||||
|
}
|
||||||
|
return ResponseEntity.badRequest().body(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/list")
|
||||||
|
@Operation(summary = "分页查询")
|
||||||
|
public ResponseEntity<Map<String, Object>> list(
|
||||||
|
@RequestParam(defaultValue = "1") Integer current,
|
||||||
|
@RequestParam(defaultValue = "10") Integer size,
|
||||||
|
@RequestParam(required = false) String tenantId,
|
||||||
|
@RequestParam(required = false) String tenantName,
|
||||||
|
@RequestParam(required = false) String loginAccount,
|
||||||
|
@RequestParam(required = false) String nickname,
|
||||||
|
@Parameter(description = "创建时间起,格式 yyyy-MM-dd HH:mm:ss")
|
||||||
|
@RequestParam(required = false) String createTimeStart,
|
||||||
|
@Parameter(description = "创建时间止,格式 yyyy-MM-dd HH:mm:ss")
|
||||||
|
@RequestParam(required = false) String createTimeEnd,
|
||||||
|
@Parameter(description = "最后一次抢单时间起,格式 yyyy-MM-dd HH:mm:ss")
|
||||||
|
@RequestParam(required = false) String lastRushBuyTimeStart,
|
||||||
|
@Parameter(description = "最后一次抢单时间止,格式 yyyy-MM-dd HH:mm:ss")
|
||||||
|
@RequestParam(required = false) String lastRushBuyTimeEnd) {
|
||||||
|
Map<String, Object> result = lbBuyAccountHistoryService.pageQuery(
|
||||||
|
current, size, tenantId, tenantName, loginAccount, nickname,
|
||||||
|
createTimeStart, createTimeEnd, lastRushBuyTimeStart, lastRushBuyTimeEnd
|
||||||
|
);
|
||||||
|
Boolean success = (Boolean) result.get("success");
|
||||||
|
if (success != null && success) {
|
||||||
|
return ResponseEntity.ok(result);
|
||||||
|
}
|
||||||
|
return ResponseEntity.internalServerError().body(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
72
src/main/java/com/rj/entity/LbBuyAccountHistory.java
Normal file
72
src/main/java/com/rj/entity/LbBuyAccountHistory.java
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
package com.rj.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@TableName("lb_buy_account_history")
|
||||||
|
@Schema(description = "LB 抢单历史表")
|
||||||
|
public class LbBuyAccountHistory implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@TableId("id")
|
||||||
|
@Schema(description = "主键,UUID")
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@TableField("tenant_id")
|
||||||
|
@Schema(description = "租户ID,关联 tenant.id")
|
||||||
|
private String tenantId;
|
||||||
|
|
||||||
|
@TableField("tenant_name")
|
||||||
|
@Schema(description = "租户名称")
|
||||||
|
private String tenantName;
|
||||||
|
|
||||||
|
@TableField("login_account")
|
||||||
|
@Schema(description = "登录账号")
|
||||||
|
private String loginAccount;
|
||||||
|
|
||||||
|
@TableField("login_password")
|
||||||
|
@Schema(description = "登录密码(明文)")
|
||||||
|
private String loginPassword;
|
||||||
|
|
||||||
|
@TableField("nickname")
|
||||||
|
@Schema(description = "昵称")
|
||||||
|
private String nickname;
|
||||||
|
|
||||||
|
@TableField("max_grab_amount")
|
||||||
|
@Schema(description = "成功抢单总金额")
|
||||||
|
private Integer maxGrabAmount;
|
||||||
|
|
||||||
|
@TableField("max_grab_count")
|
||||||
|
@Schema(description = "抢单总次数(含成功与失败)")
|
||||||
|
private Integer maxGrabCount;
|
||||||
|
|
||||||
|
@TableField("rush_buy_fail_count")
|
||||||
|
@Schema(description = "抢单失败次数")
|
||||||
|
private Integer rushBuyFailCount;
|
||||||
|
|
||||||
|
@TableField("rush_buy_result")
|
||||||
|
@Schema(description = "抢单结果")
|
||||||
|
private String rushBuyResult;
|
||||||
|
|
||||||
|
@TableField("last_rush_buy_time")
|
||||||
|
@Schema(description = "最后一次抢单时间")
|
||||||
|
private LocalDateTime lastRushBuyTime;
|
||||||
|
|
||||||
|
@TableField("create_time")
|
||||||
|
@Schema(description = "创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@TableField("update_time")
|
||||||
|
@Schema(description = "修改时间")
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.rj.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.rj.entity.LbBuyAccountHistory;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface LbBuyAccountHistoryMapper extends BaseMapper<LbBuyAccountHistory> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.rj.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.rj.entity.LbBuyAccountHistory;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public interface ILbBuyAccountHistoryService extends IService<LbBuyAccountHistory> {
|
||||||
|
|
||||||
|
Map<String, Object> add(LbBuyAccountHistory entity);
|
||||||
|
|
||||||
|
Map<String, Object> update(LbBuyAccountHistory entity);
|
||||||
|
|
||||||
|
Map<String, Object> deleteById(String id);
|
||||||
|
|
||||||
|
Map<String, Object> pageQuery(Integer current,
|
||||||
|
Integer size,
|
||||||
|
String tenantId,
|
||||||
|
String tenantName,
|
||||||
|
String loginAccount,
|
||||||
|
String nickname,
|
||||||
|
String createTimeStart,
|
||||||
|
String createTimeEnd,
|
||||||
|
String lastRushBuyTimeStart,
|
||||||
|
String lastRushBuyTimeEnd);
|
||||||
|
}
|
||||||
@@ -0,0 +1,270 @@
|
|||||||
|
package com.rj.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.rj.entity.LbBuyAccountHistory;
|
||||||
|
import com.rj.mapper.LbBuyAccountHistoryMapper;
|
||||||
|
import com.rj.service.ILbBuyAccountHistoryService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class LbBuyAccountHistoryServiceImpl
|
||||||
|
extends ServiceImpl<LbBuyAccountHistoryMapper, LbBuyAccountHistory>
|
||||||
|
implements ILbBuyAccountHistoryService {
|
||||||
|
|
||||||
|
private static final DateTimeFormatter DATE_TIME_FORMATTER =
|
||||||
|
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> add(LbBuyAccountHistory entity) {
|
||||||
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
try {
|
||||||
|
Map<String, Object> validation = validateRequiredForAdd(entity);
|
||||||
|
if (validation != null) {
|
||||||
|
return validation;
|
||||||
|
}
|
||||||
|
trimStringFields(entity);
|
||||||
|
defaultIntegerFields(entity);
|
||||||
|
|
||||||
|
if (entity.getId() == null || entity.getId().trim().isEmpty()) {
|
||||||
|
entity.setId(UUID.randomUUID().toString());
|
||||||
|
}
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
if (entity.getCreateTime() == null) {
|
||||||
|
entity.setCreateTime(now);
|
||||||
|
}
|
||||||
|
entity.setUpdateTime(now);
|
||||||
|
|
||||||
|
boolean ok = this.save(entity);
|
||||||
|
result.put("success", ok);
|
||||||
|
result.put("message", ok ? "新增成功" : "新增失败");
|
||||||
|
if (ok) {
|
||||||
|
result.put("data", entity);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("抢单历史新增异常", e);
|
||||||
|
result.put("success", false);
|
||||||
|
result.put("message", "新增异常:" + e.getMessage());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> update(LbBuyAccountHistory entity) {
|
||||||
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
try {
|
||||||
|
if (entity.getId() == null || entity.getId().trim().isEmpty()) {
|
||||||
|
result.put("success", false);
|
||||||
|
result.put("message", "id不能为空");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
trimStringFields(entity);
|
||||||
|
entity.setUpdateTime(LocalDateTime.now());
|
||||||
|
boolean ok = this.updateById(entity);
|
||||||
|
result.put("success", ok);
|
||||||
|
result.put("message", ok ? "编辑成功" : "编辑失败");
|
||||||
|
if (ok) {
|
||||||
|
result.put("data", this.getById(entity.getId()));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("抢单历史编辑异常", e);
|
||||||
|
result.put("success", false);
|
||||||
|
result.put("message", "编辑异常:" + e.getMessage());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> deleteById(String id) {
|
||||||
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
try {
|
||||||
|
if (id == null || id.trim().isEmpty()) {
|
||||||
|
result.put("success", false);
|
||||||
|
result.put("message", "id不能为空");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
boolean ok = this.removeById(id.trim());
|
||||||
|
result.put("success", ok);
|
||||||
|
result.put("message", ok ? "删除成功" : "删除失败");
|
||||||
|
return result;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("抢单历史删除异常", e);
|
||||||
|
result.put("success", false);
|
||||||
|
result.put("message", "删除异常:" + e.getMessage());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> pageQuery(Integer current,
|
||||||
|
Integer size,
|
||||||
|
String tenantId,
|
||||||
|
String tenantName,
|
||||||
|
String loginAccount,
|
||||||
|
String nickname,
|
||||||
|
String createTimeStart,
|
||||||
|
String createTimeEnd,
|
||||||
|
String lastRushBuyTimeStart,
|
||||||
|
String lastRushBuyTimeEnd) {
|
||||||
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
try {
|
||||||
|
if (current == null || current < 1) {
|
||||||
|
current = 1;
|
||||||
|
}
|
||||||
|
if (size == null || size < 1) {
|
||||||
|
size = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
LambdaQueryWrapper<LbBuyAccountHistory> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
if (tenantId != null && !tenantId.trim().isEmpty()) {
|
||||||
|
queryWrapper.eq(LbBuyAccountHistory::getTenantId, tenantId.trim());
|
||||||
|
}
|
||||||
|
if (tenantName != null && !tenantName.trim().isEmpty()) {
|
||||||
|
queryWrapper.like(LbBuyAccountHistory::getTenantName, tenantName.trim());
|
||||||
|
}
|
||||||
|
if (loginAccount != null && !loginAccount.trim().isEmpty()) {
|
||||||
|
queryWrapper.like(LbBuyAccountHistory::getLoginAccount, loginAccount.trim());
|
||||||
|
}
|
||||||
|
if (nickname != null && !nickname.trim().isEmpty()) {
|
||||||
|
queryWrapper.like(LbBuyAccountHistory::getNickname, nickname.trim());
|
||||||
|
}
|
||||||
|
|
||||||
|
LocalDateTime createStart = parseDateTime(createTimeStart);
|
||||||
|
if (createTimeStart != null && !createTimeStart.trim().isEmpty() && createStart == null) {
|
||||||
|
result.put("success", false);
|
||||||
|
result.put("message", "createTimeStart 格式错误,请使用 yyyy-MM-dd HH:mm:ss");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
LocalDateTime createEnd = parseDateTime(createTimeEnd);
|
||||||
|
if (createTimeEnd != null && !createTimeEnd.trim().isEmpty() && createEnd == null) {
|
||||||
|
result.put("success", false);
|
||||||
|
result.put("message", "createTimeEnd 格式错误,请使用 yyyy-MM-dd HH:mm:ss");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
if (createStart != null) {
|
||||||
|
queryWrapper.ge(LbBuyAccountHistory::getCreateTime, createStart);
|
||||||
|
}
|
||||||
|
if (createEnd != null) {
|
||||||
|
queryWrapper.le(LbBuyAccountHistory::getCreateTime, createEnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
LocalDateTime rushStart = parseDateTime(lastRushBuyTimeStart);
|
||||||
|
if (lastRushBuyTimeStart != null && !lastRushBuyTimeStart.trim().isEmpty() && rushStart == null) {
|
||||||
|
result.put("success", false);
|
||||||
|
result.put("message", "lastRushBuyTimeStart 格式错误,请使用 yyyy-MM-dd HH:mm:ss");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
LocalDateTime rushEnd = parseDateTime(lastRushBuyTimeEnd);
|
||||||
|
if (lastRushBuyTimeEnd != null && !lastRushBuyTimeEnd.trim().isEmpty() && rushEnd == null) {
|
||||||
|
result.put("success", false);
|
||||||
|
result.put("message", "lastRushBuyTimeEnd 格式错误,请使用 yyyy-MM-dd HH:mm:ss");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
if (rushStart != null) {
|
||||||
|
queryWrapper.ge(LbBuyAccountHistory::getLastRushBuyTime, rushStart);
|
||||||
|
}
|
||||||
|
if (rushEnd != null) {
|
||||||
|
queryWrapper.le(LbBuyAccountHistory::getLastRushBuyTime, rushEnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
queryWrapper.orderByDesc(LbBuyAccountHistory::getLastRushBuyTime)
|
||||||
|
.orderByDesc(LbBuyAccountHistory::getUpdateTime)
|
||||||
|
.orderByDesc(LbBuyAccountHistory::getCreateTime);
|
||||||
|
|
||||||
|
Page<LbBuyAccountHistory> page = this.page(new Page<>(current, size), queryWrapper);
|
||||||
|
result.put("success", true);
|
||||||
|
result.put("message", "查询成功");
|
||||||
|
result.put("data", page.getRecords());
|
||||||
|
result.put("total", page.getTotal());
|
||||||
|
result.put("current", page.getCurrent());
|
||||||
|
result.put("size", page.getSize());
|
||||||
|
result.put("pages", page.getPages());
|
||||||
|
return result;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("抢单历史查询异常", e);
|
||||||
|
result.put("success", false);
|
||||||
|
result.put("message", "查询异常:" + e.getMessage());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, Object> validateRequiredForAdd(LbBuyAccountHistory entity) {
|
||||||
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
if (entity.getTenantId() == null || entity.getTenantId().trim().isEmpty()) {
|
||||||
|
result.put("success", false);
|
||||||
|
result.put("message", "tenantId不能为空");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
if (entity.getTenantName() == null || entity.getTenantName().trim().isEmpty()) {
|
||||||
|
result.put("success", false);
|
||||||
|
result.put("message", "tenantName不能为空");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
if (entity.getLoginAccount() == null || entity.getLoginAccount().trim().isEmpty()) {
|
||||||
|
result.put("success", false);
|
||||||
|
result.put("message", "loginAccount不能为空");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
if (entity.getLoginPassword() == null || entity.getLoginPassword().trim().isEmpty()) {
|
||||||
|
result.put("success", false);
|
||||||
|
result.put("message", "loginPassword不能为空");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void trimStringFields(LbBuyAccountHistory entity) {
|
||||||
|
if (entity.getTenantId() != null) {
|
||||||
|
entity.setTenantId(entity.getTenantId().trim());
|
||||||
|
}
|
||||||
|
if (entity.getTenantName() != null) {
|
||||||
|
entity.setTenantName(entity.getTenantName().trim());
|
||||||
|
}
|
||||||
|
if (entity.getLoginAccount() != null) {
|
||||||
|
entity.setLoginAccount(entity.getLoginAccount().trim());
|
||||||
|
}
|
||||||
|
if (entity.getLoginPassword() != null) {
|
||||||
|
entity.setLoginPassword(entity.getLoginPassword().trim());
|
||||||
|
}
|
||||||
|
if (entity.getNickname() != null) {
|
||||||
|
entity.setNickname(entity.getNickname().trim());
|
||||||
|
}
|
||||||
|
if (entity.getRushBuyResult() != null) {
|
||||||
|
entity.setRushBuyResult(entity.getRushBuyResult().trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void defaultIntegerFields(LbBuyAccountHistory entity) {
|
||||||
|
if (entity.getMaxGrabAmount() == null) {
|
||||||
|
entity.setMaxGrabAmount(0);
|
||||||
|
}
|
||||||
|
if (entity.getMaxGrabCount() == null) {
|
||||||
|
entity.setMaxGrabCount(0);
|
||||||
|
}
|
||||||
|
if (entity.getRushBuyFailCount() == null) {
|
||||||
|
entity.setRushBuyFailCount(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static LocalDateTime parseDateTime(String text) {
|
||||||
|
if (text == null || text.trim().isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return LocalDateTime.parse(text.trim(), DATE_TIME_FORMATTER);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -54,6 +54,12 @@ public class LbOrderRowServiceImpl extends ServiceImpl<LbOrderRowMapper, LbOrder
|
|||||||
|
|
||||||
private static final long SUM_PLACEHOLDER_USER_ID = 10000L;
|
private static final long SUM_PLACEHOLDER_USER_ID = 10000L;
|
||||||
|
|
||||||
|
/** seller_id 缺失时的占位默认值 */
|
||||||
|
private static final long DEFAULT_SELLER_ID = 20000L;
|
||||||
|
|
||||||
|
/** merchandise_id 统计行占位默认值 */
|
||||||
|
private static final long DEFAULT_MERCHANDISE_ID = 30000L;
|
||||||
|
|
||||||
private static final String SUM_ORDER_SN = "order_sn_10000";
|
private static final String SUM_ORDER_SN = "order_sn_10000";
|
||||||
|
|
||||||
private static final DateTimeFormatter DAY_TIME_FMT = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
private static final DateTimeFormatter DAY_TIME_FMT = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||||
@@ -87,9 +93,7 @@ public class LbOrderRowServiceImpl extends ServiceImpl<LbOrderRowMapper, LbOrder
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if (entity.getSellerId() == null) {
|
if (entity.getSellerId() == null) {
|
||||||
result.put("success", false);
|
entity.setSellerId(DEFAULT_SELLER_ID);
|
||||||
result.put("message", "sellerId不能为空");
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
if (entity.getBuyerId() == null) {
|
if (entity.getBuyerId() == null) {
|
||||||
result.put("success", false);
|
result.put("success", false);
|
||||||
@@ -657,7 +661,7 @@ public class LbOrderRowServiceImpl extends ServiceImpl<LbOrderRowMapper, LbOrder
|
|||||||
sum.setTodayUnresellCount(unresellCount);
|
sum.setTodayUnresellCount(unresellCount);
|
||||||
sum.setTodayOrderCount(orderCount);
|
sum.setTodayOrderCount(orderCount);
|
||||||
sum.setAvgAmt(avgAmt);
|
sum.setAvgAmt(avgAmt);
|
||||||
sum.setSellerId(SUM_PLACEHOLDER_USER_ID);
|
sum.setSellerId(DEFAULT_SELLER_ID);
|
||||||
sum.setBuyerId(SUM_PLACEHOLDER_USER_ID);
|
sum.setBuyerId(SUM_PLACEHOLDER_USER_ID);
|
||||||
sum.setOrderSn(SUM_ORDER_SN);
|
sum.setOrderSn(SUM_ORDER_SN);
|
||||||
sum.setPhone("18808852688");
|
sum.setPhone("18808852688");
|
||||||
@@ -668,7 +672,7 @@ public class LbOrderRowServiceImpl extends ServiceImpl<LbOrderRowMapper, LbOrder
|
|||||||
sum.setIsShow(1);
|
sum.setIsShow(1);
|
||||||
sum.setPayTime(payTime);
|
sum.setPayTime(payTime);
|
||||||
sum.setBuyTime(payTime);
|
sum.setBuyTime(payTime);
|
||||||
sum.setMerchandiseId(0L);
|
sum.setMerchandiseId(DEFAULT_MERCHANDISE_ID);
|
||||||
sum.setCreatedAt(nowStr);
|
sum.setCreatedAt(nowStr);
|
||||||
sum.setUpdatedAt(nowStr);
|
sum.setUpdatedAt(nowStr);
|
||||||
return sum;
|
return sum;
|
||||||
@@ -701,9 +705,11 @@ public class LbOrderRowServiceImpl extends ServiceImpl<LbOrderRowMapper, LbOrder
|
|||||||
stat.setId(id);
|
stat.setId(id);
|
||||||
stat.setTenantId(tenantId);
|
stat.setTenantId(tenantId);
|
||||||
stat.setDataType(BUYER_DAY_STAT_DATA_TYPE);
|
stat.setDataType(BUYER_DAY_STAT_DATA_TYPE);
|
||||||
|
stat.setSellerId(DEFAULT_SELLER_ID);
|
||||||
stat.setBuyerPhone(buyerPhone);
|
stat.setBuyerPhone(buyerPhone);
|
||||||
stat.setBuyerId(sample.getBuyerId());
|
stat.setBuyerId(sample.getBuyerId());
|
||||||
stat.setBuyerName(sample.getBuyerName());
|
stat.setBuyerName(sample.getBuyerName());
|
||||||
|
stat.setConsignee(resolveConsigneeFromRows(buyerDayRows));
|
||||||
stat.setPhone(buyerPhone);
|
stat.setPhone(buyerPhone);
|
||||||
stat.setTodayTotalMoneySum(moneySum);
|
stat.setTodayTotalMoneySum(moneySum);
|
||||||
stat.setTodayOrderCount(orderCount);
|
stat.setTodayOrderCount(orderCount);
|
||||||
@@ -712,13 +718,35 @@ public class LbOrderRowServiceImpl extends ServiceImpl<LbOrderRowMapper, LbOrder
|
|||||||
stat.setOrderSn("day_stat_" + buyerPhone + "_" + day.format(DAY_FMT));
|
stat.setOrderSn("day_stat_" + buyerPhone + "_" + day.format(DAY_FMT));
|
||||||
stat.setPayTime(payTime);
|
stat.setPayTime(payTime);
|
||||||
stat.setBuyTime(payTime);
|
stat.setBuyTime(payTime);
|
||||||
|
stat.setIsResell(1);
|
||||||
stat.setStatus(1);
|
stat.setStatus(1);
|
||||||
stat.setIsShow(1);
|
stat.setIsShow(1);
|
||||||
|
stat.setMerchandiseId(DEFAULT_MERCHANDISE_ID);
|
||||||
stat.setCreatedAt(nowStr);
|
stat.setCreatedAt(nowStr);
|
||||||
stat.setUpdatedAt(nowStr);
|
stat.setUpdatedAt(nowStr);
|
||||||
return stat;
|
return stat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 从明细中取收货人姓名,优先 consignee,其次 buyer_name */
|
||||||
|
private static String resolveConsigneeFromRows(List<LbOrderRow> rows) {
|
||||||
|
if (rows == null || rows.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
for (LbOrderRow row : rows) {
|
||||||
|
String consignee = trimToNull(row.getConsignee());
|
||||||
|
if (consignee != null) {
|
||||||
|
return consignee;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (LbOrderRow row : rows) {
|
||||||
|
String buyerName = trimToNull(row.getBuyerName());
|
||||||
|
if (buyerName != null) {
|
||||||
|
return buyerName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/** 同一天、同一租户、同一 buyer_phone 已存在 day_stat 则复用其 id,否则生成占位 id */
|
/** 同一天、同一租户、同一 buyer_phone 已存在 day_stat 则复用其 id,否则生成占位 id */
|
||||||
private Long resolveBuyerDayStatRowId(String tenantId, String buyerPhone, String payTime) {
|
private Long resolveBuyerDayStatRowId(String tenantId, String buyerPhone, String payTime) {
|
||||||
LambdaQueryWrapper<LbOrderRow> w = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<LbOrderRow> w = new LambdaQueryWrapper<>();
|
||||||
@@ -807,6 +835,7 @@ public class LbOrderRowServiceImpl extends ServiceImpl<LbOrderRowMapper, LbOrder
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
entity.setTenantId(tenantId);
|
entity.setTenantId(tenantId);
|
||||||
|
ensureSellerId(entity);
|
||||||
deduped.put(compositeKey(tenantId, entity.getId()), entity);
|
deduped.put(compositeKey(tenantId, entity.getId()), entity);
|
||||||
}
|
}
|
||||||
if (deduped.isEmpty()) {
|
if (deduped.isEmpty()) {
|
||||||
@@ -964,6 +993,12 @@ public class LbOrderRowServiceImpl extends ServiceImpl<LbOrderRowMapper, LbOrder
|
|||||||
return trimToNull(tenantIdFromParam);
|
return trimToNull(tenantIdFromParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void ensureSellerId(LbOrderRow entity) {
|
||||||
|
if (entity.getSellerId() == null) {
|
||||||
|
entity.setSellerId(DEFAULT_SELLER_ID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static String compositeKey(String tenantId, Long id) {
|
private static String compositeKey(String tenantId, Long id) {
|
||||||
return tenantId + ":" + id;
|
return tenantId + ":" + id;
|
||||||
}
|
}
|
||||||
|
|||||||
17
src/main/sql/lb_buy_account_history.sql
Normal file
17
src/main/sql/lb_buy_account_history.sql
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
CREATE TABLE `lb_buy_account_history` (
|
||||||
|
`id` char(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '主键,UUID',
|
||||||
|
`tenant_id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '租户ID,关联 tenant.id',
|
||||||
|
`tenant_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '租户名称',
|
||||||
|
`login_account` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '登录账号',
|
||||||
|
`login_password` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '登录密码,明文',
|
||||||
|
`nickname` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '昵称',
|
||||||
|
`max_grab_amount` int NOT NULL DEFAULT 0 COMMENT '成功抢单总金额',
|
||||||
|
`max_grab_count` int NOT NULL DEFAULT 0 COMMENT '抢单总次数(含成功与失败)',
|
||||||
|
`rush_buy_fail_count` int NOT NULL DEFAULT 0 COMMENT '抢单失败次数',
|
||||||
|
`rush_buy_result` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '抢单结果',
|
||||||
|
`last_rush_buy_time` datetime NULL DEFAULT NULL COMMENT '最后一次抢单时间',
|
||||||
|
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||||
|
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
|
||||||
|
PRIMARY KEY (`id`) USING BTREE,
|
||||||
|
INDEX `idx_lta_login_account`(`login_account` ASC) USING BTREE
|
||||||
|
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = 'LB 抢单历史表' ROW_FORMAT = DYNAMIC;
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
-- 调整 lb_buy_account_history 字段含义,并新增抢单失败次数字段
|
||||||
|
ALTER TABLE `lb_buy_account_history`
|
||||||
|
MODIFY COLUMN `max_grab_amount` int NOT NULL DEFAULT 0 COMMENT '成功抢单总金额',
|
||||||
|
MODIFY COLUMN `max_grab_count` int NOT NULL DEFAULT 0 COMMENT '抢单总次数(含成功与失败)',
|
||||||
|
ADD COLUMN `rush_buy_fail_count` int NOT NULL DEFAULT 0 COMMENT '抢单失败次数' AFTER `max_grab_count`;
|
||||||
Reference in New Issue
Block a user