1. add merchant purchasing module
This commit is contained in:
2026-04-24 21:21:56 +08:00
parent 5f44987416
commit 140fb13702
45 changed files with 2602 additions and 40 deletions

View File

@@ -1,6 +1,65 @@
alter table market_cash_performance add dividend_amount decimal(14, 2) default 0.00;
alter table market_cash_performance
add dividend_amount decimal(14, 2) default 0.00;
comment on column market_cash_performance.dividend_amount is '可分红业绩';
alter table market_performance_day_log add dividend_amount decimal(14, 2) default 0.00;
alter table market_performance_day_log
add dividend_amount decimal(14, 2) default 0.00;
comment on column market_performance_day_log.dividend_amount is '昨日可分红业绩';
alter table user_market_info
add merchant_type int4 default 0 not null;
comment on column user_market_info.merchant_type is '自营商家类型 0:未审核 1:个人商家 2:企业商家';
create table merchant_application
(
id int8 not null primary key,
user_id int8 not null,
user_account varchar(20) not null,
type int4 not null,
company_name varchar(100),
business_license varchar(100),
business_license_url TEXT,
legal_person varchar(50),
remark TEXT,
create_user int8,
create_dept int8,
create_time timestamp(6),
update_user int8,
update_time timestamp(6),
status int4 default 1, -- 1: 待审核 -- 2: 已通过 -- 3: 已拒绝
is_deleted int4 default 0
);
CREATE INDEX idx_merchant_app_type_status ON merchant_application (type, status) where is_deleted = 0;
CREATE INDEX idx_merchant_app_user_acc ON merchant_application (user_account) where is_deleted = 0;
CREATE INDEX idx_merchant_app_user_id ON merchant_application (user_id) where is_deleted = 0;
comment on table merchant_application is '商家入驻申请表';
comment on column merchant_application.id is '主键';
comment on column merchant_application.user_id is '用户id';
comment on column merchant_application.user_account is '用户账号';
comment on column merchant_application.type is '商家类型: 0-未审核, 1-个人商家, 2-企业商家';
comment on column merchant_application.company_name is '公司名称(企业商家时必填)';
comment on column merchant_application.business_license is '营业执照注册号';
comment on column merchant_application.business_license_url is '营业执照图片URL';
comment on column merchant_application.legal_person is '法人姓名';
comment on column merchant_application.remark is '备注';
comment on column merchant_application.create_user is '创建人';
comment on column merchant_application.create_dept is '创建部门';
comment on column merchant_application.create_time is '创建时间';
comment on column merchant_application.update_user is '修改人';
comment on column merchant_application.update_time is '修改时间';
comment on column merchant_application.status is '状态: 1-待审核 2-已通过 3-已拒绝';
comment on column merchant_application.is_deleted is '是否已删除';
INSERT INTO blade_menu(id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark, is_deleted)
VALUES ('2046772140345806850', '1123598815738675201', 'application', '商家入驻', 'menu', '/market/marketMerchantApplication', 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 ('2046772140345806851', '2046772140345806850', 'application_add', '新增', 'add', '/market/marketMerchantApplication/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 ('2046772140345806852', '2046772140345806850', 'application_edit', '修改', 'edit', '/market/marketMerchantApplication/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 ('2046772140345806853', '2046772140345806850', 'application_delete', '删除', 'delete', '/api/blade-application/marketMerchantApplication/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 ('2046772140345806854', '2046772140345806850', 'application_view', '查看', 'view', '/market/marketMerchantApplication/view', 'file-text', 4, 2, 2, 1, NULL, 0);

View File

@@ -0,0 +1,106 @@
drop table if exists merchant_product;
create table merchant_product
(
id int8 not null primary key,
user_id int8 not null default -1,
user_account varchar(20) not null,
product_name varchar(255) not null default '',
type int4 not null,
main_image_urls text[] DEFAULT '{}' NOT NULL,
detail_image_urls text[] DEFAULT '{}' NULL,
thumb_image_url text NULL,
specs JSONB DEFAULT '[]',
cost_price DECIMAL(10, 2) DEFAULT 0.00 NOT NULL,
remark TEXT,
create_user int8,
create_dept int8,
create_time timestamp(6),
update_user int8,
update_time timestamp(6),
status int4,
is_deleted int4 default 0
);
CREATE INDEX idx_merchant_product_type ON merchant_product (type) where is_deleted = 0;
CREATE INDEX idx_merchant_product_user_id ON merchant_product (user_id) where is_deleted = 0;
CREATE INDEX idx_merchant_product_user_id_account ON merchant_product (user_account) where is_deleted = 0;
comment on table merchant_product is '自营商家商品表';
comment on column merchant_product.id is '主键';
comment on column merchant_product.user_id is '用户id';
comment on column merchant_product.user_account is '用户账号';
comment on column merchant_product.type is '商品类型: 1-平台商品, 2-商家商品';
comment on column merchant_product.product_name is '商品名称';
comment on column merchant_product.main_image_urls is '商品主图';
comment on column merchant_product.detail_image_urls is '商品详情图';
comment on column merchant_product.thumb_image_url is '商品缩略图';
comment on column merchant_product.specs is '商品型号';
comment on column merchant_product.cost_price is '成本价(进货价, 单位为现金券)';
comment on column merchant_product.remark is '备注';
comment on column merchant_product.create_user is '创建人';
comment on column merchant_product.create_dept is '创建部门';
comment on column merchant_product.create_time is '创建时间';
comment on column merchant_product.update_user is '修改人';
comment on column merchant_product.update_time is '修改时间';
comment on column merchant_product.status is '状态: 1-待审核 2-已通过 3-已拒绝';
comment on column merchant_product.is_deleted is '是否已删除';
drop table if exists merchant_product_inventory;
create table merchant_product_inventory
(
id int8 not null primary key,
user_id int8 not null default -1,
user_account varchar(20) not null,
type int4 not null,
product_name varchar(255) not null default '',
product_id int8 not null,
quantity int4 default 0 NOT NULL,
remark TEXT,
version int4 DEFAULT 0 NULL,
create_user int8,
create_dept int8,
create_time timestamp(6),
update_user int8,
update_time timestamp(6),
status int4,
is_deleted int4 default 0
);
CREATE INDEX idx_merchant_product_inventory_user_id ON merchant_product_inventory (user_id) where is_deleted = 0;
CREATE INDEX idx_merchant_product_inventory_user_id_account ON merchant_product_inventory (user_account) where is_deleted = 0;
comment on table merchant_product_inventory is '自营商家库存表';
comment on column merchant_product_inventory.id is '主键';
comment on column merchant_product_inventory.user_id is '用户id';
comment on column merchant_product_inventory.user_account is '用户账号';
comment on column merchant_product_inventory.type is '商品类型: 1-平台商品, 2-商家商品';
comment on column merchant_product_inventory.product_name is '商品名称';
comment on column merchant_product_inventory.product_id is '商品id';
comment on column merchant_product_inventory.quantity is '库存数量';
comment on column merchant_product_inventory.remark is '备注';
comment on column merchant_product_inventory.create_user is '创建人';
comment on column merchant_product_inventory.create_dept is '创建部门';
comment on column merchant_product_inventory.create_time is '创建时间';
comment on column merchant_product_inventory.update_user is '修改人';
comment on column merchant_product_inventory.update_time is '修改时间';
comment on column merchant_product_inventory.status is '状态';
comment on column merchant_product_inventory.is_deleted is '是否已删除';
INSERT INTO blade_menu(id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark,
is_deleted)
VALUES ('2047553982355394562', '1123598815738675201', 'merchantproduct', '自营商家商品表', 'menu',
'/market/merchantProduct', 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 ('2047553982355394563', '2047553982355394562', 'merchantproduct_add', '新增', 'add',
'/market/merchantProduct/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 ('2047553982355394564', '2047553982355394562', 'merchantproduct_edit', '修改', 'edit',
'/market/merchantProduct/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 ('2047553982355394565', '2047553982355394562', 'merchantproduct_delete', '删除', 'delete',
'/api/market/merchantProduct/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 ('2047553982355394566', '2047553982355394562', 'merchantproduct_view', '查看', 'view',
'/market/merchantProduct/view', 'file-text', 4, 2, 2, 1, NULL, 0);

View File

@@ -4,6 +4,7 @@ import org.springblade.core.cache.utils.CacheUtil;
import org.springblade.core.tool.utils.SpringUtil;
import org.springblade.modules.market.service.IMarketBankCardService;
import org.springblade.modules.market.service.IMarketInfoService;
import org.springblade.modules.market.service.IMarketMerchantApplicationService;
import static org.springblade.common.constant.MarketInfoConstant.MARKET_INFO_CONFIG_CACHE;
@@ -13,13 +14,18 @@ public class MarketInfoCache {
public static final String BANK_CARD = "bankCard:";
public static final String MERCHANT = "merchant:";
private static final IMarketInfoService marketInfoService;
private static final IMarketBankCardService bankCardService;
public static final IMarketMerchantApplicationService merchantService;
static {
marketInfoService = SpringUtil.getBean(IMarketInfoService.class);
bankCardService = SpringUtil.getBean(IMarketBankCardService.class);
merchantService = SpringUtil.getBean(IMarketMerchantApplicationService.class);
}
public static boolean hasVerifyRealName(Long userId) {
@@ -30,4 +36,8 @@ public class MarketInfoCache {
return Boolean.TRUE.equals(CacheUtil.get(MARKET_INFO_CONFIG_CACHE, BANK_CARD, userId, () -> bankCardService.hasVerifyBankCard(userId)));
}
public static Integer checkMerchantType(Long userId) {
return CacheUtil.get(MARKET_INFO_CONFIG_CACHE, MERCHANT, userId, () -> merchantService.checkMerchantType(userId));
}
}

View File

@@ -0,0 +1,88 @@
package org.springblade.modules.api.market;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import org.springblade.core.secure.annotation.PreAuth;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.modules.api.request.IncreaseInventoryRequest;
import org.springblade.modules.api.request.SubmitMerchantProductRequest;
import org.springblade.modules.api.request.VerifyMerchantRequest;
import org.springblade.modules.api.response.MerchantStatusResponse;
import org.springblade.modules.api.vo.MarketMerchantProductApiVO;
import org.springblade.modules.api.vo.MarketMerchantInventoryApiVO;
import org.springblade.modules.market.service.IMarketMerchantApplicationService;
import org.springblade.modules.market.service.IMerchantInventoryService;
import org.springblade.modules.market.service.IMerchantProductService;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@AllArgsConstructor
@RequestMapping("/market/merchant")
@Tag(name = "Market自营商家接口", description = "Market自营商家接口")
@PreAuth(role = "Market")
public class MarketMerchantController {
private final IMarketMerchantApplicationService applicationService;
private final IMerchantProductService merchantProductService;
private final IMerchantInventoryService inventoryService;
@PostMapping("/merchant-apply")
@ApiOperationSupport(order = 1)
@Operation(summary = "自营商家认证提交")
public R verifyMerchant(@RequestBody @Valid VerifyMerchantRequest request) {
return R.status(applicationService.applyMerchant(AuthUtil.getUserId(), request.getType(), request.getCompanyName(), request.getBusinessLicense(), request.getBusinessLicenseUrl(), request.getLegalPerson()));
}
@GetMapping("/merchant-audit-status")
@ApiOperationSupport(order = 2)
@Operation(summary = "审核状态查询")
public R<MerchantStatusResponse> checkStatus() {
return R.data(applicationService.checkAuditStatus(AuthUtil.getUserId()));
}
@GetMapping("/merchant-type")
@ApiOperationSupport(order = 3)
@Operation(summary = "商家身份查询")
public R<Integer> merchantType() {
return R.data(applicationService.merchantType(AuthUtil.getUserId()));
}
@GetMapping("/product-list")
@ApiOperationSupport(order = 4)
@Operation(summary = "商品列表")
public R<List<MarketMerchantProductApiVO>> productList() {
return R.data(merchantProductService.productListByUserId(AuthUtil.getUserId()));
}
@PostMapping("/submit-product")
@ApiOperationSupport(order = 5)
@Operation(summary = "提交商品")
public R addProduct(@RequestBody @Valid SubmitMerchantProductRequest request) {
return R.status(merchantProductService.submitMerchantProduct(AuthUtil.getUserId(), request.getId(), request.getProductName(), request.getThumbImageUrl(), request.getMainImageUrls(), request.getDetailImageUrls(), request.getSpecs()));
}
@GetMapping("/inventory-list")
@ApiOperationSupport(order = 6)
@Operation(summary = "商品库存列表")
public R<List<MarketMerchantInventoryApiVO>> inventoryList() {
return R.data(inventoryService.inventoryListByUserId(AuthUtil.getUserId()));
}
@PostMapping("/increase-inventory")
@ApiOperationSupport(order = 7)
@Operation(summary = "增加库存")
public R increaseInventory(@RequestBody @Valid IncreaseInventoryRequest request) {
return R.status(inventoryService.increase(AuthUtil.getUserId(), request.getProductId(), request.getNum()));
}
}

View File

@@ -0,0 +1,14 @@
package org.springblade.modules.api.request;
import lombok.Data;
import java.io.Serializable;
@Data
public class IncreaseInventoryRequest implements Serializable {
private Long productId;
private Integer num;
}

View File

@@ -0,0 +1,31 @@
package org.springblade.modules.api.request;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import org.springblade.modules.market.pojo.entity.MerchantProductEntity;
import java.io.Serializable;
import java.util.List;
@Data
public class SubmitMerchantProductRequest implements Serializable {
private Long id;
@NotEmpty
private String productName;
@NotNull
private List<String> mainImageUrls;
@NotNull
private List<String> detailImageUrls;
@NotEmpty
private String thumbImageUrl;
private List<MerchantProductEntity.Spec> specs;
}

View File

@@ -0,0 +1,23 @@
package org.springblade.modules.api.request;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import java.io.Serializable;
@Data
public class VerifyMerchantRequest implements Serializable {
@NotNull(message = "无效参数")
private Integer type;
private String companyName;
private String businessLicense;
private String businessLicenseUrl;
private String legalPerson;
}

View File

@@ -0,0 +1,28 @@
package org.springblade.modules.api.response;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
@Data
public class MerchantStatusResponse implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
private Integer type;
private String companyName;
private String businessLicense;
private String businessLicenseUrl;
private String legalPerson;
private Integer status;
private String remark;
}

View File

@@ -0,0 +1,28 @@
package org.springblade.modules.api.vo;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
@Data
public class MarketMerchantInventoryApiVO implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
private Long id;
private Long productId;
private Integer type;
private String productName;
private String thumbImageUrl;
private Integer stock;
private String remark;
}

View File

@@ -0,0 +1,27 @@
package org.springblade.modules.api.vo;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
public class MarketMerchantProductApiVO implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
private Long id;
private Integer type;
private String productName;
private String thumbImageUrl;
private BigDecimal costPrice;
private String remark;
}

View File

@@ -0,0 +1,154 @@
/**
* 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.mp.support.Condition;
import org.springblade.core.mp.support.Query;
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.metadata.IPage;
import org.springblade.modules.market.pojo.entity.MarketMerchantApplicationEntity;
import org.springblade.modules.market.pojo.vo.MarketMerchantApplicationVO;
import org.springblade.modules.market.service.IMarketMerchantApplicationService;
import org.springblade.core.boot.ctrl.BladeController;
import java.util.Map;
/**
* 商家入驻申请表 控制器
*
* @author RayL
* @since 2026-04-22
*/
@RestController
@AllArgsConstructor
@RequestMapping("/merchant-application")
@Tag(name = "商家入驻申请表", description = "商家入驻申请表接口")
public class MarketMerchantApplicationController extends BladeController {
private final IMarketMerchantApplicationService applicationService;
/**
* 商家入驻申请表 详情
*/
@GetMapping("/detail")
@ApiOperationSupport(order = 1)
@Operation(summary = "详情", description = "传入application")
public R<MarketMerchantApplicationEntity> detail(MarketMerchantApplicationEntity application) {
MarketMerchantApplicationEntity detail = applicationService.getOne(Condition.getQueryWrapper(application));
return R.data(detail);
}
/**
* 商家入驻申请表 分页
*/
@GetMapping("/list")
@ApiOperationSupport(order = 2)
@Operation(summary = "分页", description = "传入application")
public R<IPage<MarketMerchantApplicationEntity>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> application, Query query) {
IPage<MarketMerchantApplicationEntity> pages = applicationService.page(Condition.getPage(query), Condition.getQueryWrapper(application, MarketMerchantApplicationEntity.class));
return R.data(pages);
}
/**
* 商家入驻申请表 自定义分页
*/
@GetMapping("/page")
@ApiOperationSupport(order = 3)
@Operation(summary = "分页", description = "传入application")
public R<IPage<MarketMerchantApplicationVO>> page(MarketMerchantApplicationVO application, Query query) {
IPage<MarketMerchantApplicationVO> pages = applicationService.selectApplicationPage(Condition.getPage(query), application);
return R.data(pages);
}
/**
* 商家入驻申请表 新增
*/
@PostMapping("/save")
@ApiOperationSupport(order = 4)
@Operation(summary = "新增", description = "传入application")
public R save(@Valid @RequestBody MarketMerchantApplicationEntity application) {
return R.status(applicationService.save(application));
}
/**
* 商家入驻申请表 修改
*/
@PostMapping("/update")
@ApiOperationSupport(order = 5)
@Operation(summary = "修改", description = "传入application")
public R update(@Valid @RequestBody MarketMerchantApplicationEntity application) {
return R.status(applicationService.updateById(application));
}
/**
* 商家入驻申请表 新增或修改
*/
@PostMapping("/submit")
@ApiOperationSupport(order = 6)
@Operation(summary = "新增或修改", description = "传入application")
public R submit(@Valid @RequestBody MarketMerchantApplicationEntity application) {
return R.status(applicationService.saveOrUpdate(application));
}
/**
* 商家入驻申请表 删除
*/
@PostMapping("/remove")
@ApiOperationSupport(order = 7)
@Operation(summary = "逻辑删除", description = "传入ids")
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
return R.status(applicationService.deleteLogic(Func.toLongList(ids)));
}
/**
* 商家入驻申请表 审核通过
*/
@PostMapping("/approve")
@ApiOperationSupport(order = 8)
@Operation(summary = "审核通过", description = "传入id")
public R approve(@RequestParam String id) {
return R.status(applicationService.approve(Func.toLong(id)));
}
/**
* 商家入驻申请表 审核拒绝
*/
@PostMapping("/reject")
@ApiOperationSupport(order = 8)
@Operation(summary = "审核拒绝", description = "传入id")
public R approve(@RequestParam String id, @RequestParam String reason) {
return R.status(applicationService.reject(Func.toLong(id), reason));
}
}

