1. 新增硒茶商汇交易白名单功能,白名单内的用户可无视直系上下线规则进行买卖
This commit is contained in:
2026-05-23 14:04:54 +08:00
parent 08b76b9584
commit 804a0348ab
15 changed files with 839 additions and 30 deletions

View File

@@ -1,14 +1,12 @@
alter table merchant_catalog
add stock int4 default 0 not null;
-- merchant_catalog
alter table merchant_catalog add stock int4 default 0 not null;
alter table merchant_catalog add version int4 default 0 not null;
comment on column merchant_catalog.stock is '库存';
alter table merchant_catalog
add version int4 default 0 not null;
comment on column merchant_catalog.version is '乐观锁';
-- merchant_catalog_operate_log
DROP TABLE IF EXISTS merchant_catalog_operate_log;
create table merchant_catalog_operate_log
(
@@ -29,15 +27,9 @@ create table merchant_catalog_operate_log
is_deleted int4 default 0
);
CREATE INDEX idx_merchant_catalog_log_merchant_id_create_time
ON merchant_catalog_operate_log (merchant_id, create_time DESC) WHERE is_deleted = 0;
CREATE INDEX idx_merchant_catalog_log_product_id_create_time
ON merchant_catalog_operate_log (product_id, create_time DESC) WHERE is_deleted = 0;
CREATE INDEX idx_merchant_catalog_log_create_time
ON merchant_catalog_operate_log (create_time DESC) WHERE is_deleted = 0;
CREATE INDEX idx_merchant_catalog_log_merchant_id_create_time ON merchant_catalog_operate_log (merchant_id, create_time DESC) WHERE is_deleted = 0;
CREATE INDEX idx_merchant_catalog_log_product_id_create_time ON merchant_catalog_operate_log (product_id, create_time DESC) WHERE is_deleted = 0;
CREATE INDEX idx_merchant_catalog_log_create_time ON merchant_catalog_operate_log (create_time DESC) WHERE is_deleted = 0;
COMMENT ON TABLE merchant_catalog_operate_log IS '自营商家产品目录操作日志';
COMMENT ON COLUMN merchant_catalog_operate_log.id IS '主键';
@@ -57,26 +49,65 @@ comment on column merchant_catalog_operate_log.status is '状态';
comment on column merchant_catalog_operate_log.is_deleted is '是否已删除';
alter table market_daily_summary
rename column personal_benefits_level to personal_benefits_level_id;
-- market_daily_summary
alter table market_daily_summary rename column personal_benefits_level to personal_benefits_level_id;
alter table market_daily_summary rename column personal_cash_level to personal_cash_level_id;
alter table market_daily_summary add personal_benefits_level_name varchar(255);
alter table market_daily_summary add personal_cash_level_name varchar(255);
alter table market_daily_summary
rename column personal_cash_level to personal_cash_level_id;
comment on column market_daily_summary.personal_benefits_level_name is '福利等级名称';
comment on column market_daily_summary.personal_cash_level_name is '现金等级名称';
alter table market_upgrade_config
add level integer default 0 not null;
-- market_upgrade_config
alter table market_upgrade_config add level integer default 0 not null;
comment on column market_upgrade_config.level is '等级';
alter table market_daily_summary
add personal_benefits_level_name varchar(255);
-- merchant_whitelist
DROP TABLE IF EXISTS merchant_whitelist;
create table merchant_whitelist
(
id int8 not null primary key,
user_id int8 not null default -1,
user_account varchar(20) not null default '',
type int4 default 1, -- 1-自营商家
remark text,
create_user int8,
create_dept int8,
create_time timestamp(6),
update_user int8,
update_time timestamp(6),
status int4 null,
is_deleted int4 default 0
);
comment on column market_daily_summary.personal_benefits_level_name is '福利等级名称';
CREATE INDEX idx_merchant_whitelist_user_id_type ON merchant_whitelist (user_id, type) WHERE is_deleted = 0;
CREATE INDEX idx_merchant_whitelist_user_account_type ON merchant_whitelist (user_account, type) WHERE is_deleted = 0;
alter table market_daily_summary
add personal_cash_level_name varchar(255);
COMMENT ON TABLE merchant_whitelist IS '自营商家白名单';
COMMENT ON COLUMN merchant_whitelist.id IS '主键';
COMMENT ON COLUMN merchant_whitelist.user_id IS '用户id';
COMMENT ON COLUMN merchant_whitelist.user_account IS '用户账号';
COMMENT ON COLUMN merchant_whitelist.type IS '作用类型:1-自营商家';
COMMENT ON COLUMN merchant_whitelist.remark IS '备注';
comment on column merchant_whitelist.create_user is '创建人';
comment on column merchant_whitelist.create_dept is '创建部门';
comment on column merchant_whitelist.create_time is '创建时间';
comment on column merchant_whitelist.update_user is '修改人';
comment on column merchant_whitelist.update_time is '修改时间';
comment on column merchant_whitelist.status is '状态';
comment on column merchant_whitelist.is_deleted is '是否已删除';
comment on column market_daily_summary.personal_cash_level_name is '现金等级名称';
INSERT INTO blade_menu(id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted)
VALUES ('2058049305280409601', '1123598815738675201', 'whitelist', '自营商家白名单', 'menu', '/market/whitelist', NULL, 1, 1, 0, 1, NULL, 0);
INSERT INTO blade_menu(id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted)
VALUES ('2058049305280409602', '2058049305280409601', 'whitelist_add', '新增', 'add', '/market/whitelist/add', 'plus', 1, 2, 1, 1, NULL, 0);
INSERT INTO blade_menu(id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted)
VALUES ('2058049305280409603', '2058049305280409601', 'whitelist_edit', '修改', 'edit', '/market/whitelist/edit', 'form', 2, 2, 2, 1, NULL, 0);
INSERT INTO blade_menu(id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted)
VALUES ('2058049305280409604', '2058049305280409601', 'whitelist_delete', '删除', 'delete', '/api/market/merchant-whitelist/whitelist/remove', 'delete', 3, 2, 3, 1, NULL, 0);
INSERT INTO blade_menu(id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted)
VALUES ('2058049305280409605', '2058049305280409601', 'whitelist_view', '查看', 'view', '/market/whitelist/view', 'file-text', 4, 2, 2, 1, NULL, 0);

