feat:智能柜商品
This commit is contained in:
1 parent
91d3a5e40b
commit
14eca5c7e0
11 files changed
+114
-24
No files matched your search
+23
-21
@@ -277,27 +277,29 @@ CREATE TABLE hard_auth
|
||||
DROP TABLE IF EXISTS hard_spu;
|
||||
CREATE TABLE hard_spu
|
||||
(
|
||||
id bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
|
||||
spu_category_id bigint NOT NULL COMMENT '商品分类id',
|
||||
name varchar(64) NOT NULL COMMENT '商品名',
|
||||
pic varchar(256) NOT NULL COMMENT '商品图片',
|
||||
price int NOT NULL COMMENT '单价(分)',
|
||||
sales_count int DEFAULT 0 NOT NULL COMMENT '销量',
|
||||
repertory_count int DEFAULT 0 NOT NULL COMMENT '库存',
|
||||
sort int DEFAULT 0 NOT NULL COMMENT '排序',
|
||||
status char(1) DEFAULT '0' COMMENT '是否启用',
|
||||
is_default char(1) DEFAULT '0' COMMENT '是否为标品',
|
||||
ks_status char(1) DEFAULT '0' COMMENT '旷世审核状态',
|
||||
ks_status_title varchar(64) NOT NULL COMMENT '旷世审核状态标题',
|
||||
ks_comments varchar(512) DEFAULT NULL COMMENT '旷世审核状态描述',
|
||||
mch_id bigint DEFAULT NULL COMMENT '商户id',
|
||||
mch_dept_id bigint DEFAULT NULL COMMENT '商户部门id',
|
||||
create_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
|
||||
create_time datetime DEFAULT NULL COMMENT '创建时间',
|
||||
update_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '修改人',
|
||||
update_time datetime DEFAULT NULL COMMENT '修改时间',
|
||||
del_flag char(1) COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标记',
|
||||
tenant_id bigint DEFAULT NULL COMMENT '租户ID',
|
||||
id bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
|
||||
spu_category_id bigint NOT NULL COMMENT '商品分类id',
|
||||
name varchar(64) NOT NULL COMMENT '商品名',
|
||||
pic varchar(256) NOT NULL COMMENT '商品图片',
|
||||
price int NOT NULL COMMENT '单价(分)',
|
||||
sales_count int DEFAULT 0 NOT NULL COMMENT '销量',
|
||||
repertory_count int DEFAULT 0 NOT NULL COMMENT '库存',
|
||||
sort int DEFAULT 0 NOT NULL COMMENT '排序',
|
||||
status char(1) DEFAULT '0' COMMENT '是否启用',
|
||||
is_default char(1) DEFAULT '0' COMMENT '是否为标品',
|
||||
ks_status char(1) DEFAULT NULL COMMENT '旷世审核状态',
|
||||
ks_status_title varchar(64) DEFAULT NULL COMMENT '旷世审核状态标题',
|
||||
ks_comments varchar(512) DEFAULT NULL COMMENT '旷世审核状态描述',
|
||||
hard_id bigint NOT NULL COMMENT '硬件id',
|
||||
hard_door_number int DEFAULT NULL COMMENT '硬件id',
|
||||
mch_id bigint NOT NULL COMMENT '商户id',
|
||||
mch_dept_id bigint NOT NULL COMMENT '商户部门id',
|
||||
create_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
|
||||
create_time datetime DEFAULT NULL COMMENT '创建时间',
|
||||
update_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '修改人',
|
||||
update_time datetime DEFAULT NULL COMMENT '修改时间',
|
||||
del_flag char(1) COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标记',
|
||||
tenant_id bigint DEFAULT NULL COMMENT '租户ID',
|
||||
PRIMARY KEY (id)
|
||||
) ENGINE = InnoDB COMMENT ='硬件商品';
|
||||
|
||||
|
||||
+5
@@ -6,4 +6,9 @@ import lombok.Data;
|
||||
@Data
|
||||
public class HardSpuCategoryDto extends HardSpuCategoryEntity {
|
||||
|
||||
/**
|
||||
* 设备id
|
||||
*/
|
||||
private Long hardId;
|
||||
|
||||
}
|
||||
+6
@@ -99,6 +99,12 @@ public class HardSpuEntity extends Model<HardSpuEntity> {
|
||||
@Schema(description = "旷世审核状态描述")
|
||||
private String ksComments;
|
||||
|
||||
/**
|
||||
* 设备id
|
||||
*/
|
||||
@Schema(description = "设备id")
|
||||
private Long hardId;
|
||||
|
||||
/**
|
||||
* 商户id
|
||||
*/
|
||||
|
||||
+9
-1
@@ -1,11 +1,12 @@
|
||||
package com.bsd.pjcloud.hard.api.vo.spu;
|
||||
|
||||
import com.bsd.pjcloud.hard.api.entity.spu.HardSpuEntity;
|
||||
import com.bsd.pjcloud.hard.api.vo.base.BaseHardInterface;
|
||||
import com.bsd.pjcloud.wallet.api.vo.base.BaseMchInterface;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class HardSpuVo extends HardSpuEntity implements BaseMchInterface {
|
||||
public class HardSpuVo extends HardSpuEntity implements BaseMchInterface, BaseHardInterface {
|
||||
/**
|
||||
* 分类相关
|
||||
*/
|
||||
@@ -20,4 +21,11 @@ public class HardSpuVo extends HardSpuEntity implements BaseMchInterface {
|
||||
|
||||
private String logoPic;
|
||||
|
||||
/**
|
||||
* 设备相关
|
||||
*/
|
||||
private String hardName;
|
||||
|
||||
private String hardType;
|
||||
|
||||
}
|
||||
+6
@@ -40,6 +40,12 @@ public class HardManagerController {
|
||||
|
||||
private final HardManagerService hardManagerService;
|
||||
|
||||
@Operation(summary = "下拉选择", description = "下拉选择")
|
||||
@GetMapping("/select")
|
||||
public R select(@ParameterObject Page page, @ParameterObject HardManagerDto dto) {
|
||||
return R.ok(hardManagerService.scopePageList(page, dto));
|
||||
}
|
||||
|
||||
@Operation(summary = "分页查询", description = "分页查询")
|
||||
@GetMapping("/page")
|
||||
@PreAuthorize("@pms.hasPermission('hard_hardManager_view')")
|
||||
|
||||
+7
@@ -52,6 +52,13 @@ public class HardSpuCategoryController {
|
||||
return R.ok(hardSpuCategoryService.scopPageJoin(page, dto, dataScope));
|
||||
}
|
||||
|
||||
@Operation(summary = "下拉", description = "下拉")
|
||||
@GetMapping("/select")
|
||||
public R select(@ParameterObject Page page, @ParameterObject HardSpuCategoryDto dto) {
|
||||
DataScope dataScope = null;
|
||||
return R.ok(hardSpuCategoryService.scopPageJoin(page, dto, dataScope));
|
||||
}
|
||||
|
||||
@Operation(summary = "通过id查询", description = "通过id查询")
|
||||
@GetMapping("/{id}")
|
||||
@PreAuthorize("@pms.hasPermission('hard_hardSpuCategory_view')")
|
||||
|
||||
+7
@@ -36,6 +36,13 @@ public class HardSpuController {
|
||||
|
||||
private final HardSpuService hardSpuService;
|
||||
|
||||
@Operation(summary = "下拉查询", description = "下拉查询")
|
||||
@GetMapping("/select")
|
||||
public R select(@ParameterObject Page page, @ParameterObject HardSpuDto dto) {
|
||||
DataScope dataScope = null;
|
||||
return R.ok(hardSpuService.scopPageJoin(page, dto, dataScope));
|
||||
}
|
||||
|
||||
@Operation(summary = "分页查询", description = "分页查询")
|
||||
@GetMapping("/page")
|
||||
@PreAuthorize("@pms.hasPermission('hard_hardSpu_view')")
|
||||
|
||||
+2
@@ -16,6 +16,8 @@ public interface HardSpuCategoryMapper extends PjcloudBaseMapper<HardSpuCategory
|
||||
|
||||
default Page<HardSpuCategoryVo> scopPageJoin(Page page, HardSpuCategoryDto dto, DataScope dataScope) {
|
||||
LambdaQueryWrapper<HardSpuCategoryEntity> wrapper = new LambdaQueryWrapper<HardSpuCategoryEntity>()
|
||||
.eq(ObjectUtil.isNotEmpty(dto.getMchId()), HardSpuCategoryEntity::getMchId, dto.getMchId())
|
||||
.eq(ObjectUtil.isNotEmpty(dto.getMchDeptId()), HardSpuCategoryEntity::getMchDeptId, dto.getMchDeptId())
|
||||
.like(ObjectUtil.isNotEmpty(dto.getName()), HardSpuCategoryEntity::getName, dto.getName())
|
||||
.orderByDesc(HardSpuCategoryEntity::getSort)
|
||||
.orderByDesc(HardSpuCategoryEntity::getCreateTime);
|
||||
|
||||
+11
@@ -7,9 +7,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.common.core.util.CollectionUtils;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.hard.api.dto.spu.HardSpuCategoryDto;
|
||||
import com.bsd.pjcloud.hard.api.entity.HardManagerEntity;
|
||||
import com.bsd.pjcloud.hard.api.entity.spu.HardSpuCategoryEntity;
|
||||
import com.bsd.pjcloud.hard.api.vo.spu.HardSpuCategoryVo;
|
||||
import com.bsd.pjcloud.hard.mapper.spu.HardSpuCategoryMapper;
|
||||
import com.bsd.pjcloud.hard.service.HardManagerService;
|
||||
import com.bsd.pjcloud.hard.service.HardSpuCategoryService;
|
||||
import com.bsd.pjcloud.wallet.api.feign.RemoteMchService;
|
||||
import com.bsd.pjcloud.wallet.api.utils.WalletDataUtil;
|
||||
@@ -31,6 +33,8 @@ import java.util.List;
|
||||
@Service
|
||||
public class HardSpuCategoryServiceImpl extends ServiceImpl<HardSpuCategoryMapper, HardSpuCategoryEntity> implements HardSpuCategoryService {
|
||||
|
||||
private final HardManagerService hardManagerService;
|
||||
|
||||
private final RemoteMchService remoteMchService;
|
||||
|
||||
/**
|
||||
@@ -38,6 +42,13 @@ public class HardSpuCategoryServiceImpl extends ServiceImpl<HardSpuCategoryMappe
|
||||
*/
|
||||
@Override
|
||||
public Page<HardSpuCategoryVo> scopPageJoin(Page page, HardSpuCategoryDto dto, DataScope dataScope) {
|
||||
// 设备id
|
||||
if (ObjectUtil.isNotEmpty(dto.getHardId())) {
|
||||
HardManagerEntity hardDetail = hardManagerService.getById(dto.getHardId());
|
||||
if (ObjectUtil.isNotEmpty(hardDetail)) {
|
||||
dto.setMchId(hardDetail.getMerchantId());
|
||||
}
|
||||
}
|
||||
Page<HardSpuCategoryVo> pageList = baseMapper.scopPageJoin(page, dto, dataScope);
|
||||
disposeList(pageList.getRecords(), dto);
|
||||
return pageList;
|
||||
|
||||
+34
-2
@@ -6,10 +6,16 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.common.core.util.CollectionUtils;
|
||||
import com.bsd.pjcloud.common.data.datascope.DataScope;
|
||||
import com.bsd.pjcloud.hard.api.dto.HardManagerDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.spu.HardSpuDto;
|
||||
import com.bsd.pjcloud.hard.api.entity.HardManagerEntity;
|
||||
import com.bsd.pjcloud.hard.api.entity.spu.HardSpuEntity;
|
||||
import com.bsd.pjcloud.hard.api.utils.HardUtil;
|
||||
import com.bsd.pjcloud.hard.api.vo.HardManagerVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.spu.HardSpuVo;
|
||||
import com.bsd.pjcloud.hard.mapper.HardManagerMapper;
|
||||
import com.bsd.pjcloud.hard.mapper.spu.HardSpuMapper;
|
||||
import com.bsd.pjcloud.hard.service.HardManagerService;
|
||||
import com.bsd.pjcloud.hard.service.HardSpuService;
|
||||
import com.bsd.pjcloud.wallet.api.feign.RemoteMchService;
|
||||
import com.bsd.pjcloud.wallet.api.utils.WalletDataUtil;
|
||||
@@ -31,8 +37,12 @@ import java.util.List;
|
||||
@Service
|
||||
public class HardSpuServiceImpl extends ServiceImpl<HardSpuMapper, HardSpuEntity> implements HardSpuService {
|
||||
|
||||
private final HardManagerService hardManagerService;
|
||||
|
||||
private final RemoteMchService remoteMchService;
|
||||
|
||||
private final HardManagerMapper hardManagerMapper;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
@@ -51,11 +61,17 @@ public class HardSpuServiceImpl extends ServiceImpl<HardSpuMapper, HardSpuEntity
|
||||
if (existName(entity)) {
|
||||
throw new RuntimeException("商品名不能重复");
|
||||
}
|
||||
// 查询设备
|
||||
HardManagerVo hardManager = hardManagerService.getById(entity.getHardId());
|
||||
if (ObjectUtil.isEmpty(hardManager)) {
|
||||
throw new RuntimeException("设备不存在");
|
||||
}
|
||||
// 查询商户
|
||||
MchManageVo mchDetail = remoteMchService.getById(entity.getMchId()).getData();
|
||||
MchManageVo mchDetail = remoteMchService.getById(hardManager.getMerchantId()).getData();
|
||||
if (ObjectUtil.isEmpty(mchDetail)) {
|
||||
throw new RuntimeException("商户不存在");
|
||||
}
|
||||
entity.setMchId(mchDetail.getId());
|
||||
entity.setMchDeptId(mchDetail.getDeptId());
|
||||
baseMapper.insert(entity);
|
||||
return entity.getId();
|
||||
@@ -69,11 +85,17 @@ public class HardSpuServiceImpl extends ServiceImpl<HardSpuMapper, HardSpuEntity
|
||||
if (existName(entity)) {
|
||||
throw new RuntimeException("商品名不能重复");
|
||||
}
|
||||
// 查询设备
|
||||
HardManagerVo hardManager = hardManagerService.getById(entity.getHardId());
|
||||
if (ObjectUtil.isEmpty(hardManager)) {
|
||||
throw new RuntimeException("设备不存在");
|
||||
}
|
||||
// 查询商户
|
||||
MchManageVo mchDetail = remoteMchService.getById(entity.getMchId()).getData();
|
||||
MchManageVo mchDetail = remoteMchService.getById(hardManager.getMerchantId()).getData();
|
||||
if (ObjectUtil.isEmpty(mchDetail)) {
|
||||
throw new RuntimeException("商户不存在");
|
||||
}
|
||||
entity.setMchId(mchDetail.getId());
|
||||
entity.setMchDeptId(mchDetail.getDeptId());
|
||||
baseMapper.updateById(entity);
|
||||
return entity.getId();
|
||||
@@ -113,6 +135,16 @@ public class HardSpuServiceImpl extends ServiceImpl<HardSpuMapper, HardSpuEntity
|
||||
WalletDataUtil.convertMchList(list, CollectionUtils.convertMap(mchList, MchManageVo::getId));
|
||||
}
|
||||
}
|
||||
// 设备
|
||||
List<Long> hardIds = list.stream().map(HardSpuVo::getHardId).filter(ObjectUtil::isNotEmpty).distinct().toList();
|
||||
if (ObjectUtil.isNotEmpty(hardIds)) {
|
||||
HardManagerDto hardManagerDto = new HardManagerDto();
|
||||
hardManagerDto.setIds(hardIds);
|
||||
List<HardManagerEntity> hardList = hardManagerMapper.list(hardManagerDto);
|
||||
if (ObjectUtil.isNotEmpty(hardList)) {
|
||||
HardUtil.convertHardList(list, CollectionUtils.convertMap(hardList, HardManagerEntity::getId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -40,6 +40,7 @@
|
||||
a.ks_status,
|
||||
a.ks_status_title,
|
||||
a.ks_comments,
|
||||
a.hard_id,
|
||||
a.mch_id,
|
||||
a.mch_dept_id,
|
||||
a.create_by,
|
||||
@@ -61,6 +62,9 @@
|
||||
<if test="dto.spuCategoryId != null ">
|
||||
and a.spu_category_id = #{dto.spuCategoryId}
|
||||
</if>
|
||||
<if test="dto.hardId != null ">
|
||||
and a.hard_id = #{dto.hardId}
|
||||
</if>
|
||||
<if test="dto.status != null and dto.status != '' ">
|
||||
and a.status = #{dto.status}
|
||||
</if>
|
||||
|
||||
Reference in new issue
Block a user