View File

@@ -0,0 +1,133 @@
/**
* 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 com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.market.pojo.entity.MerchantInventoryEntity;
import org.springblade.modules.market.pojo.vo.MerchantInventoryVO;
import org.springblade.modules.market.service.IMerchantInventoryService;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/**
* 自营商家库存表 控制器
*
* @author BladeX
* @since 2026-04-24
*/
@RestController
@AllArgsConstructor
@RequestMapping("/market/merchant-inventory")
@Tag(name = "自营商家库存表", description = "自营商家库存表接口")
public class MerchantInventoryController extends BladeController {
private final IMerchantInventoryService inventoryService;
/**
* 自营商家库存表 详情
*/
@GetMapping("/detail")
@ApiOperationSupport(order = 1)
@Operation(summary = "详情", description = "传入productInventory")
public R<MerchantInventoryEntity> detail(MerchantInventoryEntity productInventory) {
MerchantInventoryEntity detail = inventoryService.getById(productInventory.getId());
return R.data(detail);
}
/**
* 自营商家库存表 分页
*/
@GetMapping("/list")
@ApiOperationSupport(order = 2)
@Operation(summary = "分页", description = "传入productInventory")
public R<IPage<MerchantInventoryEntity>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> productInventory, Query query) {
IPage<MerchantInventoryEntity> pages = inventoryService.page(Condition.getPage(query), Condition.getQueryWrapper(productInventory, MerchantInventoryEntity.class));
return R.data(pages);
}
/**
* 自营商家库存表 自定义分页
*/
@GetMapping("/page")
@ApiOperationSupport(order = 3)
@Operation(summary = "分页", description = "传入productInventory")
public R<IPage<MerchantInventoryVO>> page(MerchantInventoryVO inventory, Query query) {
IPage<MerchantInventoryVO> pages = inventoryService.selectProductInventoryPage(Condition.getPage(query), inventory);
return R.data(pages);
}
/**
* 自营商家库存表 新增
*/
@PostMapping("/save")
@ApiOperationSupport(order = 4)
@Operation(summary = "新增", description = "传入productInventory")
public R save(@Valid @RequestBody MerchantInventoryEntity productInventory) {
return R.status(inventoryService.save(productInventory));
}
/**
* 自营商家库存表 修改
*/
@PostMapping("/update")
@ApiOperationSupport(order = 5)
@Operation(summary = "修改", description = "传入productInventory")
public R update(@Valid @RequestBody MerchantInventoryEntity productInventory) {
return R.status(inventoryService.updateById(productInventory));
}
/**
* 自营商家库存表 新增或修改
*/
@PostMapping("/submit")
@ApiOperationSupport(order = 6)
@Operation(summary = "新增或修改", description = "传入productInventory")
public R submit(@Valid @RequestBody MerchantInventoryEntity productInventory) {
return R.status(inventoryService.saveOrUpdate(productInventory));
}
/**
* 自营商家库存表 删除
*/
@PostMapping("/remove")
@ApiOperationSupport(order = 7)
@Operation(summary = "逻辑删除", description = "传入ids")
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
return R.status(inventoryService.deleteLogic(Func.toLongList(ids)));
}
}