View File

@@ -0,0 +1,163 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.modules.market.controller;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import lombok.AllArgsConstructor;
import jakarta.validation.Valid;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.secure.annotation.IsAdmin;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.annotation.PreAuth;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.modules.market.pojo.entity.MerchantWhitelistEntity;
import org.springblade.modules.market.pojo.vo.MerchantWhitelistVO;
import org.springblade.modules.market.excel.MerchantWhitelistExcel;
import org.springblade.modules.market.wrapper.MerchantWhitelistWrapper;
import org.springblade.modules.market.service.IMerchantWhitelistService;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.excel.util.ExcelUtil;
import org.springblade.core.tool.constant.BladeConstant;
import java.util.Map;
import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
/**
* 自营商家白名单 控制器
*
* @author BladeX
* @since 2026-05-23
*/
@RestController
@AllArgsConstructor
@RequestMapping("/market/merchant-whitelist")
@PreAuth("hasAnyRole('administrator', 'admin', 'operator')")
@Tag(name = "自营商家白名单", description = "自营商家白名单接口")
public class MerchantWhitelistController extends BladeController {
private final IMerchantWhitelistService whitelistService;
/**
* 自营商家白名单 详情
*/
@GetMapping("/detail")
@ApiOperationSupport(order = 1)
@Operation(summary = "详情", description = "传入whitelist")
public R<MerchantWhitelistVO> detail(MerchantWhitelistEntity whitelist) {
MerchantWhitelistEntity detail = whitelistService.getOne(Condition.getQueryWrapper(whitelist));
return R.data(MerchantWhitelistWrapper.build().entityVO(detail));
}
/**
* 自营商家白名单 分页
*/
@GetMapping("/list")
@ApiOperationSupport(order = 2)
@Operation(summary = "分页", description = "传入whitelist")
public R<IPage<MerchantWhitelistVO>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> whitelist, Query query) {
IPage<MerchantWhitelistEntity> pages = whitelistService.page(Condition.getPage(query), Condition.getQueryWrapper(whitelist, MerchantWhitelistEntity.class));
return R.data(MerchantWhitelistWrapper.build().pageVO(pages));
}
/**
* 自营商家白名单 自定义分页
*/
@GetMapping("/page")
@ApiOperationSupport(order = 3)
@Operation(summary = "分页", description = "传入whitelist")
public R<IPage<MerchantWhitelistVO>> page(MerchantWhitelistVO whitelist, Query query) {
IPage<MerchantWhitelistVO> pages = whitelistService.selectMerchantWhitelistPage(Condition.getPage(query), whitelist);
return R.data(pages);
}
/**
* 自营商家白名单 新增
*/
@PostMapping("/save")
@ApiOperationSupport(order = 4)
@Operation(summary = "新增", description = "传入whitelist")
public R save(@Valid @RequestBody MerchantWhitelistEntity whitelist) {
return R.status(whitelistService.saveByAccount(whitelist));
}
/**
* 自营商家白名单 修改
*/
@PostMapping("/update")
@ApiOperationSupport(order = 5)
@Operation(summary = "修改", description = "传入whitelist")
public R update(@Valid @RequestBody MerchantWhitelistEntity whitelist) {
return R.status(whitelistService.updateById(whitelist));
}
/**
* 自营商家白名单 新增或修改
*/
@PostMapping("/submit")
@ApiOperationSupport(order = 6)
@Operation(summary = "新增或修改", description = "传入whitelist")
public R submit(@Valid @RequestBody MerchantWhitelistEntity whitelist) {
return R.status(whitelistService.saveOrUpdate(whitelist));
}
/**
* 自营商家白名单 删除
*/
@PostMapping("/remove")
@ApiOperationSupport(order = 7)
@Operation(summary = "逻辑删除", description = "传入ids")
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
return R.status(whitelistService.deleteLogic(Func.toLongList(ids)));
}
/**
* 导出数据
*/
@IsAdmin
@GetMapping("/export-whitelist")
@ApiOperationSupport(order = 9)
@Operation(summary = "导出数据", description = "传入whitelist")
public void exportMerchantWhitelist(@Parameter(hidden = true) @RequestParam Map<String, Object> whitelist, BladeUser bladeUser, HttpServletResponse response) {
QueryWrapper<MerchantWhitelistEntity> queryWrapper = Condition.getQueryWrapper(whitelist, MerchantWhitelistEntity.class);
//if (!AuthUtil.isAdministrator()) {
// queryWrapper.lambda().eq(MerchantWhitelist::getTenantId, bladeUser.getTenantId());
//}
//queryWrapper.lambda().eq(MerchantWhitelistEntity::getIsDeleted, BladeConstant.DB_NOT_DELETED);
List<MerchantWhitelistExcel> list = whitelistService.exportMerchantWhitelist(queryWrapper);
ExcelUtil.export(response, "自营商家白名单数据" + DateUtil.time(), "自营商家白名单数据表", list, MerchantWhitelistExcel.class);
}
}

