parent
2c6d3e6942
commit
a994688726
@ -0,0 +1,34 @@
|
|||||||
|
package com.xjs.mall;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.constant.ServiceNameConstants;
|
||||||
|
import com.xjs.mall.other.R;
|
||||||
|
import com.xjs.mall.to.SkuReductionTo;
|
||||||
|
import com.xjs.mall.to.SpuBoundTo;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 远程调用优惠服务接口feign
|
||||||
|
* @author xiejs
|
||||||
|
* @since 2022-03-20
|
||||||
|
*/
|
||||||
|
@FeignClient(contextId = "remoteCouponFeign",
|
||||||
|
value = ServiceNameConstants.MALL_COUPON_SERVICE)
|
||||||
|
public interface RemoteCouponFeign {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存spu优惠信息接口
|
||||||
|
*/
|
||||||
|
@PostMapping("/coupon/spubounds/save")
|
||||||
|
R saveSpuBounds(@RequestBody SpuBoundTo spuBoundTo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存满减、会员价信息接口
|
||||||
|
* @param skuReductionTo 满减信息
|
||||||
|
* @return R
|
||||||
|
*/
|
||||||
|
@PostMapping("/coupon/skufullreduction/saveinfo")
|
||||||
|
R saveSkuReduction(@RequestBody SkuReductionTo skuReductionTo);
|
||||||
|
}
|
@ -1,21 +1,26 @@
|
|||||||
|
|
||||||
package com.xjs.to;
|
package com.xjs.mall.to;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Auto-generated: 2019-11-26 10:50:34
|
* 会员价vo
|
||||||
*
|
* @author xiejs
|
||||||
* @author bejson.com (i@bejson.com)
|
* @since 2022-03-20 13:51:55
|
||||||
* @website http://www.bejson.com/java2pojo/
|
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class MemberPrice {
|
public class MemberPrice {
|
||||||
|
|
||||||
private Long id;
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 会员名称
|
||||||
|
*/
|
||||||
private String name;
|
private String name;
|
||||||
|
/**
|
||||||
|
* 会员价格
|
||||||
|
*/
|
||||||
private BigDecimal price;
|
private BigDecimal price;
|
||||||
|
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.xjs.to;
|
package com.xjs.mall.to;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
@ -0,0 +1,10 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
// 保存spu关联的所有信息
|
||||||
|
export function saveSpuInfo(data) {
|
||||||
|
return request({
|
||||||
|
url: '/mall-product/product/spuinfo/save',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
@ -0,0 +1,73 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<el-select placeholder="请选择" v-model="brandId" filterable clearable>
|
||||||
|
<el-option
|
||||||
|
v-for="item in brands"
|
||||||
|
:key="item.brandId"
|
||||||
|
:label="item.brandName"
|
||||||
|
:value="item.brandId"
|
||||||
|
></el-option>
|
||||||
|
</el-select>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
import {catelogList} from "@/api/mall/product/brand";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {},
|
||||||
|
props: {},
|
||||||
|
data() {
|
||||||
|
//这里存放数据
|
||||||
|
return {
|
||||||
|
catId: 0,
|
||||||
|
brands: [
|
||||||
|
{
|
||||||
|
label: "a",
|
||||||
|
value: 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
brandId: "",
|
||||||
|
subscribe: null
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {},
|
||||||
|
//监控data中的数据变化
|
||||||
|
watch: {
|
||||||
|
brandId(val) {
|
||||||
|
this.PubSub.publish("brandId", val);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
//方法集合
|
||||||
|
methods: {
|
||||||
|
getCatBrands() {
|
||||||
|
let catId = {
|
||||||
|
brand: this.catId
|
||||||
|
}
|
||||||
|
catelogList(catId).then(res => {
|
||||||
|
this.brands = res.data;
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
created() {
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
//监听三级分类消息的变化
|
||||||
|
this.subscribe = PubSub.subscribe("catPath", (msg, val) => {
|
||||||
|
this.catId = val[val.length - 1];
|
||||||
|
this.getCatBrands();
|
||||||
|
});
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
beforeDestroy() {
|
||||||
|
PubSub.unsubscribe(this.subscribe); //销毁订阅
|
||||||
|
},
|
||||||
|
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<style scoped>
|
||||||
|
</style>
|
@ -0,0 +1,89 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form :inline="true" :model="dataForm">
|
||||||
|
<el-form-item label="分类">
|
||||||
|
<category-cascader :catelogPath.sync="catelogPath"></category-cascader>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="品牌">
|
||||||
|
<brand-select style="width:160px"></brand-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="状态">
|
||||||
|
<el-select style="width:160px" v-model="dataForm.status" clearable>
|
||||||
|
<el-option label="新建" :value="0"></el-option>
|
||||||
|
<el-option label="上架" :value="1"></el-option>
|
||||||
|
<el-option label="下架" :value="2"></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="检索">
|
||||||
|
<el-input style="width:160px" v-model="dataForm.key" clearable></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" @click="searchSpuInfo">查询</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="24">
|
||||||
|
<spuinfo :catId="catId"></spuinfo>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import CategoryCascader from '../../../components/mall/category-cascader'
|
||||||
|
import BrandSelect from "../../../components/mall/brand-select";
|
||||||
|
import Spuinfo from "./spuinfo";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
//import引入的组件需要注入到对象中才能使用
|
||||||
|
components: {CategoryCascader, Spuinfo, BrandSelect},
|
||||||
|
props: {},
|
||||||
|
name: "SpuList",
|
||||||
|
data() {
|
||||||
|
//这里存放数据
|
||||||
|
return {
|
||||||
|
catId: 0,
|
||||||
|
catelogPath: [],
|
||||||
|
dataForm: {
|
||||||
|
status: "",
|
||||||
|
key: "",
|
||||||
|
brandId: 0,
|
||||||
|
catelogId: 0
|
||||||
|
},
|
||||||
|
catPathSub: null,
|
||||||
|
brandIdSub: null
|
||||||
|
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {},
|
||||||
|
//监控data中的数据变化
|
||||||
|
watch: {},
|
||||||
|
//方法集合
|
||||||
|
methods: {
|
||||||
|
searchSpuInfo() {
|
||||||
|
console.log("搜索条件", this.dataForm);
|
||||||
|
this.PubSub.publish("dataForm", this.dataForm);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.catPathSub = PubSub.subscribe("catPath", (msg, val) => {
|
||||||
|
this.dataForm.catelogId = val[val.length - 1];
|
||||||
|
});
|
||||||
|
this.brandIdSub = PubSub.subscribe("brandId", (msg, val) => {
|
||||||
|
this.dataForm.brandId = val;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
beforeDestroy() {
|
||||||
|
PubSub.unsubscribe(this.catPathSub);
|
||||||
|
PubSub.unsubscribe(this.brandIdSub);
|
||||||
|
},
|
||||||
|
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<style scoped>
|
||||||
|
</style>
|
@ -0,0 +1,153 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<el-table
|
||||||
|
:data="dataList"
|
||||||
|
border
|
||||||
|
v-loading="dataListLoading"
|
||||||
|
@selection-change="selectionChangeHandle"
|
||||||
|
style="width: 100%;"
|
||||||
|
>
|
||||||
|
<el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
|
||||||
|
<el-table-column prop="spuName" header-align="center" align="center" label="名称"></el-table-column>
|
||||||
|
<el-table-column prop="spuDescription" header-align="center" align="center" label="描述"></el-table-column>
|
||||||
|
<el-table-column prop="catalogId" header-align="center" align="center" label="分类"></el-table-column>
|
||||||
|
<el-table-column prop="brandId" header-align="center" align="center" label="品牌"></el-table-column>
|
||||||
|
<el-table-column prop="weight" header-align="center" align="center" label="重量"></el-table-column>
|
||||||
|
<el-table-column prop="publishStatus" header-align="center" align="center" label="上架状态">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-tag v-if="scope.row.publishStatus === 0">新建</el-tag>
|
||||||
|
<el-tag v-if="scope.row.publishStatus === 1">已上架</el-tag>
|
||||||
|
<el-tag v-if="scope.row.publishStatus === 2">已下架</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="createTime" header-align="center" align="center" label="创建时间"></el-table-column>
|
||||||
|
<el-table-column prop="updateTime" header-align="center" align="center" label="修改时间"></el-table-column>
|
||||||
|
<el-table-column fixed="right" header-align="center" align="center" width="150" label="操作">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-button
|
||||||
|
v-if="scope.row.publishStatus === 0"
|
||||||
|
type="text"
|
||||||
|
size="small"
|
||||||
|
@click="productUp(scope.row.id)"
|
||||||
|
>上架</el-button>
|
||||||
|
<el-button type="text" size="small" @click="attrUpdateShow(scope.row)">规格</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<el-pagination
|
||||||
|
@size-change="sizeChangeHandle"
|
||||||
|
@current-change="currentChangeHandle"
|
||||||
|
:current-page="pageIndex"
|
||||||
|
:page-sizes="[10, 20, 50, 100]"
|
||||||
|
:page-size="pageSize"
|
||||||
|
:total="totalPage"
|
||||||
|
layout="total, sizes, prev, pager, next, jumper"
|
||||||
|
></el-pagination>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
dataSub: null,
|
||||||
|
dataForm: {},
|
||||||
|
dataList: [],
|
||||||
|
pageIndex: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
totalPage: 0,
|
||||||
|
dataListLoading: false,
|
||||||
|
dataListSelections: [],
|
||||||
|
addOrUpdateVisible: false
|
||||||
|
};
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
catId: {
|
||||||
|
type: Number,
|
||||||
|
default: 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
components: {},
|
||||||
|
activated() {
|
||||||
|
this.getDataList();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
productUp(id) {
|
||||||
|
this.$http({
|
||||||
|
url: this.$http.adornUrl("/product/spuinfo/" + id + "/up"),
|
||||||
|
method: "post"
|
||||||
|
}).then(({ data }) => {
|
||||||
|
if (data && data.code === 0) {
|
||||||
|
this.$message({
|
||||||
|
message: "操作成功",
|
||||||
|
type: "success",
|
||||||
|
duration: 1500,
|
||||||
|
onClose: () => {
|
||||||
|
this.getDataList();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.$message.error(data.msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
attrUpdateShow(row) {
|
||||||
|
console.log(row);
|
||||||
|
this.$router.push({
|
||||||
|
path: "/product-attrupdate",
|
||||||
|
query: { spuId: row.id, catalogId: row.catalogId }
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 获取数据列表
|
||||||
|
getDataList() {
|
||||||
|
this.dataListLoading = true;
|
||||||
|
let param = {};
|
||||||
|
Object.assign(param, this.dataForm, {
|
||||||
|
page: this.pageIndex,
|
||||||
|
limit: this.pageSize
|
||||||
|
});
|
||||||
|
this.$http({
|
||||||
|
url: this.$http.adornUrl("/product/spuinfo/list"),
|
||||||
|
method: "get",
|
||||||
|
params: this.$http.adornParams(param)
|
||||||
|
}).then(({ data }) => {
|
||||||
|
if (data && data.code === 0) {
|
||||||
|
this.dataList = data.page.list;
|
||||||
|
this.totalPage = data.page.totalCount;
|
||||||
|
} else {
|
||||||
|
this.dataList = [];
|
||||||
|
this.totalPage = 0;
|
||||||
|
}
|
||||||
|
this.dataListLoading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 每页数
|
||||||
|
sizeChangeHandle(val) {
|
||||||
|
this.pageSize = val;
|
||||||
|
this.pageIndex = 1;
|
||||||
|
this.getDataList();
|
||||||
|
},
|
||||||
|
// 当前页
|
||||||
|
currentChangeHandle(val) {
|
||||||
|
this.pageIndex = val;
|
||||||
|
this.getDataList();
|
||||||
|
},
|
||||||
|
// 多选
|
||||||
|
selectionChangeHandle(val) {
|
||||||
|
this.dataListSelections = val;
|
||||||
|
},
|
||||||
|
// 新增 / 修改
|
||||||
|
addOrUpdateHandle(id) {}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.dataSub = PubSub.subscribe("dataForm", (msg, val) => {
|
||||||
|
this.dataForm = val;
|
||||||
|
this.getDataList();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
beforeDestroy() {
|
||||||
|
PubSub.unsubscribe(this.dataSub);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
@ -1,29 +1,164 @@
|
|||||||
package com.xjs.mall.product.service.impl;
|
package com.xjs.mall.product.service.impl;
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import java.util.Map;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
|
import com.xjs.mall.RemoteCouponFeign;
|
||||||
|
import com.xjs.mall.product.dao.SpuInfoDao;
|
||||||
|
import com.xjs.mall.product.entity.*;
|
||||||
|
import com.xjs.mall.product.service.*;
|
||||||
|
import com.xjs.mall.product.vo.spu.*;
|
||||||
|
import com.xjs.mall.to.SkuReductionTo;
|
||||||
|
import com.xjs.mall.to.SpuBoundTo;
|
||||||
import com.xjs.utils.PageUtils;
|
import com.xjs.utils.PageUtils;
|
||||||
import com.xjs.utils.Query;
|
import com.xjs.utils.Query;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import com.xjs.mall.product.dao.SpuInfoDao;
|
import javax.annotation.Resource;
|
||||||
import com.xjs.mall.product.entity.SpuInfoEntity;
|
import java.math.BigDecimal;
|
||||||
import com.xjs.mall.product.service.SpuInfoService;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
@Service("spuInfoService")
|
@Service("spuInfoService")
|
||||||
|
@Transactional
|
||||||
public class SpuInfoServiceImpl extends ServiceImpl<SpuInfoDao, SpuInfoEntity> implements SpuInfoService {
|
public class SpuInfoServiceImpl extends ServiceImpl<SpuInfoDao, SpuInfoEntity> implements SpuInfoService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SpuInfoDescService spuInfoDescService;
|
||||||
|
@Autowired
|
||||||
|
private SpuImagesService spuImagesService;
|
||||||
|
@Autowired
|
||||||
|
private ProductAttrValueService productAttrValueService;
|
||||||
|
@Autowired
|
||||||
|
private SkuInfoService skuInfoService;
|
||||||
|
@Autowired
|
||||||
|
private SkuImagesService skuImagesService;
|
||||||
|
@Autowired
|
||||||
|
private SkuSaleAttrValueService skuSaleAttrValueService;
|
||||||
|
@Resource
|
||||||
|
private RemoteCouponFeign remoteCouponFeign;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageUtils queryPage(Map<String, Object> params) {
|
public PageUtils queryPage(Map<String, Object> params) {
|
||||||
IPage<SpuInfoEntity> page = this.page(
|
IPage<SpuInfoEntity> page = this.page(
|
||||||
new Query<SpuInfoEntity>().getPage(params),
|
new Query<SpuInfoEntity>().getPage(params),
|
||||||
new QueryWrapper<SpuInfoEntity>()
|
new QueryWrapper<>()
|
||||||
);
|
);
|
||||||
|
|
||||||
return new PageUtils(page);
|
return new PageUtils(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
@Override
|
||||||
|
public void saveSpuInfo(SpuSaveVo spuSaveVo) {
|
||||||
|
//1、保存spu基本信息 pms_spu_info
|
||||||
|
SpuInfoEntity spuInfoEntity = new SpuInfoEntity();
|
||||||
|
BeanUtils.copyProperties(spuSaveVo, spuInfoEntity);
|
||||||
|
spuInfoEntity.setCreateTime(new Date());
|
||||||
|
spuInfoEntity.setUpdateTime(new Date());
|
||||||
|
this.saveBaseSpuInfo(spuInfoEntity);
|
||||||
|
//---------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
//2、保存spu的描述图片 pms_spu_info_desc
|
||||||
|
List<String> decript = spuSaveVo.getDecript();
|
||||||
|
SpuInfoDescEntity descEntity = new SpuInfoDescEntity();
|
||||||
|
descEntity.setSpuId(spuInfoEntity.getId());
|
||||||
|
descEntity.setDecript(String.join(",", decript)); //把list集合用 , 分割成字符串
|
||||||
|
spuInfoDescService.saveSpuInfoDesc(descEntity);
|
||||||
|
//---------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
//3、保存spu的图片集 pms_spu_images
|
||||||
|
List<String> images = spuSaveVo.getImages();
|
||||||
|
spuImagesService.saveImages(spuInfoEntity.getId(), images);
|
||||||
|
//---------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
//4、保存spu的规格参数 pms_product_attr_value
|
||||||
|
List<BaseAttrs> baseAttrs = spuSaveVo.getBaseAttrs();
|
||||||
|
productAttrValueService.saveProductAttr(baseAttrs, spuInfoEntity.getId());
|
||||||
|
//---------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// 保存spu的积分信息
|
||||||
|
Bounds bounds = spuSaveVo.getBounds();
|
||||||
|
SpuBoundTo spuBoundTo = new SpuBoundTo(); //服务之间调用传输对象To
|
||||||
|
BeanUtils.copyProperties(bounds, spuBoundTo);
|
||||||
|
spuBoundTo.setSpuId(spuInfoEntity.getId());
|
||||||
|
remoteCouponFeign.saveSpuBounds(spuBoundTo);
|
||||||
|
|
||||||
|
//5、保存当前spu对应的sku信息
|
||||||
|
//---------------------------------------------------------------------------------------------------------
|
||||||
|
//5.1、保存sku的基本信息 pms_sku_info
|
||||||
|
List<Skus> skus = spuSaveVo.getSkus();
|
||||||
|
if (CollUtil.isNotEmpty(skus)) {
|
||||||
|
skus.forEach(item -> {
|
||||||
|
|
||||||
|
String defaultImg = "";
|
||||||
|
for (Images image : item.getImages()) {
|
||||||
|
if (image.getDefaultImg() == 1) { //判断是默认图片
|
||||||
|
defaultImg = image.getImgUrl();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SkuInfoEntity skuInfoEntity = new SkuInfoEntity();
|
||||||
|
BeanUtils.copyProperties(item, skuInfoEntity);
|
||||||
|
skuInfoEntity.setBrandId(spuInfoEntity.getBrandId());
|
||||||
|
skuInfoEntity.setCatalogId(spuInfoEntity.getCatalogId());
|
||||||
|
skuInfoEntity.setSaleCount(0L); //销量默认0
|
||||||
|
skuInfoEntity.setSpuId(spuInfoEntity.getId());
|
||||||
|
skuInfoEntity.setSkuDefaultImg(defaultImg);
|
||||||
|
skuInfoService.saveSkuInfo(skuInfoEntity);
|
||||||
|
//---------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Long skuId = skuInfoEntity.getSkuId();
|
||||||
|
|
||||||
|
//5.2、保存sku的图片信息
|
||||||
|
List<SkuImagesEntity> imagesEntities = item.getImages().stream().map(img -> {
|
||||||
|
SkuImagesEntity skuImagesEntity = new SkuImagesEntity();
|
||||||
|
skuImagesEntity.setSkuId(skuId);
|
||||||
|
skuImagesEntity.setImgUrl(img.getImgUrl());
|
||||||
|
skuImagesEntity.setDefaultImg(img.getDefaultImg());
|
||||||
|
return skuImagesEntity;
|
||||||
|
}).filter(entity ->
|
||||||
|
StringUtils.isNotEmpty(entity.getImgUrl())
|
||||||
|
).collect(Collectors.toList());
|
||||||
|
skuImagesService.saveBatch(imagesEntities);
|
||||||
|
//---------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
//5.3、保存sku的销售属性信息
|
||||||
|
List<Attr> attr = item.getAttr();
|
||||||
|
List<SkuSaleAttrValueEntity> skuSaleAttrValueEntities = attr.stream().map(a -> {
|
||||||
|
SkuSaleAttrValueEntity skuSaleAttrValueEntity = new SkuSaleAttrValueEntity();
|
||||||
|
BeanUtils.copyProperties(a, skuSaleAttrValueEntity);
|
||||||
|
skuSaleAttrValueEntity.setSkuId(skuId);
|
||||||
|
return skuSaleAttrValueEntity;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
skuSaleAttrValueService.saveBatch(skuSaleAttrValueEntities);
|
||||||
|
//---------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
//5.4、保存sku的优惠满减等信息
|
||||||
|
SkuReductionTo skuReductionTo = new SkuReductionTo();
|
||||||
|
BeanUtils.copyProperties(item, skuReductionTo);
|
||||||
|
skuReductionTo.setSkuId(skuId);
|
||||||
|
if (skuReductionTo.getFullCount() > 0 &&
|
||||||
|
skuReductionTo.getFullPrice().compareTo(new BigDecimal("0")) == 1) {
|
||||||
|
remoteCouponFeign.saveSkuReduction(skuReductionTo);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveBaseSpuInfo(SpuInfoEntity spuInfoEntity) {
|
||||||
|
super.baseMapper.insert(spuInfoEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -0,0 +1,40 @@
|
|||||||
|
package com.xjs.mall.product.vo;
|
||||||
|
|
||||||
|
import com.xjs.mall.product.entity.AttrEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* attr分组和attrVo
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class AttrGroupWithAttrsVo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分组id
|
||||||
|
*/
|
||||||
|
private Long attrGroupId;
|
||||||
|
/**
|
||||||
|
* 组名
|
||||||
|
*/
|
||||||
|
private String attrGroupName;
|
||||||
|
/**
|
||||||
|
* 排序
|
||||||
|
*/
|
||||||
|
private Integer sort;
|
||||||
|
/**
|
||||||
|
* 描述
|
||||||
|
*/
|
||||||
|
private String descript;
|
||||||
|
/**
|
||||||
|
* 组图标
|
||||||
|
*/
|
||||||
|
private String icon;
|
||||||
|
/**
|
||||||
|
* 所属分类id
|
||||||
|
*/
|
||||||
|
private Long catelogId;
|
||||||
|
|
||||||
|
private List<AttrEntity> attrs;
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2019 bejson.com
|
||||||
|
*/
|
||||||
|
package com.xjs.mall.product.vo.spu;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*属性vo
|
||||||
|
* @author xiejs
|
||||||
|
* @since 2022-03-20 13:49:29
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class Attr {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 属性Id
|
||||||
|
*/
|
||||||
|
private Long attrId;
|
||||||
|
/**
|
||||||
|
* 属性名称
|
||||||
|
*/
|
||||||
|
private String attrName;
|
||||||
|
/**
|
||||||
|
* 属性值
|
||||||
|
*/
|
||||||
|
private String attrValue;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
|
||||||
|
package com.xjs.mall.product.vo.spu;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 基本属性vo
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class BaseAttrs {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 属性Id
|
||||||
|
*/
|
||||||
|
private Long attrId;
|
||||||
|
/**
|
||||||
|
* 属性值
|
||||||
|
*/
|
||||||
|
private String attrValues;
|
||||||
|
/**
|
||||||
|
* 属性描述状态
|
||||||
|
*/
|
||||||
|
private Integer showDesc;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2019 bejson.com
|
||||||
|
*/
|
||||||
|
package com.xjs.mall.product.vo.spu;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class Bounds {
|
||||||
|
|
||||||
|
private BigDecimal buyBounds;
|
||||||
|
private BigDecimal growBounds;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2019 bejson.com
|
||||||
|
*/
|
||||||
|
package com.xjs.mall.product.vo.spu;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*图集vo
|
||||||
|
* @author xiejs
|
||||||
|
* @since 2022-03-20 13:50:18
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class Images {
|
||||||
|
/**
|
||||||
|
* 图片地址
|
||||||
|
*/
|
||||||
|
private String imgUrl;
|
||||||
|
/**
|
||||||
|
* 默认数量
|
||||||
|
*/
|
||||||
|
private Integer defaultImg;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,86 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2019 bejson.com
|
||||||
|
*/
|
||||||
|
package com.xjs.mall.product.vo.spu;
|
||||||
|
|
||||||
|
import com.xjs.mall.to.MemberPrice;
|
||||||
|
import com.xjs.validation.group.AddGroup;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.Min;
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*sku vo
|
||||||
|
* @author xiejs
|
||||||
|
* @since 2022-03-20 13:48:50
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class Skus {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 属性bean
|
||||||
|
*/
|
||||||
|
private List<Attr> attr;
|
||||||
|
/**
|
||||||
|
* sku名称
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "sku名称不能为空", groups = {AddGroup.class})
|
||||||
|
private String skuName;
|
||||||
|
/**
|
||||||
|
* 价格
|
||||||
|
*/
|
||||||
|
@NotNull(message = "价格不能为空", groups = {AddGroup.class})
|
||||||
|
@Min(message = "价格应该大于 0 ", groups = {AddGroup.class},value = 1)
|
||||||
|
private BigDecimal price;
|
||||||
|
/**
|
||||||
|
* sku标题
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "sku标题不能为空", groups = {AddGroup.class})
|
||||||
|
private String skuTitle;
|
||||||
|
/**
|
||||||
|
* sku副标题
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "sku副标题不能为空", groups = {AddGroup.class})
|
||||||
|
private String skuSubtitle;
|
||||||
|
/**
|
||||||
|
* 图集
|
||||||
|
*/
|
||||||
|
private List<Images> images;
|
||||||
|
/**
|
||||||
|
* 图集描述
|
||||||
|
*/
|
||||||
|
private List<String> descar;
|
||||||
|
/**
|
||||||
|
* 满多少满减
|
||||||
|
*/
|
||||||
|
private Integer fullCount;
|
||||||
|
/**
|
||||||
|
* 满减数量
|
||||||
|
*/
|
||||||
|
private BigDecimal discount;
|
||||||
|
|
||||||
|
private Integer countStatus;
|
||||||
|
/**
|
||||||
|
* 正常价格
|
||||||
|
*/
|
||||||
|
private BigDecimal fullPrice;
|
||||||
|
/**
|
||||||
|
* 优惠价格
|
||||||
|
*/
|
||||||
|
private BigDecimal reducePrice;
|
||||||
|
/**
|
||||||
|
* 价格状态
|
||||||
|
*/
|
||||||
|
private Integer priceStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员bean
|
||||||
|
*/
|
||||||
|
private List<MemberPrice> memberPrice;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,80 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2019 bejson.com
|
||||||
|
*/
|
||||||
|
package com.xjs.mall.product.vo.spu;
|
||||||
|
|
||||||
|
import com.xjs.validation.group.AddGroup;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Spu保存的vo
|
||||||
|
* @author xiejs
|
||||||
|
* @since 2022-03-20 13:42:13
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class SpuSaveVo {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* spu名称
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "商品名称不能为空",groups = {AddGroup.class})
|
||||||
|
@Size(message = "商品名称长度在 1 到 100 之间",groups = {AddGroup.class},max = 100)
|
||||||
|
private String spuName;
|
||||||
|
/**
|
||||||
|
* spu描述
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "商品描述不能为空",groups = {AddGroup.class})
|
||||||
|
@Size(message = "商品描述长度在 1 到 200 之间",groups = {AddGroup.class},max = 200)
|
||||||
|
private String spuDescription;
|
||||||
|
/**
|
||||||
|
* 三级分类id
|
||||||
|
*/
|
||||||
|
@NotNull(message = "三级分类不能为空",groups = {AddGroup.class})
|
||||||
|
private Long catalogId;
|
||||||
|
/**
|
||||||
|
* 品牌id
|
||||||
|
*/
|
||||||
|
@NotNull(message = "品牌不能为空",groups = {AddGroup.class})
|
||||||
|
private Long brandId;
|
||||||
|
/**
|
||||||
|
* 重量
|
||||||
|
*/
|
||||||
|
@NotNull(message = "商品重量不能为空",groups = {AddGroup.class})
|
||||||
|
private BigDecimal weight;
|
||||||
|
/**
|
||||||
|
* 发布状态
|
||||||
|
*/
|
||||||
|
private Integer publishStatus;
|
||||||
|
/**
|
||||||
|
* 图集描述
|
||||||
|
*/
|
||||||
|
private List<String> decript;
|
||||||
|
/**
|
||||||
|
* 图集
|
||||||
|
*/
|
||||||
|
private List<String> images;
|
||||||
|
|
||||||
|
@Valid
|
||||||
|
private Bounds bounds;
|
||||||
|
/**
|
||||||
|
* 基本属性
|
||||||
|
*/
|
||||||
|
@Valid
|
||||||
|
private List<BaseAttrs> baseAttrs;
|
||||||
|
/**
|
||||||
|
* sku
|
||||||
|
*/
|
||||||
|
@Valid
|
||||||
|
private List<Skus> skus;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in new issue