View File

@@ -0,0 +1,145 @@
/**
* 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.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.market.pojo.entity.MerchantProductEntity;
import org.springblade.modules.market.pojo.vo.MerchantProductVO;
import org.springblade.modules.market.service.IMerchantProductService;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.core.boot.ctrl.BladeController;
import java.util.Map;
/**
* 自营商家商品表 控制器
*
* @author RayL
* @since 2026-04-24
*/
@RestController
@AllArgsConstructor
@RequestMapping("/market/merchant-product")
@Tag(name = "自营商家商品表", description = "自营商家商品表接口")
public class MerchantProductController extends BladeController {
private final IMerchantProductService productService;
/**
* 自营商家商品表 详情
*/
@GetMapping("/detail")
@ApiOperationSupport(order = 1)
@Operation(summary = "详情", description = "传入product")
public R<MerchantProductEntity> detail(MerchantProductEntity product) {
MerchantProductEntity detail = productService.getById(product.getId());
return R.data(detail);
}
/**
* 自营商家商品表 分页
*/
@GetMapping("/list")
@ApiOperationSupport(order = 2)
@Operation(summary = "分页", description = "传入product")
public R<IPage<MerchantProductEntity>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> product, Query query) {
IPage<MerchantProductEntity> pages = productService.page(Condition.getPage(query), Condition.getQueryWrapper(product, MerchantProductEntity.class));
return R.data(pages);
}
/**
* 自营商家商品表 自定义分页
*/
@GetMapping("/page")
@ApiOperationSupport(order = 3)
@Operation(summary = "分页", description = "传入product")
public R<IPage<MerchantProductVO>> page(MerchantProductVO product, Query query) {
IPage<MerchantProductVO> pages = productService.selectMerchantProductPage(Condition.getPage(query), product);
return R.data(pages);
}
/**
* 自营商家商品表 新增
*/
@PostMapping("/save")
@ApiOperationSupport(order = 4)
@Operation(summary = "新增", description = "传入product")
public R save(@Valid @RequestBody MerchantProductEntity product) {
return R.status(productService.save(product));
}
/**
* 自营商家商品表 修改
*/
@PostMapping("/update")
@ApiOperationSupport(order = 5)
@Operation(summary = "修改", description = "传入product")
public R update(@Valid @RequestBody MerchantProductEntity product) {
return R.status(productService.updateById(product));
}
/**
* 自营商家商品表 新增或修改
*/
@PostMapping("/submit")
@ApiOperationSupport(order = 6)
@Operation(summary = "新增或修改", description = "传入product")
public R submit(@Valid @RequestBody MerchantProductEntity product) {
return R.status(productService.saveOrUpdate(product));
}
/**
* 自营商家商品表 删除
*/
@PostMapping("/remove")
@ApiOperationSupport(order = 7)
@Operation(summary = "逻辑删除", description = "传入ids")
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
return R.status(productService.deleteLogic(Func.toLongList(ids)));
}
/**
* 自营商家商品表 新增平台商品
*/
@PostMapping("/submit-product")
@ApiOperationSupport(order = 8)
@Operation(summary = "新增平台商品", description = "传入product")
public R submitProduct(@Valid @RequestBody MerchantProductEntity product) {
return R.status(productService.submitPlatformProduct(product));
}
}