View File

@@ -0,0 +1,18 @@
package org.springblade.modules.market.eums;
import lombok.Getter;
@Getter
public enum WhitelistType {
MERCHANT(1, "自营商家");
private final int code;
private final String desc;
WhitelistType(int code, String desc){
this.code = code;
this.desc = desc;
}
}

View File

@@ -0,0 +1,92 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.modules.market.excel;
import lombok.Data;
import java.util.Date;
import cn.idev.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.write.style.ColumnWidth;
import cn.idev.excel.annotation.write.style.ContentRowHeight;
import cn.idev.excel.annotation.write.style.HeadRowHeight;
import java.io.Serializable;
import java.io.Serial;
/**
* 自营商家白名单 Excel实体类
*
* @author BladeX
* @since 2026-05-23
*/
@Data
@ColumnWidth(25)
@HeadRowHeight(20)
@ContentRowHeight(18)
public class MerchantWhitelistExcel implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@ColumnWidth(20)
@ExcelProperty("主键")
private Long id;
/**
* 用户id
*/
@ColumnWidth(20)
@ExcelProperty("用户id")
private Long userId;
/**
* 用户账号
*/
@ColumnWidth(20)
@ExcelProperty("用户账号")
private String userAccount;
/**
* 作用类型:1-自营商家
*/
@ColumnWidth(20)
@ExcelProperty("作用类型:1-自营商家")
private Integer type;
/**
* 备注
*/
@ColumnWidth(20)
@ExcelProperty("备注")
private String remark;
/**
* 是否已删除
*/
@ColumnWidth(20)
@ExcelProperty("是否已删除")
private Integer isDeleted;
}

