feat: 积分商城-对账优化2

This commit is contained in:
2026-09-01 16:25:59 +08:00
parent d2cb60f5cf
commit 43d0d973c9
6 changed files with 33 additions and 10 deletions
@@ -411,6 +411,15 @@ public class Sys_user extends BaseModel implements Serializable {
@ColDefine(type = ColType.VARCHAR, width = 50)
private String openId;
@Column("vuser_id")
@Comment("虚拟用户ID")
@ColDefine(type = ColType.VARCHAR, width = 64)
private String vuserId;
@Column("vorg_id")
@Comment("虚拟组织ID")
@ColDefine(type = ColType.VARCHAR, width = 255)
private String vorgId;
/**
* 基金会员
@@ -2,6 +2,7 @@ package com.budwk.app.zhgh.pointsmall.mallbridge.service;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.budwk.app.sys.models.Sys_user;
import com.budwk.app.zhgh.pointsmall.mallbridge.dto.MallOrderQueryDTO;
import com.budwk.app.zhgh.pointsmall.mallbridge.dto.MallOrderEventDTO;
import com.budwk.app.zhgh.pointsmall.mallbridge.dto.OrderInfoDTO;
@@ -369,7 +370,11 @@ public class MallInboundEventService extends AbstractMallBridgeSupport {
.and("orderId", "in", orderIds)
.and("delFlag", "=", false);
if (StrUtil.isNotBlank(dto.getUserId())) {
subCnd.and("userId", "=", dto.getUserId());
Sys_user user = fetchUser(dto.getUserId());
if (user == null) {
return MallInboundResult.fail(400, "用户ID未配置或不存在");
}
subCnd.and("userId", "=", user.getId());
}
List<PointsMallOrderSub> subs = dao.query(PointsMallOrderSub.class, subCnd);
@@ -2,6 +2,7 @@ package com.budwk.app.zhgh.pointsmall.mallbridge.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import com.budwk.app.sys.models.Sys_user;
import com.budwk.app.zhgh.pointsmall.mallbridge.dto.MallPendingOrderDTO;
import com.budwk.app.zhgh.pointsmall.mallbridge.model.MallInboundResult;
import com.budwk.app.zhgh.pointsmall.mallbridge.service.support.AbstractMallBridgeSupport;
@@ -32,13 +33,17 @@ public class MallInboundPendingOrderService extends AbstractMallBridgeSupport {
if (dto.getOrderInfo() == null || StrUtil.isBlank(dto.getOrderInfo().getOrderId())) {
return MallInboundResult.fail(400, "订单信息不能为空");
}
Sys_user user = fetchUser(dto.getUserId());
if (user == null) {
return MallInboundResult.fail(400, "用户虚拟ID未配置或不存在");
}
log.info("积分商城接收待支付订单开始,supplierId={}orderId={}", dto.getSupplierId(), dto.getOrderInfo().getOrderId());
if (dao.count(PointsMallOrderMain.class, Cnd.where("orderId", "=", dto.getOrderInfo().getOrderId())
.and("supplierId", "=", dto.getSupplierId()).and("delFlag", "=", false)) > 0) {
return MallInboundResult.fail(-1, "订单已存在");
}
Trans.exec((Atom) () -> {
PointsMallOrderMain main = toMain(dto.getSupplierId(), dto.getUserId(), dto.getOrderInfo(), ORDER_PENDING_PAY);
PointsMallOrderMain main = toMain(dto.getSupplierId(), user.getId(), dto.getOrderInfo(), ORDER_PENDING_PAY);
dao.insert(main);
// 新增主单历史记录
@@ -57,12 +57,12 @@ public abstract class AbstractMallBridgeSupport {
return dto != null && !StrUtil.hasBlank(dto.getSupplierId(), dto.getOrderId(), dto.getMainOrderId(), dto.getUserId());
}
protected Sys_user fetchUser(String userId) {
Sys_user user = dao.fetch(Sys_user.class, Cnd.where("id", "=", userId).and("disabled", "=", false).and("delFlag", "=", false));
if (user != null) {
return user;
protected Sys_user fetchUser(String vuserId) {
if (StrUtil.isBlank(vuserId)) {
return null;
}
return dao.fetch(Sys_user.class, Cnd.where("loginname", "=", userId).and("disabled", "=", false).and("delFlag", "=", false));
return dao.fetch(Sys_user.class, Cnd.where("vuser_id", "=", vuserId)
.and("disabled", "=", false).and("delFlag", "=", false));
}
protected PointsMallOrderExchange toExchange(MallOrderEventDTO dto, OrderInfoDTO orderInfo, PointsMallOrderSub sub, Integer orderStatus) {
+4
View File
@@ -510,3 +510,7 @@ CREATE TABLE IF NOT EXISTS `points_mall_schedule_user_points_record` (
KEY `idx_points_mall_schedule_user_points_user` (`userId`),
KEY `idx_points_mall_schedule_user_points_status` (`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='积分商城定时发放积分记录';
ALTER TABLE sys_user
ADD COLUMN vuser_id VARCHAR(64) NULL COMMENT '虚拟用户ID,积分商城向供应商传递的用户标识',
ADD COLUMN vorg_id VARCHAR(255) NULL COMMENT '虚拟组织ID';
@@ -151,13 +151,13 @@ layout("/layouts/platform_h5.html"){
this.$toast("暂无跳转地址")
return
}
const userId = this.$store && this.$store.state.user ? this.$store.state.user.id : ""
if (!userId) {
const vuserId = this.$store && this.$store.state.user ? this.$store.state.user.vuserId : ""
if (!vuserId) {
this.$toast("获取用户信息失败,请重新登录后再试")
return
}
window.location.href = this.withSupplierQuery(item.supplierUrl, {
userId: userId
userId: vuserId
})
},
withSupplierQuery(url, params) {