线上超市-1

This commit is contained in:
zjf committed 2025-01-21 17:43:06 +08:00
1 parent 6c35beee34
commit 0dee2a34ef
10 files changed
+471

No files matched your search

@@ -0,0 +1,26 @@
package com.bsd.pjcloud.supermarketerp.api.feign;
import com.bsd.pjcloud.common.core.constant.ServiceNameConstants;
import com.bsd.pjcloud.common.core.util.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
/**
* @author zjf
* @date 2018/6/22
*/
@FeignClient(contextId = "remoteSupermarketCategoryServic", value = ServiceNameConstants.SUPERMARKET_SERVICE)
public interface RemoteSupermarketCategoryService {
/**
* 查询所有的分类
* @return R
*/
@GetMapping("/supermarketCategory/simpleAll")
R getSimpleAll();
}
@@ -0,0 +1,89 @@
/*
*
* Copyright (c) 2018-2025, pjcloud All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: pjcloud
*
*/
package com.bsd.pjcloud.supermarketerp.api.feign;
import com.bsd.pjcloud.common.core.constant.ServiceNameConstants;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.supermarketerp.dto.SupermarketSpuQueryDTO;
import com.bsd.pjcloud.supermarketerp.dto.SupermarketSpuUpdateStockReqDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
/**
* @author zjf
* @date 2018/6/22
*/
@FeignClient(contextId = "remoteSupermarketSpuService", value = ServiceNameConstants.SUPERMARKET_SERVICE)
public interface RemoteSupermarketSpuService {
/**
* 查询所有的超市spu列表信息,根据条件
* @return R
*/
@PostMapping("/supermarketSpu/ad/selectListAll")
R getSupermarketSpuScope(@RequestBody SupermarketSpuQueryDTO supermarketSpuQueryDTO);
/**
* 根据spu id 查询spu详情,详情包括辅助条码和包装单位基本信息
* @param id
* @return
*/
@GetMapping("/supermarketSpu/ad/SpuDetails")
R getSupermarketSpuDetailById(@RequestParam("id")Long id);
/**
* 更新库存
* @param updateStockReqDTO
* @return
*/
@PostMapping("/supermarketSpu/ad/updateSpuStock")
R updateSpuStock(@RequestBody SupermarketSpuUpdateStockReqDTO updateStockReqDTO);
/**
* 查询所有的超市spu列表信息,根据条件
* @return R
*/
@PostMapping("/supermarketSpu/app/selectListAll")
R getSupermarketSpu(@RequestBody SupermarketSpuQueryDTO supermarketSpuQueryDTO);
/**
* 购物车效验库存
* @param spuId
* @param incrCount 扣减数量,正数负数都行
* @return
*/
@GetMapping("/supermarketSpu/app/checkSpuStock")
R checkSpuStock(@RequestParam(value ="spuId")Long spuId,@RequestParam("incrCount")Integer incrCount);
}
@@ -0,0 +1,51 @@
/*
*
* Copyright (c) 2018-2025, pjcloud All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the pig4cloud.com developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: pjcloud
*
*/
package com.bsd.pjcloud.supermarketerp.api.feign;
import com.bsd.pjcloud.common.core.constant.ServiceNameConstants;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.supermarketerp.vo.SupermarketUnitWithSpuVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
/**
* @author zjf
* @date 2018/6/22
*/
@FeignClient(contextId = "remoteSupermarketUnitSkuService", value = ServiceNameConstants.SUPERMARKET_SERVICE)
public interface RemoteSupermarketUnitSkuService {
/**
* sku 包装单位
* 根据包装ids查询
* @param ids
* @return
*/
@PostMapping("/supermarketUnit/ad/getSupermarketUnits")
R<List<SupermarketUnitWithSpuVo>> getSupermarketUnits(@RequestBody List<Long> ids);
}
@@ -0,0 +1,3 @@
com.bsd.pjcloud.supermarketerp.api.feign.RemoteSupermarketCategoryService
com.bsd.pjcloud.supermarketerp.api.feign.RemoteSupermarketSpuService
com.bsd.pjcloud.supermarketerp.api.feign.RemoteSupermarketUnitSkuService
@@ -0,0 +1,121 @@
package com.bsd.pjcloud.supermarket.controller;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.supermarket.entity.SmSpuEntity;
import com.bsd.pjcloud.supermarket.service.SmSpuService;
import org.springframework.security.access.prepost.PreAuthorize;
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import org.springdoc.core.annotations.ParameterObject;
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.web.bind.annotation.*;
import java.util.List;
import java.util.Objects;
/**
* 线上超市
*
* @author zjf
* @date 2025-01-21 17:38:38
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/smSpu" )
@Tag(description = "smSpu" , name = "线上超市管理" )
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class SmSpuController {
private final SmSpuService smSpuService;
/**
* 分页查询
* @param page 分页对象
* @param smSpu 线上超市
* @return
*/
@Operation(summary = "分页查询" , description = "分页查询" )
@GetMapping("/page" )
@PreAuthorize("@pms.hasPermission('supermarket_smSpu_view')" )
public R getSmSpuPage(@ParameterObject Page page, @ParameterObject SmSpuEntity smSpu) {
LambdaQueryWrapper<SmSpuEntity> wrapper = Wrappers.lambdaQuery();
wrapper.like(StrUtil.isNotBlank(smSpu.getErpSpuId()),SmSpuEntity::getErpSpuId,smSpu.getErpSpuId());
return R.ok(smSpuService.page(page, wrapper));
}
/**
* 通过id查询线上超市
* @param id id
* @return R
*/
@Operation(summary = "通过id查询" , description = "通过id查询" )
@GetMapping("/{id}" )
@PreAuthorize("@pms.hasPermission('supermarket_smSpu_view')" )
public R getById(@PathVariable("id" ) Long id) {
return R.ok(smSpuService.getById(id));
}
/**
* 新增线上超市
* @param smSpu 线上超市
* @return R
*/
@Operation(summary = "新增线上超市" , description = "新增线上超市" )
@SysLog("新增线上超市" )
@PostMapping
@PreAuthorize("@pms.hasPermission('supermarket_smSpu_add')" )
public R save(@RequestBody SmSpuEntity smSpu) {
return R.ok(smSpuService.save(smSpu));
}
/**
* 修改线上超市
* @param smSpu 线上超市
* @return R
*/
@Operation(summary = "修改线上超市" , description = "修改线上超市" )
@SysLog("修改线上超市" )
@PutMapping
@PreAuthorize("@pms.hasPermission('supermarket_smSpu_edit')" )
public R updateById(@RequestBody SmSpuEntity smSpu) {
return R.ok(smSpuService.updateById(smSpu));
}
/**
* 通过id删除线上超市
* @param ids id列表
* @return R
*/
@Operation(summary = "通过id删除线上超市" , description = "通过id删除线上超市" )
@SysLog("通过id删除线上超市" )
@DeleteMapping
@PreAuthorize("@pms.hasPermission('supermarket_smSpu_del')" )
public R removeById(@RequestBody Long[] ids) {
return R.ok(smSpuService.removeBatchByIds(CollUtil.toList(ids)));
}
/**
* 导出excel 表格
* @param smSpu 查询条件
* @param ids 导出指定ID
* @return excel 文件流
*/
@ResponseExcel
@GetMapping("/export")
@PreAuthorize("@pms.hasPermission('supermarket_smSpu_export')" )
public List<SmSpuEntity> export(SmSpuEntity smSpu,Long[] ids) {
return smSpuService.list(Wrappers.lambdaQuery(smSpu).in(ArrayUtil.isNotEmpty(ids), SmSpuEntity::getId, ids));
}
}
@@ -0,0 +1,123 @@
package com.bsd.pjcloud.supermarket.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.bsd.pjcloud.common.core.util.TenantTable;
import java.time.LocalDateTime;
/**
* 线上超市
*
* @author zjf
* @date 2025-01-21 17:38:38
*/
@Data
@TenantTable
@TableName("sm_spu")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "线上超市")
public class SmSpuEntity extends Model<SmSpuEntity> {
/**
* 线上SPU 编号,自增
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description="线上SPU 编号,自增")
private Long id;
/**
* 库存商品id
*/
@Schema(description="库存商品id")
private String erpSpuId;
/**
* 商品详情
*/
@Schema(description="商品详情")
private String description;
/**
* 商品轮播图地址
数组,以逗号分隔
最多上传15张
*/
@Schema(description="商品轮播图地址")
private String sliderPicUrls;
/**
* 排序字段
*/
@Schema(description="排序字段")
private Integer sort;
/**
* 商品状态: 1 上架(开启) 0 下架(禁用) -1 回收
*/
@Schema(description="商品状态: 1 上架(开启) 0 下架(禁用) -1 回收")
private String status;
/**
* 赠送积分
*/
@Schema(description="赠送积分")
private Integer giveIntegral;
/**
* 部门id
*/
@Schema(description="部门id")
private Long deptId;
/**
* 销量
*/
@Schema(description="销量")
private Integer salesCount;
/**
* 创建人
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description="创建人")
private String createBy;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description="创建时间")
private LocalDateTime createTime;
/**
* 更新人
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description="更新人")
private String updateBy;
/**
* 更新时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description="更新时间")
private LocalDateTime updateTime;
/**
* 是否删除
*/
@TableLogic
@TableField(fill = FieldFill.INSERT)
@Schema(description="是否删除")
private String delFlag;
/**
* 租户编号
*/
@Schema(description="租户编号")
private Long tenantId;
}
@@ -0,0 +1,11 @@
package com.bsd.pjcloud.supermarket.mapper;
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
import com.bsd.pjcloud.supermarket.entity.SmSpuEntity;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface SmSpuMapper extends PjcloudBaseMapper<SmSpuEntity> {
}
@@ -0,0 +1,8 @@
package com.bsd.pjcloud.supermarket.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bsd.pjcloud.supermarket.entity.SmSpuEntity;
public interface SmSpuService extends IService<SmSpuEntity> {
}
@@ -0,0 +1,16 @@
package com.bsd.pjcloud.supermarket.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.supermarket.entity.SmSpuEntity;
import com.bsd.pjcloud.supermarket.mapper.SmSpuMapper;
import com.bsd.pjcloud.supermarket.service.SmSpuService;
import org.springframework.stereotype.Service;
/**
* 线上超市
*
* @author zjf
* @date 2025-01-21 17:38:38
*/
@Service
public class SmSpuServiceImpl extends ServiceImpl<SmSpuMapper, SmSpuEntity> implements SmSpuService {
}
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bsd.pjcloud.supermarket.mapper.SmSpuMapper">
<resultMap id="smSpuMap" type="com.bsd.pjcloud.supermarket.entity.SmSpuEntity">
<id property="id" column="id"/>
<result property="erpSpuId" column="erp_spu_id"/>
<result property="description" column="description"/>
<result property="sliderPicUrls" column="slider_pic_urls"/>
<result property="sort" column="sort"/>
<result property="status" column="status"/>
<result property="giveIntegral" column="give_integral"/>
<result property="deptId" column="dept_id"/>
<result property="salesCount" column="sales_count"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="delFlag" column="del_flag"/>
<result property="tenantId" column="tenant_id"/>
</resultMap>
</mapper>