View File

@@ -0,0 +1,63 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.modules.market.mapper;
import org.springblade.modules.market.pojo.entity.MerchantWhitelistEntity;
import org.springblade.modules.market.pojo.vo.MerchantWhitelistVO;
import org.springblade.modules.market.excel.MerchantWhitelistExcel;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 自营商家白名单 Mapper 接口
*
* @author BladeX
* @since 2026-05-23
*/
public interface MerchantWhitelistMapper extends BaseMapper<MerchantWhitelistEntity> {
/**
* 自定义分页
*
* @param page 分页参数
* @param whitelist 查询参数
* @return List<MerchantWhitelistVO>
*/
List<MerchantWhitelistVO> selectMerchantWhitelistPage(IPage page, MerchantWhitelistVO whitelist);
/**
* 获取导出数据
*
* @param queryWrapper 查询条件
* @return List<MerchantWhitelistExcel>
*/
List<MerchantWhitelistExcel> exportMerchantWhitelist(@Param("ew") Wrapper<MerchantWhitelistEntity> queryWrapper);
}

View File

@@ -0,0 +1,35 @@
<?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="org.springblade.modules.market.mapper.MerchantWhitelistMapper">
<!-- 通用查询映射结果 -->
<resultMap id="whitelistResultMap" type="org.springblade.modules.market.pojo.entity.MerchantWhitelistEntity">
<result column="id" property="id"/>
<result column="user_id" property="userId"/>
<result column="user_account" property="userAccount"/>
<result column="type" property="type"/>
<result column="remark" property="remark"/>
<result column="create_user" property="createUser"/>
<result column="create_dept" property="createDept"/>
<result column="create_time" property="createTime"/>
<result column="update_user" property="updateUser"/>
<result column="update_time" property="updateTime"/>
<result column="status" property="status"/>
<result column="is_deleted" property="isDeleted"/>
</resultMap>
<select id="selectMerchantWhitelistPage" resultMap="whitelistResultMap">
select * from merchant_whitelist where is_deleted = 0
<if test="whitelist.userAccount != null and whitelist.userAccount != '' ">
and user_account = #{whitelist.userAccount}
</if>
order by create_time desc
</select>
<select id="exportMerchantWhitelist" resultType="org.springblade.modules.market.excel.MerchantWhitelistExcel">
SELECT * FROM merchant_whitelist ${ew.customSqlSegment}
</select>
</mapper>

View File

@@ -0,0 +1,45 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.modules.market.pojo.dto;
import org.springblade.modules.market.pojo.entity.MerchantWhitelistEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serial;
/**
* 自营商家白名单 数据传输对象实体类
*
* @author BladeX
* @since 2026-05-23
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class MerchantWhitelistDTO extends MerchantWhitelistEntity {
@Serial
private static final long serialVersionUID = 1L;
}

View File

@@ -0,0 +1,71 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.modules.market.pojo.entity;
import lombok.Data;
import io.swagger.v3.oas.annotations.media.Schema;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.base.BaseEntity;
import java.io.Serial;
/**
* 自营商家白名单 实体类
*
* @author BladeX
* @since 2026-05-23
*/
@Data
@TableName("merchant_whitelist")
@Schema(description = "MerchantWhitelist对象")
@EqualsAndHashCode(callSuper = true)
public class MerchantWhitelistEntity extends BaseEntity {
@Serial
private static final long serialVersionUID = 1L;
/**
* 用户id
*/
@Schema(description = "用户id")
private Long userId;
/**
* 用户账号
*/
@Schema(description = "用户账号")
private String userAccount;
/**
* 作用类型:1-自营商家
*/
@Schema(description = "作用类型:1-自营商家")
private Integer type;
/**
* 备注
*/
@Schema(description = "备注")
private String remark;
}

View File

