feat:智能柜商品手动上架

feat:增加搜索条件
This commit is contained in:
dzc committed 2025-04-07 14:58:42 +08:00
1 parent 71d39761d5
commit 37469c9ad4
17 files changed
+356 -60

No files matched your search

+6 -5
View File
@@ -291,7 +291,7 @@ CREATE TABLE hard_spu
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',
hard_door_number int DEFAULT NULL COMMENT '商品放置层数',
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 '创建人',
@@ -329,11 +329,12 @@ CREATE TABLE hard_spu_category
DROP TABLE IF EXISTS hard_spu_repertory;
CREATE TABLE hard_spu_repertory
(
id bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
user_id bigint NOT NULL COMMENT '用户id',
hard_id bigint NOT NULL COMMENT '设备id',
spu_id bigint NOT NULL COMMENT '商品id',
id bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
user_id bigint NOT NULL COMMENT '用户id',
hard_id bigint NOT NULL COMMENT '设备id',
spu_id bigint NOT NULL COMMENT '商品id',
count bigint DEFAULT 0 COMMENT '更新库存数量',
biz_type tinytext NOT NULL COMMENT '上架类型',
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 '修改人',
@@ -0,0 +1,27 @@
package com.bsd.pjcloud.hard.api.constant.spu;
import cn.hutool.core.util.ObjectUtil;
import com.bsd.pjcloud.hard.api.constant.HardPrintStatusEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Arrays;
/**
* 上架类型
*/
@AllArgsConstructor
@Getter
public enum SpuRepertoryTypeEnum {
HANDLER("10", "手动上架"),
AUTO("20", "自动上架"),
;
private final String type;
private final String description;
public static SpuRepertoryTypeEnum valueOfByType(String type) {
if (ObjectUtil.isEmpty(type)) return null;
return Arrays.stream(values()).filter(v -> ObjectUtil.equals(type, v.getType())).findFirst().get();
}
}
@@ -3,7 +3,14 @@ package com.bsd.pjcloud.hard.api.dto.spu;
import com.bsd.pjcloud.hard.api.entity.spu.HardSpuRepertoryEntity;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
@Data
public class HardSpuRepertoryDto extends HardSpuRepertoryEntity {
private LocalDateTime[] createTimeList;
private List<Long> userIds;
}
@@ -105,6 +105,12 @@ public class HardSpuEntity extends Model<HardSpuEntity> {
@Schema(description = "设备id")
private Long hardId;
/**
* 商品放置层数
*/
@Schema(description = "商品放置层数")
private Long hardDoorNumber;
/**
* 商户id
*/
@@ -3,9 +3,13 @@ package com.bsd.pjcloud.hard.api.entity.spu;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.bsd.pjcloud.common.core.util.TenantTable;
import java.time.LocalDateTime;
/**
@@ -19,76 +23,85 @@ import java.time.LocalDateTime;
public class HardSpuRepertoryEntity extends Model<HardSpuRepertoryEntity> {
/**
* 编号
*/
/**
* 编号
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description="编号")
@Schema(description = "编号")
private Long id;
/**
* 用户id
*/
@Schema(description="用户id")
/**
* 用户id
*/
@Schema(description = "用户id")
private Long userId;
/**
* 设备id
*/
@Schema(description="设备id")
/**
* 设备id
*/
@Schema(description = "设备id")
private Long hardId;
/**
* 商品id
*/
@Schema(description="商品id")
/**
* 商品id
*/
@Schema(description = "商品id")
private Long spuId;
/**
* 更新库存数量
*/
@Schema(description="更新库存数量")
/**
* 更新库存数量
*/
@NotNull(message = "更新库存数量不能为空")
@Min(value = 1, message = "更新库存数量不能小于1")
@Max(value = 100, message = "更新库存数量不能大于100")
@Schema(description = "更新库存数量")
private Long count;
/**
* 创建人
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description="创建人")
/**
* 上架类型
*/
@Schema(description = "上架类型")
private String bizType;
/**
* 创建人
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description = "创建人")
private String createBy;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description="创建时间")
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description = "创建时间")
private LocalDateTime createTime;
/**
* 修改人
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description="修改人")
/**
* 修改人
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description = "修改人")
private String updateBy;
/**
* 修改时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description="修改时间")
/**
* 修改时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description = "修改时间")
private LocalDateTime updateTime;
/**
* 删除标记
*/
/**
* 删除标记
*/
@TableLogic
@TableField(fill = FieldFill.INSERT)
@Schema(description="删除标记")
@TableField(fill = FieldFill.INSERT)
@Schema(description = "删除标记")
private String delFlag;
/**
* 租户ID
*/
@Schema(description="租户ID")
/**
* 租户ID
*/
@Schema(description = "租户ID")
private Long tenantId;
}
@@ -1,9 +1,55 @@
package com.bsd.pjcloud.hard.api.vo.spu;
import com.bsd.pjcloud.admin.api.vo.base.BaseUserInterface;
import com.bsd.pjcloud.hard.api.entity.spu.HardSpuRepertoryEntity;
import com.bsd.pjcloud.hard.api.vo.base.BaseHardInterface;
import com.bsd.pjcloud.wallet.api.vo.base.BaseMchInterface;
import lombok.Data;
@Data
public class HardSpuRepertoryVo extends HardSpuRepertoryEntity {
public class HardSpuRepertoryVo extends HardSpuRepertoryEntity implements BaseMchInterface, BaseHardInterface, BaseUserInterface {
/**
* 商品相关
*/
private String spuName;
private Long spuCategoryId;
private Long spuMchId;
private Long hardDoorNumber;
/**
* 分类相关
*/
private String spuCategoryName;
/**
* 商户相关
*/
private Long merchantId;
private String merchantName;
private String logoPic;
/**
* 设备相关
*/
private String hardName;
private String hardType;
/**
* 用户相关
*/
private String username;
private String userMobile;
private String userAvatar;
}
@@ -148,6 +148,12 @@
<version>5.7.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.yungouos.pay</groupId>
<artifactId>yungouos-pay-sdk</artifactId>
<version>2.0.4</version>
<scope>compile</scope>
</dependency>
</dependencies>
<profiles>
<profile>
@@ -182,6 +182,17 @@ public class HardOrderController {
PjcloudUser user = SecurityUtils.getUser();
CurrentUserHardTypeInfoDto hardTypeInfo = hardManagerService.getCurrentUserHardTypeInfo(user);
dto.setMchTypeCodes(hardTypeInfo.getHardTypeList());
// 查询商户和下面的子商户
List<Long> mchDtoIds = dto.getMchIds();
if (ObjectUtil.isNotEmpty(mchDtoIds) && mchDtoIds.size() == 1) {
Long mchId = mchDtoIds.get(0);
List<MchManageVo> mchList = mchService.getByParentId(mchId).getData();
if (ObjectUtil.isNotEmpty(mchList)) {
List<Long> mchIds = mchList.stream().map(MchManageVo::getId).toList();
mchDtoIds.addAll(mchIds);
dto.setMchIds(mchDtoIds);
}
}
return R.ok(hardwareOrderService.scopePageList(page, dto, dataScope));
}
@@ -219,6 +230,22 @@ public class HardOrderController {
@GetMapping("/export")
@PreAuthorize("@pms.hasPermission('hard_hardwareOrder_export')")
public void export(HttpServletResponse response, HardOrderDto dto) throws IOException {
DataScope dataScope = DataScope.of().func(DataScopeFuncEnum.ALL);
dataScope.setScopeDeptName("merchant_dept_id");
PjcloudUser user = SecurityUtils.getUser();
CurrentUserHardTypeInfoDto hardTypeInfo = hardManagerService.getCurrentUserHardTypeInfo(user);
dto.setMchTypeCodes(hardTypeInfo.getHardTypeList());
// 查询商户和下面的子商户
List<Long> mchDtoIds = dto.getMchIds();
if (ObjectUtil.isNotEmpty(mchDtoIds) && mchDtoIds.size() == 1) {
Long mchId = mchDtoIds.get(0);
List<MchManageVo> mchList = mchService.getByParentId(mchId).getData();
if (ObjectUtil.isNotEmpty(mchList)) {
List<Long> mchIds = mchList.stream().map(MchManageVo::getId).toList();
mchDtoIds.addAll(mchIds);
dto.setMchIds(mchDtoIds);
}
}
List<HardOrderVo> list = hardwareOrderService.scopeList(dto);
List<HardOrderExcelVo> excelList = BeanUtils.toBean(list, HardOrderExcelVo.class);
try (ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).withTemplate(ResourceUtil.getStream("file/订单交易汇总.xlsx")).build()) {
@@ -23,6 +23,8 @@ import com.bsd.pjcloud.hard.api.vo.order.HardOrderCsVo;
import com.bsd.pjcloud.hard.api.vo.order.HardOrderPayTypeVo;
import com.bsd.pjcloud.hard.api.vo.order.HardOrderSbVo;
import com.bsd.pjcloud.hard.service.HardOrderTotalService;
import com.bsd.pjcloud.wallet.api.feign.RemoteMchService;
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
@@ -49,6 +51,8 @@ public class HardOrderTotalController {
private final HardOrderTotalService hardOrderTotalService;
private final RemoteMchService mchService;
/* ************************************* start 远程调用 start ************************************* */
/* ************************************* end 远程调用 end ************************************* */
@@ -74,6 +78,17 @@ public class HardOrderTotalController {
@Operation(summary = "商户交易记录")
public R<List<HardOrderCsVo>> pageListCs(@RequestBody HardOrderDto dto) {
dto.setOrderStatusCodes(HardOrderStatusEnum.getPaySuccessCodes());
// 查询商户和下面的子商户
List<Long> mchDtoIds = dto.getMchIds();
if (ObjectUtil.isNotEmpty(mchDtoIds) && mchDtoIds.size() == 1) {
Long mchId = mchDtoIds.get(0);
List<MchManageVo> mchList = mchService.getByParentId(mchId).getData();
if (ObjectUtil.isNotEmpty(mchList)) {
List<Long> mchIds = mchList.stream().map(MchManageVo::getId).toList();
mchDtoIds.addAll(mchIds);
dto.setMchIds(mchDtoIds);
}
}
return R.ok(hardOrderTotalService.listCs(dto));
}
@@ -8,6 +8,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.common.security.service.PjcloudUser;
import com.bsd.pjcloud.common.security.util.SecurityUtils;
import com.bsd.pjcloud.hard.api.dto.spu.HardSpuRepertoryDto;
import com.bsd.pjcloud.hard.api.entity.spu.HardSpuRepertoryEntity;
import com.bsd.pjcloud.hard.service.HardSpuRepertoryService;
@@ -19,6 +21,7 @@ import org.springframework.http.HttpHeaders;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@@ -68,8 +71,9 @@ public class HardSpuRepertoryController {
@SysLog("新增硬件商品库存更新记录")
@PostMapping
@PreAuthorize("@pms.hasPermission('hard_hardSpuRepertory_add')")
public R save(@RequestBody HardSpuRepertoryEntity hardSpuRepertory) {
return R.ok(hardSpuRepertoryService.save(hardSpuRepertory));
public R save(@Validated @RequestBody HardSpuRepertoryEntity hardSpuRepertory) {
PjcloudUser user = SecurityUtils.getUser();
return R.ok(hardSpuRepertoryService.create(hardSpuRepertory, user));
}
@Operation(summary = "修改硬件商品库存更新记录", description = "修改硬件商品库存更新记录")
@@ -3,6 +3,7 @@ package com.bsd.pjcloud.hard.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.common.security.service.PjcloudUser;
import com.bsd.pjcloud.hard.api.dto.spu.HardSpuRepertoryDto;
import com.bsd.pjcloud.hard.api.entity.spu.HardSpuRepertoryEntity;
import com.bsd.pjcloud.hard.api.vo.spu.HardSpuRepertoryVo;
@@ -11,4 +12,8 @@ public interface HardSpuRepertoryService extends IService<HardSpuRepertoryEntity
Page<HardSpuRepertoryVo> scopePageJoin(Page page, HardSpuRepertoryDto dto, DataScope dataScope);
/**
* 新增
*/
Long create(HardSpuRepertoryEntity entity, PjcloudUser user);
}
@@ -1,18 +1,38 @@
package com.bsd.pjcloud.hard.service.impl.spu;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.admin.api.entity.SysUser;
import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
import com.bsd.pjcloud.admin.api.utils.DataUtil;
import com.bsd.pjcloud.common.core.util.CollectionUtils;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.common.security.service.PjcloudUser;
import com.bsd.pjcloud.hard.api.constant.spu.SpuRepertoryTypeEnum;
import com.bsd.pjcloud.hard.api.dto.HardManagerDto;
import com.bsd.pjcloud.hard.api.dto.spu.HardSpuRepertoryDto;
import com.bsd.pjcloud.hard.api.entity.HardManagerEntity;
import com.bsd.pjcloud.hard.api.entity.spu.HardSpuEntity;
import com.bsd.pjcloud.hard.api.entity.spu.HardSpuRepertoryEntity;
import com.bsd.pjcloud.hard.api.utils.HardUtil;
import com.bsd.pjcloud.hard.api.vo.spu.HardSpuRepertoryVo;
import com.bsd.pjcloud.hard.mapper.HardManagerMapper;
import com.bsd.pjcloud.hard.mapper.spu.HardSpuRepertoryMapper;
import com.bsd.pjcloud.hard.service.HardSpuRepertoryService;
import com.bsd.pjcloud.hard.service.HardSpuService;
import com.bsd.pjcloud.wallet.api.feign.RemoteMchService;
import com.bsd.pjcloud.wallet.api.utils.WalletDataUtil;
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import java.util.ArrayList;
import java.util.List;
/**
* 硬件商品库存更新记录
*/
@@ -22,8 +42,62 @@ import org.springframework.validation.annotation.Validated;
@Service
public class HardSpuRepertoryServiceImpl extends ServiceImpl<HardSpuRepertoryMapper, HardSpuRepertoryEntity> implements HardSpuRepertoryService {
private final HardSpuService hardSpuService;
private final RemoteMchService remoteMchService;
private final RemoteUserService remoteUserService;
private final HardManagerMapper hardManagerMapper;
@Override
public Page<HardSpuRepertoryVo> scopePageJoin(Page page, HardSpuRepertoryDto dto, DataScope dataScope) {
return baseMapper.scopePageJoin(page, dto, dataScope);
Page<HardSpuRepertoryVo> pageList = baseMapper.scopePageJoin(page, dto, dataScope);
disposeList(pageList.getRecords(), dto);
return pageList;
}
/**
* 新增
*/
@Override
public Long create(HardSpuRepertoryEntity entity, PjcloudUser user) {
// 查询商品
HardSpuEntity spuDetail = hardSpuService.getById(entity.getSpuId());
if (ObjectUtil.isEmpty(spuDetail)) {
throw new RuntimeException("商品不存在");
}
entity.setUserId(user.getId());
entity.setHardId(spuDetail.getHardId());
entity.setBizType(SpuRepertoryTypeEnum.HANDLER.getType());
baseMapper.insert(entity);
return entity.getId();
}
private void disposeList(List<HardSpuRepertoryVo> list, HardSpuRepertoryDto dto) {
if (ObjectUtil.isEmpty(list)) return;
// 商户
List<Long> mchIds = list.stream().map(HardSpuRepertoryVo::getSpuMchId).filter(ObjectUtil::isNotEmpty).distinct().toList();
if (ObjectUtil.isNotEmpty(mchIds)) {
List<MchManageVo> mchList = remoteMchService.getByIds(mchIds).getData();
if (ObjectUtil.isNotEmpty(mchList)) {
WalletDataUtil.convertMchList(list, CollectionUtils.convertMap(mchList, MchManageVo::getId));
}
}
// 设备
List<Long> hardIds = list.stream().map(HardSpuRepertoryVo::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));
}
}
// 用户
List<Long> userIds = list.stream().map(HardSpuRepertoryVo::getUserId).distinct().toList();
R<List<SysUser>> userList = remoteUserService.getUserById(new ArrayList<>(userIds));
if (ObjectUtil.isNotEmpty(userList.getData())) {
DataUtil.convertUserList(list, CollectionUtils.convertMap(userList.getData(), SysUser::getUserId));
}
}
}
@@ -227,6 +227,7 @@
from hard_order a
<where>
<include refid="whereA"/>
and a.merchant_id is not null
<if test="dto.hardTypeCodes != null and dto.hardTypeCodes.size() != 0">
and m.type in
<foreach collection="dto.hardTypeCodes" item="v" open="(" close=")" separator=",">
@@ -8,6 +8,7 @@
<result property="hardId" column="hard_id"/>
<result property="spuId" column="spu_id"/>
<result property="count" column="count"/>
<result property="bizType" column="biz_type"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
@@ -16,6 +17,55 @@
<result property="tenantId" column="tenant_id"/>
</resultMap>
<sql id="selectA">
select a.id,
a.user_id,
a.hard_id,
a.spu_id,
a.count,
a.biz_type,
a.create_by,
a.create_time,
a.update_by,
a.update_time,
a.del_flag,
a.tenant_id,
</sql>
<sql id="whereA">
<if test="dto.hardId != null and dto.hardId != '' ">
and a.hard_id = #{dto.hardId}
</if>
<if test="dto.spuId != null and dto.spuId != '' ">
and a.spu_id = #{dto.spuId}
</if>
<if test="dto.bizType != null and dto.bizType != '' ">
and a.biz_type = #{dto.bizType}
</if>
<if test="dto.userIds != null and dto.userIds.size() != 0">
and a.user_id in
<foreach collection="dto.userIds" item="v" open="(" close=")" separator=",">
#{v}
</foreach>
</if>
<if test="dto.createTimeList != null and dto.createTimeList.length == 2">
and a.create_time between #{dto.createTimeList[0]} and #{dto.createTimeList[1]}
</if>
</sql>
<select id="scopePageJoin" resultType="com.bsd.pjcloud.hard.api.vo.spu.HardSpuRepertoryVo">
<include refid="selectA"/>
s.name,
s.spu_category_id,
s.hard_door_number,
s.mch_id as spuMchId,
c.name as spuCategoryName
from hard_spu_repertory a
left join hard_spu s on s.id = a.spu_id
left join hard_spu_category c on c.id = s.spu_category_id
<where>
<include refid="whereA"/>
</where>
order by a.create_time desc , a.id desc
</select>
</mapper>
@@ -18,6 +18,10 @@ public interface RemoteMchService {
@GetMapping("/mch-manage/get-by-id")
R<MchManageVo> getById(@RequestParam Long id);
@NoToken
@GetMapping("/mch-manage/get-by-parent-id")
R<List<MchManageVo>> getByParentId(@RequestParam Long parentId);
@NoToken
@GetMapping("/mch-manage/get-by-ids")
R<List<MchManageVo>> getByIds(@RequestParam List<Long> ids);
@@ -51,6 +51,16 @@ public class MchManageController {
return R.ok(mchManageVo);
}
@Inner
@GetMapping("/get-by-parent-id")
public R<List<MchManageVo>> getByParentId(@RequestParam Long parentId) {
MchManageDto dto = new MchManageDto();
dto.setParentId(parentId);
List<MchManageVo> mchManageVo = mchManageService.list(dto);
if (ObjectUtil.isEmpty(mchManageVo)) return R.ok(List.of());
return R.ok(mchManageVo);
}
@Inner
@GetMapping("/get-by-ids")
public R<List<MchManageVo>> getByIds(@RequestParam List<Long> ids) {
@@ -309,7 +309,7 @@ public class WalletManageServiceImpl extends ServiceImpl<WalletManageMapper, Wal
if (ObjectUtil.isEmpty(itemList)) continue;
for (WalletManageBalanceVo j : itemList) {
// j.setWalletTypeName(i.getName());
walletPage.getRecords().stream().filter(v -> ObjectUtil.equals(v.getUserId(), j.getUserId())).findFirst().ifPresent(v -> {
walletPage.getRecords().stream().filter(v -> ObjectUtil.equals(i.getId(), v.getWalletTypeId()) && ObjectUtil.equals(v.getUserId(), j.getUserId())).findFirst().ifPresent(v -> {
if (ObjectUtil.isNotEmpty(j.getBalance())) {
v.setBalance(j.getBalance());
v.setLastTopUpTime(j.getCreateTime());