feat: 积分商城-对账优化3
This commit is contained in:
@@ -411,15 +411,15 @@ public class Sys_user extends BaseModel implements Serializable {
|
||||
@ColDefine(type = ColType.VARCHAR, width = 50)
|
||||
private String openId;
|
||||
|
||||
@Column("vuser_id")
|
||||
@Column("virtual_id")
|
||||
@Comment("虚拟用户ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 64)
|
||||
private String vuserId;
|
||||
private String virtualId;
|
||||
|
||||
@Column("vorg_id")
|
||||
@Column("virtual_org_id")
|
||||
@Comment("虚拟组织ID")
|
||||
@ColDefine(type = ColType.VARCHAR, width = 255)
|
||||
private String vorgId;
|
||||
private String virtualOrgId;
|
||||
|
||||
/**
|
||||
* 基金会员
|
||||
|
||||
+4
-10
@@ -61,7 +61,7 @@ public class MallCancelSubOrderEventHandler implements MallOrderEventHandler {
|
||||
if (dto == null || StrUtil.hasBlank(dto.getSupplierId(), dto.getOrderId(), dto.getUserId())) {
|
||||
return MallInboundResult.fail(400, "供应商、订单、用户不能为空");
|
||||
}
|
||||
// userId 兼容系统用户ID和工号,后续消息推送需要使用用户信息。
|
||||
// 供应商传入 userId 为虚拟用户ID,转换为系统用户后用于消息推送。
|
||||
Sys_user user = fetchUser(dto.getUserId());
|
||||
if (user == null) {
|
||||
return MallInboundResult.fail(-1, "用户不存在");
|
||||
@@ -110,14 +110,8 @@ public class MallCancelSubOrderEventHandler implements MallOrderEventHandler {
|
||||
return MallInboundResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 入参 userId 可能是系统用户ID或工号,按当前项目用户表兼容查询。
|
||||
*/
|
||||
private 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;
|
||||
}
|
||||
return dao.fetch(Sys_user.class, Cnd.where("loginname", "=", userId).and("disabled", "=", false).and("delFlag", "=", false));
|
||||
private Sys_user fetchUser(String virtualId) {
|
||||
return dao.fetch(Sys_user.class, Cnd.where("virtual_id", "=", virtualId)
|
||||
.and("disabled", "=", false).and("delFlag", "=", false));
|
||||
}
|
||||
}
|
||||
|
||||
+18
-3
@@ -1,9 +1,13 @@
|
||||
package com.budwk.app.zhgh.pointsmall.mallbridge.service;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.budwk.app.sys.models.Sys_user;
|
||||
import com.budwk.app.zhgh.pointsmall.mallbridge.dto.MallPointQueryDTO;
|
||||
import com.budwk.app.zhgh.pointsmall.mallbridge.model.MallInboundPointsResult;
|
||||
import com.budwk.app.zhgh.pointsmall.mallbridge.service.support.AbstractMallBridgeSupport;
|
||||
import com.budwk.app.zhgh.pointsmall.points.service.PointsMallUserPointsService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
|
||||
@@ -11,17 +15,28 @@ import org.nutz.ioc.loader.annotation.IocBean;
|
||||
* 商城桥接积分查询服务。
|
||||
*/
|
||||
@Slf4j
|
||||
@IocBean
|
||||
public class MallInboundPointsQueryService {
|
||||
@IocBean(args = {"refer:dao"})
|
||||
public class MallInboundPointsQueryService extends AbstractMallBridgeSupport {
|
||||
|
||||
@Inject
|
||||
private PointsMallUserPointsService pointsMallUserPointsService;
|
||||
|
||||
public MallInboundPointsQueryService(Dao dao) {
|
||||
super(dao);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户可用积分。
|
||||
*/
|
||||
public MallInboundPointsResult queryPoints(MallPointQueryDTO dto) {
|
||||
log.info("积分商城查询用户积分,supplierId={},userId={}", dto == null ? null : dto.getSupplierId(), dto == null ? null : dto.getUserId());
|
||||
return MallInboundPointsResult.success(pointsMallUserPointsService.availablePoints(dto.getUserId()));
|
||||
if (dto == null || StrUtil.isBlank(dto.getUserId())) {
|
||||
return MallInboundPointsResult.fail(400, "用户虚拟ID不能为空");
|
||||
}
|
||||
Sys_user user = fetchUser(dto.getUserId());
|
||||
if (user == null) {
|
||||
return MallInboundPointsResult.fail(400, "用户虚拟ID未配置或不存在");
|
||||
}
|
||||
return MallInboundPointsResult.success(pointsMallUserPointsService.availablePoints(user.getId()));
|
||||
}
|
||||
}
|
||||
|
||||
+8
-4
@@ -57,20 +57,24 @@ public abstract class AbstractMallBridgeSupport {
|
||||
return dto != null && !StrUtil.hasBlank(dto.getSupplierId(), dto.getOrderId(), dto.getMainOrderId(), dto.getUserId());
|
||||
}
|
||||
|
||||
protected Sys_user fetchUser(String vuserId) {
|
||||
if (StrUtil.isBlank(vuserId)) {
|
||||
protected Sys_user fetchUser(String virtualId) {
|
||||
if (StrUtil.isBlank(virtualId)) {
|
||||
return null;
|
||||
}
|
||||
return dao.fetch(Sys_user.class, Cnd.where("vuser_id", "=", vuserId)
|
||||
return dao.fetch(Sys_user.class, Cnd.where("virtual_id", "=", virtualId)
|
||||
.and("disabled", "=", false).and("delFlag", "=", false));
|
||||
}
|
||||
|
||||
protected PointsMallOrderExchange toExchange(MallOrderEventDTO dto, OrderInfoDTO orderInfo, PointsMallOrderSub sub, Integer orderStatus) {
|
||||
Sys_user user = fetchUser(dto.getUserId());
|
||||
if (user == null) {
|
||||
throw new IllegalArgumentException("用户虚拟ID未配置或不存在");
|
||||
}
|
||||
PointsMallOrderExchange exchange = new PointsMallOrderExchange();
|
||||
exchange.setOrderMainId(dto.getMainOrderId());
|
||||
exchange.setOrderId(dto.getOrderId());
|
||||
exchange.setSupplierId(dto.getSupplierId());
|
||||
exchange.setUserId(dto.getUserId());
|
||||
exchange.setUserId(user.getId());
|
||||
exchange.setAplName(orderInfo.getAplName());
|
||||
exchange.setOrderCreateTime(parseDate(orderInfo.getCreateTime()));
|
||||
exchange.setOrderUpdateTime(parseDate(orderInfo.getUpdateTime()));
|
||||
|
||||
+8
-1
@@ -7,6 +7,7 @@ import cn.hutool.json.JSONUtil;
|
||||
import com.budwk.app.base.page.Pagination;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.base.service.impl.BaseServiceImpl;
|
||||
import com.budwk.app.sys.models.Sys_user;
|
||||
import com.budwk.app.web.commons.auth.utils.SecurityUtil;
|
||||
import com.budwk.app.zhgh.pointsmall.mallbridge.dto.OrderInfoByReconciliationDTO;
|
||||
import com.budwk.app.zhgh.pointsmall.mallbridge.dto.OrderProInfoDTO;
|
||||
@@ -205,7 +206,13 @@ public class PointsMallReconciliationServiceImpl extends BaseServiceImpl<PointsM
|
||||
resultNoticeDTO.setReconciliationResults(reconciliationList1.stream().map(o -> {
|
||||
ReconciliationResultOrderDTO resultOrderDTO = new ReconciliationResultOrderDTO();
|
||||
resultOrderDTO.setOrderId(o.getOrderId());
|
||||
resultOrderDTO.setUserId(o.getUserId());
|
||||
if (StrUtil.isNotBlank(o.getUserId())) {
|
||||
Sys_user user = dao().fetch(Sys_user.class, o.getUserId());
|
||||
if (user == null || StrUtil.isBlank(user.getVirtualId())) {
|
||||
throw new IllegalArgumentException("用户虚拟ID未配置或不存在");
|
||||
}
|
||||
resultOrderDTO.setUserId(user.getVirtualId());
|
||||
}
|
||||
resultOrderDTO.setReconciliationStatus(o.getDiffType() == 0 ? 1 : 2);
|
||||
resultOrderDTO.setDiffType(o.getDiffType());
|
||||
resultOrderDTO.setDiffReason(o.getDiffReason());
|
||||
|
||||
@@ -512,5 +512,8 @@ CREATE TABLE IF NOT EXISTS `points_mall_schedule_user_points_record` (
|
||||
) 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';
|
||||
ADD COLUMN virtual_id VARCHAR(64) NULL COMMENT '虚拟用户ID,积分商城向供应商传递的用户标识',
|
||||
ADD COLUMN virtual_org_id VARCHAR(255) NULL COMMENT '虚拟组织ID';
|
||||
|
||||
UPDATE sys_user SET virtual_id = MD5(CONCAT(id, '_', loginName, '_', salt))
|
||||
where id is not null and loginName is not null and salt is not null;
|
||||
@@ -151,13 +151,13 @@ layout("/layouts/platform_h5.html"){
|
||||
this.$toast("暂无跳转地址")
|
||||
return
|
||||
}
|
||||
const vuserId = this.$store && this.$store.state.user ? this.$store.state.user.vuserId : ""
|
||||
if (!vuserId) {
|
||||
const virtualId = this.$store && this.$store.state.user ? this.$store.state.user.virtualId : ""
|
||||
if (!virtualId) {
|
||||
this.$toast("获取用户信息失败,请重新登录后再试")
|
||||
return
|
||||
}
|
||||
window.location.href = this.withSupplierQuery(item.supplierUrl, {
|
||||
userId: vuserId
|
||||
userId: virtualId
|
||||
})
|
||||
},
|
||||
withSupplierQuery(url, params) {
|
||||
|
||||
Reference in New Issue
Block a user