update:
1. fix
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
drop table if exists merchant_product;
|
drop table if exists merchant_catalog;
|
||||||
create table merchant_product
|
create table merchant_catalog
|
||||||
(
|
(
|
||||||
id int8 not null primary key,
|
id int8 not null primary key,
|
||||||
user_id int8 not null default -1,
|
user_id int8 not null default -1,
|
||||||
@@ -20,52 +20,82 @@ create table merchant_product
|
|||||||
status int4,
|
status int4,
|
||||||
is_deleted int4 default 0
|
is_deleted int4 default 0
|
||||||
);
|
);
|
||||||
CREATE INDEX idx_merchant_product_type ON merchant_product (type) where is_deleted = 0;
|
CREATE INDEX idx_merchant_catalog_type ON merchant_catalog (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_catalog_user_id ON merchant_catalog (user_id) where is_deleted = 0;
|
||||||
CREATE INDEX idx_merchant_product_user_id_account ON merchant_product (user_account) where is_deleted = 0;
|
CREATE INDEX idx_merchant_catalog_user_id_account ON merchant_catalog (user_account) where is_deleted = 0;
|
||||||
|
|
||||||
|
comment on table merchant_catalog is '自营商家商品表';
|
||||||
|
comment on column merchant_catalog.id is '主键';
|
||||||
|
comment on column merchant_catalog.user_id is '用户id';
|
||||||
|
comment on column merchant_catalog.user_account is '用户账号';
|
||||||
|
comment on column merchant_catalog.type is '商品类型: 1-平台商品, 2-商家商品';
|
||||||
|
comment on column merchant_catalog.product_name is '商品名称';
|
||||||
|
comment on column merchant_catalog.main_image_urls is '商品主图';
|
||||||
|
comment on column merchant_catalog.detail_image_urls is '商品详情图';
|
||||||
|
comment on column merchant_catalog.thumb_image_url is '商品缩略图';
|
||||||
|
comment on column merchant_catalog.specs is '商品型号';
|
||||||
|
comment on column merchant_catalog.cost_price is '成本价(进货价, 单位为现金券)';
|
||||||
|
comment on column merchant_catalog.remark is '备注';
|
||||||
|
comment on column merchant_catalog.create_user is '创建人';
|
||||||
|
comment on column merchant_catalog.create_dept is '创建部门';
|
||||||
|
comment on column merchant_catalog.create_time is '创建时间';
|
||||||
|
comment on column merchant_catalog.update_user is '修改人';
|
||||||
|
comment on column merchant_catalog.update_time is '修改时间';
|
||||||
|
comment on column merchant_catalog.status is '状态';
|
||||||
|
comment on column merchant_catalog.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', 'merchantcatalog', '自营商家商品表', 'menu',
|
||||||
|
'/market/merchantCatalog', 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', 'merchantcatalog_add', '新增', 'add',
|
||||||
|
'/market/merchantCatalog/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', 'merchantcatalog_edit', '修改', 'edit',
|
||||||
|
'/market/merchantCatalog/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', 'merchantcatalog_delete', '删除', 'delete',
|
||||||
|
'/api/market/merchantCatalog/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', 'merchantcatalog_view', '查看', 'view',
|
||||||
|
'/market/merchantCatalog/view', 'file-text', 4, 2, 2, 1, NULL, 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;
|
drop table if exists merchant_product_inventory;
|
||||||
create table merchant_product_inventory
|
create table merchant_product_inventory
|
||||||
(
|
(
|
||||||
id int8 not null primary key,
|
id int8 not null primary key,
|
||||||
user_id int8 not null default -1,
|
user_id int8 not null default -1,
|
||||||
user_account varchar(20) not null,
|
user_account varchar(20) not null,
|
||||||
type int4 not null,
|
type int4 not null,
|
||||||
product_name varchar(255) not null default '',
|
product_name varchar(255) not null default '',
|
||||||
product_id int8 not null,
|
product_id int8 not null,
|
||||||
quantity int4 default 0 NOT NULL,
|
store_name varchar(255) not null,
|
||||||
remark TEXT,
|
thumb_image_url text NULL,
|
||||||
version int4 DEFAULT 0 NULL,
|
unit_price decimal(10, 2) default 0.00 not null,
|
||||||
create_user int8,
|
gift_type int4 default 0 NOT NULL,
|
||||||
create_dept int8,
|
unit_gift_amount decimal(10, 2) default 0.00 not null,
|
||||||
create_time timestamp(6),
|
stock int4 default 0 NOT NULL,
|
||||||
update_user int8,
|
remark TEXT,
|
||||||
update_time timestamp(6),
|
version int4 DEFAULT 0 NULL,
|
||||||
status int4,
|
create_user int8,
|
||||||
is_deleted int4 default 0
|
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 EXTENSION IF NOT EXISTS pg_trgm;
|
||||||
CREATE INDEX idx_merchant_product_inventory_user_id_account ON merchant_product_inventory (user_account) where is_deleted = 0;
|
|
||||||
|
CREATE INDEX CONCURRENTLY idx_merch_inv_user_id_is_deleted ON merchant_product_inventory (user_id, is_deleted);
|
||||||
|
CREATE INDEX CONCURRENTLY idx_merch_inv_prodname_trgm ON merchant_product_inventory USING GIN (product_name gin_trgm_ops) WHERE status = 1 AND is_deleted = 0;
|
||||||
|
CREATE INDEX CONCURRENTLY idx_merch_inv_storename_trgm ON merchant_product_inventory USING GIN (store_name gin_trgm_ops) WHERE status = 1 AND is_deleted = 0;
|
||||||
|
|
||||||
comment on table merchant_product_inventory is '自营商家库存表';
|
comment on table merchant_product_inventory is '自营商家库存表';
|
||||||
comment on column merchant_product_inventory.id is '主键';
|
comment on column merchant_product_inventory.id is '主键';
|
||||||
@@ -74,36 +104,42 @@ 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.type is '商品类型: 1-平台商品, 2-商家商品';
|
||||||
comment on column merchant_product_inventory.product_name is '商品名称';
|
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.product_id is '商品id';
|
||||||
comment on column merchant_product_inventory.quantity is '库存数量';
|
comment on column merchant_product_inventory.store_name is '店铺名称';
|
||||||
|
comment on column merchant_product_inventory.thumb_image_url is '缩略图';
|
||||||
|
comment on column merchant_product_inventory.unit_price is '商品单价';
|
||||||
|
comment on column merchant_product_inventory.gift_type is '赠品类型 1-福利积分 2-佣金 3-现金券';
|
||||||
|
comment on column merchant_product_inventory.unit_gift_amount is '赠品数量';
|
||||||
|
comment on column merchant_product_inventory.stock is '库存数量';
|
||||||
comment on column merchant_product_inventory.remark 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_user is '创建人';
|
||||||
comment on column merchant_product_inventory.create_dept 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.create_time is '创建时间';
|
||||||
comment on column merchant_product_inventory.update_user 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.update_time is '修改时间';
|
||||||
comment on column merchant_product_inventory.status is '状态';
|
comment on column merchant_product_inventory.status is '状态 1-上架 2-下架';
|
||||||
comment on column merchant_product_inventory.is_deleted 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,
|
INSERT INTO blade_menu(id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark,
|
||||||
is_deleted)
|
is_deleted)
|
||||||
VALUES ('2047553982355394562', '1123598815738675201', 'merchantproduct', '自营商家商品表', 'menu',
|
VALUES ('2047553982355394567', '1123598815738675201', 'merchantinventory', '自营商家库存表', 'menu',
|
||||||
'/market/merchantProduct', NULL, 1, 1, 0, 1, NULL, 0);
|
'/market/merchantInventory', 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,
|
INSERT INTO blade_menu(id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark,
|
||||||
is_deleted)
|
is_deleted)
|
||||||
VALUES ('2047553982355394563', '2047553982355394562', 'merchantproduct_add', '新增', 'add',
|
VALUES ('2047553982355394568', '2047553982355394567', 'merchantinventory_add', '新增', 'add',
|
||||||
'/market/merchantProduct/add', 'plus', 1, 2, 1, 1, NULL, 0);
|
'/market/merchantInventory/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,
|
INSERT INTO blade_menu(id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark,
|
||||||
is_deleted)
|
is_deleted)
|
||||||
VALUES ('2047553982355394564', '2047553982355394562', 'merchantproduct_edit', '修改', 'edit',
|
VALUES ('2047553982355394569', '2047553982355394567', 'merchantinventory_edit', '修改', 'edit',
|
||||||
'/market/merchantProduct/edit', 'form', 2, 2, 2, 1, NULL, 0);
|
'/market/merchantInventory/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,
|
INSERT INTO blade_menu(id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark,
|
||||||
is_deleted)
|
is_deleted)
|
||||||
VALUES ('2047553982355394565', '2047553982355394562', 'merchantproduct_delete', '删除', 'delete',
|
VALUES ('2047553982355394570', '2047553982355394567', 'merchantinventory_delete', '删除', 'delete',
|
||||||
'/api/market/merchantProduct/remove', 'delete', 3, 2, 3, 1, NULL, 0);
|
'/api/market/merchantInventory/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,
|
INSERT INTO blade_menu(id, parent_id, code, name, alias, path, source, sort, category, action, is_open, remark,
|
||||||
is_deleted)
|
is_deleted)
|
||||||
VALUES ('2047553982355394566', '2047553982355394562', 'merchantproduct_view', '查看', 'view',
|
VALUES ('2047553982355394571', '2047553982355394567', 'merchantinventory_view', '查看', 'view',
|
||||||
'/market/merchantProduct/view', 'file-text', 4, 2, 2, 1, NULL, 0);
|
'/market/merchantInventory/view', 'file-text', 4, 2, 2, 1, NULL, 0);
|
||||||
|
|
||||||
drop table if exists merchant_store_favorite;
|
drop table if exists merchant_store_favorite;
|
||||||
create table merchant_store_favorite
|
create table merchant_store_favorite
|
||||||
|
|||||||
@@ -14,13 +14,13 @@ import org.springblade.modules.api.request.SubmitMerchantProductRequest;
|
|||||||
import org.springblade.modules.api.request.SubmitPayoutAccountRequest;
|
import org.springblade.modules.api.request.SubmitPayoutAccountRequest;
|
||||||
import org.springblade.modules.api.request.VerifyMerchantRequest;
|
import org.springblade.modules.api.request.VerifyMerchantRequest;
|
||||||
import org.springblade.modules.api.response.MerchantStatusResponse;
|
import org.springblade.modules.api.response.MerchantStatusResponse;
|
||||||
import org.springblade.modules.api.vo.MarketMerchantProductApiVO;
|
import org.springblade.modules.api.vo.MarketMerchantCatalogApiVO;
|
||||||
import org.springblade.modules.api.vo.MarketMerchantInventoryApiVO;
|
import org.springblade.modules.api.vo.MarketMerchantInventoryApiVO;
|
||||||
import org.springblade.modules.api.vo.MerchantPayoutAccountApiVO;
|
import org.springblade.modules.api.vo.MerchantPayoutAccountApiVO;
|
||||||
import org.springblade.modules.market.service.IMarketMerchantApplicationService;
|
import org.springblade.modules.market.service.IMarketMerchantApplicationService;
|
||||||
import org.springblade.modules.market.service.IMerchantInventoryService;
|
import org.springblade.modules.market.service.IMerchantInventoryService;
|
||||||
import org.springblade.modules.market.service.IMerchantPayoutAccountService;
|
import org.springblade.modules.market.service.IMerchantPayoutAccountService;
|
||||||
import org.springblade.modules.market.service.IMerchantProductService;
|
import org.springblade.modules.market.service.IMerchantCatalogService;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -35,7 +35,7 @@ public class MarketMerchantController {
|
|||||||
|
|
||||||
private final IMarketMerchantApplicationService applicationService;
|
private final IMarketMerchantApplicationService applicationService;
|
||||||
|
|
||||||
private final IMerchantProductService merchantProductService;
|
private final IMerchantCatalogService merchantProductService;
|
||||||
|
|
||||||
private final IMerchantInventoryService inventoryService;
|
private final IMerchantInventoryService inventoryService;
|
||||||
|
|
||||||
@@ -62,18 +62,18 @@ public class MarketMerchantController {
|
|||||||
return R.data(applicationService.merchantType(AuthUtil.getUserId()));
|
return R.data(applicationService.merchantType(AuthUtil.getUserId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/product-list")
|
@GetMapping("/catalog-list")
|
||||||
@ApiOperationSupport(order = 4)
|
@ApiOperationSupport(order = 4)
|
||||||
@Operation(summary = "商品列表")
|
@Operation(summary = "商品目录列表")
|
||||||
public R<List<MarketMerchantProductApiVO>> productList() {
|
public R<List<MarketMerchantCatalogApiVO>> catalogList() {
|
||||||
return R.data(merchantProductService.productListByUserId(AuthUtil.getUserId()));
|
return R.data(merchantProductService.catalogListByUserId(AuthUtil.getUserId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/submit-product")
|
@PostMapping("/submit-product")
|
||||||
@ApiOperationSupport(order = 5)
|
@ApiOperationSupport(order = 5)
|
||||||
@Operation(summary = "提交商品")
|
@Operation(summary = "提交商品")
|
||||||
public R addProduct(@RequestBody @Valid SubmitMerchantProductRequest request) {
|
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()));
|
return R.status(merchantProductService.submitMerchantCatalog(AuthUtil.getUserId(), request.getId(), request.getProductName(), request.getThumbImageUrl(), request.getMainImageUrls(), request.getDetailImageUrls(), request.getSpecs()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/inventory-list")
|
@GetMapping("/inventory-list")
|
||||||
@@ -87,7 +87,7 @@ public class MarketMerchantController {
|
|||||||
@ApiOperationSupport(order = 7)
|
@ApiOperationSupport(order = 7)
|
||||||
@Operation(summary = "增加库存")
|
@Operation(summary = "增加库存")
|
||||||
public R increaseInventory(@RequestBody @Valid IncreaseInventoryRequest request) {
|
public R increaseInventory(@RequestBody @Valid IncreaseInventoryRequest request) {
|
||||||
return R.status(inventoryService.increase(AuthUtil.getUserId(), request.getProductId(), request.getNum()));
|
return R.status(inventoryService.increase(AuthUtil.getUserId(), request.getProductId(), request.getNum(),request.getPrice(), request.getGiftType(), request.getGiftAmount()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/is-available")
|
@GetMapping("/is-available")
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import jakarta.validation.constraints.NotNull;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class IncreaseInventoryRequest implements Serializable {
|
public class IncreaseInventoryRequest implements Serializable {
|
||||||
@@ -14,4 +15,10 @@ public class IncreaseInventoryRequest implements Serializable {
|
|||||||
@NotNull(message = "无效参数")
|
@NotNull(message = "无效参数")
|
||||||
private Integer num;
|
private Integer num;
|
||||||
|
|
||||||
|
private BigDecimal price;
|
||||||
|
|
||||||
|
private Integer giftType;
|
||||||
|
|
||||||
|
private BigDecimal giftAmount;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package org.springblade.modules.api.request;
|
|||||||
import jakarta.validation.constraints.NotEmpty;
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.springblade.modules.market.pojo.entity.MerchantProductEntity;
|
import org.springblade.modules.market.pojo.entity.MerchantCatalogEntity;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -25,7 +25,7 @@ public class SubmitMerchantProductRequest implements Serializable {
|
|||||||
@NotEmpty(message = "无效参数")
|
@NotEmpty(message = "无效参数")
|
||||||
private String thumbImageUrl;
|
private String thumbImageUrl;
|
||||||
|
|
||||||
private List<MerchantProductEntity.Spec> specs;
|
private List<MerchantCatalogEntity.Spec> specs;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import java.io.Serializable;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class MarketMerchantProductApiVO implements Serializable {
|
public class MarketMerchantCatalogApiVO implements Serializable {
|
||||||
|
|
||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@@ -36,9 +36,9 @@ import org.springblade.core.mp.support.Condition;
|
|||||||
import org.springblade.core.mp.support.Query;
|
import org.springblade.core.mp.support.Query;
|
||||||
import org.springblade.core.tool.api.R;
|
import org.springblade.core.tool.api.R;
|
||||||
import org.springblade.core.tool.utils.Func;
|
import org.springblade.core.tool.utils.Func;
|
||||||
import org.springblade.modules.market.pojo.entity.MerchantProductEntity;
|
import org.springblade.modules.market.pojo.entity.MerchantCatalogEntity;
|
||||||
import org.springblade.modules.market.pojo.vo.MerchantProductVO;
|
import org.springblade.modules.market.pojo.vo.MerchantCatalogVO;
|
||||||
import org.springblade.modules.market.service.IMerchantProductService;
|
import org.springblade.modules.market.service.IMerchantCatalogService;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import org.springblade.core.boot.ctrl.BladeController;
|
import org.springblade.core.boot.ctrl.BladeController;
|
||||||
@@ -53,20 +53,20 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@RequestMapping("/market/merchant-product")
|
@RequestMapping("/market/merchant-catalog")
|
||||||
@Tag(name = "自营商家商品表", description = "自营商家商品表接口")
|
@Tag(name = "自营商家商品表", description = "自营商家商品表接口")
|
||||||
public class MerchantProductController extends BladeController {
|
public class MerchantCatalogController extends BladeController {
|
||||||
|
|
||||||
private final IMerchantProductService productService;
|
private final IMerchantCatalogService catalogService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自营商家商品表 详情
|
* 自营商家商品表 详情
|
||||||
*/
|
*/
|
||||||
@GetMapping("/detail")
|
@GetMapping("/detail")
|
||||||
@ApiOperationSupport(order = 1)
|
@ApiOperationSupport(order = 1)
|
||||||
@Operation(summary = "详情", description = "传入product")
|
@Operation(summary = "详情", description = "传入catalog")
|
||||||
public R<MerchantProductEntity> detail(MerchantProductEntity product) {
|
public R<MerchantCatalogEntity> detail(MerchantCatalogEntity catalog) {
|
||||||
MerchantProductEntity detail = productService.getById(product.getId());
|
MerchantCatalogEntity detail = catalogService.getById(catalog.getId());
|
||||||
return R.data(detail);
|
return R.data(detail);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,9 +75,9 @@ public class MerchantProductController extends BladeController {
|
|||||||
*/
|
*/
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
@ApiOperationSupport(order = 2)
|
@ApiOperationSupport(order = 2)
|
||||||
@Operation(summary = "分页", description = "传入product")
|
@Operation(summary = "分页", description = "传入catalog")
|
||||||
public R<IPage<MerchantProductEntity>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> product, Query query) {
|
public R<IPage<MerchantCatalogEntity>> list(@Parameter(hidden = true) @RequestParam Map<String, Object> catalog, Query query) {
|
||||||
IPage<MerchantProductEntity> pages = productService.page(Condition.getPage(query), Condition.getQueryWrapper(product, MerchantProductEntity.class));
|
IPage<MerchantCatalogEntity> pages = catalogService.page(Condition.getPage(query), Condition.getQueryWrapper(catalog, MerchantCatalogEntity.class));
|
||||||
return R.data(pages);
|
return R.data(pages);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,9 +86,9 @@ public class MerchantProductController extends BladeController {
|
|||||||
*/
|
*/
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@ApiOperationSupport(order = 3)
|
@ApiOperationSupport(order = 3)
|
||||||
@Operation(summary = "分页", description = "传入product")
|
@Operation(summary = "分页", description = "传入catalog")
|
||||||
public R<IPage<MerchantProductVO>> page(MerchantProductVO product, Query query) {
|
public R<IPage<MerchantCatalogVO>> page(MerchantCatalogVO catalog, Query query) {
|
||||||
IPage<MerchantProductVO> pages = productService.selectMerchantProductPage(Condition.getPage(query), product);
|
IPage<MerchantCatalogVO> pages = catalogService.selectMerchantCatalogPage(Condition.getPage(query), catalog);
|
||||||
return R.data(pages);
|
return R.data(pages);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,9 +97,9 @@ public class MerchantProductController extends BladeController {
|
|||||||
*/
|
*/
|
||||||
@PostMapping("/save")
|
@PostMapping("/save")
|
||||||
@ApiOperationSupport(order = 4)
|
@ApiOperationSupport(order = 4)
|
||||||
@Operation(summary = "新增", description = "传入product")
|
@Operation(summary = "新增", description = "传入catalog")
|
||||||
public R save(@Valid @RequestBody MerchantProductEntity product) {
|
public R save(@Valid @RequestBody MerchantCatalogEntity catalog) {
|
||||||
return R.status(productService.save(product));
|
return R.status(catalogService.save(catalog));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -107,9 +107,9 @@ public class MerchantProductController extends BladeController {
|
|||||||
*/
|
*/
|
||||||
@PostMapping("/update")
|
@PostMapping("/update")
|
||||||
@ApiOperationSupport(order = 5)
|
@ApiOperationSupport(order = 5)
|
||||||
@Operation(summary = "修改", description = "传入product")
|
@Operation(summary = "修改", description = "传入catalog")
|
||||||
public R update(@Valid @RequestBody MerchantProductEntity product) {
|
public R update(@Valid @RequestBody MerchantCatalogEntity catalog) {
|
||||||
return R.status(productService.updateById(product));
|
return R.status(catalogService.updateById(catalog));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -117,9 +117,9 @@ public class MerchantProductController extends BladeController {
|
|||||||
*/
|
*/
|
||||||
@PostMapping("/submit")
|
@PostMapping("/submit")
|
||||||
@ApiOperationSupport(order = 6)
|
@ApiOperationSupport(order = 6)
|
||||||
@Operation(summary = "新增或修改", description = "传入product")
|
@Operation(summary = "新增或修改", description = "传入catalog")
|
||||||
public R submit(@Valid @RequestBody MerchantProductEntity product) {
|
public R submit(@Valid @RequestBody MerchantCatalogEntity catalog) {
|
||||||
return R.status(productService.saveOrUpdate(product));
|
return R.status(catalogService.saveOrUpdate(catalog));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -129,17 +129,17 @@ public class MerchantProductController extends BladeController {
|
|||||||
@ApiOperationSupport(order = 7)
|
@ApiOperationSupport(order = 7)
|
||||||
@Operation(summary = "逻辑删除", description = "传入ids")
|
@Operation(summary = "逻辑删除", description = "传入ids")
|
||||||
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
public R remove(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
||||||
return R.status(productService.deleteLogic(Func.toLongList(ids)));
|
return R.status(catalogService.deleteLogic(Func.toLongList(ids)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自营商家商品表 新增平台商品
|
* 自营商家商品表 新增平台商品
|
||||||
*/
|
*/
|
||||||
@PostMapping("/submit-product")
|
@PostMapping("/submit-catalog")
|
||||||
@ApiOperationSupport(order = 8)
|
@ApiOperationSupport(order = 8)
|
||||||
@Operation(summary = "新增平台商品", description = "传入product")
|
@Operation(summary = "新增平台商品", description = "传入catalog")
|
||||||
public R submitProduct(@Valid @RequestBody MerchantProductEntity product) {
|
public R submitCatalog(@Valid @RequestBody MerchantCatalogEntity catalog) {
|
||||||
return R.status(productService.submitPlatformProduct(product));
|
return R.status(catalogService.submitPlatformCatalog(catalog));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package org.springblade.modules.market.convert;
|
package org.springblade.modules.market.convert;
|
||||||
|
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.springblade.modules.api.vo.MarketMerchantProductApiVO;
|
import org.springblade.modules.api.vo.MarketMerchantCatalogApiVO;
|
||||||
import org.springblade.modules.api.vo.MerchantPayoutAccountApiVO;
|
import org.springblade.modules.api.vo.MerchantPayoutAccountApiVO;
|
||||||
import org.springblade.modules.market.pojo.entity.MerchantPayoutAccountEntity;
|
import org.springblade.modules.market.pojo.entity.MerchantPayoutAccountEntity;
|
||||||
import org.springblade.modules.market.pojo.entity.MerchantProductEntity;
|
import org.springblade.modules.market.pojo.entity.MerchantCatalogEntity;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -13,9 +13,9 @@ public interface MarketMerchantConvert {
|
|||||||
|
|
||||||
MarketMerchantConvert INSTANCE = MarketMerchantConvert.INSTANCE;
|
MarketMerchantConvert INSTANCE = MarketMerchantConvert.INSTANCE;
|
||||||
|
|
||||||
MarketMerchantProductApiVO convertMerchantProductEntityToApiVO(MerchantProductEntity marketMerchantProductEntity);
|
MarketMerchantCatalogApiVO convertMerchantProductEntityToApiVO(MerchantCatalogEntity marketMerchantCatalogEntity);
|
||||||
|
|
||||||
List<MarketMerchantProductApiVO> convertMerchantProductEntityToApiVOList(List<MerchantProductEntity> marketMerchantProductEntityList);
|
List<MarketMerchantCatalogApiVO> convertMerchantProductEntityToApiVOList(List<MerchantCatalogEntity> marketMerchantCatalogEntityList);
|
||||||
|
|
||||||
MerchantPayoutAccountApiVO convertMerchantPayoutAccountEntityToApiVO(MerchantPayoutAccountEntity merchantPayoutAccountEntity);
|
MerchantPayoutAccountApiVO convertMerchantPayoutAccountEntityToApiVO(MerchantPayoutAccountEntity merchantPayoutAccountEntity);
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ public enum MarketBusinessModule {
|
|||||||
CASH_UPGRADE("现金动态升级", "cash_upgrade"),
|
CASH_UPGRADE("现金动态升级", "cash_upgrade"),
|
||||||
CASH_ACCELERATION("现金动态加速", "cash_acceleration"),
|
CASH_ACCELERATION("现金动态加速", "cash_acceleration"),
|
||||||
MERCHANT_PURCHASING("自营商城进货", "merchant_purchasing"),
|
MERCHANT_PURCHASING("自营商城进货", "merchant_purchasing"),
|
||||||
|
MERCHANT_PUBLISH("自营商城上架商品", "merchant_publish")
|
||||||
;
|
;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package org.springblade.modules.market.eums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public enum MerchantGiftType {
|
||||||
|
|
||||||
|
BENEFIT_POINT(1, "福利积分"),
|
||||||
|
CASH_COUPON(2, "现金券"),
|
||||||
|
COMMISSION(3, "佣金");
|
||||||
|
|
||||||
|
private final int code;
|
||||||
|
|
||||||
|
private final String desc;
|
||||||
|
|
||||||
|
MerchantGiftType(int code, String desc){
|
||||||
|
this.code = code;
|
||||||
|
this.desc = desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MerchantGiftType getByCode(int code) {
|
||||||
|
for (MerchantGiftType merchantGiftType : MerchantGiftType.values()) {
|
||||||
|
if (merchantGiftType.getCode() == code) {
|
||||||
|
return merchantGiftType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -27,8 +27,8 @@ package org.springblade.modules.market.mapper;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import org.springblade.modules.market.pojo.entity.MerchantProductEntity;
|
import org.springblade.modules.market.pojo.entity.MerchantCatalogEntity;
|
||||||
import org.springblade.modules.market.pojo.vo.MerchantProductVO;
|
import org.springblade.modules.market.pojo.vo.MerchantCatalogVO;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ import java.util.List;
|
|||||||
* @author RayL
|
* @author RayL
|
||||||
* @since 2026-04-24
|
* @since 2026-04-24
|
||||||
*/
|
*/
|
||||||
public interface MerchantProductMapper extends BaseMapper<MerchantProductEntity> {
|
public interface MerchantCatalogMapper extends BaseMapper<MerchantCatalogEntity> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自定义分页
|
* 自定义分页
|
||||||
@@ -47,7 +47,7 @@ public interface MerchantProductMapper extends BaseMapper<MerchantProductEntity>
|
|||||||
* @param product 查询参数
|
* @param product 查询参数
|
||||||
* @return List<MerchantProductVO>
|
* @return List<MerchantProductVO>
|
||||||
*/
|
*/
|
||||||
List<MerchantProductVO> selectMerchantProductPage(IPage page, MerchantProductVO product);
|
List<MerchantCatalogVO> selectMerchantCatalogPage(IPage page, MerchantCatalogVO product);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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">
|
<!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">
|
<mapper namespace="org.springblade.modules.market.mapper.MerchantCatalogMapper">
|
||||||
|
|
||||||
<!-- 通用查询映射结果 -->
|
<!-- 通用查询映射结果 -->
|
||||||
<resultMap id="merchantproductResultMap" type="org.springblade.modules.market.pojo.entity.MerchantProductEntity">
|
<resultMap id="merchantCatalogResultMap" type="org.springblade.modules.market.pojo.entity.MerchantCatalogEntity">
|
||||||
<result column="id" property="id"/>
|
<result column="id" property="id"/>
|
||||||
<result column="user_id" property="userId"/>
|
<result column="user_id" property="userId"/>
|
||||||
<result column="user_account" property="userAccount"/>
|
<result column="user_account" property="userAccount"/>
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
|
|
||||||
<select id="selectMerchantProductPage" resultMap="merchantproductResultMap">
|
<select id="selectMerchantCatalogPage" resultMap="merchantCatalogResultMap">
|
||||||
select * from merchant_product where is_deleted = 0
|
select * from merchant_product where is_deleted = 0
|
||||||
<if test="product.type !=null">
|
<if test="product.type !=null">
|
||||||
and type = #{product.type}
|
and type = #{product.type}
|
||||||
@@ -10,7 +10,12 @@
|
|||||||
<result column="type" property="type"/>
|
<result column="type" property="type"/>
|
||||||
<result column="product_name" property="productName"/>
|
<result column="product_name" property="productName"/>
|
||||||
<result column="product_id" property="productId"/>
|
<result column="product_id" property="productId"/>
|
||||||
<result column="quantity" property="quantity"/>
|
<result column="store_name" property="storeName"/>
|
||||||
|
<result column="thumb_image_url" property="thumbImageUrl"/>
|
||||||
|
<result column="unit_price" property="unitPrice"/>
|
||||||
|
<result column="gift_type" property="giftType"/>
|
||||||
|
<result column="unit_gift_amount" property="unitGiftAmount"/>
|
||||||
|
<result column="stock" property="stock"/>
|
||||||
<result column="remark" property="remark"/>
|
<result column="remark" property="remark"/>
|
||||||
<result column="create_user" property="createUser"/>
|
<result column="create_user" property="createUser"/>
|
||||||
<result column="create_dept" property="createDept"/>
|
<result column="create_dept" property="createDept"/>
|
||||||
@@ -27,33 +32,26 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectProductInventoryApiList" resultType="org.springblade.modules.api.vo.MarketMerchantInventoryApiVO">
|
<select id="selectProductInventoryApiList" resultType="org.springblade.modules.api.vo.MarketMerchantInventoryApiVO">
|
||||||
select mpi.id as id,
|
select *
|
||||||
mp.id as productId,
|
from merchant_product_inventory
|
||||||
mpi.type as type,
|
where user_id = #{userId}
|
||||||
mpi.product_name as productName,
|
and is_deleted = 0
|
||||||
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>
|
</select>
|
||||||
|
|
||||||
<update id="increaseInventory">
|
<update id="increaseInventory">
|
||||||
update
|
update
|
||||||
merchant_product_inventory
|
merchant_product_inventory
|
||||||
set quantity = quantity + #{num} , version = version + 1
|
set stock = stock + #{num} , version = version + 1
|
||||||
where id = #{id} and version = #{version}
|
where id = #{id} and version = #{version}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<update id="reduceInventory">
|
<update id="reduceInventory">
|
||||||
update
|
update
|
||||||
merchant_product_inventory
|
merchant_product_inventory
|
||||||
set quantity = quantity - #{num},
|
set stock = stock - #{num},
|
||||||
version = version + 1
|
version = version + 1
|
||||||
where id = #{userId}
|
where id = #{userId}
|
||||||
and version = #{version}
|
and version = #{version}
|
||||||
and (quantity - #{num}) >= 0
|
and (stock - #{num}) >= 0
|
||||||
</update>
|
</update>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package org.springblade.modules.market.pojo.dto;
|
package org.springblade.modules.market.pojo.dto;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
import org.springblade.modules.market.eums.MarketBusinessModule;
|
import org.springblade.modules.market.eums.MarketBusinessModule;
|
||||||
import org.springblade.modules.market.pojo.entity.MarketBenefitPointLogEntity;
|
import org.springblade.modules.market.pojo.entity.MarketBenefitPointLogEntity;
|
||||||
@@ -11,6 +13,8 @@ import java.math.BigDecimal;
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
public class MarketBenefitPointApiDTO {
|
public class MarketBenefitPointApiDTO {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ package org.springblade.modules.market.pojo.dto;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import org.springblade.modules.market.pojo.entity.MerchantProductEntity;
|
import org.springblade.modules.market.pojo.entity.MerchantCatalogEntity;
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ import java.io.Serial;
|
|||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class MerchantProductDTO extends MerchantProductEntity {
|
public class MerchantCatalogDTO extends MerchantCatalogEntity {
|
||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@@ -34,8 +34,6 @@ import lombok.EqualsAndHashCode;
|
|||||||
import org.springblade.common.handler.PgJsonbTypeHandler;
|
import org.springblade.common.handler.PgJsonbTypeHandler;
|
||||||
import org.springblade.common.handler.PgStringArrayToListTypeHandler;
|
import org.springblade.common.handler.PgStringArrayToListTypeHandler;
|
||||||
import org.springblade.core.mp.base.BaseEntity;
|
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.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
@@ -49,10 +47,10 @@ import java.util.List;
|
|||||||
* @since 2026-04-24
|
* @since 2026-04-24
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@TableName(value = "merchant_product", autoResultMap = true)
|
@TableName(value = "merchant_catalog", autoResultMap = true)
|
||||||
@Schema(description = "MerchantProduct对象")
|
@Schema(description = "MerchantCatalog对象")
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class MerchantProductEntity extends BaseEntity {
|
public class MerchantCatalogEntity extends BaseEntity {
|
||||||
|
|
||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@@ -34,6 +34,7 @@ import org.springblade.core.mp.base.BaseEntity;
|
|||||||
import org.springblade.core.tenant.mp.TenantEntity;
|
import org.springblade.core.tenant.mp.TenantEntity;
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自营商家库存表 实体类
|
* 自营商家库存表 实体类
|
||||||
@@ -75,11 +76,36 @@ public class MerchantInventoryEntity extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
@Schema(description = "商品id")
|
@Schema(description = "商品id")
|
||||||
private Long productId;
|
private Long productId;
|
||||||
|
/**
|
||||||
|
* 店铺名称
|
||||||
|
*/
|
||||||
|
@Schema(description = "店铺名称")
|
||||||
|
private String storeName;
|
||||||
|
/**
|
||||||
|
* 缩略图
|
||||||
|
*/
|
||||||
|
@Schema(description = "缩略图")
|
||||||
|
private String thumbImageUrl;
|
||||||
|
/**
|
||||||
|
* 单价
|
||||||
|
*/
|
||||||
|
@Schema(description = "单价")
|
||||||
|
private BigDecimal unitPrice;
|
||||||
|
/**
|
||||||
|
* 赠品类型
|
||||||
|
*/
|
||||||
|
@Schema(description = "赠品类型")
|
||||||
|
private Integer giftType;
|
||||||
|
/**
|
||||||
|
* 赠品数量
|
||||||
|
*/
|
||||||
|
@Schema(description = "赠品数量")
|
||||||
|
private BigDecimal unitGiftAmount;
|
||||||
/**
|
/**
|
||||||
* 库存数量
|
* 库存数量
|
||||||
*/
|
*/
|
||||||
@Schema(description = "库存数量")
|
@Schema(description = "库存数量")
|
||||||
private Integer quantity;
|
private Integer stock;
|
||||||
/**
|
/**
|
||||||
* 备注
|
* 备注
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ package org.springblade.modules.market.pojo.vo;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import org.springblade.modules.market.pojo.entity.MerchantProductEntity;
|
import org.springblade.modules.market.pojo.entity.MerchantCatalogEntity;
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ import java.io.Serial;
|
|||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class MerchantProductVO extends MerchantProductEntity {
|
public class MerchantCatalogVO extends MerchantCatalogEntity {
|
||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@@ -27,9 +27,9 @@ package org.springblade.modules.market.service;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import org.springblade.core.mp.base.BaseService;
|
import org.springblade.core.mp.base.BaseService;
|
||||||
import org.springblade.modules.api.vo.MarketMerchantProductApiVO;
|
import org.springblade.modules.api.vo.MarketMerchantCatalogApiVO;
|
||||||
import org.springblade.modules.market.pojo.entity.MerchantProductEntity;
|
import org.springblade.modules.market.pojo.entity.MerchantCatalogEntity;
|
||||||
import org.springblade.modules.market.pojo.vo.MerchantProductVO;
|
import org.springblade.modules.market.pojo.vo.MerchantCatalogVO;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -39,20 +39,20 @@ import java.util.List;
|
|||||||
* @author RayL
|
* @author RayL
|
||||||
* @since 2026-04-24
|
* @since 2026-04-24
|
||||||
*/
|
*/
|
||||||
public interface IMerchantProductService extends BaseService<MerchantProductEntity> {
|
public interface IMerchantCatalogService extends BaseService<MerchantCatalogEntity> {
|
||||||
/**
|
/**
|
||||||
* 自定义分页
|
* 自定义分页
|
||||||
*
|
*
|
||||||
* @param page 分页参数
|
* @param page 分页参数
|
||||||
* @param productVO 查询参数
|
* @param catalogVO 查询参数
|
||||||
* @return IPage<MerchantProductVO>
|
* @return IPage<MerchantProductVO>
|
||||||
*/
|
*/
|
||||||
IPage<MerchantProductVO> selectMerchantProductPage(IPage<MerchantProductVO> page, MerchantProductVO productVO);
|
IPage<MerchantCatalogVO> selectMerchantCatalogPage(IPage<MerchantCatalogVO> page, MerchantCatalogVO catalogVO);
|
||||||
|
|
||||||
boolean submitPlatformProduct(MerchantProductEntity product);
|
boolean submitPlatformCatalog(MerchantCatalogEntity catalog);
|
||||||
|
|
||||||
List<MarketMerchantProductApiVO> productListByUserId(Long userId);
|
List<MarketMerchantCatalogApiVO> catalogListByUserId(Long userId);
|
||||||
|
|
||||||
boolean submitMerchantProduct(Long userId, Long productId, String productName, String thumbImageUrl, List<String> mainImageUrls, List<String> detailImageUrls, List<MerchantProductEntity.Spec> specs);
|
boolean submitMerchantCatalog(Long userId, Long productId, String productName, String thumbImageUrl, List<String> mainImageUrls, List<String> detailImageUrls, List<MerchantCatalogEntity.Spec> specs);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -31,6 +31,7 @@ import org.springblade.modules.api.vo.MarketMerchantInventoryApiVO;
|
|||||||
import org.springblade.modules.market.pojo.entity.MerchantInventoryEntity;
|
import org.springblade.modules.market.pojo.entity.MerchantInventoryEntity;
|
||||||
import org.springblade.modules.market.pojo.vo.MerchantInventoryVO;
|
import org.springblade.modules.market.pojo.vo.MerchantInventoryVO;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -51,6 +52,6 @@ public interface IMerchantInventoryService extends BaseService<MerchantInventory
|
|||||||
|
|
||||||
List<MarketMerchantInventoryApiVO> inventoryListByUserId(Long userId);
|
List<MarketMerchantInventoryApiVO> inventoryListByUserId(Long userId);
|
||||||
|
|
||||||
boolean increase(Long userId, Long productId, Integer num);
|
boolean increase(Long userId, Long productId, Integer num, BigDecimal price,Integer giftType, BigDecimal giftAmount);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,14 +34,14 @@ import org.springblade.core.log.exception.ServiceException;
|
|||||||
import org.springblade.core.mp.base.BaseServiceImpl;
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
||||||
import org.springblade.core.redis.ratelimiter.RateLimiter;
|
import org.springblade.core.redis.ratelimiter.RateLimiter;
|
||||||
import org.springblade.core.tool.utils.StringUtil;
|
import org.springblade.core.tool.utils.StringUtil;
|
||||||
import org.springblade.modules.api.vo.MarketMerchantProductApiVO;
|
import org.springblade.modules.api.vo.MarketMerchantCatalogApiVO;
|
||||||
import org.springblade.modules.market.convert.MarketMerchantConvert;
|
import org.springblade.modules.market.convert.MarketMerchantConvert;
|
||||||
import org.springblade.modules.market.eums.MerchantProductType;
|
import org.springblade.modules.market.eums.MerchantProductType;
|
||||||
import org.springblade.modules.market.eums.MerchantType;
|
import org.springblade.modules.market.eums.MerchantType;
|
||||||
import org.springblade.modules.market.mapper.MerchantProductMapper;
|
import org.springblade.modules.market.mapper.MerchantCatalogMapper;
|
||||||
import org.springblade.modules.market.pojo.entity.MerchantProductEntity;
|
import org.springblade.modules.market.pojo.entity.MerchantCatalogEntity;
|
||||||
import org.springblade.modules.market.pojo.vo.MerchantProductVO;
|
import org.springblade.modules.market.pojo.vo.MerchantCatalogVO;
|
||||||
import org.springblade.modules.market.service.IMerchantProductService;
|
import org.springblade.modules.market.service.IMerchantCatalogService;
|
||||||
import org.springblade.modules.system.pojo.entity.User;
|
import org.springblade.modules.system.pojo.entity.User;
|
||||||
import org.springblade.modules.system.service.IUserService;
|
import org.springblade.modules.system.service.IUserService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -59,44 +59,44 @@ import java.util.concurrent.TimeUnit;
|
|||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class MerchantProductServiceImpl extends BaseServiceImpl<MerchantProductMapper, MerchantProductEntity> implements IMerchantProductService {
|
public class MerchantCatalogServiceImpl extends BaseServiceImpl<MerchantCatalogMapper, MerchantCatalogEntity> implements IMerchantCatalogService {
|
||||||
|
|
||||||
private final IUserService userService;
|
private final IUserService userService;
|
||||||
|
|
||||||
private static final String MERCHANT_PRODUCT_QUANTITY_LIMIT = "merchant.product.quantity.limit";
|
private static final String MERCHANT_CATALOG_QUANTITY_LIMIT = "merchant.catalog.quantity.limit";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IPage<MerchantProductVO> selectMerchantProductPage(IPage<MerchantProductVO> page, MerchantProductVO productVO) {
|
public IPage<MerchantCatalogVO> selectMerchantCatalogPage(IPage<MerchantCatalogVO> page, MerchantCatalogVO catalogVO) {
|
||||||
return page.setRecords(baseMapper.selectMerchantProductPage(page, productVO));
|
return page.setRecords(baseMapper.selectMerchantCatalogPage(page, catalogVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean submitPlatformProduct(MerchantProductEntity product) {
|
public boolean submitPlatformCatalog(MerchantCatalogEntity catalog) {
|
||||||
if (product.getCostPrice() == null || product.getCostPrice().compareTo(BigDecimal.ZERO) < 1 || StringUtil.isBlank(product.getProductName())) {
|
if (catalog.getCostPrice() == null || catalog.getCostPrice().compareTo(BigDecimal.ZERO) < 1 || StringUtil.isBlank(catalog.getProductName())) {
|
||||||
throw new ServiceException("必填参数不能为空");
|
throw new ServiceException("必填参数不能为空");
|
||||||
}
|
}
|
||||||
if (product.getId() != null) {
|
if (catalog.getId() != null) {
|
||||||
MerchantProductEntity entity = getById(product.getId());
|
MerchantCatalogEntity entity = getById(catalog.getId());
|
||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
if (!Objects.equals(entity.getType(), MerchantProductType.PLATFORM.getCode()) || product.getUserId() != null) {
|
if (!Objects.equals(entity.getType(), MerchantProductType.PLATFORM.getCode()) || catalog.getUserId() != null) {
|
||||||
throw new ServiceException("企业商品不可修改");
|
throw new ServiceException("企业商品不可修改");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
product.setType(MerchantProductType.PLATFORM.getCode());
|
catalog.setType(MerchantProductType.PLATFORM.getCode());
|
||||||
return saveOrUpdate(product);
|
return saveOrUpdate(catalog);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<MarketMerchantProductApiVO> productListByUserId(Long userId) {
|
public List<MarketMerchantCatalogApiVO> catalogListByUserId(Long userId) {
|
||||||
if (Objects.isNull(userId)) {
|
if (Objects.isNull(userId)) {
|
||||||
throw new ServiceException("无效用户");
|
throw new ServiceException("无效用户");
|
||||||
}
|
}
|
||||||
List<MerchantProductEntity> list = list(Wrappers.lambdaQuery(MerchantProductEntity.class).eq(MerchantProductEntity::getIsDeleted, 0)
|
List<MerchantCatalogEntity> list = list(Wrappers.lambdaQuery(MerchantCatalogEntity.class).eq(MerchantCatalogEntity::getIsDeleted, 0)
|
||||||
.and(wrapper -> wrapper
|
.and(wrapper -> wrapper
|
||||||
.eq(MerchantProductEntity::getType, MerchantProductType.PLATFORM.getCode())
|
.eq(MerchantCatalogEntity::getType, MerchantProductType.PLATFORM.getCode())
|
||||||
.or()
|
.or()
|
||||||
.eq(MerchantProductEntity::getType, MerchantProductType.MERCHANT.getCode()).eq(MerchantProductEntity::getUserId, userId)
|
.eq(MerchantCatalogEntity::getType, MerchantProductType.MERCHANT.getCode()).eq(MerchantCatalogEntity::getUserId, userId)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
return MarketMerchantConvert.INSTANCE.convertMerchantProductEntityToApiVOList(list);
|
return MarketMerchantConvert.INSTANCE.convertMerchantProductEntityToApiVOList(list);
|
||||||
@@ -104,7 +104,7 @@ public class MerchantProductServiceImpl extends BaseServiceImpl<MerchantProductM
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@RateLimiter(value = "merchant:product", param = "#userId", max = 1, ttl = 10, timeUnit = TimeUnit.SECONDS)
|
@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) {
|
public boolean submitMerchantCatalog(Long userId, Long productId, String productName, String thumbImageUrl, List<String> mainImageUrls, List<String> detailImageUrls, List<MerchantCatalogEntity.Spec> specs) {
|
||||||
if (Objects.isNull(userId)) {
|
if (Objects.isNull(userId)) {
|
||||||
throw new ServiceException("无效用户");
|
throw new ServiceException("无效用户");
|
||||||
}
|
}
|
||||||
@@ -122,17 +122,17 @@ public class MerchantProductServiceImpl extends BaseServiceImpl<MerchantProductM
|
|||||||
|
|
||||||
boolean isNew = (productId == null);
|
boolean isNew = (productId == null);
|
||||||
if (isNew) {
|
if (isNew) {
|
||||||
String limit = ParamCache.getValue(MERCHANT_PRODUCT_QUANTITY_LIMIT);
|
String limit = ParamCache.getValue(MERCHANT_CATALOG_QUANTITY_LIMIT);
|
||||||
if (StringUtil.isBlank(limit)) {
|
if (StringUtil.isBlank(limit)) {
|
||||||
throw new ServiceException("系统配置异常:商品数量上限未设置");
|
throw new ServiceException("系统配置异常:商品数量上限未设置");
|
||||||
}
|
}
|
||||||
long count = count(Wrappers.lambdaQuery(MerchantProductEntity.class).eq(MerchantProductEntity::getUserId, userId).eq(MerchantProductEntity::getIsDeleted, 0));
|
long count = count(Wrappers.lambdaQuery(MerchantCatalogEntity.class).eq(MerchantCatalogEntity::getUserId, userId).eq(MerchantCatalogEntity::getIsDeleted, 0));
|
||||||
if (count >= Long.parseLong(limit)) {
|
if (count >= Long.parseLong(limit)) {
|
||||||
throw new ServiceException("商品数量已经超过上限");
|
throw new ServiceException("商品数量已经超过上限");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MerchantProductEntity entity = new MerchantProductEntity();
|
MerchantCatalogEntity entity = new MerchantCatalogEntity();
|
||||||
entity.setType(MerchantProductType.MERCHANT.getCode());
|
entity.setType(MerchantProductType.MERCHANT.getCode());
|
||||||
entity.setUserId(userId);
|
entity.setUserId(userId);
|
||||||
entity.setUserAccount(user.getAccount());
|
entity.setUserAccount(user.getAccount());
|
||||||
@@ -142,7 +142,7 @@ public class MerchantProductServiceImpl extends BaseServiceImpl<MerchantProductM
|
|||||||
entity.setDetailImageUrls(detailImageUrls);
|
entity.setDetailImageUrls(detailImageUrls);
|
||||||
entity.setSpecs(specs);
|
entity.setSpecs(specs);
|
||||||
if (productId != null) {
|
if (productId != null) {
|
||||||
MerchantProductEntity p = getById(productId);
|
MerchantCatalogEntity p = getById(productId);
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
if (!Objects.equals(p.getUserId(), entity.getUserId())) {
|
if (!Objects.equals(p.getUserId(), entity.getUserId())) {
|
||||||
throw new ServiceException("无效参数");
|
throw new ServiceException("无效参数");
|
||||||
@@ -34,16 +34,17 @@ import org.springblade.core.mp.base.BaseServiceImpl;
|
|||||||
import org.springblade.core.redis.ratelimiter.RateLimiter;
|
import org.springblade.core.redis.ratelimiter.RateLimiter;
|
||||||
import org.springblade.modules.api.vo.MarketMerchantInventoryApiVO;
|
import org.springblade.modules.api.vo.MarketMerchantInventoryApiVO;
|
||||||
import org.springblade.modules.market.eums.MarketBusinessModule;
|
import org.springblade.modules.market.eums.MarketBusinessModule;
|
||||||
|
import org.springblade.modules.market.eums.MerchantGiftType;
|
||||||
import org.springblade.modules.market.eums.MerchantProductType;
|
import org.springblade.modules.market.eums.MerchantProductType;
|
||||||
import org.springblade.modules.market.eums.MerchantType;
|
import org.springblade.modules.market.eums.MerchantType;
|
||||||
import org.springblade.modules.market.mapper.MerchantInventoryMapper;
|
import org.springblade.modules.market.mapper.MerchantInventoryMapper;
|
||||||
|
import org.springblade.modules.market.pojo.dto.MarketBenefitPointApiDTO;
|
||||||
import org.springblade.modules.market.pojo.dto.MarketCashCouponApiDTO;
|
import org.springblade.modules.market.pojo.dto.MarketCashCouponApiDTO;
|
||||||
|
import org.springblade.modules.market.pojo.entity.MarketInfoEntity;
|
||||||
import org.springblade.modules.market.pojo.entity.MerchantInventoryEntity;
|
import org.springblade.modules.market.pojo.entity.MerchantInventoryEntity;
|
||||||
import org.springblade.modules.market.pojo.entity.MerchantProductEntity;
|
import org.springblade.modules.market.pojo.entity.MerchantCatalogEntity;
|
||||||
import org.springblade.modules.market.pojo.vo.MerchantInventoryVO;
|
import org.springblade.modules.market.pojo.vo.MerchantInventoryVO;
|
||||||
import org.springblade.modules.market.service.IMarketCashCouponService;
|
import org.springblade.modules.market.service.*;
|
||||||
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.pojo.entity.User;
|
||||||
import org.springblade.modules.system.service.IUserService;
|
import org.springblade.modules.system.service.IUserService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -67,10 +68,14 @@ public class MerchantInventoryServiceImpl extends BaseServiceImpl<MerchantInvent
|
|||||||
|
|
||||||
private final IUserService userService;
|
private final IUserService userService;
|
||||||
|
|
||||||
private final IMerchantProductService productService;
|
private final IMerchantCatalogService productService;
|
||||||
|
|
||||||
private final IMarketCashCouponService cashCouponService;
|
private final IMarketCashCouponService cashCouponService;
|
||||||
|
|
||||||
|
private final IMarketInfoService infoService;
|
||||||
|
|
||||||
|
private final IMarketBenefitPointService benefitPointService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IPage<MerchantInventoryVO> selectProductInventoryPage(IPage<MerchantInventoryVO> page, MerchantInventoryVO inventory) {
|
public IPage<MerchantInventoryVO> selectProductInventoryPage(IPage<MerchantInventoryVO> page, MerchantInventoryVO inventory) {
|
||||||
return page.setRecords(baseMapper.selectProductInventoryPage(page, inventory));
|
return page.setRecords(baseMapper.selectProductInventoryPage(page, inventory));
|
||||||
@@ -87,7 +92,7 @@ public class MerchantInventoryServiceImpl extends BaseServiceImpl<MerchantInvent
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@RateLimiter(value = "inventory:limiter", param = "#userId", max = 1, ttl = 10, timeUnit = TimeUnit.SECONDS)
|
@RateLimiter(value = "inventory:limiter", param = "#userId", max = 1, ttl = 10, timeUnit = TimeUnit.SECONDS)
|
||||||
public boolean increase(Long userId, Long productId, Integer num) {
|
public boolean increase(Long userId, Long productId, Integer num, BigDecimal price, Integer giftType, BigDecimal giftAmount) {
|
||||||
if (Objects.isNull(userId)) {
|
if (Objects.isNull(userId)) {
|
||||||
throw new ServiceException("无效用户");
|
throw new ServiceException("无效用户");
|
||||||
}
|
}
|
||||||
@@ -99,7 +104,7 @@ public class MerchantInventoryServiceImpl extends BaseServiceImpl<MerchantInvent
|
|||||||
throw new IllegalArgumentException("无效数量");
|
throw new IllegalArgumentException("无效数量");
|
||||||
}
|
}
|
||||||
Integer merchantType = MarketInfoCache.checkMerchantType(userId);
|
Integer merchantType = MarketInfoCache.checkMerchantType(userId);
|
||||||
MerchantProductEntity product = productService.getById(productId);
|
MerchantCatalogEntity product = productService.getById(productId);
|
||||||
if (Objects.isNull(product)) {
|
if (Objects.isNull(product)) {
|
||||||
throw new ServiceException("无效商品");
|
throw new ServiceException("无效商品");
|
||||||
}
|
}
|
||||||
@@ -107,54 +112,58 @@ public class MerchantInventoryServiceImpl extends BaseServiceImpl<MerchantInvent
|
|||||||
if (userType.getCode() == MerchantType.UNREVIEWED.getCode()) {
|
if (userType.getCode() == MerchantType.UNREVIEWED.getCode()) {
|
||||||
throw new ServiceException("用户没有该操作权限");
|
throw new ServiceException("用户没有该操作权限");
|
||||||
}
|
}
|
||||||
switch (MerchantProductType.fromCode(product.getType())) {
|
|
||||||
|
MerchantProductType currentType = MerchantProductType.fromCode(product.getType());
|
||||||
|
switch (currentType) {
|
||||||
case PLATFORM -> {
|
case PLATFORM -> {
|
||||||
BigDecimal totalAmount = product.getCostPrice().multiply(BigDecimal.valueOf(num));
|
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)));
|
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 -> {
|
case MERCHANT -> {
|
||||||
if (userType.getCode() != MerchantType.ENTERPRISE.getCode()) {
|
if (userType.getCode() != MerchantType.ENTERPRISE.getCode()) {
|
||||||
throw new ServiceException("无法添加该类型商品");
|
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("操作失败");
|
MerchantInventoryEntity inventory = getOne(Wrappers.lambdaQuery(MerchantInventoryEntity.class).eq(MerchantInventoryEntity::getUserId, userId).eq(MerchantInventoryEntity::getType, currentType.getCode()).eq(MerchantInventoryEntity::getProductId, productId).eq(MerchantInventoryEntity::getIsDeleted, 0).orderByDesc(MerchantInventoryEntity::getId));
|
||||||
|
BigDecimal totalBenefitPointAmount = BigDecimal.ZERO;
|
||||||
|
if (Objects.nonNull(inventory)) {
|
||||||
|
BigDecimal multiply = inventory.getUnitGiftAmount().multiply(BigDecimal.valueOf(num));
|
||||||
|
totalBenefitPointAmount = totalBenefitPointAmount.add(multiply);
|
||||||
|
if (baseMapper.increaseInventory(inventory.getId(), num, inventory.getVersion()) < 1) {
|
||||||
|
throw new ServiceException("操作失败");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (Objects.isNull(price) || price.compareTo(BigDecimal.ZERO) < 1 || Objects.isNull(giftAmount) || giftAmount.compareTo(BigDecimal.ZERO) < 1) {
|
||||||
|
throw new ServiceException("无效参数");
|
||||||
|
}
|
||||||
|
MerchantInventoryEntity entity = new MerchantInventoryEntity();
|
||||||
|
entity.setUserId(userId);
|
||||||
|
entity.setUserAccount(user.getAccount());
|
||||||
|
entity.setType(currentType.getCode());
|
||||||
|
entity.setProductName(product.getProductName());
|
||||||
|
entity.setProductId(productId);
|
||||||
|
MarketInfoEntity info = infoService.getById(userId);
|
||||||
|
if (Objects.nonNull(info)) {
|
||||||
|
entity.setStoreName(info.getStoreName());
|
||||||
|
}
|
||||||
|
entity.setThumbImageUrl(product.getThumbImageUrl());
|
||||||
|
entity.setUnitPrice(price);
|
||||||
|
entity.setGiftType(MerchantGiftType.BENEFIT_POINT.getCode());
|
||||||
|
entity.setUnitGiftAmount(giftAmount);
|
||||||
|
entity.setStock(num);
|
||||||
|
BigDecimal multiply = giftAmount.multiply(BigDecimal.valueOf(num));
|
||||||
|
totalBenefitPointAmount = totalBenefitPointAmount.add(multiply);
|
||||||
|
if (!save(entity)) {
|
||||||
|
throw new ServiceException("操作失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BigDecimal fee = totalBenefitPointAmount.multiply(BigDecimal.valueOf(0.2));
|
||||||
|
totalBenefitPointAmount = totalBenefitPointAmount.add(fee);
|
||||||
|
if (!benefitPointService.deductBenefitPoint(new MarketBenefitPointApiDTO(userId, totalBenefitPointAmount, fee, MarketBusinessModule.MERCHANT_PUBLISH, null, String.format("上架商品[%s],ID[%d],数量[%d]", product.getProductName(), product.getId(), num), ""))) {
|
||||||
|
throw new ServiceException("操作失败");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user