@@ -0,0 +1,45 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.modules.market.pojo.vo;
import org.springblade.modules.market.pojo.entity.MerchantWhitelistEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serial;
/**
* 自营商家白名单 视图实体类
*
* @author BladeX
* @since 2026-05-23
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class MerchantWhitelistVO extends MerchantWhitelistEntity {
@Serial
private static final long serialVersionUID = 1L;
}

View File

@@ -0,0 +1,65 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.modules.market.service;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import org.springblade.modules.market.eums.WhitelistType;
import org.springblade.modules.market.pojo.entity.MerchantWhitelistEntity;
import org.springblade.modules.market.pojo.vo.MerchantWhitelistVO;
import org.springblade.modules.market.excel.MerchantWhitelistExcel;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.core.mp.base.BaseService;
import java.util.List;
/**
* 自营商家白名单 服务类
*
* @author BladeX
* @since 2026-05-23
*/
public interface IMerchantWhitelistService extends BaseService<MerchantWhitelistEntity> {
/**
* 自定义分页
*
* @param page 分页参数
* @param whitelist 查询参数
* @return IPage<MerchantWhitelistVO>
*/
IPage<MerchantWhitelistVO> selectMerchantWhitelistPage(IPage<MerchantWhitelistVO> page, MerchantWhitelistVO whitelist);
/**
* 导出数据
*
* @param queryWrapper 查询条件
* @return List<MerchantWhitelistExcel>
*/
List<MerchantWhitelistExcel> exportMerchantWhitelist(Wrapper<MerchantWhitelistEntity> queryWrapper);
boolean saveByAccount(MerchantWhitelistEntity whitelist);
boolean checkExistForMerchant(Long userId, Long merchantId, WhitelistType type);
}

View File