View File

@@ -0,0 +1,19 @@
package org.springblade.modules.market.convert;
import org.mapstruct.Mapper;
import org.springblade.modules.api.vo.MarketMerchantProductApiVO;
import org.springblade.modules.market.pojo.entity.MerchantProductEntity;
import java.util.List;
@Mapper
public interface MarketMerchantConvert {
MarketMerchantConvert INSTANCE = MarketMerchantConvert.INSTANCE;
MarketMerchantProductApiVO convertMerchantProductEntityToApiVO(MerchantProductEntity marketMerchantProductEntity);
List<MarketMerchantProductApiVO> convertMerchantProductEntityToApiVOList(List<MerchantProductEntity> marketMerchantProductEntityList);
}

View File

@@ -15,6 +15,7 @@ public enum MarketBusinessModule {
CASH_UPGRADE("现金动态升级", "cash_upgrade"),
CASH_ACCELERATION("现金动态加速", "cash_acceleration"),
MERCHANT_PURCHASING("自营商城进货", "merchant_purchasing"),
;
@Getter

View File

@@ -0,0 +1,36 @@
package org.springblade.modules.market.eums;
import lombok.Getter;
@Getter
public enum MerchantAuditStatus {
PENDING(1, "待审核"),
APPROVED(2, "已通过"),
REJECTED(3, "已拒绝");
private final int code;
private final String description;
MerchantAuditStatus(int code, String description) {
this.code = code;
this.description = description;
}
/**
* 根据状态码获取对应的枚举值
*
* @param code 状态码
* @return 对应的枚举
* @throws IllegalArgumentException 如果状态码无效
*/
public static MerchantAuditStatus fromCode(int code) {
for (MerchantAuditStatus status : MerchantAuditStatus.values()) {
if (status.getCode() == code) {
return status;
}
}
throw new IllegalArgumentException("Invalid merchant audit status code: " + code);
}
}

View File

@@ -0,0 +1,27 @@
package org.springblade.modules.market.eums;
import lombok.Getter;
@Getter
public enum MerchantProductType {
PLATFORM(1,"平台商品"),
MERCHANT(2,"商家商品");
private final Integer code;
private final String desc;
MerchantProductType(Integer code, String desc) {
this.code = code;
this.desc = desc;
}
public static MerchantProductType fromCode(Integer code) {
for (MerchantProductType type : MerchantProductType.values()) {
if (type.code.equals(code)) {
return type;
}
}
throw new IllegalArgumentException("无效的商品类型 code: " + code);
}
}

View File

@@ -0,0 +1,29 @@
package org.springblade.modules.market.eums;
import lombok.Getter;
@Getter
public enum MerchantType {
UNREVIEWED(0, "未审核"),
INDIVIDUAL(1, "个人商家"),
ENTERPRISE(2, "企业商家");
private final int code;
private final String description;
MerchantType(int code, String description) {
this.code = code;
this.description = description;
}
// 根据 code 获取对应的枚举值
public static MerchantType fromCode(int code) {
for (MerchantType type : MerchantType.values()) {
if (type.getCode() == code) {
return type;
}
}
throw new IllegalArgumentException("Invalid merchant type code: " + code);
}
}

View File

@@ -0,0 +1,51 @@
/**
* 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.MarketMerchantApplicationEntity;
import org.springblade.modules.market.pojo.vo.MarketMerchantApplicationVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import java.util.List;
/**
* 商家入驻申请表 Mapper 接口
*
* @author RayL
* @since 2026-04-22
*/
public interface MarketMerchantApplicationMapper extends BaseMapper<MarketMerchantApplicationEntity> {
/**
* 自定义分页
*
* @param page 分页参数
* @param application 查询参数
* @return List<ApplicationVO>
*/
List<MarketMerchantApplicationVO> selectApplicationPage(IPage page, MarketMerchantApplicationVO application);
}

View File

@@ -0,0 +1,40 @@
<?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.MarketMerchantApplicationMapper">
<!-- 通用查询映射结果 -->
<resultMap id="applicationResultMap" type="org.springblade.modules.market.pojo.entity.MarketMerchantApplicationEntity">
<result column="id" property="id"/>
<result column="user_id" property="userId"/>
<result column="user_account" property="userAccount"/>
<result column="type" property="type"/>
<result column="company_name" property="companyName"/>
<result column="business_license" property="businessLicense"/>
<result column="business_license_url" property="businessLicenseUrl"/>
<result column="legal_person" property="legalPerson"/>
<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="selectApplicationPage" resultMap="applicationResultMap">
select * from merchant_application where is_deleted = 0
<if test="application.userAccount !=null">
and user_account = #{application.userAccount}
</if>
<if test="application.type != null">
and type = #{application.type}
</if>
<if test="application.status != null">
and status = #{application.status}
</if>
order by create_time desc
</select>
</mapper>

View File

@@ -0,0 +1,58 @@
/**
* 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 com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.modules.api.vo.MarketMerchantInventoryApiVO;
import org.springblade.modules.market.pojo.entity.MerchantInventoryEntity;
import org.springblade.modules.market.pojo.vo.MerchantInventoryVO;
import java.util.List;
/**
* 自营商家库存表 Mapper 接口
*
* @author BladeX
* @since 2026-04-24
*/
public interface MerchantInventoryMapper extends BaseMapper<MerchantInventoryEntity> {
/**
* 自定义分页
*
* @param page 分页参数
* @param productInventory 查询参数
* @return List<ProductInventoryVO>
*/
List<MerchantInventoryVO> selectProductInventoryPage(IPage page, MerchantInventoryVO productInventory);
List<MarketMerchantInventoryApiVO> selectProductInventoryApiList(Long userId);
int increaseInventory(Long id, Integer num, Integer version);
int reduceInventory(Long id, Integer num, Integer version);
}

View File

@@ -0,0 +1,59 @@
<?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.MerchantInventoryMapper">
<!-- 通用查询映射结果 -->
<resultMap id="productInventoryResultMap" type="org.springblade.modules.market.pojo.entity.MerchantInventoryEntity">
<result column="id" property="id"/>
<result column="user_id" property="userId"/>
<result column="user_account" property="userAccount"/>
<result column="type" property="type"/>
<result column="product_name" property="productName"/>
<result column="product_id" property="productId"/>
<result column="quantity" property="quantity"/>
<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="selectProductInventoryPage" resultMap="productInventoryResultMap">
select * from merchant_product_inventory where is_deleted = 0
</select>
<select id="selectProductInventoryApiList" resultType="org.springblade.modules.api.vo.MarketMerchantInventoryApiVO">
select mpi.id as id,
mp.id as productId,
mpi.type as type,
mpi.product_name as productName,
mp.thumb_image_url as thumbImageUrl,
mpi.quantity as stock,
mpi.remark as remark
from merchant_product_inventory mpi
left join merchant_product mp on mpi.product_id = mp.id
where mpi.user_id = #{userId}
and mpi.is_deleted = 0
</select>
<update id="increaseInventory">
update
merchant_product_inventory
set quantity = quantity + #{num} , version = version + 1
where id = #{id} and version = #{version}
</update>
<update id="reduceInventory">
update
merchant_product_inventory
set quantity = quantity - #{num},
version = version + 1
where id = #{userId}
and version = #{version}
and (quantity - #{num}) >= 0
</update>
</mapper>

View File

@@ -0,0 +1,53 @@
/**
* 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 com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.modules.market.pojo.entity.MerchantProductEntity;
import org.springblade.modules.market.pojo.vo.MerchantProductVO;
import java.util.List;
/**
* 自营商家商品表 Mapper 接口
*
* @author RayL
* @since 2026-04-24
*/
public interface MerchantProductMapper extends BaseMapper<MerchantProductEntity> {
/**
* 自定义分页
*
* @param page 分页参数
* @param product 查询参数
* @return List<MerchantProductVO>
*/
List<MerchantProductVO> selectMerchantProductPage(IPage page, MerchantProductVO product);
}

View File

@@ -0,0 +1,39 @@
<?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.MerchantProductMapper">
<!-- 通用查询映射结果 -->
<resultMap id="merchantproductResultMap" type="org.springblade.modules.market.pojo.entity.MerchantProductEntity">
<result column="id" property="id"/>
<result column="user_id" property="userId"/>
<result column="user_account" property="userAccount"/>
<result column="type" property="type"/>
<result column="product_name" property="productName"/>
<result column="main_image_urls" property="mainImageUrls" typeHandler="org.springblade.common.handler.PgStringArrayToListTypeHandler"/>
<result column="detail_image_urls" property="detailImageUrls" typeHandler="org.springblade.common.handler.PgStringArrayToListTypeHandler"/>
<result column="thumb_image_url" property="thumbImageUrl"/>
<result column="specs" property="specs" typeHandler="org.springblade.common.handler.PgJsonbTypeHandler"/>
<result column="cost_price" property="costPrice"/>
<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="selectMerchantProductPage" resultMap="merchantproductResultMap">
select * from merchant_product where is_deleted = 0
<if test="product.type !=null">
and type = #{product.type}
</if>
<if test="product.userAccount !=null">
and user_account = #{product.userAccount}
</if>
order by create_time desc
</select>
</mapper>

View File

@@ -38,4 +38,16 @@ public class MarketCashCouponApiDTO {
*/
private String remark;
public MarketCashCouponApiDTO() {
}
public MarketCashCouponApiDTO(Long userId, BigDecimal amount, MarketBusinessModule sourceType, Long sourceId, String sourceDetail, String remark) {
this.userId = userId;
this.amount = amount;
this.sourceType = sourceType;
this.sourceId = sourceId;
this.sourceDetail = sourceDetail;
this.remark = 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.dto;
import org.springblade.modules.market.pojo.entity.MarketMerchantApplicationEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serial;
/**
* 商家入驻申请表 数据传输对象实体类
*
* @author RayL
* @since 2026-04-22
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class MarketMerchantApplicationDTO extends MarketMerchantApplicationEntity {
@Serial
private static final long serialVersionUID = 1L;
}

View File

@@ -0,0 +1,46 @@
/**
* 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 lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.modules.market.pojo.entity.MerchantInventoryEntity;
import java.io.Serial;
/**
* 自营商家库存表 数据传输对象实体类
*
* @author BladeX
* @since 2026-04-24
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class MerchantInventoryDTO extends MerchantInventoryEntity {
@Serial
private static final long serialVersionUID = 1L;
}

View File

@@ -0,0 +1,46 @@
/**
* 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 lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.modules.market.pojo.entity.MerchantProductEntity;
import java.io.Serial;
/**
* 自营商家商品表 数据传输对象实体类
*
* @author RayL
* @since 2026-04-24
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class MerchantProductDTO extends MerchantProductEntity {
@Serial
private static final long serialVersionUID = 1L;
}

View File

@@ -28,9 +28,12 @@ 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 java.util.Date;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.base.BaseEntity;
import java.io.Serial;
/**
@@ -108,6 +111,11 @@ public class MarketInfoEntity extends BaseEntity {
*/
@Schema(description = "地址")
private String address;
/**
* 自营商家类型 0:未审核 1:个人商家 2:企业商家
*/
@Schema(description = "自营商家类型 0:未审核 1:个人商家 2:企业商家")
private Integer merchantType;
}

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.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 org.springblade.core.tenant.mp.TenantEntity;
import java.io.Serial;
/**
* 商家入驻申请表 实体类
*
* @author RayL
* @since 2026-04-22
*/
@Data
@TableName("merchant_application")
@Schema(description = "Application对象")
@EqualsAndHashCode(callSuper = true)
public class MarketMerchantApplicationEntity extends BaseEntity {
@Serial
private static final long serialVersionUID = 1L;
/**
* 用户id
*/
@Schema(description = "用户id")
private Long userId;
/**
* 用户账号
*/
@Schema(description = "用户账号")
private String userAccount;
/**
* 商家类型: 0-未审核, 1-个人商家, 2-企业商家
*/
@Schema(description = "商家类型: 0-未审核, 1-个人商家, 2-企业商家")
private Integer type;
/**
* 公司名称(企业商家时必填)
*/
@Schema(description = "公司名称(企业商家时必填)")
private String companyName;
/**
* 营业执照注册号
*/
@Schema(description = "营业执照注册号")
private String businessLicense;
/**
* 营业执照图片URL
*/
@Schema(description = "营业执照图片URL")
private String businessLicenseUrl;
/**
* 法人姓名
*/
@Schema(description = "法人姓名")
private String legalPerson;
/**
* 备注
*/
@Schema(description = "备注")
private String remark;
}

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.pojo.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.Version;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.base.BaseEntity;
import org.springblade.core.tenant.mp.TenantEntity;
import java.io.Serial;
/**
* 自营商家库存表 实体类
*
* @author BladeX
* @since 2026-04-24
*/
@Data
@TableName("merchant_product_inventory")
@Schema(description = "ProductInventory对象")
@EqualsAndHashCode(callSuper = true)
public class MerchantInventoryEntity extends BaseEntity {
@Serial
private static final long serialVersionUID = 1L;
/**
* 用户id
*/
@Schema(description = "用户id")
private Long userId;
/**
* 用户账号
*/
@Schema(description = "用户账号")
private String userAccount;
/**
* 商品类型: 1-自营商品, 2-企业商品
*/
@Schema(description = "商品类型: 1-自营商品, 2-企业商品")
private Integer type;
/**
* 商品名称
*/
@Schema(description = "商品名称")
private String productName;
/**
* 商品id
*/
@Schema(description = "商品id")
private Long productId;
/**
* 库存数量
*/
@Schema(description = "库存数量")
private Integer quantity;
/**
* 备注
*/
@Schema(description = "备注")
private String remark;
@Version
private Integer version;
}

View File

@@ -0,0 +1,124 @@
/**
* 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 com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.common.handler.PgJsonbTypeHandler;
import org.springblade.common.handler.PgStringArrayToListTypeHandler;
import org.springblade.core.mp.base.BaseEntity;
import org.springblade.core.tenant.mp.TenantEntity;
import org.springblade.modules.mall.pojo.entity.MallProductEntity;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
/**
* 自营商家商品表 实体类
*
* @author RayL
* @since 2026-04-24
*/
@Data
@TableName(value = "merchant_product", autoResultMap = true)
@Schema(description = "MerchantProduct对象")
@EqualsAndHashCode(callSuper = true)
public class MerchantProductEntity extends BaseEntity {
@Serial
private static final long serialVersionUID = 1L;
/**
* 用户id
*/
@Schema(description = "用户id")
private Long userId;
/**
* 用户账号
*/
@Schema(description = "用户账号")
private String userAccount;
/**
* 商品类型: 1-平台商品, 2-商家商品
*/
@Schema(description = "商品类型: 1-平台商品, 2-商家商品")
private Integer type;
/**
* 商品名称
*/
@Schema(description = "商品名称")
private String productName;
/**
* 商品主图
*/
@TableField(typeHandler = PgStringArrayToListTypeHandler.class)
@Schema(description = "商品主图")
private List<String> mainImageUrls;
/**
* 商品详情图
*/
@TableField(typeHandler = PgStringArrayToListTypeHandler.class)
@Schema(description = "商品详情图")
private List<String> detailImageUrls;
/**
* 商品缩略图
*/
@Schema(description = "商品缩略图")
private String thumbImageUrl;
/**
* 商品型号
*/
@TableField(typeHandler = PgJsonbTypeHandler.class)
@JsonDeserialize(contentAs = Spec.class)
@Schema(description = "商品型号")
private List<Spec> specs;
/**
* 成本价(进货价, 单位为现金券)
*/
@Schema(description = "成本价(进货价, 单位为现金券)")
private BigDecimal costPrice;
/**
* 备注
*/
@Schema(description = "备注")
private String remark;
@Data
public static class Spec implements Serializable {
private String attr;
private String value;
}
}

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.MarketMerchantApplicationEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serial;
/**
* 商家入驻申请表 视图实体类
*
* @author RayL
* @since 2026-04-22
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class MarketMerchantApplicationVO extends MarketMerchantApplicationEntity {
@Serial
private static final long serialVersionUID = 1L;
}

View File

@@ -0,0 +1,46 @@
/**
* 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 lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.modules.market.pojo.entity.MerchantInventoryEntity;
import java.io.Serial;
/**
* 自营商家库存表 视图实体类
*
* @author BladeX
* @since 2026-04-24
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class MerchantInventoryVO extends MerchantInventoryEntity {
@Serial
private static final long serialVersionUID = 1L;
}

View File

@@ -0,0 +1,46 @@
/**
* 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 lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.modules.market.pojo.entity.MerchantProductEntity;
import java.io.Serial;
/**
* 自营商家商品表 视图实体类
*
* @author RayL
* @since 2026-04-24
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class MerchantProductVO extends MerchantProductEntity {
@Serial
private static final long serialVersionUID = 1L;
}

View File

@@ -0,0 +1,66 @@
/**
* 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 org.springblade.modules.api.response.MerchantStatusResponse;
import org.springblade.modules.market.pojo.entity.MarketMerchantApplicationEntity;
import org.springblade.modules.market.pojo.vo.MarketMerchantApplicationVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.core.mp.base.BaseService;
import java.util.List;
/**
* 商家入驻申请表 服务类
*
* @author RayL
* @since 2026-04-22
*/
public interface IMarketMerchantApplicationService extends BaseService<MarketMerchantApplicationEntity> {
/**
* 自定义分页
*
* @param page 分页参数
* @param application 查询参数
* @return IPage<ApplicationVO>
*/
IPage<MarketMerchantApplicationVO> selectApplicationPage(IPage<MarketMerchantApplicationVO> page, MarketMerchantApplicationVO application);
MarketMerchantApplicationEntity getByUserId(Long userId);
boolean approve(Long id);
boolean reject(Long id, String reason);
boolean applyMerchant(Long userId, Integer type, String companyName, String businessLicense, String businessLicenseUrl, String legalPerson);
int checkMerchantType(Long userId);
MerchantStatusResponse checkAuditStatus(Long userId);
Integer merchantType(Long userId);
}

View File

@@ -0,0 +1,56 @@
/**
* 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.metadata.IPage;
import org.springblade.core.mp.base.BaseService;
import org.springblade.modules.api.vo.MarketMerchantInventoryApiVO;
import org.springblade.modules.market.pojo.entity.MerchantInventoryEntity;
import org.springblade.modules.market.pojo.vo.MerchantInventoryVO;
import java.util.List;
/**
* 自营商家库存表 服务类
*
* @author BladeX
* @since 2026-04-24
*/
public interface IMerchantInventoryService extends BaseService<MerchantInventoryEntity> {
/**
* 自定义分页
*
* @param page 分页参数
* @param productInventory 查询参数
* @return IPage<ProductInventoryVO>
*/
IPage<MerchantInventoryVO> selectProductInventoryPage(IPage<MerchantInventoryVO> page, MerchantInventoryVO productInventory);
List<MarketMerchantInventoryApiVO> inventoryListByUserId(Long userId);
boolean increase(Long userId, Long productId, Integer num);
}

View File

@@ -0,0 +1,58 @@
/**
* 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.metadata.IPage;
import org.springblade.core.mp.base.BaseService;
import org.springblade.modules.api.vo.MarketMerchantProductApiVO;
import org.springblade.modules.market.pojo.entity.MerchantProductEntity;
import org.springblade.modules.market.pojo.vo.MerchantProductVO;
import java.util.List;
/**
* 自营商家商品表 服务类
*
* @author RayL
* @since 2026-04-24
*/
public interface IMerchantProductService extends BaseService<MerchantProductEntity> {
/**
* 自定义分页
*
* @param page 分页参数
* @param productVO 查询参数
* @return IPage<MerchantProductVO>
*/
IPage<MerchantProductVO> selectMerchantProductPage(IPage<MerchantProductVO> page, MerchantProductVO productVO);
boolean submitPlatformProduct(MerchantProductEntity product);
List<MarketMerchantProductApiVO> productListByUserId(Long userId);
boolean submitMerchantProduct(Long userId, Long productId, String productName, String thumbImageUrl, List<String> mainImageUrls, List<String> detailImageUrls, List<MerchantProductEntity.Spec> specs);
}

View File

@@ -0,0 +1,207 @@
/**
* 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.common.cache.MarketInfoCache;
import org.springblade.core.cache.utils.CacheUtil;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.utils.StringPool;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.modules.api.response.MerchantStatusResponse;
import org.springblade.modules.market.eums.MerchantAuditStatus;
import org.springblade.modules.market.eums.MerchantType;
import org.springblade.modules.market.pojo.entity.MarketInfoEntity;
import org.springblade.modules.market.pojo.entity.MarketMerchantApplicationEntity;
import org.springblade.modules.market.pojo.vo.MarketMerchantApplicationVO;
import org.springblade.modules.market.mapper.MarketMerchantApplicationMapper;
import org.springblade.modules.market.service.IMarketInfoService;
import org.springblade.modules.market.service.IMarketMerchantApplicationService;
import org.springblade.modules.system.service.IUserService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.transaction.annotation.Transactional;
import java.util.Objects;
import static org.springblade.common.cache.MarketInfoCache.MERCHANT;
import static org.springblade.common.constant.MarketInfoConstant.MARKET_INFO_CONFIG_CACHE;
/**
* 商家入驻申请表 服务实现类
*
* @author RayL
* @since 2026-04-22
*/
@Service
@AllArgsConstructor
public class MarketMerchantApplicationServiceImpl extends BaseServiceImpl<MarketMerchantApplicationMapper, MarketMerchantApplicationEntity> implements IMarketMerchantApplicationService {
private final IUserService userService;
private final IMarketInfoService marketInfoService;
@Override
public IPage<MarketMerchantApplicationVO> selectApplicationPage(IPage<MarketMerchantApplicationVO> page, MarketMerchantApplicationVO application) {
return page.setRecords(baseMapper.selectApplicationPage(page, application));
}
@Override
public MarketMerchantApplicationEntity getByUserId(Long userId) {
if (Objects.isNull(userId)) {
throw new ServiceException("无效参数");
}
return getOne(Wrappers.lambdaQuery(MarketMerchantApplicationEntity.class).eq(MarketMerchantApplicationEntity::getUserId, userId).eq(MarketMerchantApplicationEntity::getIsDeleted, 0).orderByDesc(MarketMerchantApplicationEntity::getId));
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean approve(Long id) {
MarketMerchantApplicationEntity application = getById(id);
if (Objects.isNull(application)) {
throw new ServiceException("申请记录不存在");
}
if (application.getStatus() != MerchantAuditStatus.PENDING.getCode()) {
throw new ServiceException("仅待审核状态可操作");
}
application.setStatus(MerchantAuditStatus.APPROVED.getCode());
if (!updateById(application)) {
throw new ServiceException("申请状态更新失败");
}
MarketInfoEntity marketInfo = marketInfoService.getById(application.getUserId());
if (marketInfo == null) {
throw new ServiceException("商户信息缺失");
}
marketInfo.setMerchantType(application.getType());
if (!marketInfoService.updateById(marketInfo)) {
throw new ServiceException("商户类型更新失败");
}
CacheUtil.evict(MARKET_INFO_CONFIG_CACHE, MERCHANT, application.getUserId());
return true;
}
@Override
public boolean reject(Long id, String reason) {
if (StringUtil.isBlank(reason)) {
throw new ServiceException("请填写拒绝原因");
}
return update(Wrappers.lambdaUpdate(MarketMerchantApplicationEntity.class).eq(MarketMerchantApplicationEntity::getId, id)
.set(MarketMerchantApplicationEntity::getStatus, MerchantAuditStatus.REJECTED.getCode())
.set(MarketMerchantApplicationEntity::getRemark, reason));
}
@Override
public boolean applyMerchant(Long userId, Integer type, String companyName, String businessLicense, String businessLicenseUrl, String legalPerson) {
if (Objects.isNull(userId) || Objects.isNull(type)) {
throw new ServiceException("无效参数");
}
if (!MarketInfoCache.hasVerifyRealName(userId)) {
throw new ServiceException("请先实名");
}
if (!MarketInfoCache.hasVerifyBankCard(userId)) {
throw new ServiceException("请先绑定银行卡");
}
MarketMerchantApplicationEntity application = new MarketMerchantApplicationEntity();
MarketMerchantApplicationEntity userApplication = getByUserId(userId);
if (userApplication != null) {
if (userApplication.getStatus() != MerchantAuditStatus.REJECTED.getCode()) {
throw new ServiceException("请勿重复提交申请");
}
application.setId(userApplication.getId());
application.setStatus(MerchantAuditStatus.PENDING.getCode());
} else {
application.setUserId(userId);
application.setUserAccount(userService.getById(userId).getAccount());
}
switch (MerchantType.fromCode(type)) {
case UNREVIEWED -> throw new ServiceException("无效类型");
case ENTERPRISE -> {
application.setType(MerchantType.ENTERPRISE.getCode());
if (StringUtil.isAnyBlank(companyName, businessLicense, businessLicenseUrl, legalPerson)) {
throw new ServiceException("无效参数");
}
application.setCompanyName(companyName);
application.setBusinessLicense(businessLicense);
application.setBusinessLicenseUrl(businessLicenseUrl);
application.setLegalPerson(legalPerson);
}
case INDIVIDUAL -> {
application.setType(MerchantType.INDIVIDUAL.getCode());
application.setCompanyName(StringPool.EMPTY);
application.setBusinessLicense(StringPool.EMPTY);
application.setBusinessLicenseUrl(StringPool.EMPTY);
application.setLegalPerson(StringPool.EMPTY);
}
}
return saveOrUpdate(application);
}
@Override
public int checkMerchantType(Long userId) {
MarketInfoEntity marketInfo = marketInfoService.getById(userId);
if (marketInfo != null) {
return marketInfo.getMerchantType();
}
return MerchantType.UNREVIEWED.getCode();
}
@Override
public MerchantStatusResponse checkAuditStatus(Long userId) {
if (Objects.isNull(userId)) {
throw new ServiceException("无效用户");
}
MerchantStatusResponse response = new MerchantStatusResponse();
response.setStatus(MerchantAuditStatus.PENDING.getCode());
MarketMerchantApplicationEntity application = getByUserId(userId);
if (Objects.nonNull(application)) {
response.setType(application.getType());
response.setCompanyName(application.getCompanyName());
response.setBusinessLicense(application.getBusinessLicense());
response.setBusinessLicenseUrl(application.getBusinessLicenseUrl());
response.setLegalPerson(application.getLegalPerson());
response.setStatus(application.getStatus());
response.setRemark(application.getRemark());
}
return response;
}
@Override
public Integer merchantType(Long userId) {
if (Objects.isNull(userId)) {
throw new ServiceException("无效用户");
}
return MarketInfoCache.checkMerchantType(userId);
}
}

View File

@@ -0,0 +1,160 @@
/**
* 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.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.AllArgsConstructor;
import org.springblade.common.cache.MarketInfoCache;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.redis.ratelimiter.RateLimiter;
import org.springblade.modules.api.vo.MarketMerchantInventoryApiVO;
import org.springblade.modules.market.eums.MarketBusinessModule;
import org.springblade.modules.market.eums.MerchantProductType;
import org.springblade.modules.market.eums.MerchantType;
import org.springblade.modules.market.mapper.MerchantInventoryMapper;
import org.springblade.modules.market.pojo.dto.MarketCashCouponApiDTO;
import org.springblade.modules.market.pojo.entity.MerchantInventoryEntity;
import org.springblade.modules.market.pojo.entity.MerchantProductEntity;
import org.springblade.modules.market.pojo.vo.MerchantInventoryVO;
import org.springblade.modules.market.service.IMarketCashCouponService;
import org.springblade.modules.market.service.IMerchantInventoryService;
import org.springblade.modules.market.service.IMerchantProductService;
import org.springblade.modules.system.pojo.entity.User;
import org.springblade.modules.system.service.IUserService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
/**
* 自营商家库存表 服务实现类
*
* @author BladeX
* @since 2026-04-24
*/
@Service
@AllArgsConstructor
public class MerchantInventoryServiceImpl extends BaseServiceImpl<MerchantInventoryMapper, MerchantInventoryEntity> implements IMerchantInventoryService {
private final IUserService userService;
private final IMerchantProductService productService;
private final IMarketCashCouponService cashCouponService;
@Override
public IPage<MerchantInventoryVO> selectProductInventoryPage(IPage<MerchantInventoryVO> page, MerchantInventoryVO inventory) {
return page.setRecords(baseMapper.selectProductInventoryPage(page, inventory));
}
@Override
public List<MarketMerchantInventoryApiVO> inventoryListByUserId(Long userId) {
if (Objects.isNull(userId)) {
throw new ServiceException("无效用户");
}
return baseMapper.selectProductInventoryApiList(userId);
}
@Override
@Transactional(rollbackFor = Exception.class)
@RateLimiter(value = "inventory:limiter", param = "#userId", max = 1, ttl = 10, timeUnit = TimeUnit.SECONDS)
public boolean increase(Long userId, Long productId, Integer num) {
if (Objects.isNull(userId)) {
throw new ServiceException("无效用户");
}
User user = userService.getById(userId);
if (Objects.isNull(user)) {
throw new ServiceException("无效用户");
}
if (num < 1) {
throw new IllegalArgumentException("无效数量");
}
Integer merchantType = MarketInfoCache.checkMerchantType(userId);
MerchantProductEntity product = productService.getById(productId);
if (Objects.isNull(product)) {
throw new ServiceException("无效商品");
}
MerchantType userType = MerchantType.fromCode(merchantType);
if (userType.getCode() == MerchantType.UNREVIEWED.getCode()) {
throw new ServiceException("用户没有该操作权限");
}
switch (MerchantProductType.fromCode(product.getType())) {
case PLATFORM -> {
BigDecimal totalAmount = product.getCostPrice().multiply(BigDecimal.valueOf(num));
cashCouponService.deductCashCoupon(new MarketCashCouponApiDTO(userId, totalAmount, MarketBusinessModule.MERCHANT_PURCHASING, null, "", String.format("采购商品[%s],ID[%d],数量[%d]", product.getProductName(), product.getId(), num)));
MerchantInventoryEntity inventory = getOne(Wrappers.lambdaQuery(MerchantInventoryEntity.class).eq(MerchantInventoryEntity::getUserId, userId).eq(MerchantInventoryEntity::getType, MerchantProductType.PLATFORM.getCode()).eq(MerchantInventoryEntity::getProductId, productId).eq(MerchantInventoryEntity::getIsDeleted, 0).orderByDesc(MerchantInventoryEntity::getId));
if (Objects.nonNull(inventory)) {
if (baseMapper.increaseInventory(inventory.getId(), num, inventory.getVersion()) < 1) {
throw new ServiceException("操作失败");
}
} else {
MerchantInventoryEntity entity = new MerchantInventoryEntity();
entity.setUserId(userId);
entity.setUserAccount(user.getAccount());
entity.setType(MerchantProductType.PLATFORM.getCode());
entity.setProductId(productId);
entity.setProductName(product.getProductName());
entity.setQuantity(num);
if (!save(entity)) {
throw new ServiceException("操作失败");
}
}
return true;
}
case MERCHANT -> {
if (userType.getCode() != MerchantType.ENTERPRISE.getCode()) {
throw new ServiceException("无法添加该类型商品");
}
MerchantInventoryEntity inventory = getOne(Wrappers.lambdaQuery(MerchantInventoryEntity.class).eq(MerchantInventoryEntity::getUserId, userId).eq(MerchantInventoryEntity::getType, MerchantProductType.MERCHANT.getCode()).eq(MerchantInventoryEntity::getProductId, productId).eq(MerchantInventoryEntity::getIsDeleted, 0).orderByDesc(MerchantInventoryEntity::getId));
if (Objects.nonNull(inventory)) {
if (baseMapper.increaseInventory(inventory.getId(), num, inventory.getVersion()) < 1) {
throw new ServiceException("操作失败");
}
} else {
MerchantInventoryEntity entity = new MerchantInventoryEntity();
entity.setUserId(userId);
entity.setUserAccount(user.getAccount());
entity.setType(MerchantProductType.MERCHANT.getCode());
entity.setProductId(productId);
entity.setProductName(product.getProductName());
entity.setQuantity(num);
if (!save(entity)) {
throw new ServiceException("操作失败");
}
}
return true;
}
}
throw new ServiceException("操作失败");
}
}

View File

@@ -0,0 +1,157 @@
/**
* 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.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.AllArgsConstructor;
import org.springblade.common.cache.MarketInfoCache;
import org.springblade.common.cache.ParamCache;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.redis.ratelimiter.RateLimiter;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.modules.api.vo.MarketMerchantProductApiVO;
import org.springblade.modules.market.convert.MarketMerchantConvert;
import org.springblade.modules.market.eums.MerchantProductType;
import org.springblade.modules.market.eums.MerchantType;
import org.springblade.modules.market.mapper.MerchantProductMapper;
import org.springblade.modules.market.pojo.entity.MerchantProductEntity;
import org.springblade.modules.market.pojo.vo.MerchantProductVO;
import org.springblade.modules.market.service.IMerchantProductService;
import org.springblade.modules.system.pojo.entity.User;
import org.springblade.modules.system.service.IUserService;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
/**
* 自营商家商品表 服务实现类
*
* @author RayL
* @since 2026-04-24
*/
@Service
@AllArgsConstructor
public class MerchantProductServiceImpl extends BaseServiceImpl<MerchantProductMapper, MerchantProductEntity> implements IMerchantProductService {
private final IUserService userService;
private static final String MERCHANT_PRODUCT_QUANTITY_LIMIT = "merchant.product.quantity.limit";
@Override
public IPage<MerchantProductVO> selectMerchantProductPage(IPage<MerchantProductVO> page, MerchantProductVO productVO) {
return page.setRecords(baseMapper.selectMerchantProductPage(page, productVO));
}
@Override
public boolean submitPlatformProduct(MerchantProductEntity product) {
if (product.getCostPrice() == null || product.getCostPrice().compareTo(BigDecimal.ZERO) < 1 || StringUtil.isBlank(product.getProductName())) {
throw new ServiceException("必填参数不能为空");
}
if (product.getId() != null) {
MerchantProductEntity entity = getById(product.getId());
if (entity != null) {
if (!Objects.equals(entity.getType(), MerchantProductType.PLATFORM.getCode()) || product.getUserId() != null) {
throw new ServiceException("企业商品不可修改");
}
}
}
product.setType(MerchantProductType.PLATFORM.getCode());
return saveOrUpdate(product);
}
@Override
public List<MarketMerchantProductApiVO> productListByUserId(Long userId) {
if (Objects.isNull(userId)) {
throw new ServiceException("无效用户");
}
List<MerchantProductEntity> list = list(Wrappers.lambdaQuery(MerchantProductEntity.class).eq(MerchantProductEntity::getIsDeleted, 0)
.and(wrapper -> wrapper
.eq(MerchantProductEntity::getType, MerchantProductType.PLATFORM.getCode())
.or()
.eq(MerchantProductEntity::getType, MerchantProductType.MERCHANT.getCode()).eq(MerchantProductEntity::getUserId, userId)
)
);
return MarketMerchantConvert.INSTANCE.convertMerchantProductEntityToApiVOList(list);
}
@Override
@RateLimiter(value = "merchant:product", param = "#userId", max = 1, ttl = 10, timeUnit = TimeUnit.SECONDS)
public boolean submitMerchantProduct(Long userId, Long productId, String productName, String thumbImageUrl, List<String> mainImageUrls, List<String> detailImageUrls, List<MerchantProductEntity.Spec> specs) {
if (Objects.isNull(userId)) {
throw new ServiceException("无效用户");
}
if (MarketInfoCache.checkMerchantType(userId) != MerchantType.ENTERPRISE.getCode()) {
throw new ServiceException("此功能仅针对企业商家开放");
}
if (StringUtil.isAnyBlank(productName, thumbImageUrl) || mainImageUrls.isEmpty() || detailImageUrls.isEmpty()) {
throw new ServiceException("请正确填写产品参数");
}
User user = userService.getById(userId);
if (Objects.isNull(user)) {
throw new ServiceException("无效用户");
}
boolean isNew = (productId == null);
if (isNew) {
String limit = ParamCache.getValue(MERCHANT_PRODUCT_QUANTITY_LIMIT);
if (StringUtil.isBlank(limit)) {
throw new ServiceException("系统配置异常:商品数量上限未设置");
}
long count = count(Wrappers.lambdaQuery(MerchantProductEntity.class).eq(MerchantProductEntity::getUserId, userId).eq(MerchantProductEntity::getIsDeleted, 0));
if (count >= Long.parseLong(limit)) {
throw new ServiceException("商品数量已经超过上限");
}
}
MerchantProductEntity entity = new MerchantProductEntity();
entity.setType(MerchantProductType.MERCHANT.getCode());
entity.setUserId(userId);
entity.setUserAccount(user.getAccount());
entity.setProductName(productName);
entity.setThumbImageUrl(thumbImageUrl);
entity.setMainImageUrls(mainImageUrls);
entity.setDetailImageUrls(detailImageUrls);
entity.setSpecs(specs);
if (productId != null) {
MerchantProductEntity p = getById(productId);
if (p != null) {
if (!Objects.equals(p.getUserId(), entity.getUserId())) {
throw new ServiceException("无效参数");
} else {
entity.setId(productId);
}
}
}
return saveOrUpdate(entity);
}
}

View File

@@ -60,31 +60,12 @@ blade:
address: redis://192.168.31.132:6379
password: 112233
#aliyun:
# sms:
# # 阿里云账号的AccessKey
# accessKeyId: LTAI5tPYSrdSipANposndbrt
# accessKeySecret: ldVngFWpwPtTQgKzbJK3GrZoRmPIX2
# # 区域,默认为杭州
# regionId: cn-hangzhou
# # 默认短信签名
# signName: 速通互联验证平台
# # 默认短信模板CODE
# templateCode: 100001
# endpoint: dypnsapi.aliyuncs.com
#xxl:
# job:
# admin:
# addresses: http://192.168.1.3:8999/yichayilu-job-boot
# accessToken: yichayilu_token
# executor:
# appname: yichayilu-boot
# address:
# ip: 192.168.1.3
# port: 9999
# logpath: /Users/ray/dev/xxl-logs
# logretentiondays: 30
##job服务配置
powerjob:
worker:
enabled: true
app-name: blade-job
port: 27777
server-address: 192.168.31.132:7700
# server-address: 172.24.19.16:7700
# server-address: 192.168.1.4:7700

View File

@@ -55,3 +55,13 @@ blade:
##生产环境推荐使用阿里云高可用redis服务并设置密码
address: redis://172.30.0.63:6379
password: bladexadmin
##job服务配置
powerjob:
worker:
enabled: true
app-name: blade-job
port: 27777
# server-address: 192.168.31.132:7700
server-address: 172.24.19.16:7700
# server-address: 192.168.1.4:7700

View File

@@ -55,3 +55,13 @@ blade:
##生产环境推荐使用阿里云高可用redis服务并设置密码
address: redis://172.30.0.63:6379
password: bladexadmin
##job服务配置
powerjob:
worker:
enabled: true
app-name: blade-job
port: 27777
server-address: 192.168.31.132:7700
# server-address: 172.24.19.16:7700
# server-address: 192.168.1.4:7700

View File

@@ -155,16 +155,6 @@ report:
provider:
prefix: blade-
##job服务配置
powerjob:
worker:
enabled: true
app-name: blade-job
port: 27777
server-address: 192.168.31.132:7700
# server-address: 172.24.19.16:7700
# server-address: 192.168.1.4:7700
#blade配置
blade:
#oauth2配置
@@ -306,6 +296,12 @@ blade:
- method: ALL
pattern: /market/user/bank-card-anti-check
crypto: "sha1"
- method: POST
pattern: /market/merchant/submit-product
crypto: "sha1"
- method: POST
pattern: /market/merchant/increase-inventory
crypto: "sha1"
#多终端认证配置
client:
- client-id: web-admin
@@ -331,6 +327,7 @@ blade:
- client-id: market
path-patterns:
- /market/user/**
- /market/merchant/**
#多租户配置
tenant: