1、发布商品实现

2、通用类路径调整
pull/254/head
xjs 4 years ago
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);
}

@ -6,9 +6,9 @@
*
*/
package com.xjs.utils;
package com.xjs.mall.other;
import org.apache.http.HttpStatus;
import com.ruoyi.common.core.constant.HttpStatus;
import java.util.HashMap;
import java.util.Map;
@ -27,11 +27,11 @@ public class R extends HashMap<String, Object> {
}
public static R error() {
return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, "未知异常,请联系管理员");
return error(HttpStatus.ERROR, "未知异常,请联系管理员");
}
public static R error(String msg) {
return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, msg);
return error(HttpStatus.ERROR, msg);
}
public static R error(int code, String msg) {

@ -1,21 +1,26 @@
package com.xjs.to;
package com.xjs.mall.to;
import lombok.Data;
import java.math.BigDecimal;
/**
* Auto-generated: 2019-11-26 10:50:34
*
* @author bejson.com (i@bejson.com)
* @website http://www.bejson.com/java2pojo/
* vo
* @author xiejs
* @since 2022-03-20 13:51:55
*/
@Data
public class MemberPrice {
private Long id;
/**
*
*/
private String name;
/**
*
*/
private BigDecimal price;
}

@ -1,4 +1,4 @@
package com.xjs.to;
package com.xjs.mall.to;
import lombok.Data;
@ -9,10 +9,22 @@ import java.util.List;
public class SkuReductionTo {
private Long skuId;
/**
*
*/
private int fullCount;
/**
*
*/
private BigDecimal discount;
private int countStatus;
/**
*
*/
private BigDecimal fullPrice;
/**
*
*/
private BigDecimal reducePrice;
private int priceStatus;
private List<MemberPrice> memberPrice;

@ -5,8 +5,7 @@ package com.ruoyi.common.core.constant;
*
* @author ruoyi
*/
public class ServiceNameConstants
{
public class ServiceNameConstants {
/**
* serviceid
*/
@ -43,9 +42,10 @@ public class ServiceNameConstants
*/
public static final String BUSINESS_WEBMAGIC_SERVICE = "xjs-webmagic";
/**
* serviceid
*/
public static final String MALL_COUPON_SERVICE = "xjs-mall-coupon";
}

@ -50,6 +50,7 @@
"js-cookie": "3.0.1",
"jsencrypt": "3.2.1",
"nprogress": "0.2.0",
"pubsub-js": "^1.9.4",
"quill": "1.3.7",
"screenfull": "5.0.2",
"sortablejs": "1.10.2",

@ -70,6 +70,14 @@ export function addRelation(ids) {
})
}
// 根据分类id获取分类属性
export function getAttrGroupWithAttrs(catelogId) {
return request({
url: `/mall-product/product/attrgroup/${catelogId}/withattr`,
method: 'get',
})
}

@ -44,5 +44,14 @@ export function delBrand(ids) {
})
}
// 根据分类id找到品牌
export function catelogList(catId) {
return request({
url: '/mall-product/product/categorybrandrelation/brands/list',
method: 'get',
params:catId
})
}

@ -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
})
}

@ -9,7 +9,9 @@
:on-remove="handleRemove"
:on-success="handleUploadSuccess"
:on-preview="handlePreview"
:before-remove="removeImg"
:limit="maxCount"
accept="image/*"
:on-exceed="handleExceed"
>
<i class="el-icon-plus"></i>
@ -20,7 +22,7 @@
</div>
</template>
<script>
import { policy } from "./policy";
import {policy, removeImg} from "@/api/common";
import { getUUID } from '@/utils'
export default {
name: "multiUpload",
@ -74,12 +76,22 @@ export default {
this.dialogVisible = true;
this.dialogImageUrl = file.url;
},
beforeUpload(file) {
let _self = this;
return new Promise((resolve, reject) => {
let isRightSize = file.size / 1024 / 1024 < 10
if (!isRightSize) {
this.$message.error('文件大小超过 10MB')
}
let isAccept = new RegExp('image/*').test(file.type)
if (!isAccept) {
this.$message.error('应该选择image/*类型的文件')
}
if (isRightSize && isAccept) {
policy()
.then(response => {
console.log("这是什么${filename}");
_self.dataObj.policy = response.data.policy;
_self.dataObj.signature = response.data.signature;
_self.dataObj.ossaccessKeyId = response.data.accessid;
@ -92,8 +104,15 @@ export default {
console.log("出错了...",err)
reject(false);
});
}else {
reject(false);
}
});
},
handleUploadSuccess(res, file) {
this.fileList.push({
name: file.name,
@ -108,7 +127,17 @@ export default {
type: "warning",
duration: 1000
});
},
//
removeImg(file,fileList) {
if (file.url) {
let pictureUrl = {"url": file.url};
removeImg(pictureUrl).then(res => {
})
this.emitInput('');
}
},
}
};
</script>

@ -37,6 +37,8 @@ import DictTag from '@/components/DictTag'
import VueMeta from 'vue-meta'
// 字典数据组件
import DictData from '@/components/DictData'
// 消息发布订阅组件
import PubSub from 'pubsub-js'
// 全局方法挂载
Vue.prototype.getDicts = getDicts
@ -48,6 +50,7 @@ Vue.prototype.selectDictLabel = selectDictLabel
Vue.prototype.selectDictLabels = selectDictLabels
Vue.prototype.download = download
Vue.prototype.handleTree = handleTree
Vue.prototype.PubSub = PubSub //组件发布订阅消息
// 全局组件挂载
Vue.component('DictTag', DictTag)

@ -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>

@ -51,6 +51,7 @@ export default {
},
paths(v) {
this.$emit("update:catelogPath", v);
this.PubSub.publish("catPath", v);
}
},
//
@ -59,11 +60,14 @@ export default {
getMenus().then(res => {
this.categorys = res.page
})
}
},
},
created() {
this.getCategorys();
},
mounted() {
}
};
</script>

@ -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,799 @@
<template>
<div class="app-container">
<el-row>
<el-col :span="24">
<el-steps :active="step" finish-status="success">
<el-step title="基本信息"></el-step>
<el-step title="规格参数"></el-step>
<el-step title="销售属性"></el-step>
<el-step title="SKU信息"></el-step>
<el-step title="保存完成"></el-step>
</el-steps>
</el-col>
<el-col :span="24" v-show="step===0">
<el-card class="box-card" style="width:80%;margin:20px auto">
<el-form ref="spuBaseForm" :model="spu" label-width="120px" :rules="spuBaseInfoRules">
<el-form-item label="商品名称" prop="spuName">
<el-input v-model="spu.spuName"></el-input>
</el-form-item>
<el-form-item label="商品描述" prop="spuDescription">
<el-input v-model="spu.spuDescription"></el-input>
</el-form-item>
<el-form-item label="选择分类" prop="catalogId">
<category-cascader></category-cascader>
</el-form-item>
<el-form-item label="选择品牌" prop="brandId">
<brand-select></brand-select>
</el-form-item>
<el-form-item label="商品重量(Kg)" prop="weight">
<el-input-number v-model.number="spu.weight" :min="0" :precision="3" :step="0.1"></el-input-number>
</el-form-item>
<el-form-item label="设置积分" prop="bounds">
<label>金币</label>
<el-input-number
style="width:130px"
placeholder="金币"
v-model="spu.bounds.buyBounds"
:min="0"
controls-position="right"
></el-input-number>
<label style="margin-left:15px">成长值</label>
<el-input-number
style="width:130px"
placeholder="成长值"
v-model="spu.bounds.growBounds"
:min="0"
controls-position="right"
>
<template slot="prepend">成长值</template>
</el-input-number>
</el-form-item>
<el-form-item label="商品介绍" prop="decript">
<multi-upload v-model="spu.decript"></multi-upload>
</el-form-item>
<el-form-item label="商品图集" prop="images">
<multi-upload v-model="spu.images"></multi-upload>
</el-form-item>
<el-form-item>
<el-button type="success" @click="collectSpuBaseInfo"></el-button>
</el-form-item>
</el-form>
</el-card>
</el-col>
<el-col :span="24" v-show="step===1">
<el-card class="box-card" style="width:80%;margin:20px auto">
<el-tabs tab-position="left" style="width:98%">
<el-tab-pane
:label="group.attrGroupName"
v-for="(group,gidx) in dataResp.attrGroups"
:key="group.attrGroupId"
>
<!-- 遍历属性,每个tab-pane对应一个表单每个属性是一个表单项 spu.baseAttrs[0] = [{attrId:xx,val:}]-->
<el-form ref="form" :model="spu">
<el-form-item
label-width="90px"
:label="attr.attrName"
v-for="(attr,aidx) in group.attrs"
:key="attr.attrId"
>
<el-input
v-model="dataResp.baseAttrs[gidx][aidx].attrId"
type="hidden"
v-show="false"
></el-input>
<el-select
v-model="dataResp.baseAttrs[gidx][aidx].attrValues"
:multiple="attr.valueType === 1"
filterable
allow-create
default-first-option
placeholder="请选择或输入值"
>
<el-option
v-for="(val,vidx) in attr.valueSelect.split(';')"
:key="vidx"
:label="val"
:value="val"
></el-option>
</el-select>
<el-checkbox
style="margin-left: 20px"
v-model="dataResp.baseAttrs[gidx][aidx].showDesc"
:true-label="1"
:false-label="0"
>快速展示
</el-checkbox>
</el-form-item>
</el-form>
</el-tab-pane>
</el-tabs>
<div style="margin-top: 20px">
<el-button type="primary" @click="step = 0">上一步</el-button>
<el-button type="success" @click="generateSaleAttrs"></el-button>
</div>
</el-card>
</el-col>
<el-col :span="24" v-show="step===2">
<el-card class="box-card" style="width:80%;margin:20px auto">
<el-card class="box-card">
<div slot="header" class="clearfix">
<span style="font-size: 15px;font-weight: 800">选择销售属性</span>
<el-form ref="saleform" :model="spu">
<el-form-item
label-width="90px"
:label="attr.attrName"
v-for="(attr,aidx) in dataResp.saleAttrs"
:key="attr.attrId"
>
<el-input
v-model="dataResp.tempSaleAttrs[aidx].attrId"
type="hidden"
v-show="false"
></el-input>
<el-checkbox-group v-model="dataResp.tempSaleAttrs[aidx].attrValues">
<el-checkbox
v-if="dataResp.saleAttrs[aidx].valueSelect !== ''"
:label="val"
v-for="val in dataResp.saleAttrs[aidx].valueSelect.split(';')"
:key="val"
></el-checkbox>
<div style="margin-left:20px;display:inline">
<el-button
v-show="!inputVisible[aidx].view"
class="button-new-tag"
size="mini"
@click="showInput(aidx)"
>+自定义
</el-button>
<el-input
v-show="inputVisible[aidx].view"
v-model="inputValue[aidx].val"
:ref="'saveTagInput'+aidx"
size="mini"
style="width:150px"
@keyup.enter.native="handleInputConfirm(aidx)"
@blur="handleInputConfirm(aidx)"
></el-input>
</div>
</el-checkbox-group>
</el-form-item>
</el-form>
</div>
<el-button type="primary" @click="step = 1">上一步</el-button>
<el-button type="success" @click="generateSkus">SKU</el-button>
</el-card>
</el-card>
</el-col>
<el-col :span="24" v-show="step===3">
<el-card class="box-card" style="width:80%;margin:20px auto">
<el-table :data="spu.skus" style="width: 100%">
<el-table-column label="属性组合" align="center">
<el-table-column align="center"
:label="item.attrName"
v-for="(item,index) in dataResp.tableAttrColumn"
:key="item.attrId"
>
<template slot-scope="scope">
<span style="margin-left: 10px">{{ scope.row.attr[index].attrValue }}</span>
</template>
</el-table-column>
</el-table-column>
<el-table-column label="商品名称" prop="skuName" align="center">
<template slot-scope="scope">
<el-input v-model="scope.row.skuName"></el-input>
</template>
</el-table-column>
<el-table-column label="标题" prop="skuTitle" align="center">
<template slot-scope="scope">
<el-input v-model="scope.row.skuTitle"></el-input>
</template>
</el-table-column>
<el-table-column label="副标题" prop="skuSubtitle" align="center">
<template slot-scope="scope">
<el-input v-model="scope.row.skuSubtitle"></el-input>
</template>
</el-table-column>
<el-table-column label="价格" prop="price" align="center">
<template slot-scope="scope">
<el-input v-model="scope.row.price"></el-input>
</template>
</el-table-column>
<el-table-column type="expand">
<template slot-scope="scope">
<el-row style="margin-top:15px;margin-left: 20px">
<el-col :span="24">
<label style="display:block;float:left">选择图集</label>
<multi-upload
style="float:left;margin-left:10px;"
:showFile="false"
:listType="'text'"
v-model="uploadImages"
></multi-upload>
</el-col>
<el-col :span="24">
<el-divider></el-divider>
</el-col>
<el-col :span="24">
<el-card
style="width:170px;float:left;margin-left:15px;margin-top:15px;"
:body-style="{ padding: '0px' }"
v-for="(img,index) in spu.images"
:key="index"
>
<img :src="img" style="width:160px;height:120px" alt=""/>
<div style="padding: 14px;">
<el-row>
<el-col :span="8">
<el-checkbox
v-model="scope.row.images[index].imgUrl"
:true-label="img"
false-label
></el-checkbox>
</el-col>
<el-col :span="8">
<el-tag v-if="scope.row.images[index].defaultImg === 1">
<input
type="radio"
checked
:name="scope.row.skuName"
@change="checkDefaultImg(scope.row,index,img)"
/>
</el-tag>
<el-tag v-else>
<input
type="radio"
:name="scope.row.skuName"
@change="checkDefaultImg(scope.row,index,img)"
/>
</el-tag>
</el-col>
</el-row>
</div>
</el-card>
</el-col>
</el-row>
<!-- 折扣满减会员价 -->
<el-form :model="scope.row" style="margin-top:35px;margin-left: 20px">
<el-row>
<el-col :span="24">
<el-form-item label="设置折扣">
<label></label>
<el-input-number
style="width:120px"
:min="0"
controls-position="right"
v-model="scope.row.fullCount"
></el-input-number>
<label></label>
<label style="margin-left:15px;"></label>
<el-input-number
style="width:120px"
v-model="scope.row.discount"
:precision="2"
:max="1"
:min="0"
:step="0.01"
controls-position="right"
></el-input-number>
<label></label>
<el-checkbox
style="margin-left: 15px"
v-model="scope.row.countStatus"
:true-label="1"
:false-label="0"
>可叠加优惠
</el-checkbox>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="设置满减">
<label></label>
<el-input-number
style="width:120px"
v-model="scope.row.fullPrice"
:step="100"
:min="0"
controls-position="right"
></el-input-number>
<label></label>
<label style="margin-left:15px;"></label>
<el-input-number
style="width:120px"
v-model="scope.row.reducePrice"
:step="10"
:min="0"
controls-position="right"
></el-input-number>
<label></label>
<el-checkbox
style="margin-left: 15px"
v-model="scope.row.priceStatus"
:true-label="1"
:false-label="0"
>可叠加优惠
</el-checkbox>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="设置会员价" v-if="scope.row.memberPrice.length>0">
<br/>
<!-- @change="handlePriceChange(scope,mpidx,$event)" -->
<el-form-item v-for="(mp,mpidx) in scope.row.memberPrice" :key="mp.id">
{{ mp.name }}
<el-input-number
style="width:120px"
v-model="scope.row.memberPrice[mpidx].price"
:precision="2"
:min="0"
controls-position="right"
></el-input-number>
</el-form-item>
</el-form-item>
</el-col>
</el-row>
</el-form>
</template>
</el-table-column>
</el-table>
<el-button type="primary" @click="step = 2">上一步</el-button>
<el-button type="success" @click="submitSkus" :loading="loadingButton">下一步保存商品信息</el-button>
</el-card>
</el-col>
<el-col :span="24" v-show="step===4">
<el-card class="box-card" style="width:80%;margin:20px auto">
<el-result icon="success" title="保存成功" subTitle="">
<template slot="extra">
</template>
</el-result>
<el-button type="primary" @click="addAgian"></el-button>
</el-card>
</el-col>
</el-row>
</div>
</template>
<script>
import CategoryCascader from '../../../components/mall/category-cascader'
import BrandSelect from "../../../components/mall/brand-select";
import MultiUpload from "@/components/OssUpload/multiUpload";
import {getMemberLevelList} from "@/api/mall/member/level";
import {getAttrGroupWithAttrs} from "@/api/mall/product/attr-group";
import {getBaseAttrList} from "@/api/mall/product/attr";
import {saveSpuInfo} from "@/api/mall/product/spu-info";
export default {
name:"SpuAdd",
components: {CategoryCascader, BrandSelect, MultiUpload},
props: {},
data() {
return {
catPathSub: null,
brandIdSub: null,
uploadDialogVisible: false,
uploadImages: [],
step: 0,
loadingButton:false,
spu: {
//
spuName: "",
spuDescription: "",
catalogId: 0,
brandId: "",
weight: "",
publishStatus: 0,
decript: [], //
images: [], //sku
bounds: {
//
buyBounds: 0,
growBounds: 0
},
baseAttrs: [], //
skus: [] //sku
},
spuBaseInfoRules: {
spuName: [
{required: true, message: "请输入商品名字", trigger: "blur"}
],
spuDescription: [
{required: true, message: "请编写一个简单描述", trigger: "blur"}
],
catalogId: [
{required: true, message: "请选择一个分类", trigger: "blur"}
],
brandId: [
{required: true, message: "请选择一个品牌", trigger: "blur"}
],
decript: [
{required: true, message: "请上传商品详情图集", trigger: "blur"}
],
images: [
{required: true, message: "请上传商品图片集", trigger: "blur"}
],
weight: [
{
type: "number",
required: true,
message: "请填写正确的重量值",
trigger: "blur"
}
]
},
dataResp: {
//
attrGroups: [],
baseAttrs: [],
saleAttrs: [],
tempSaleAttrs: [],
tableAttrColumn: [],
memberLevels: [],
steped: [false, false, false, false, false]
},
inputVisible: [],
inputValue: []
};
},
computed: {},
//data
watch: {
uploadImages(val) {
//skusimgs
let imgArr = Array.from(new Set(this.spu.images.concat(val)));
//{imgUrl:"",defaultImg:0} concat+
this.spu.skus.forEach((item, index) => {
let len = imgArr.length - this.spu.skus[index].images.length; //
if (len > 0) {
let imgs = new Array(len);
imgs = imgs.fill({imgUrl: "", defaultImg: 0});
this.spu.skus[index].images = item.images.concat(imgs);
}
});
this.spu.images = imgArr; //
}
},
//
methods: {
addAgian() {
this.step = 0;
this.resetSpuData();
},
resetSpuData() {
this.spu = {
spuName: "",
spuDescription: "",
catalogId: 0,
brandId: "",
weight: "",
publishStatus: 0,
decript: [],
images: [],
bounds: {
buyBounds: 0,
growBounds: 0
},
baseAttrs: [],
skus: []
};
//
},
handlePriceChange(scope, mpidx, e) {
this.spu.skus[scope.$index].memberPrice[mpidx].price = e;
},
//
getMemberLevels() {
let params = {
page: 1,
limit: 500
}
getMemberLevelList(params).then(res => {
this.dataResp.memberLevels = res.page.list;
})
},
showInput(idx) {
console.log("``````", this.view);
this.inputVisible[idx].view = true;
},
checkDefaultImg(row, index, img) {
console.log("默认图片", row, index);
//
row.images[index].imgUrl = img; //
row.images[index].defaultImg = 1; //;
//
row.images.forEach((item, idx) => {
if (idx !== index) {
row.images[idx].defaultImg = 0;
}
});
},
handleInputConfirm(idx) {
let inputValue = this.inputValue[idx].val;
if (inputValue) {
// this.dynamicTags.push(inputValue);
if (this.dataResp.saleAttrs[idx].valueSelect === "") {
this.dataResp.saleAttrs[idx].valueSelect = inputValue;
} else {
this.dataResp.saleAttrs[idx].valueSelect += ";" + inputValue;
}
}
this.inputVisible[idx].view = false;
this.inputValue[idx].val = "";
},
collectSpuBaseInfo() {
//spuBaseForm
this.$refs.spuBaseForm.validate(valid => {
if (valid) {
this.step = 1;
this.showBaseAttrs();
} else {
return false;
}
});
},
generateSaleAttrs() {
//attrspu,
this.spu.baseAttrs = [];
this.dataResp.baseAttrs.forEach(item => {
item.forEach(attr => {
let {attrId, attrValues, showDesc} = attr;
//
if (attrValues !== "") {
if (attrValues instanceof Array) {
//;
attrValues = attrValues.join(";");
}
this.spu.baseAttrs.push({attrId, attrValues, showDesc});
}
});
});
console.log("baseAttrs", this.spu.baseAttrs);
this.step = 2;
this.getShowSaleAttr();
},
generateSkus: function () {
this.step = 3;
//sku
let selectValues = [];
this.dataResp.tableAttrColumn = [];
this.dataResp.tempSaleAttrs.forEach(item => {
if (item.attrValues.length > 0) {
selectValues.push(item.attrValues);
this.dataResp.tableAttrColumn.push(item);
}
});
let descartes = this.descartes(selectValues);
//[["","6GB",""],["","6GB",""],["","8GB",""],["","8GB",""],
//["","6GB",""],["","6GB",""],["","8GB",""],["","8GB",""],
//["","6GB",""],["","6GB",""],["","8GB",""],["","8GB",""]]
console.log("生成的组合", JSON.stringify(descartes));
//descartessku
let skus = [];
descartes.forEach((descar, descaridx) => {
let attrArray = []; //sku
descar.forEach((de, index) => {
//saleAttr
let saleAttrItem = {
attrId: this.dataResp.tableAttrColumn[index].attrId,
attrName: this.dataResp.tableAttrColumn[index].attrName,
attrValue: de
};
attrArray.push(saleAttrItem);
});
//images
let imgs = [];
this.spu.images.forEach((img, idx) => {
imgs.push({imgUrl: "", defaultImg: 0});
});
//
let memberPrices = [];
if (this.dataResp.memberLevels.length > 0) {
for (let i = 0; i < this.dataResp.memberLevels.length; i++) {
if (this.dataResp.memberLevels[i].priviledgeMemberPrice === 1) {
memberPrices.push({
id: this.dataResp.memberLevels[i].id,
name: this.dataResp.memberLevels[i].name,
price: 0
});
}
}
}
//;descaridx;
let res = this.hasAndReturnSku(this.spu.skus, descar);
if (res === null) {
skus.push({
attr: attrArray,
skuName: this.spu.spuName + " " + descar.join(" "),
price: 0,
skuTitle: this.spu.spuName + " " + descar.join(" "),
skuSubtitle: "",
images: imgs,
descar: descar,
fullCount: 0,
discount: 0,
countStatus: 0,
fullPrice: 0.0,
reducePrice: 0.0,
priceStatus: 0,
memberPrice: new Array().concat(memberPrices)
});
} else {
skus.push(res);
}
});
this.spu.skus = skus;
console.log("结果!!!", this.spu.skus, this.dataResp.tableAttrColumn);
},
//skudescarsku
hasAndReturnSku(skus, descar) {
let res = null;
if (skus.length > 0) {
for (let i = 0; i < skus.length; i++) {
if (skus[i].descar.join(" ") === descar.join(" ")) {
res = skus[i];
}
}
}
return res;
},
getShowSaleAttr() {
//使
if (!this.dataResp.steped[1] && this.spu.catalogId !== 0) {
let params = {
page: 1,
limit: 500
}
this.$modal.loading("请稍后...")
getBaseAttrList(params, this.spu.catalogId, "sale").then(res => {
this.dataResp.saleAttrs = res.page.list;
res.page.list.forEach(item => {
this.dataResp.tempSaleAttrs.push({
attrId: item.attrId,
attrValues: [],
attrName: item.attrName
});
this.inputVisible.push({view: false});
this.inputValue.push({val: ""});
});
this.dataResp.steped[1] = true;
this.$modal.closeLoading()
})
}
},
showBaseAttrs() {
if (!this.dataResp.steped[0]) {
this.$modal.loading("请稍后...")
getAttrGroupWithAttrs(this.spu.catalogId).then(res => {
//baseAttrs
res.data.forEach(item => {
let attrArray = [];
item.attrs.forEach(attr => {
attrArray.push({
attrId: attr.attrId,
attrValues: "",
showDesc: attr.showDesc
});
});
this.dataResp.baseAttrs.push(attrArray);
});
this.dataResp.steped[0] = 0;
this.dataResp.attrGroups = res.data;
this.$modal.closeLoading()
})
}
},
submitSkus() {
console.log("~~~~~", JSON.stringify(this.spu));
this.$confirm("将要提交商品数据,需要一小段时间,是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
})
.then(() => {
this.loadingButton=true
saveSpuInfo(this.spu).then(res =>{
this.step = 4;
this.$modal.notifySuccess("保存成功")
this.loadingButton=false
}).catch(err =>{
this.loadingButton=false
})
})
},
//
descartes(list) {
//parent;count
var point = {};
var result = [];
var pIndex = null;
var tempCount = 0;
var temp = [];
//
for (var index in list) {
if (typeof list[index] == "object") {
point[index] = {parent: pIndex, count: 0};
pIndex = index;
}
}
//
if (pIndex == null) {
return list;
}
//
while (true) {
for (var index in list) {
tempCount = point[index]["count"];
temp.push(list[index][tempCount]);
}
//
result.push(temp);
temp = [];
//
while (true) {
if (point[index]["count"] + 1 >= list[index].length) {
point[index]["count"] = 0;
pIndex = point[index]["parent"];
if (pIndex == null) {
return result;
}
//parent
index = pIndex;
} else {
point[index]["count"]++;
break;
}
}
}
}
},
created() {
},
mounted() {
this.catPathSub = PubSub.subscribe("catPath", (msg, val) => {
this.spu.catalogId = val[val.length - 1];
});
this.brandIdSub = PubSub.subscribe("brandId", (msg, val) => {
this.spu.brandId = val;
});
this.getMemberLevels();
},
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>

@ -7,6 +7,7 @@ import com.alibaba.fastjson.support.config.FastJsonConfig;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.fasterxml.jackson.databind.SerializationFeature;
import lombok.extern.log4j.Log4j2;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.context.annotation.Bean;
@ -19,10 +20,12 @@ import java.util.List;
/**
*
*
* @author xiejs
* @since 2021-12-26
*/
@Configuration
@Log4j2
public class JsonConfig {
@Bean
public HttpMessageConverters fastJsonHttpMessageConverters() {
@ -63,8 +66,10 @@ public class JsonConfig {
//忽略某些空值
PropertyFilter filter = (source, key, value) -> {
if (value instanceof List && ((List) value).size() == 0) {
if ("children".equals(key)) {
return false;
}
}
return true;
};

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.xjs.mall.coupon.entity.CouponEntity;
import com.xjs.mall.coupon.service.CouponService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.xjs.mall.coupon.entity.CouponHistoryEntity;
import com.xjs.mall.coupon.service.CouponHistoryService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.xjs.mall.coupon.entity.CouponSpuCategoryRelationEntity;
import com.xjs.mall.coupon.service.CouponSpuCategoryRelationService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.xjs.mall.coupon.entity.CouponSpuRelationEntity;
import com.xjs.mall.coupon.service.CouponSpuRelationService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.xjs.mall.coupon.entity.HomeAdvEntity;
import com.xjs.mall.coupon.service.HomeAdvService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.xjs.mall.coupon.entity.HomeSubjectEntity;
import com.xjs.mall.coupon.service.HomeSubjectService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.xjs.mall.coupon.entity.HomeSubjectSpuEntity;
import com.xjs.mall.coupon.service.HomeSubjectSpuService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.xjs.mall.coupon.entity.MemberPriceEntity;
import com.xjs.mall.coupon.service.MemberPriceService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.xjs.mall.coupon.entity.SeckillPromotionEntity;
import com.xjs.mall.coupon.service.SeckillPromotionService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.xjs.mall.coupon.entity.SeckillSessionEntity;
import com.xjs.mall.coupon.service.SeckillSessionService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.xjs.mall.coupon.entity.SeckillSkuNoticeEntity;
import com.xjs.mall.coupon.service.SeckillSkuNoticeService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.xjs.mall.coupon.entity.SeckillSkuRelationEntity;
import com.xjs.mall.coupon.service.SeckillSkuRelationService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;

@ -1,19 +1,17 @@
package com.xjs.mall.coupon.controller;
import java.util.Arrays;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.xjs.mall.coupon.entity.SkuFullReductionEntity;
import com.xjs.mall.coupon.service.SkuFullReductionService;
import com.xjs.mall.other.R;
import com.xjs.mall.to.SkuReductionTo;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.Map;
@ -26,10 +24,19 @@ import com.xjs.utils.R;
*/
@RestController
@RequestMapping("coupon/skufullreduction")
@Api(tags = "商城-优惠-满减")
public class SkuFullReductionController {
@Autowired
private SkuFullReductionService skuFullReductionService;
@PostMapping("/saveinfo")
@ApiOperation("保存满减信息")
public R saveInfo(@RequestBody SkuReductionTo skuReductionTo) {
skuFullReductionService.saveSkuReduction(skuReductionTo);
return R.ok();
}
/**
*
*/

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.xjs.mall.coupon.entity.SkuLadderEntity;
import com.xjs.mall.coupon.service.SkuLadderService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;

@ -1,19 +1,16 @@
package com.xjs.mall.coupon.controller;
import java.util.Arrays;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.xjs.mall.coupon.entity.SpuBoundsEntity;
import com.xjs.mall.coupon.service.SpuBoundsService;
import com.xjs.mall.other.R;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.Map;
@ -26,6 +23,7 @@ import com.xjs.utils.R;
*/
@RestController
@RequestMapping("coupon/spubounds")
@Api(tags = "商城-优惠-SPU积分")
public class SpuBoundsController {
@Autowired
private SpuBoundsService spuBoundsService;
@ -52,9 +50,10 @@ public class SpuBoundsController {
}
/**
*
* 使
*/
@RequestMapping("/save")
@PostMapping("/save")
@ApiOperation("保存")
public R save(@RequestBody SpuBoundsEntity spuBounds){
spuBoundsService.save(spuBounds);

@ -1,6 +1,7 @@
package com.xjs.mall.coupon.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.xjs.mall.to.SkuReductionTo;
import com.xjs.utils.PageUtils;
import com.xjs.mall.coupon.entity.SkuFullReductionEntity;
@ -16,5 +17,11 @@ import java.util.Map;
public interface SkuFullReductionService extends IService<SkuFullReductionEntity> {
PageUtils queryPage(Map<String, Object> params);
/**
* sku
* @param skuReductionTo To
*/
void saveSkuReduction(SkuReductionTo skuReductionTo);
}

@ -1,21 +1,37 @@
package com.xjs.mall.coupon.service.impl;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xjs.utils.PageUtils;
import com.xjs.utils.Query;
import com.xjs.mall.coupon.dao.SkuFullReductionDao;
import com.xjs.mall.coupon.entity.MemberPriceEntity;
import com.xjs.mall.coupon.entity.SkuFullReductionEntity;
import com.xjs.mall.coupon.entity.SkuLadderEntity;
import com.xjs.mall.coupon.service.MemberPriceService;
import com.xjs.mall.coupon.service.SkuFullReductionService;
import com.xjs.mall.coupon.service.SkuLadderService;
import com.xjs.mall.to.MemberPrice;
import com.xjs.mall.to.SkuReductionTo;
import com.xjs.utils.PageUtils;
import com.xjs.utils.Query;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service("skuFullReductionService")
public class SkuFullReductionServiceImpl extends ServiceImpl<SkuFullReductionDao, SkuFullReductionEntity> implements SkuFullReductionService {
@Autowired
private SkuLadderService skuLadderService;
@Autowired
private MemberPriceService memberPriceService;
@Override
public PageUtils queryPage(Map<String, Object> params) {
IPage<SkuFullReductionEntity> page = this.page(
@ -26,4 +42,43 @@ public class SkuFullReductionServiceImpl extends ServiceImpl<SkuFullReductionDao
return new PageUtils(page);
}
@Override
public void saveSkuReduction(SkuReductionTo skuReductionTo) {
//保存满减打折、会员价
SkuLadderEntity skuLadderEntity = new SkuLadderEntity();
skuLadderEntity.setSkuId(skuReductionTo.getSkuId());
skuLadderEntity.setFullCount(skuReductionTo.getFullCount());
skuLadderEntity.setDiscount(skuReductionTo.getDiscount());
skuLadderEntity.setAddOther(skuReductionTo.getCountStatus());
//计算折后价
//skuLadderEntity.setPrice();
if (skuReductionTo.getFullCount() > 0) {
skuLadderService.save(skuLadderEntity);
}
SkuFullReductionEntity skuFullReductionEntity = new SkuFullReductionEntity();
BeanUtils.copyProperties(skuReductionTo, skuFullReductionEntity);
if (skuFullReductionEntity.getFullPrice().compareTo(new BigDecimal("0")) == 1) {
super.save(skuFullReductionEntity);
}
//会员价
List<MemberPrice> memberPrice = skuReductionTo.getMemberPrice();
List<MemberPriceEntity> collect = memberPrice.stream().map(item -> {
MemberPriceEntity memberPriceEntity = new MemberPriceEntity();
memberPriceEntity.setSkuId(skuReductionTo.getSkuId());
memberPriceEntity.setMemberLevelId(item.getId());
memberPriceEntity.setMemberLevelName(item.getName());
memberPriceEntity.setMemberPrice(item.getPrice());
memberPriceEntity.setAddOther(1);
return memberPriceEntity;
}).filter(item ->
item.getMemberPrice().compareTo(new BigDecimal("0")) == 1
).collect(Collectors.toList());
memberPriceService.saveBatch(collect);
}
}

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.xjs.mall.member.entity.GrowthChangeHistoryEntity;
import com.xjs.mall.member.service.GrowthChangeHistoryService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.xjs.mall.member.entity.IntegrationChangeHistoryEntity;
import com.xjs.mall.member.service.IntegrationChangeHistoryService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.xjs.mall.member.entity.MemberCollectSpuEntity;
import com.xjs.mall.member.service.MemberCollectSpuService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.xjs.mall.member.entity.MemberCollectSubjectEntity;
import com.xjs.mall.member.service.MemberCollectSubjectService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.xjs.mall.member.entity.MemberEntity;
import com.xjs.mall.member.service.MemberService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;

@ -5,7 +5,7 @@ import com.ruoyi.common.log.enums.BusinessType;
import com.xjs.mall.member.entity.MemberLevelEntity;
import com.xjs.mall.member.service.MemberLevelService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.xjs.mall.member.entity.MemberLoginLogEntity;
import com.xjs.mall.member.service.MemberLoginLogService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.xjs.mall.member.entity.MemberReceiveAddressEntity;
import com.xjs.mall.member.service.MemberReceiveAddressService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.xjs.mall.member.entity.MemberStatisticsInfoEntity;
import com.xjs.mall.member.service.MemberStatisticsInfoService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.xjs.mall.order.entity.OrderEntity;
import com.xjs.mall.order.service.OrderService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.xjs.mall.order.entity.OrderItemEntity;
import com.xjs.mall.order.service.OrderItemService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.xjs.mall.order.entity.OrderOperateHistoryEntity;
import com.xjs.mall.order.service.OrderOperateHistoryService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.xjs.mall.order.entity.OrderReturnApplyEntity;
import com.xjs.mall.order.service.OrderReturnApplyService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.xjs.mall.order.entity.OrderReturnReasonEntity;
import com.xjs.mall.order.service.OrderReturnReasonService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.xjs.mall.order.entity.OrderSettingEntity;
import com.xjs.mall.order.service.OrderSettingService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.xjs.mall.order.entity.PaymentInfoEntity;
import com.xjs.mall.order.service.PaymentInfoService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.xjs.mall.order.entity.RefundInfoEntity;
import com.xjs.mall.order.service.RefundInfoService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;

@ -7,7 +7,7 @@ import com.xjs.mall.product.vo.AttrGroupRelationVo;
import com.xjs.mall.product.vo.AttrResponseVo;
import com.xjs.mall.product.vo.AttrVo;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;
import com.xjs.validation.group.AddGroup;
import com.xjs.validation.group.UpdateGroup;
import io.swagger.annotations.Api;

@ -9,8 +9,9 @@ import com.xjs.mall.product.service.AttrGroupService;
import com.xjs.mall.product.service.AttrService;
import com.xjs.mall.product.service.CategoryService;
import com.xjs.mall.product.vo.AttrGroupRelationVo;
import com.xjs.mall.product.vo.AttrGroupWithAttrsVo;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;
import com.xjs.validation.group.AddGroup;
import com.xjs.validation.group.UpdateGroup;
import io.swagger.annotations.Api;
@ -45,6 +46,15 @@ public class AttrGroupController {
@Autowired
private AttrAttrgroupRelationService attrAttrgroupRelationService;
@GetMapping("/{catelogId}/withattr")
@ApiOperation("根据分类id获取规格参数")
public R getAttrGroupWithAttrs(@PathVariable("catelogId")Long catelogId){
//1、查出当前分类下的所有属性分组
//2、查出每个属性分组的所有属性
List<AttrGroupWithAttrsVo> vos = attrGroupService.getAttrGroupWithAttrsByCatelogId(catelogId);
return R.ok().put("data",vos);
}
/**
*
*

@ -5,7 +5,7 @@ import com.ruoyi.common.log.enums.BusinessType;
import com.xjs.mall.product.entity.BrandEntity;
import com.xjs.mall.product.service.BrandService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;
import com.xjs.validation.group.AddGroup;
import com.xjs.validation.group.SelectGroup;
import com.xjs.validation.group.UpdateGroup;

@ -7,7 +7,7 @@ import com.xjs.mall.product.entity.BrandEntity;
import com.xjs.mall.product.entity.CategoryBrandRelationEntity;
import com.xjs.mall.product.service.CategoryBrandRelationService;
import com.xjs.mall.product.vo.BrandVo;
import com.xjs.utils.R;
import com.xjs.mall.other.R;
import com.xjs.validation.group.AddGroup;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@ -4,7 +4,7 @@ import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.xjs.mall.product.entity.CategoryEntity;
import com.xjs.mall.product.service.CategoryService;
import com.xjs.utils.R;
import com.xjs.mall.other.R;
import com.xjs.validation.group.AddGroup;
import com.xjs.validation.group.UpdateGroup;
import io.swagger.annotations.Api;
@ -80,6 +80,7 @@ public class CategoryController {
}
@PutMapping("/update/sort")
@ApiOperation("修改商品分类排序")
@Log(title = "商品分类", businessType = BusinessType.UPDATE)
public R updateSort(@RequestBody CategoryEntity[] categoryEntities) {
categoryService.updateBatchById(Arrays.asList(categoryEntities));

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.xjs.mall.product.entity.CommentReplayEntity;
import com.xjs.mall.product.service.CommentReplayService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.xjs.mall.product.entity.ProductAttrValueEntity;
import com.xjs.mall.product.service.ProductAttrValueService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.xjs.mall.product.entity.SkuImagesEntity;
import com.xjs.mall.product.service.SkuImagesService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;

@ -1,19 +1,15 @@
package com.xjs.mall.product.controller;
import java.util.Arrays;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.xjs.mall.product.entity.SkuInfoEntity;
import com.xjs.mall.product.service.SkuInfoService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.Map;
@ -22,10 +18,11 @@ import com.xjs.utils.R;
*
* @author xiejs
* @email 1294405880@qq.com
* @date 2022-03-15 10:16:53
* @since 2022-03-15 10:16:53
*/
@RestController
@RequestMapping("product/skuinfo")
@Api(tags = "商城-商品-SKU信息")
public class SkuInfoController {
@Autowired
private SkuInfoService skuInfoService;

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.xjs.mall.product.entity.SkuSaleAttrValueEntity;
import com.xjs.mall.product.service.SkuSaleAttrValueService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.xjs.mall.product.entity.SpuCommentEntity;
import com.xjs.mall.product.service.SpuCommentService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.xjs.mall.product.entity.SpuImagesEntity;
import com.xjs.mall.product.service.SpuImagesService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;

@ -1,20 +1,19 @@
package com.xjs.mall.product.controller;
import java.util.Arrays;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.xjs.mall.other.R;
import com.xjs.mall.product.entity.SpuInfoEntity;
import com.xjs.mall.product.service.SpuInfoService;
import com.xjs.mall.product.vo.spu.SpuSaveVo;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.validation.group.AddGroup;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.Map;
/**
@ -22,10 +21,11 @@ import com.xjs.utils.R;
*
* @author xiejs
* @email 1294405880@qq.com
* @date 2022-03-15 10:16:53
* @since 2022-03-15 10:16:53
*/
@RestController
@RequestMapping("product/spuinfo")
@Api(tags = "商城-商品-SPU信息")
public class SpuInfoController {
@Autowired
private SpuInfoService spuInfoService;
@ -52,11 +52,12 @@ public class SpuInfoController {
}
/**
*
* (spu)
*/
@RequestMapping("/save")
public R save(@RequestBody SpuInfoEntity spuInfo){
spuInfoService.save(spuInfo);
@PostMapping("/save")
@ApiOperation("保存spu关联的所有信息")
public R saveSpuInfo(@Validated(AddGroup.class) @RequestBody SpuSaveVo spuInfo) {
spuInfoService.saveSpuInfo(spuInfo);
return R.ok();
}

@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.xjs.mall.product.entity.SpuInfoDescEntity;
import com.xjs.mall.product.service.SpuInfoDescService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;

@ -1,6 +1,5 @@
package com.xjs.mall.product.entity;
import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
@ -72,7 +71,6 @@ public class CategoryEntity implements Serializable {
/**
*
*/
@JSONField
@TableField(exist = false)
private List<CategoryEntity> children;

@ -1,11 +1,11 @@
package com.xjs.mall.product.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* spu
@ -22,7 +22,7 @@ public class SpuInfoDescEntity implements Serializable {
/**
* id
*/
@TableId
@TableId(type = IdType.INPUT)
private Long spuId;
/**
*

@ -2,6 +2,7 @@ package com.xjs.mall.product.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.xjs.mall.product.entity.AttrGroupEntity;
import com.xjs.mall.product.vo.AttrGroupWithAttrsVo;
import com.xjs.utils.PageUtils;
import java.util.List;
@ -32,11 +33,12 @@ public interface AttrGroupService extends IService<AttrGroupEntity> {
*/
void removeAttrGroup(List<Long> ids);
/**
* id
* @param categoryId id
* @return list
*/
//List<AttrGroupWithAttrsVo> getAttrGroupWithAttrsByCatelogId(Long categoryId);
List<AttrGroupWithAttrsVo> getAttrGroupWithAttrsByCatelogId(Long categoryId);
}

@ -1,9 +1,11 @@
package com.xjs.mall.product.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.xjs.mall.product.vo.spu.BaseAttrs;
import com.xjs.utils.PageUtils;
import com.xjs.mall.product.entity.ProductAttrValueEntity;
import java.util.List;
import java.util.Map;
/**
@ -11,10 +13,17 @@ import java.util.Map;
*
* @author xiejs
* @email 1294405880@qq.com
* @date 2022-03-15 10:16:53
* @since 2022-03-15 10:16:53
*/
public interface ProductAttrValueService extends IService<ProductAttrValueEntity> {
PageUtils queryPage(Map<String, Object> params);
/**
* spu
* @param baseAttrs
* @param spuId spuId
*/
void saveProductAttr(List<BaseAttrs> baseAttrs,Long spuId);
}

@ -16,5 +16,11 @@ import java.util.Map;
public interface SkuInfoService extends IService<SkuInfoEntity> {
PageUtils queryPage(Map<String, Object> params);
/**
* sku
* @param skuInfoEntity sku
*/
void saveSkuInfo(SkuInfoEntity skuInfoEntity);
}

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.xjs.utils.PageUtils;
import com.xjs.mall.product.entity.SpuImagesEntity;
import java.util.List;
import java.util.Map;
/**
@ -11,10 +12,17 @@ import java.util.Map;
*
* @author xiejs
* @email 1294405880@qq.com
* @date 2022-03-15 10:16:53
* @since 2022-03-15 10:16:53
*/
public interface SpuImagesService extends IService<SpuImagesEntity> {
PageUtils queryPage(Map<String, Object> params);
/**
* spu
* @param id spuId
* @param images
*/
void saveImages(Long id, List<String> images);
}

@ -11,10 +11,16 @@ import java.util.Map;
*
* @author xiejs
* @email 1294405880@qq.com
* @date 2022-03-15 10:16:53
* @since 2022-03-15 10:16:53
*/
public interface SpuInfoDescService extends IService<SpuInfoDescEntity> {
PageUtils queryPage(Map<String, Object> params);
/**
* spu
* @param descEntity spu
*/
void saveSpuInfoDesc(SpuInfoDescEntity descEntity);
}

@ -1,8 +1,9 @@
package com.xjs.mall.product.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.xjs.utils.PageUtils;
import com.xjs.mall.product.entity.SpuInfoEntity;
import com.xjs.mall.product.vo.spu.SpuSaveVo;
import com.xjs.utils.PageUtils;
import java.util.Map;
@ -11,10 +12,23 @@ import java.util.Map;
*
* @author xiejs
* @email 1294405880@qq.com
* @date 2022-03-15 10:16:53
* @since 2022-03-15 10:16:53
*/
public interface SpuInfoService extends IService<SpuInfoEntity> {
PageUtils queryPage(Map<String, Object> params);
/**
* spu
* @param spuInfo spu
*/
void saveSpuInfo(SpuSaveVo spuInfo);
/**
* spu
* @param spuInfoEntity spu
*/
void saveBaseSpuInfo(SpuInfoEntity spuInfoEntity);
}

@ -2,17 +2,21 @@ package com.xjs.mall.product.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xjs.exception.MallException;
import com.xjs.mall.product.dao.AttrGroupDao;
import com.xjs.mall.product.entity.AttrAttrgroupRelationEntity;
import com.xjs.mall.product.entity.AttrEntity;
import com.xjs.mall.product.entity.AttrGroupEntity;
import com.xjs.mall.product.entity.CategoryEntity;
import com.xjs.mall.product.service.AttrAttrgroupRelationService;
import com.xjs.mall.product.service.AttrGroupService;
import com.xjs.mall.product.service.AttrService;
import com.xjs.mall.product.service.CategoryService;
import com.xjs.mall.product.vo.AttrGroupResponseVo;
import com.xjs.mall.product.vo.AttrGroupWithAttrsVo;
import com.xjs.utils.PageUtils;
import com.xjs.utils.Query;
import org.apache.commons.lang3.StringUtils;
@ -35,6 +39,8 @@ public class AttrGroupServiceImpl extends ServiceImpl<AttrGroupDao, AttrGroupEnt
@Autowired
private AttrAttrgroupRelationService attrAttrgroupRelationService;
@Autowired
private AttrService attrService;
@Override
public PageUtils queryPage(Map<String, Object> params, Long categoryId) {
@ -99,4 +105,20 @@ public class AttrGroupServiceImpl extends ServiceImpl<AttrGroupDao, AttrGroupEnt
}
@Override
public List<AttrGroupWithAttrsVo> getAttrGroupWithAttrsByCatelogId(Long catelogId) {
//1、查询分组信息
List<AttrGroupEntity> attrGroupEntities = this.list(new QueryWrapper<AttrGroupEntity>().eq("catelog_id", catelogId));
//2、查询所有属性
return attrGroupEntities.stream().map(group -> {
AttrGroupWithAttrsVo attrsVo = new AttrGroupWithAttrsVo();
BeanUtils.copyProperties(group,attrsVo);
List<AttrEntity> attrs = attrService.getRelationAttr(attrsVo.getAttrGroupId());
attrsVo.setAttrs(attrs);
return attrsVo;
}).collect(Collectors.toList());
}
}

@ -1,21 +1,30 @@
package com.xjs.mall.product.service.impl;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xjs.utils.PageUtils;
import com.xjs.utils.Query;
import com.xjs.mall.product.dao.ProductAttrValueDao;
import com.xjs.mall.product.entity.AttrEntity;
import com.xjs.mall.product.entity.ProductAttrValueEntity;
import com.xjs.mall.product.service.AttrService;
import com.xjs.mall.product.service.ProductAttrValueService;
import com.xjs.mall.product.vo.spu.BaseAttrs;
import com.xjs.utils.PageUtils;
import com.xjs.utils.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service("productAttrValueService")
public class ProductAttrValueServiceImpl extends ServiceImpl<ProductAttrValueDao, ProductAttrValueEntity> implements ProductAttrValueService {
@Autowired
private AttrService attrService;
@Override
public PageUtils queryPage(Map<String, Object> params) {
IPage<ProductAttrValueEntity> page = this.page(
@ -26,4 +35,26 @@ public class ProductAttrValueServiceImpl extends ServiceImpl<ProductAttrValueDao
return new PageUtils(page);
}
@Override
public void saveProductAttr(List<BaseAttrs> baseAttrs,Long spuId) {
List<ProductAttrValueEntity> productAttrValueEntityList = baseAttrs.stream().map(attr -> {
ProductAttrValueEntity productAttrValueEntity = new ProductAttrValueEntity();
productAttrValueEntity.setAttrId(attr.getAttrId());
//查询属性名
AttrEntity attrEntity = attrService.getById(attr.getAttrId());
productAttrValueEntity.setAttrName(attrEntity.getAttrName());
productAttrValueEntity.setAttrValue(attr.getAttrValues());
productAttrValueEntity.setQuickShow(attr.getShowDesc());
productAttrValueEntity.setSpuId(spuId);
return productAttrValueEntity;
}).collect(Collectors.toList());
super.saveBatch(productAttrValueEntityList);
}
}

@ -1,16 +1,16 @@
package com.xjs.mall.product.service.impl;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xjs.utils.PageUtils;
import com.xjs.utils.Query;
import com.xjs.mall.product.dao.SkuInfoDao;
import com.xjs.mall.product.entity.SkuInfoEntity;
import com.xjs.mall.product.service.SkuInfoService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.Query;
import org.springframework.stereotype.Service;
import java.util.Map;
@Service("skuInfoService")
@ -26,4 +26,9 @@ public class SkuInfoServiceImpl extends ServiceImpl<SkuInfoDao, SkuInfoEntity> i
return new PageUtils(page);
}
@Override
public void saveSkuInfo(SkuInfoEntity skuInfoEntity) {
super.baseMapper.insert(skuInfoEntity);
}
}

@ -1,16 +1,19 @@
package com.xjs.mall.product.service.impl;
import org.springframework.stereotype.Service;
import java.util.Map;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xjs.utils.PageUtils;
import com.xjs.utils.Query;
import com.xjs.mall.product.dao.SpuImagesDao;
import com.xjs.mall.product.entity.SpuImagesEntity;
import com.xjs.mall.product.service.SpuImagesService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.Query;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service("spuImagesService")
@ -26,4 +29,18 @@ public class SpuImagesServiceImpl extends ServiceImpl<SpuImagesDao, SpuImagesEnt
return new PageUtils(page);
}
@Override
public void saveImages(Long id, List<String> images) {
if (CollUtil.isNotEmpty(images)) {
List<SpuImagesEntity> collect = images.stream().map(img -> {
SpuImagesEntity spuImagesEntity = new SpuImagesEntity();
spuImagesEntity.setSpuId(id);
spuImagesEntity.setImgUrl(img);
return spuImagesEntity;
}).collect(Collectors.toList());
super.saveBatch(collect);
}
}
}

@ -1,16 +1,16 @@
package com.xjs.mall.product.service.impl;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xjs.utils.PageUtils;
import com.xjs.utils.Query;
import com.xjs.mall.product.dao.SpuInfoDescDao;
import com.xjs.mall.product.entity.SpuInfoDescEntity;
import com.xjs.mall.product.service.SpuInfoDescService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.Query;
import org.springframework.stereotype.Service;
import java.util.Map;
@Service("spuInfoDescService")
@ -26,4 +26,9 @@ public class SpuInfoDescServiceImpl extends ServiceImpl<SpuInfoDescDao, SpuInfoD
return new PageUtils(page);
}
@Override
public void saveSpuInfoDesc(SpuInfoDescEntity descEntity) {
super.baseMapper.insert(descEntity);
}
}

@ -1,29 +1,164 @@
package com.xjs.mall.product.service.impl;
import org.springframework.stereotype.Service;
import java.util.Map;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
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.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 com.xjs.mall.product.entity.SpuInfoEntity;
import com.xjs.mall.product.service.SpuInfoService;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service("spuInfoService")
@Transactional
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
public PageUtils queryPage(Map<String, Object> params) {
IPage<SpuInfoEntity> page = this.page(
new Query<SpuInfoEntity>().getPage(params),
new QueryWrapper<SpuInfoEntity>()
new QueryWrapper<>()
);
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;
/**
* attrattrVo
*/
@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;
/**
* Spuvo
* @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;
}

@ -3,7 +3,7 @@ package com.xjs.mall.ware.controller;
import com.xjs.mall.ware.entity.PurchaseEntity;
import com.xjs.mall.ware.service.PurchaseService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@ -3,7 +3,7 @@ package com.xjs.mall.ware.controller;
import com.xjs.mall.ware.entity.PurchaseDetailEntity;
import com.xjs.mall.ware.service.PurchaseDetailService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@ -3,7 +3,7 @@ package com.xjs.mall.ware.controller;
import com.xjs.mall.ware.entity.WareInfoEntity;
import com.xjs.mall.ware.service.WareInfoService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@ -3,7 +3,7 @@ package com.xjs.mall.ware.controller;
import com.xjs.mall.ware.entity.WareOrderTaskEntity;
import com.xjs.mall.ware.service.WareOrderTaskService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@ -3,7 +3,7 @@ package com.xjs.mall.ware.controller;
import com.xjs.mall.ware.entity.WareOrderTaskDetailEntity;
import com.xjs.mall.ware.service.WareOrderTaskDetailService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@ -3,7 +3,7 @@ package com.xjs.mall.ware.controller;
import com.xjs.mall.ware.entity.WareSkuEntity;
import com.xjs.mall.ware.service.WareSkuService;
import com.xjs.utils.PageUtils;
import com.xjs.utils.R;
import com.xjs.mall.other.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

Loading…
Cancel
Save