@@ -41,6 +41,7 @@ import org.springblade.modules.market.convert.MarketMerchantConvert;
import org.springblade.modules.market.eums.MarketBusinessModule;
import org.springblade.modules.market.eums.MerchantGiftType;
import org.springblade.modules.market.eums.PayoutAccountType;
import org.springblade.modules.market.eums.WhitelistType;
import org.springblade.modules.market.pojo.dto.MarketBenefitPointApiDTO;
import org.springblade.modules.market.pojo.entity.MerchantInventoryEntity;
import org.springblade.modules.market.pojo.entity.MerchantOrderEntity;
@@ -83,6 +84,8 @@ public class MerchantOrderServiceImpl extends BaseServiceImpl<MerchantOrderMappe
private final IMarketBenefitPointService benefitPointService;
private final IMerchantWhitelistService whitelistService;
private final ApplicationEventPublisher publisher;
private static final String MERCHANT_BUSINESS_HOURS = "merchant.business.hours";
@@ -129,10 +132,13 @@ public class MerchantOrderServiceImpl extends BaseServiceImpl<MerchantOrderMappe
if (Objects.equals(userId, inventory.getUserId())) {
throw new ServiceException("请勿购买自己的商品");
}
boolean existWhiteList = whitelistService.checkExistForMerchant(userId, inventory.getUserId(), WhitelistType.MERCHANT);
if (!existWhiteList) {
boolean inDirectLineage = hierarchyService.isInDirectLineage(inventory.getUserId(), userId);
if (!inDirectLineage) {
throw new ServiceException("您所选购的商品库存不足");
}
}
boolean reduced = inventoryService.reduceById(inventory.getId(), quantity);
if (!reduced) {
throw new ServiceException("扣减库存失败");

View File

@@ -0,0 +1,109 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.modules.market.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.AllArgsConstructor;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.modules.market.eums.WhitelistType;
import org.springblade.modules.market.pojo.entity.MerchantWhitelistEntity;
import org.springblade.modules.market.pojo.vo.MerchantWhitelistVO;
import org.springblade.modules.market.excel.MerchantWhitelistExcel;
import org.springblade.modules.market.mapper.MerchantWhitelistMapper;
import org.springblade.modules.market.service.IMerchantWhitelistService;
import org.springblade.modules.system.pojo.entity.User;
import org.springblade.modules.system.service.IUserService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.core.mp.base.BaseServiceImpl;
import java.util.List;
/**
* 自营商家白名单 服务实现类
*
* @author BladeX
* @since 2026-05-23
*/
@Service
@AllArgsConstructor
public class MerchantWhitelistServiceImpl extends BaseServiceImpl<MerchantWhitelistMapper, MerchantWhitelistEntity> implements IMerchantWhitelistService {
private final IUserService userService;
@Override
public IPage<MerchantWhitelistVO> selectMerchantWhitelistPage(IPage<MerchantWhitelistVO> page, MerchantWhitelistVO whitelist) {
return page.setRecords(baseMapper.selectMerchantWhitelistPage(page, whitelist));
}
@Override
public List<MerchantWhitelistExcel> exportMerchantWhitelist(Wrapper<MerchantWhitelistEntity> queryWrapper) {
List<MerchantWhitelistExcel> whitelistList = baseMapper.exportMerchantWhitelist(queryWrapper);
//whitelistList.forEach(whitelist -> {
// whitelist.setTypeName(DictCache.getValue(DictEnum.YES_NO, MerchantWhitelist.getType()));
//});
return whitelistList;
}
@Override
public boolean saveByAccount(MerchantWhitelistEntity whitelist) {
if (StringUtil.isBlank(whitelist.getUserAccount())) {
throw new ServiceException("用户账号不能为空");
}
User user = userService.getByAccount(whitelist.getUserAccount());
if (user == null) {
throw new ServiceException("账号不存在");
}
boolean exists = exists(Wrappers.lambdaQuery(MerchantWhitelistEntity.class).eq(MerchantWhitelistEntity::getUserId, user.getId()).eq(MerchantWhitelistEntity::getType, whitelist.getType()).eq(MerchantWhitelistEntity::getIsDeleted, 0));
if (exists) {
throw new ServiceException("该用户已添加,请勿重复操作");
}
MerchantWhitelistEntity entity = new MerchantWhitelistEntity();
entity.setUserAccount(whitelist.getUserAccount());
entity.setUserId(user.getId());
entity.setType(whitelist.getType());
entity.setRemark(whitelist.getRemark());
return saveOrUpdate(entity);
}
@Override
public boolean checkExistForMerchant(Long userId, Long merchantId, WhitelistType type) {
if (userId == null || merchantId == null || type == null) {
throw new ServiceException("无效参数");
}
return exists(Wrappers.lambdaQuery(MerchantWhitelistEntity.class)
.eq(MerchantWhitelistEntity::getIsDeleted, 0)
.eq(MerchantWhitelistEntity::getType, type.getCode())
.and(wrapper ->
wrapper.eq(MerchantWhitelistEntity::getUserId, userId)
.or()
.eq(MerchantWhitelistEntity::getUserId, merchantId)));
}
}

View File

@@ -0,0 +1,59 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.modules.market.wrapper;
import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.modules.market.pojo.entity.MerchantWhitelistEntity;
import org.springblade.modules.market.pojo.vo.MerchantWhitelistVO;
import java.util.Objects;
/**
* 自营商家白名单 包装类,返回视图层所需的字段
*
* @author BladeX
* @since 2026-05-23
*/
public class MerchantWhitelistWrapper extends BaseEntityWrapper<MerchantWhitelistEntity, MerchantWhitelistVO> {
public static MerchantWhitelistWrapper build() {
return new MerchantWhitelistWrapper();
}
@Override
public MerchantWhitelistVO entityVO(MerchantWhitelistEntity whitelist) {
MerchantWhitelistVO whitelistVO = Objects.requireNonNull(BeanUtil.copyProperties(whitelist, MerchantWhitelistVO.class));
//User createUser = UserCache.getUser(whitelist.getCreateUser());
//User updateUser = UserCache.getUser(whitelist.getUpdateUser());
//whitelistVO.setCreateUserName(createUser.getName());
//whitelistVO.setUpdateUserName(updateUser.getName());
return whitelistVO;
}
}

View File

@@ -318,4 +318,6 @@ public interface IUserService extends BaseService<User> {
boolean closeAccount();
boolean changeNickname(Long userId, String nickname);
User getByAccount(String userAccount);
}

View File

@@ -760,6 +760,11 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
);
}
@Override
public User getByAccount(String userAccount) {
return getByPhone(userAccount);
}
private boolean isPasswordValid(String password) {
// 规则: 必须包含大小写字母和数字, 长度8-12位, 仅允许字母和数字
return password.matches("^[a-zA-Z0-9]{8,}$");