Commit e9d284f5 authored by Junling Bu's avatar Junling Bu
Browse files

fix[litemall-admin, litemall-admin-api]: #293

parent e56e155e
...@@ -37,13 +37,14 @@ public class AdminGoodsService { ...@@ -37,13 +37,14 @@ public class AdminGoodsService {
private LitemallCategoryService categoryService; private LitemallCategoryService categoryService;
@Autowired @Autowired
private LitemallBrandService brandService; private LitemallBrandService brandService;
@Autowired
private LitemallCartService cartService;
@Autowired @Autowired
private QCodeService qCodeService; private QCodeService qCodeService;
public Object list(String goodsSn, String name, public Object list(Integer goodsId, String goodsSn, String name,
Integer page, Integer limit, String sort, String order) { Integer page, Integer limit, String sort, String order) {
List<LitemallGoods> goodsList = goodsService.querySelective(goodsSn, name, page, limit, sort, order); List<LitemallGoods> goodsList = goodsService.querySelective(goodsId, goodsSn, name, page, limit, sort, order);
return ResponseUtil.okList(goodsList); return ResponseUtil.okList(goodsList);
} }
...@@ -119,19 +120,25 @@ public class AdminGoodsService { ...@@ -119,19 +120,25 @@ public class AdminGoodsService {
/** /**
* 编辑商品 * 编辑商品
* <p> *
* TODO * NOTE:
* 目前商品修改的逻辑是 * 由于商品涉及到四个表,特别是litemall_goods_product表依赖litemall_goods_specification表,
* 1. 更新litemall_goods表 * 这导致允许所有字段都是可编辑会带来一些问题,因此这里商品编辑功能是受限制:
* 2. 逻辑删除litemall_goods_specification、litemall_goods_attribute、litemall_goods_product * (1)litemall_goods表可以编辑字段;
* 3. 添加litemall_goods_specification、litemall_goods_attribute、litemall_goods_product * (2)litemall_goods_specification表只能编辑pic_url字段,其他操作不支持;
* <p> * (3)litemall_goods_product表只能编辑price, number和url字段,其他操作不支持;
* 这里商品三个表的数据采用删除再添加的策略是因为 * (4)litemall_goods_attribute表支持编辑、添加和删除操作。
* 商品编辑页面,支持管理员添加删除商品规格、添加删除商品属性,因此这里仅仅更新是不可能的, *
* 只能删除三个表旧的数据,然后添加新的数据。 * NOTE2:
* 但是这里又会引入新的问题,就是存在订单商品货品ID指向了失效的商品货品表。 * 前后端这里使用了一个小技巧:
* 因此这里会拒绝管理员编辑商品,如果订单或购物车中存在商品。 * 如果前端传来的update_time字段是空,则说明前端已经更新了某个记录,则这个记录会更新;
* 所以这里可能需要重新设计。 * 否则说明这个记录没有编辑过,无需更新该记录。
*
* NOTE3:
* (1)购物车缓存了一些商品信息,因此需要及时更新。
* 目前这些字段是goods_sn, goods_name, price, pic_url。
* (2)但是订单里面的商品信息则是不会更新。
* 如果订单是未支付订单,此时仍然以旧的价格支付。
*/ */
@Transactional @Transactional
public Object update(GoodsAllinone goodsAllinone) { public Object update(GoodsAllinone goodsAllinone) {
...@@ -145,8 +152,6 @@ public class AdminGoodsService { ...@@ -145,8 +152,6 @@ public class AdminGoodsService {
LitemallGoodsSpecification[] specifications = goodsAllinone.getSpecifications(); LitemallGoodsSpecification[] specifications = goodsAllinone.getSpecifications();
LitemallGoodsProduct[] products = goodsAllinone.getProducts(); LitemallGoodsProduct[] products = goodsAllinone.getProducts();
Integer id = goods.getId();
//将生成的分享图片地址写入数据库 //将生成的分享图片地址写入数据库
String url = qCodeService.createGoodShareImage(goods.getId().toString(), goods.getPicUrl(), goods.getName()); String url = qCodeService.createGoodShareImage(goods.getId().toString(), goods.getPicUrl(), goods.getName());
goods.setShareUrl(url); goods.setShareUrl(url);
...@@ -157,26 +162,42 @@ public class AdminGoodsService { ...@@ -157,26 +162,42 @@ public class AdminGoodsService {
} }
Integer gid = goods.getId(); Integer gid = goods.getId();
specificationService.deleteByGid(gid);
attributeService.deleteByGid(gid);
productService.deleteByGid(gid);
// 商品规格表litemall_goods_specification // 商品规格表litemall_goods_specification
for (LitemallGoodsSpecification specification : specifications) { for (LitemallGoodsSpecification specification : specifications) {
specification.setGoodsId(goods.getId()); // 目前只支持更新规格表的图片字段
specificationService.add(specification); if(specification.getUpdateTime() == null){
specification.setSpecification(null);
specification.setValue(null);
specificationService.updateById(specification);
}
}
// 商品货品表litemall_product
for (LitemallGoodsProduct product : products) {
if(product.getUpdateTime() == null) {
productService.updateById(product);
}
} }
// 商品参数表litemall_goods_attribute // 商品参数表litemall_goods_attribute
for (LitemallGoodsAttribute attribute : attributes) { for (LitemallGoodsAttribute attribute : attributes) {
if (attribute.getId() == null || attribute.getId().equals(0)){
attribute.setGoodsId(goods.getId()); attribute.setGoodsId(goods.getId());
attributeService.add(attribute); attributeService.add(attribute);
} }
else if(attribute.getDeleted()){
attributeService.deleteByGid(attribute.getId());
}
else if(attribute.getUpdateTime() == null){
attributeService.updateById(attribute);
}
}
// 商品货品表litemall_product // 这里需要注意的是购物车litemall_cart有些字段是拷贝商品的一些字段,因此需要及时更新
// 目前这些字段是goods_sn, goods_name, price, pic_url
for (LitemallGoodsProduct product : products) { for (LitemallGoodsProduct product : products) {
product.setGoodsId(goods.getId()); cartService.updateProduct(product.getId(), goods.getGoodsSn(), goods.getName(), product.getPrice(), product.getUrl());
productService.add(product);
} }
return ResponseUtil.ok(); return ResponseUtil.ok();
......
...@@ -27,6 +27,7 @@ public class AdminGoodsController { ...@@ -27,6 +27,7 @@ public class AdminGoodsController {
/** /**
* 查询商品 * 查询商品
* *
* @param goodsId
* @param goodsSn * @param goodsSn
* @param name * @param name
* @param page * @param page
...@@ -38,12 +39,12 @@ public class AdminGoodsController { ...@@ -38,12 +39,12 @@ public class AdminGoodsController {
@RequiresPermissions("admin:goods:list") @RequiresPermissions("admin:goods:list")
@RequiresPermissionsDesc(menu = {"商品管理", "商品管理"}, button = "查询") @RequiresPermissionsDesc(menu = {"商品管理", "商品管理"}, button = "查询")
@GetMapping("/list") @GetMapping("/list")
public Object list(String goodsSn, String name, public Object list(Integer goodsId, String goodsSn, String name,
@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit, @RequestParam(defaultValue = "10") Integer limit,
@Sort @RequestParam(defaultValue = "add_time") String sort, @Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order) { @Order @RequestParam(defaultValue = "desc") String order) {
return adminGoodsService.list(goodsSn, name, page, limit, sort, order); return adminGoodsService.list(goodsId, goodsSn, name, page, limit, sort, order);
} }
@GetMapping("/catAndBrand") @GetMapping("/catAndBrand")
......
...@@ -5,10 +5,10 @@ ...@@ -5,10 +5,10 @@
<h3>商品介绍</h3> <h3>商品介绍</h3>
<el-form ref="goods" :rules="rules" :model="goods" label-width="150px"> <el-form ref="goods" :rules="rules" :model="goods" label-width="150px">
<el-form-item label="商品编号" prop="goodsSn"> <el-form-item label="商品编号" prop="goodsSn">
<el-input v-model="goods.goodsSn"/> <el-input v-model="goods.goodsSn" />
</el-form-item> </el-form-item>
<el-form-item label="商品名称" prop="name"> <el-form-item label="商品名称" prop="name">
<el-input v-model="goods.name"/> <el-input v-model="goods.name" />
</el-form-item> </el-form-item>
<el-form-item label="专柜价格" prop="counterPrice"> <el-form-item label="专柜价格" prop="counterPrice">
<el-input v-model="goods.counterPrice" placeholder="0.00"> <el-input v-model="goods.counterPrice" placeholder="0.00">
...@@ -46,9 +46,10 @@ ...@@ -46,9 +46,10 @@
:headers="headers" :headers="headers"
:on-success="uploadPicUrl" :on-success="uploadPicUrl"
class="avatar-uploader" class="avatar-uploader"
accept=".jpg,.jpeg,.png,.gif"> accept=".jpg,.jpeg,.png,.gif"
>
<img v-if="goods.picUrl" :src="goods.picUrl" class="avatar"> <img v-if="goods.picUrl" :src="goods.picUrl" class="avatar">
<i v-else class="el-icon-plus avatar-uploader-icon"/> <i v-else class="el-icon-plus avatar-uploader-icon" />
</el-upload> </el-upload>
</el-form-item> </el-form-item>
...@@ -62,13 +63,14 @@ ...@@ -62,13 +63,14 @@
:on-remove="handleRemove" :on-remove="handleRemove"
multiple multiple
accept=".jpg,.jpeg,.png,.gif" accept=".jpg,.jpeg,.png,.gif"
list-type="picture-card"> list-type="picture-card"
<i class="el-icon-plus"/> >
<i class="el-icon-plus" />
</el-upload> </el-upload>
</el-form-item> </el-form-item>
<el-form-item label="商品单位"> <el-form-item label="商品单位">
<el-input v-model="goods.unit" placeholder="件 / 个 / 盒"/> <el-input v-model="goods.unit" placeholder="件 / 个 / 盒" />
</el-form-item> </el-form-item>
<el-form-item label="关键字"> <el-form-item label="关键字">
...@@ -82,26 +84,27 @@ ...@@ -82,26 +84,27 @@
class="input-new-keyword" class="input-new-keyword"
@keyup.enter.native="handleInputConfirm" @keyup.enter.native="handleInputConfirm"
@blur="handleInputConfirm"/> @blur="handleInputConfirm"
/>
<el-button v-else class="button-new-keyword" type="primary" @click="showInput">+ 增加</el-button> <el-button v-else class="button-new-keyword" type="primary" @click="showInput">+ 增加</el-button>
</el-form-item> </el-form-item>
<el-form-item label="所属分类"> <el-form-item label="所属分类">
<el-cascader :options="categoryList" expand-trigger="hover" @change="handleCategoryChange"/> <el-cascader :options="categoryList" expand-trigger="hover" @change="handleCategoryChange" />
</el-form-item> </el-form-item>
<el-form-item label="所属品牌商"> <el-form-item label="所属品牌商">
<el-select v-model="goods.brandId"> <el-select v-model="goods.brandId">
<el-option v-for="item in brandList" :key="item.value" :label="item.label" :value="item.value"/> <el-option v-for="item in brandList" :key="item.value" :label="item.label" :value="item.value" />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="商品简介"> <el-form-item label="商品简介">
<el-input v-model="goods.brief"/> <el-input v-model="goods.brief" />
</el-form-item> </el-form-item>
<el-form-item label="商品详细介绍"> <el-form-item label="商品详细介绍">
<editor :init="editorInit" v-model="goods.detail"/> <editor v-model="goods.detail" :init="editorInit" />
</el-form-item> </el-form-item>
</el-form> </el-form>
</el-card> </el-card>
...@@ -121,7 +124,7 @@ ...@@ -121,7 +124,7 @@
</el-row> </el-row>
<el-table :data="specifications"> <el-table :data="specifications">
<el-table-column property="specification" label="规格名"/> <el-table-column property="specification" label="规格名" />
<el-table-column property="value" label="规格值"> <el-table-column property="value" label="规格值">
<template slot-scope="scope"> <template slot-scope="scope">
<el-tag type="primary"> <el-tag type="primary">
...@@ -139,7 +142,8 @@ ...@@ -139,7 +142,8 @@
align="center" align="center"
label="操作" label="操作"
width="250" width="250"
class-name="small-padding fixed-width"> class-name="small-padding fixed-width"
>
<template slot-scope="scope"> <template slot-scope="scope">
<el-button type="danger" size="mini" @click="handleSpecificationDelete(scope.row)">删除</el-button> <el-button type="danger" size="mini" @click="handleSpecificationDelete(scope.row)">删除</el-button>
</template> </template>
...@@ -154,12 +158,13 @@ ...@@ -154,12 +158,13 @@
status-icon status-icon
label-position="left" label-position="left"
label-width="100px" label-width="100px"
style="width: 400px; margin-left:50px;"> style="width: 400px; margin-left:50px;"
>
<el-form-item label="规格名" prop="specification"> <el-form-item label="规格名" prop="specification">
<el-input v-model="specForm.specification"/> <el-input v-model="specForm.specification" />
</el-form-item> </el-form-item>
<el-form-item label="规格值" prop="value"> <el-form-item label="规格值" prop="value">
<el-input v-model="specForm.value"/> <el-input v-model="specForm.value" />
</el-form-item> </el-form-item>
<el-form-item label="规格图片" prop="picUrl"> <el-form-item label="规格图片" prop="picUrl">
<el-upload <el-upload
...@@ -168,9 +173,10 @@ ...@@ -168,9 +173,10 @@
:headers="headers" :headers="headers"
:on-success="uploadSpecPicUrl" :on-success="uploadSpecPicUrl"
class="avatar-uploader" class="avatar-uploader"
accept=".jpg,.jpeg,.png,.gif"> accept=".jpg,.jpeg,.png,.gif"
>
<img v-if="specForm.picUrl" :src="specForm.picUrl" class="avatar"> <img v-if="specForm.picUrl" :src="specForm.picUrl" class="avatar">
<i v-else class="el-icon-plus avatar-uploader-icon"/> <i v-else class="el-icon-plus avatar-uploader-icon" />
</el-upload> </el-upload>
</el-form-item> </el-form-item>
</el-form> </el-form>
...@@ -191,8 +197,8 @@ ...@@ -191,8 +197,8 @@
</el-tag> </el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column property="price" width="100" label="货品售价"/> <el-table-column property="price" width="100" label="货品售价" />
<el-table-column property="number" width="100" label="货品数量"/> <el-table-column property="number" width="100" label="货品数量" />
<el-table-column property="url" width="100" label="货品图片"> <el-table-column property="url" width="100" label="货品图片">
<template slot-scope="scope"> <template slot-scope="scope">
<img v-if="scope.row.url" :src="scope.row.url" width="40"> <img v-if="scope.row.url" :src="scope.row.url" width="40">
...@@ -205,24 +211,25 @@ ...@@ -205,24 +211,25 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
<el-dialog :visible.sync="productVisiable" title="设置货品"> <el-dialog :visible.sync="productVisiable" title="添加货品">
<el-form <el-form
ref="productForm" ref="productForm"
:model="productForm" :model="productForm"
status-icon status-icon
label-position="left" label-position="left"
label-width="100px" label-width="100px"
style="width: 400px; margin-left:50px;"> style="width: 400px; margin-left:50px;"
>
<el-form-item label="货品规格列" prop="specifications"> <el-form-item label="货品规格列" prop="specifications">
<el-tag v-for="tag in productForm.specifications" :key="tag"> <el-tag v-for="tag in productForm.specifications" :key="tag">
{{ tag }} {{ tag }}
</el-tag> </el-tag>
</el-form-item> </el-form-item>
<el-form-item label="货品售价" prop="price"> <el-form-item label="货品售价" prop="price">
<el-input v-model="productForm.price"/> <el-input v-model="productForm.price" />
</el-form-item> </el-form-item>
<el-form-item label="货品数量" prop="number"> <el-form-item label="货品数量" prop="number">
<el-input v-model="productForm.number"/> <el-input v-model="productForm.number" />
</el-form-item> </el-form-item>
<el-form-item label="货品图片" prop="url"> <el-form-item label="货品图片" prop="url">
<el-upload <el-upload
...@@ -231,9 +238,10 @@ ...@@ -231,9 +238,10 @@
:headers="headers" :headers="headers"
:on-success="uploadProductUrl" :on-success="uploadProductUrl"
class="avatar-uploader" class="avatar-uploader"
accept=".jpg,.jpeg,.png,.gif"> accept=".jpg,.jpeg,.png,.gif"
>
<img v-if="productForm.url" :src="productForm.url" class="avatar"> <img v-if="productForm.url" :src="productForm.url" class="avatar">
<i v-else class="el-icon-plus avatar-uploader-icon"/> <i v-else class="el-icon-plus avatar-uploader-icon" />
</el-upload> </el-upload>
</el-form-item> </el-form-item>
</el-form> </el-form>
...@@ -248,8 +256,8 @@ ...@@ -248,8 +256,8 @@
<h3>商品参数</h3> <h3>商品参数</h3>
<el-button :plain="true" type="primary" @click="handleAttributeShow">添加</el-button> <el-button :plain="true" type="primary" @click="handleAttributeShow">添加</el-button>
<el-table :data="attributes"> <el-table :data="attributes">
<el-table-column property="attribute" label="商品参数名称"/> <el-table-column property="attribute" label="商品参数名称" />
<el-table-column property="value" label="商品参数值"/> <el-table-column property="value" label="商品参数值" />
<el-table-column align="center" label="操作" width="100" class-name="small-padding fixed-width"> <el-table-column align="center" label="操作" width="100" class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button type="danger" size="mini" @click="handleAttributeDelete(scope.row)">删除</el-button> <el-button type="danger" size="mini" @click="handleAttributeDelete(scope.row)">删除</el-button>
...@@ -257,19 +265,20 @@ ...@@ -257,19 +265,20 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
<el-dialog :visible.sync="attributeVisiable" title="设置商品参数"> <el-dialog :visible.sync="attributeVisiable" title="添加商品参数">
<el-form <el-form
ref="attributeForm" ref="attributeForm"
:model="attributeForm" :model="attributeForm"
status-icon status-icon
label-position="left" label-position="left"
label-width="100px" label-width="100px"
style="width: 400px; margin-left:50px;"> style="width: 400px; margin-left:50px;"
>
<el-form-item label="商品参数名称" prop="attribute"> <el-form-item label="商品参数名称" prop="attribute">
<el-input v-model="attributeForm.attribute"/> <el-input v-model="attributeForm.attribute" />
</el-form-item> </el-form-item>
<el-form-item label="商品参数值" prop="value"> <el-form-item label="商品参数值" prop="value">
<el-input v-model="attributeForm.value"/> <el-input v-model="attributeForm.value" />
</el-form-item> </el-form-item>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
...@@ -368,6 +377,7 @@ export default { ...@@ -368,6 +377,7 @@ export default {
}, },
editorInit: { editorInit: {
language: 'zh_CN', language: 'zh_CN',
height: 500,
convert_urls: false, convert_urls: false,
plugins: ['advlist anchor autolink autosave code codesample colorpicker colorpicker contextmenu directionality emoticons fullscreen hr image imagetools importcss insertdatetime link lists media nonbreaking noneditable pagebreak paste preview print save searchreplace spellchecker tabfocus table template textcolor textpattern visualblocks visualchars wordcount'], plugins: ['advlist anchor autolink autosave code codesample colorpicker colorpicker contextmenu directionality emoticons fullscreen hr image imagetools importcss insertdatetime link lists media nonbreaking noneditable pagebreak paste preview print save searchreplace spellchecker tabfocus table template textcolor textpattern visualblocks visualchars wordcount'],
toolbar: ['searchreplace bold italic underline strikethrough alignleft aligncenter alignright outdent indent blockquote undo redo removeformat subscript superscript code codesample', 'hr bullist numlist link image charmap preview anchor pagebreak insertdatetime media table emoticons forecolor backcolor fullscreen'], toolbar: ['searchreplace bold italic underline strikethrough alignleft aligncenter alignright outdent indent blockquote undo redo removeformat subscript superscript code codesample', 'hr bullist numlist link image charmap preview anchor pagebreak insertdatetime media table emoticons forecolor backcolor fullscreen'],
......
...@@ -4,11 +4,14 @@ ...@@ -4,11 +4,14 @@
<el-card class="box-card"> <el-card class="box-card">
<h3>商品介绍</h3> <h3>商品介绍</h3>
<el-form ref="goods" :rules="rules" :model="goods" label-width="150px"> <el-form ref="goods" :rules="rules" :model="goods" label-width="150px">
<el-form-item label="商品编号" prop="goodsSn"> <el-form-item label="商品ID" prop="id">
<el-input v-model="goods.goodsSn"/> <el-input v-model="goods.id" disabled />
</el-form-item> </el-form-item>
<el-form-item label="商品名称" prop="name"> <el-form-item label="商品名称" prop="name">
<el-input v-model="goods.name"/> <el-input v-model="goods.name" />
</el-form-item>
<el-form-item label="商品编号" prop="goodsSn">
<el-input v-model="goods.goodsSn" />
</el-form-item> </el-form-item>
<el-form-item label="专柜价格" prop="counterPrice"> <el-form-item label="专柜价格" prop="counterPrice">
<el-input v-model="goods.counterPrice" placeholder="0.00"> <el-input v-model="goods.counterPrice" placeholder="0.00">
...@@ -46,9 +49,10 @@ ...@@ -46,9 +49,10 @@
:show-file-list="false" :show-file-list="false"
:on-success="uploadPicUrl" :on-success="uploadPicUrl"
class="avatar-uploader" class="avatar-uploader"
accept=".jpg,.jpeg,.png,.gif"> accept=".jpg,.jpeg,.png,.gif"
>
<img v-if="goods.picUrl" :src="goods.picUrl" class="avatar"> <img v-if="goods.picUrl" :src="goods.picUrl" class="avatar">
<i v-else class="el-icon-plus avatar-uploader-icon"/> <i v-else class="el-icon-plus avatar-uploader-icon" />
</el-upload> </el-upload>
</el-form-item> </el-form-item>
...@@ -63,50 +67,49 @@ ...@@ -63,50 +67,49 @@
:on-remove="handleRemove" :on-remove="handleRemove"
multiple multiple
accept=".jpg,.jpeg,.png,.gif" accept=".jpg,.jpeg,.png,.gif"
list-type="picture-card"> list-type="picture-card"
<i class="el-icon-plus"/> >
<i class="el-icon-plus" />
</el-upload> </el-upload>
</el-form-item> </el-form-item>
<el-form-item label="商品单位"> <el-form-item label="商品单位">
<el-input v-model="goods.unit" placeholder="件 / 个 / 盒"/> <el-input v-model="goods.unit" placeholder="件 / 个 / 盒" />
</el-form-item> </el-form-item>
<el-form-item label="关键字"> <el-form-item label="关键字">
<el-tag v-for="tag in keywords" :key="tag" closable type="primary" @close="handleClose(tag)"> <el-tag v-for="tag in keywords" :key="tag" closable type="primary" @close="handleClose(tag)">
{{ tag }} {{ tag }}
</el-tag> </el-tag>
<el-input v-if="newKeywordVisible" ref="newKeywordInput" v-model="newKeyword" class="input-new-keyword" @keyup.enter.native="handleInputConfirm" @blur="handleInputConfirm"/> <el-input v-if="newKeywordVisible" ref="newKeywordInput" v-model="newKeyword" class="input-new-keyword" @keyup.enter.native="handleInputConfirm" @blur="handleInputConfirm" />
<el-button v-else class="button-new-keyword" type="primary" @click="showInput">+ 增加</el-button> <el-button v-else class="button-new-keyword" type="primary" @click="showInput">+ 增加</el-button>
</el-form-item> </el-form-item>
<el-form-item label="所属分类"> <el-form-item label="所属分类">
<el-cascader :options="categoryList" v-model="categoryIds" expand-trigger="hover" @change="handleCategoryChange"/> <el-cascader v-model="categoryIds" :options="categoryList" expand-trigger="hover" @change="handleCategoryChange" />
</el-form-item> </el-form-item>
<el-form-item label="所属品牌商"> <el-form-item label="所属品牌商">
<el-select v-model="goods.brandId"> <el-select v-model="goods.brandId">
<el-option v-for="item in brandList" :key="item.value" :label="item.label" :value="item.value"/> <el-option v-for="item in brandList" :key="item.value" :label="item.label" :value="item.value" />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="商品简介"> <el-form-item label="商品简介">
<el-input v-model="goods.brief"/> <el-input v-model="goods.brief" />
</el-form-item> </el-form-item>
<el-form-item label="商品详细介绍"> <el-form-item label="商品详细介绍">
<editor :init="editorInit" v-model="goods.detail"/> <editor v-model="goods.detail" :init="editorInit" />
</el-form-item> </el-form-item>
</el-form> </el-form>
</el-card> </el-card>
<el-card class="box-card"> <el-card class="box-card">
<h3>商品规格</h3> <h3>商品规格</h3>
<el-button :plain="true" type="primary" @click="handleSpecificationShow">添加</el-button>
<el-table :data="specifications"> <el-table :data="specifications">
<el-table-column property="specification" label="规格名" /> <el-table-column property="specification" label="规格名" />
<el-table-column property="value" label="规格值" > <el-table-column property="value" label="规格值">
<template slot-scope="scope"> <template slot-scope="scope">
<el-tag type="primary"> <el-tag type="primary">
{{ scope.row.value }} {{ scope.row.value }}
...@@ -118,9 +121,9 @@ ...@@ -118,9 +121,9 @@
<img v-if="scope.row.picUrl" :src="scope.row.picUrl" width="40"> <img v-if="scope.row.picUrl" :src="scope.row.picUrl" width="40">
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="操作" width="250" class-name="small-padding fixed-width"> <el-table-column align="center" label="操作" width="200" class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button type="danger" size="mini" @click="handleSpecificationDelete(scope.row)">删除</el-button> <el-button type="primary" size="mini" @click="handleSpecificationShow(scope.row)">设置</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
...@@ -128,10 +131,10 @@ ...@@ -128,10 +131,10 @@
<el-dialog :visible.sync="specVisiable" title="设置规格"> <el-dialog :visible.sync="specVisiable" title="设置规格">
<el-form ref="specForm" :rules="rules" :model="specForm" status-icon label-position="left" label-width="100px" style="width: 400px; margin-left:50px;"> <el-form ref="specForm" :rules="rules" :model="specForm" status-icon label-position="left" label-width="100px" style="width: 400px; margin-left:50px;">
<el-form-item label="规格名" prop="specification"> <el-form-item label="规格名" prop="specification">
<el-input v-model="specForm.specification"/> <el-input v-model="specForm.specification" disabled />
</el-form-item> </el-form-item>
<el-form-item label="规格值" prop="value"> <el-form-item label="规格值" prop="value">
<el-input v-model="specForm.value"/> <el-input v-model="specForm.value" disabled />
</el-form-item> </el-form-item>
<el-form-item label="规格图片" prop="picUrl"> <el-form-item label="规格图片" prop="picUrl">
<el-upload <el-upload
...@@ -140,15 +143,16 @@ ...@@ -140,15 +143,16 @@
:show-file-list="false" :show-file-list="false"
:on-success="uploadSpecPicUrl" :on-success="uploadSpecPicUrl"
class="avatar-uploader" class="avatar-uploader"
accept=".jpg,.jpeg,.png,.gif"> accept=".jpg,.jpeg,.png,.gif"
>
<img v-if="specForm.picUrl" :src="specForm.picUrl" class="avatar"> <img v-if="specForm.picUrl" :src="specForm.picUrl" class="avatar">
<i v-else class="el-icon-plus avatar-uploader-icon"/> <i v-else class="el-icon-plus avatar-uploader-icon" />
</el-upload> </el-upload>
</el-form-item> </el-form-item>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button @click="specVisiable = false">取消</el-button> <el-button @click="specVisiable = false">取消</el-button>
<el-button type="primary" @click="handleSpecificationAdd">确定</el-button> <el-button type="primary" @click="handleSpecificationEdit">确定</el-button>
</div> </div>
</el-dialog> </el-dialog>
</el-card> </el-card>
...@@ -156,28 +160,28 @@ ...@@ -156,28 +160,28 @@
<el-card class="box-card"> <el-card class="box-card">
<h3>商品库存</h3> <h3>商品库存</h3>
<el-table :data="products"> <el-table :data="products">
<el-table-column property="value" label="货品规格" > <el-table-column property="value" label="货品规格">
<template slot-scope="scope"> <template slot-scope="scope">
<el-tag v-for="tag in scope.row.specifications" :key="tag"> <el-tag v-for="tag in scope.row.specifications" :key="tag">
{{ tag }} {{ tag }}
</el-tag> </el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column property="price" width="100" label="货品售价"/> <el-table-column property="price" label="货品售价" />
<el-table-column property="number" width="100" label="货品数量"/> <el-table-column property="number" label="货品数量" />
<el-table-column property="url" width="100" label="货品图片"> <el-table-column property="url" label="货品图片">
<template slot-scope="scope"> <template slot-scope="scope">
<img v-if="scope.row.url" :src="scope.row.url" width="40"> <img v-if="scope.row.url" :src="scope.row.url" width="40">
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="操作" width="100" class-name="small-padding fixed-width"> <el-table-column align="center" label="操作" width="200" class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button type="primary" size="mini" @click="handleProductShow(scope.row)">设置</el-button> <el-button type="primary" size="mini" @click="handleProductShow(scope.row)">设置</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<el-dialog :visible.sync="productVisiable" title="设置货品"> <el-dialog :visible.sync="productVisiable" title="编辑货品">
<el-form ref="productForm" :model="productForm" status-icon label-position="left" label-width="100px" style="width: 400px; margin-left:50px;"> <el-form ref="productForm" :model="productForm" status-icon label-position="left" label-width="100px" style="width: 400px; margin-left:50px;">
<el-form-item label="货品规格列" prop="specifications"> <el-form-item label="货品规格列" prop="specifications">
<el-tag v-for="tag in productForm.specifications" :key="tag"> <el-tag v-for="tag in productForm.specifications" :key="tag">
...@@ -185,10 +189,10 @@ ...@@ -185,10 +189,10 @@
</el-tag> </el-tag>
</el-form-item> </el-form-item>
<el-form-item label="货品售价" prop="price"> <el-form-item label="货品售价" prop="price">
<el-input v-model="productForm.price"/> <el-input v-model="productForm.price" />
</el-form-item> </el-form-item>
<el-form-item label="货品数量" prop="number"> <el-form-item label="货品数量" prop="number">
<el-input v-model="productForm.number"/> <el-input v-model="productForm.number" />
</el-form-item> </el-form-item>
<el-form-item label="货品图片" prop="url"> <el-form-item label="货品图片" prop="url">
<el-upload <el-upload
...@@ -197,9 +201,10 @@ ...@@ -197,9 +201,10 @@
:show-file-list="false" :show-file-list="false"
:on-success="uploadProductUrl" :on-success="uploadProductUrl"
class="avatar-uploader" class="avatar-uploader"
accept=".jpg,.jpeg,.png,.gif"> accept=".jpg,.jpeg,.png,.gif"
>
<img v-if="productForm.url" :src="productForm.url" class="avatar"> <img v-if="productForm.url" :src="productForm.url" class="avatar">
<i v-else class="el-icon-plus avatar-uploader-icon"/> <i v-else class="el-icon-plus avatar-uploader-icon" />
</el-upload> </el-upload>
</el-form-item> </el-form-item>
</el-form> </el-form>
...@@ -212,29 +217,31 @@ ...@@ -212,29 +217,31 @@
<el-card class="box-card"> <el-card class="box-card">
<h3>商品参数</h3> <h3>商品参数</h3>
<el-button :plain="true" type="primary" @click="handleAttributeShow">添加</el-button> <el-button type="primary" @click="handleAttributeShow">添加</el-button>
<el-table :data="attributes"> <el-table :data="attributesData">
<el-table-column property="attribute" label="商品参数名称"/> <el-table-column property="attribute" label="商品参数名称" />
<el-table-column property="value" label="商品参数值"/> <el-table-column property="value" label="商品参数值" />
<el-table-column align="center" label="操作" width="100" class-name="small-padding fixed-width"> <el-table-column align="center" label="操作" width="200" class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button type="primary" size="mini" @click="handleAttributeShow(scope.row)">设置</el-button>
<el-button type="danger" size="mini" @click="handleAttributeDelete(scope.row)">删除</el-button> <el-button type="danger" size="mini" @click="handleAttributeDelete(scope.row)">删除</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<el-dialog :visible.sync="attributeVisiable" title="设置商品参数"> <el-dialog :visible.sync="attributeVisiable" :title="attributeAdd ? '添加商品参数' : '编辑商品参数'">
<el-form ref="attributeForm" :model="attributeForm" status-icon label-position="left" label-width="100px" style="width: 400px; margin-left:50px;"> <el-form ref="attributeForm" :model="attributeForm" status-icon label-position="left" label-width="100px" style="width: 400px; margin-left:50px;">
<el-form-item label="商品参数名称" prop="attribute"> <el-form-item label="商品参数名称" prop="attribute">
<el-input v-model="attributeForm.attribute"/> <el-input v-model="attributeForm.attribute" />
</el-form-item> </el-form-item>
<el-form-item label="商品参数值" prop="value"> <el-form-item label="商品参数值" prop="value">
<el-input v-model="attributeForm.value"/> <el-input v-model="attributeForm.value" />
</el-form-item> </el-form-item>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button @click="attributeVisiable = false">取消</el-button> <el-button @click="attributeVisiable = false">取消</el-button>
<el-button type="primary" @click="handleAttributeAdd">确定</el-button> <el-button v-if="attributeAdd" type="primary" @click="handleAttributeAdd">确定</el-button>
<el-button v-else type="primary" @click="handleAttributeEdit">确定</el-button>
</div> </div>
</el-dialog> </el-dialog>
</el-card> </el-card>
...@@ -282,6 +289,10 @@ ...@@ -282,6 +289,10 @@
height: 145px; height: 145px;
display: block; display: block;
} }
.op-container {
display: flex;
justify-content: center;
}
</style> </style>
<script> <script>
...@@ -320,16 +331,15 @@ export default { ...@@ -320,16 +331,15 @@ export default {
{ id: 0, specifications: ['标准'], price: 0.0, number: 0, url: '' } { id: 0, specifications: ['标准'], price: 0.0, number: 0, url: '' }
], ],
attributeVisiable: false, attributeVisiable: false,
attributeAdd: true,
attributeForm: { attribute: '', value: '' }, attributeForm: { attribute: '', value: '' },
attributes: [], attributes: [],
rules: { rules: {
goodsSn: [
{ required: true, message: '商品编号不能为空', trigger: 'blur' }
],
name: [{ required: true, message: '商品名称不能为空', trigger: 'blur' }] name: [{ required: true, message: '商品名称不能为空', trigger: 'blur' }]
}, },
editorInit: { editorInit: {
language: 'zh_CN', language: 'zh_CN',
height: '400px',
convert_urls: false, convert_urls: false,
plugins: [ plugins: [
'advlist anchor autolink autosave code codesample colorpicker colorpicker contextmenu directionality emoticons fullscreen hr image imagetools importcss insertdatetime link lists media nonbreaking noneditable pagebreak paste preview print save searchreplace spellchecker tabfocus table template textcolor textpattern visualblocks visualchars wordcount' 'advlist anchor autolink autosave code codesample colorpicker colorpicker contextmenu directionality emoticons fullscreen hr image imagetools importcss insertdatetime link lists media nonbreaking noneditable pagebreak paste preview print save searchreplace spellchecker tabfocus table template textcolor textpattern visualblocks visualchars wordcount'
...@@ -357,6 +367,16 @@ export default { ...@@ -357,6 +367,16 @@ export default {
return { return {
'X-Litemall-Admin-Token': getToken() 'X-Litemall-Admin-Token': getToken()
} }
},
attributesData() {
var attributesData = []
for (var i = 0; i < this.attributes.length; i++) {
if (this.attributes[i].deleted) {
continue
}
attributesData.push(this.attributes[i])
}
return attributesData
} }
}, },
created() { created() {
...@@ -488,99 +508,20 @@ export default { ...@@ -488,99 +508,20 @@ export default {
uploadSpecPicUrl: function(response) { uploadSpecPicUrl: function(response) {
this.specForm.picUrl = response.data.url this.specForm.picUrl = response.data.url
}, },
handleSpecificationShow() { handleSpecificationShow(row) {
this.specForm = { specification: '', value: '', picUrl: '' } this.specForm = Object.assign({}, row)
this.specVisiable = true this.specVisiable = true
}, },
handleSpecificationAdd() { handleSpecificationEdit() {
var index = this.specifications.length - 1 this.specForm.updateTime = ''
for (var i = 0; i < this.specifications.length; i++) { for (var i = 0; i < this.specifications.length; i++) {
const v = this.specifications[i] const v = this.specifications[i]
if (v.specification === this.specForm.specification) { if (v.id === this.specForm.id) {
index = i this.specifications.splice(i, 1, this.specForm)
break
} }
} }
this.specifications.splice(index + 1, 0, this.specForm)
this.specVisiable = false this.specVisiable = false
this.specToProduct()
},
handleSpecificationDelete(row) {
const index = this.specifications.indexOf(row)
this.specifications.splice(index, 1)
this.specToProduct()
},
specToProduct() {
if (this.specifications.length === 0) {
return
}
// 根据specifications创建临时规格列表
var specValues = []
var spec = this.specifications[0].specification
var values = []
values.push(0)
for (var i = 1; i < this.specifications.length; i++) {
const aspec = this.specifications[i].specification
if (aspec === spec) {
values.push(i)
} else {
specValues.push(values)
spec = aspec
values = []
values.push(i)
}
}
specValues.push(values)
// 根据临时规格列表生产货品规格
// 算法基于 https://blog.csdn.net/tyhj_sf/article/details/53893125
var productsIndex = 0
var products = []
var combination = []
var n = specValues.length
for (var s = 0; s < n; s++) {
combination[s] = 0
}
var index = 0
var isContinue = false
do {
var specifications = []
for (var x = 0; x < n; x++) {
var z = specValues[x][combination[x]]
specifications.push(this.specifications[z].value)
}
products[productsIndex] = {
id: productsIndex,
specifications: specifications,
price: 0.0,
number: 0,
url: ''
}
productsIndex++
index++
combination[n - 1] = index
for (var j = n - 1; j >= 0; j--) {
if (combination[j] >= specValues[j].length) {
combination[j] = 0
index = 0
if (j - 1 >= 0) {
combination[j - 1] = combination[j - 1] + 1
}
}
}
isContinue = false
for (var p = 0; p < n; p++) {
if (combination[p] !== 0) {
isContinue = true
}
}
} while (isContinue)
this.products = products
}, },
handleProductShow(row) { handleProductShow(row) {
this.productForm = Object.assign({}, row) this.productForm = Object.assign({}, row)
...@@ -590,6 +531,7 @@ export default { ...@@ -590,6 +531,7 @@ export default {
this.productForm.url = response.data.url this.productForm.url = response.data.url
}, },
handleProductEdit() { handleProductEdit() {
this.productForm.updateTime = ''
for (var i = 0; i < this.products.length; i++) { for (var i = 0; i < this.products.length; i++) {
const v = this.products[i] const v = this.products[i]
if (v.id === this.productForm.id) { if (v.id === this.productForm.id) {
...@@ -599,17 +541,34 @@ export default { ...@@ -599,17 +541,34 @@ export default {
} }
this.productVisiable = false this.productVisiable = false
}, },
handleAttributeShow() { handleAttributeShow(row) {
if (row.id) {
this.attributeForm = Object.assign({}, row)
this.attributeAdd = false
} else {
this.attributeForm = {} this.attributeForm = {}
this.attributeAdd = true
}
this.attributeVisiable = true this.attributeVisiable = true
}, },
handleAttributeAdd() { handleAttributeAdd() {
this.attributes.unshift(this.attributeForm) this.attributes.unshift(this.attributeForm)
this.attributeVisiable = false this.attributeVisiable = false
}, },
handleAttributeEdit() {
// 这是一个trick,设置updateTime的值为空,告诉后端这个记录已编辑需要更新。
this.attributeForm.updateTime = ''
for (var i = 0; i < this.attributes.length; i++) {
const v = this.attributes[i]
if (v.id === this.attributeForm.id) {
this.attributes.splice(i, 1, this.attributeForm)
break
}
}
this.attributeVisiable = false
},
handleAttributeDelete(row) { handleAttributeDelete(row) {
const index = this.attributes.indexOf(row) row.deleted = true
this.attributes.splice(index, 1)
} }
} }
} }
......
...@@ -3,8 +3,9 @@ ...@@ -3,8 +3,9 @@
<!-- 查询和其他操作 --> <!-- 查询和其他操作 -->
<div class="filter-container"> <div class="filter-container">
<el-input v-model="listQuery.goodsSn" clearable class="filter-item" style="width: 200px;" placeholder="请输入商品编号"/> <el-input v-model="listQuery.goodsId" clearable class="filter-item" style="width: 160px;" placeholder="请输入商品ID" />
<el-input v-model="listQuery.name" clearable class="filter-item" style="width: 200px;" placeholder="请输入商品名称"/> <el-input v-model="listQuery.goodsSn" clearable class="filter-item" style="width: 160px;" placeholder="请输入商品编号" />
<el-input v-model="listQuery.name" clearable class="filter-item" style="width: 160px;" placeholder="请输入商品名称" />
<el-button class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">查找</el-button> <el-button class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">查找</el-button>
<el-button class="filter-item" type="primary" icon="el-icon-edit" @click="handleCreate">添加</el-button> <el-button class="filter-item" type="primary" icon="el-icon-edit" @click="handleCreate">添加</el-button>
<el-button :loading="downloadLoading" class="filter-item" type="primary" icon="el-icon-download" @click="handleDownload">导出</el-button> <el-button :loading="downloadLoading" class="filter-item" type="primary" icon="el-icon-download" @click="handleDownload">导出</el-button>
...@@ -16,6 +17,9 @@ ...@@ -16,6 +17,9 @@
<el-table-column type="expand"> <el-table-column type="expand">
<template slot-scope="props"> <template slot-scope="props">
<el-form label-position="left" class="table-expand"> <el-form label-position="left" class="table-expand">
<el-form-item label="商品编号">
<span>{{ props.row.goodsSn }}</span>
</el-form-item>
<el-form-item label="宣传画廊"> <el-form-item label="宣传画廊">
<img v-for="pic in props.row.gallery" :key="pic" :src="pic" class="gallery"> <img v-for="pic in props.row.gallery" :key="pic" :src="pic" class="gallery">
</el-form-item> </el-form-item>
...@@ -34,16 +38,14 @@ ...@@ -34,16 +38,14 @@
<el-form-item label="品牌商ID"> <el-form-item label="品牌商ID">
<span>{{ props.row.brandId }}</span> <span>{{ props.row.brandId }}</span>
</el-form-item> </el-form-item>
<el-form-item label="商品ID">
<span>{{ props.row.id }}</span>
</el-form-item>
</el-form> </el-form>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="商品编号" prop="goodsSn"/> <el-table-column align="center" label="商品ID" prop="id" />
<el-table-column align="center" min-width="100" label="名称" prop="name"/> <el-table-column align="center" min-width="100" label="名称" prop="name" />
<el-table-column align="center" property="iconUrl" label="图片"> <el-table-column align="center" property="iconUrl" label="图片">
<template slot-scope="scope"> <template slot-scope="scope">
...@@ -60,15 +62,15 @@ ...@@ -60,15 +62,15 @@
<el-table-column align="center" label="详情" prop="detail"> <el-table-column align="center" label="详情" prop="detail">
<template slot-scope="scope"> <template slot-scope="scope">
<el-dialog :visible.sync="detailDialogVisible" title="商品详情"> <el-dialog :visible.sync="detailDialogVisible" title="商品详情">
<div v-html="goodsDetail"/> <div v-html="goodsDetail" />
</el-dialog> </el-dialog>
<el-button type="primary" size="mini" @click="showDetail(scope.row.detail)">查看</el-button> <el-button type="primary" size="mini" @click="showDetail(scope.row.detail)">查看</el-button>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="专柜价格" prop="counterPrice"/> <el-table-column align="center" label="专柜价格" prop="counterPrice" />
<el-table-column align="center" label="当前价格" prop="retailPrice"/> <el-table-column align="center" label="当前价格" prop="retailPrice" />
<el-table-column align="center" label="是否新品" prop="isNew"> <el-table-column align="center" label="是否新品" prop="isNew">
<template slot-scope="scope"> <template slot-scope="scope">
......
...@@ -61,6 +61,10 @@ public class ExpressService { ...@@ -61,6 +61,10 @@ public class ExpressService {
* @return * @return
*/ */
public ExpressInfo getExpressInfo(String expCode, String expNo) { public ExpressInfo getExpressInfo(String expCode, String expNo) {
if (!properties.isEnable()) {
return null;
}
try { try {
String result = getOrderTracesByJson(expCode, expNo); String result = getOrderTracesByJson(expCode, expNo);
ObjectMapper objMap = new ObjectMapper(); ObjectMapper objMap = new ObjectMapper();
...@@ -80,10 +84,6 @@ public class ExpressService { ...@@ -80,10 +84,6 @@ public class ExpressService {
* @throws Exception * @throws Exception
*/ */
private String getOrderTracesByJson(String expCode, String expNo) throws Exception { private String getOrderTracesByJson(String expCode, String expNo) throws Exception {
if (!properties.isEnable()) {
return null;
}
String requestData = "{'OrderCode':'','ShipperCode':'" + expCode + "','LogisticCode':'" + expNo + "'}"; String requestData = "{'OrderCode':'','ShipperCode':'" + expCode + "','LogisticCode':'" + expNo + "'}";
Map<String, String> params = new HashMap<String, String>(); Map<String, String> params = new HashMap<String, String>();
......
...@@ -8,6 +8,7 @@ import org.springframework.stereotype.Service; ...@@ -8,6 +8,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List; import java.util.List;
...@@ -102,4 +103,15 @@ public class LitemallCartService { ...@@ -102,4 +103,15 @@ public class LitemallCartService {
example.or().andGoodsIdEqualTo(goodsId).andCheckedEqualTo(true).andDeletedEqualTo(false); example.or().andGoodsIdEqualTo(goodsId).andCheckedEqualTo(true).andDeletedEqualTo(false);
return cartMapper.countByExample(example) != 0; return cartMapper.countByExample(example) != 0;
} }
public void updateProduct(Integer id, String goodsSn, String goodsName, BigDecimal price, String url) {
LitemallCart cart = new LitemallCart();
cart.setPrice(price);
cart.setPicUrl(url);
cart.setGoodsSn(goodsSn);
cart.setGoodsName(goodsName);
LitemallCartExample example = new LitemallCartExample();
example.or().andProductIdEqualTo(id);
cartMapper.updateByExampleSelective(cart, example);
}
} }
...@@ -35,4 +35,9 @@ public class LitemallGoodsAttributeService { ...@@ -35,4 +35,9 @@ public class LitemallGoodsAttributeService {
example.or().andGoodsIdEqualTo(gid); example.or().andGoodsIdEqualTo(gid);
goodsAttributeMapper.logicalDeleteByExample(example); goodsAttributeMapper.logicalDeleteByExample(example);
} }
public void updateById(LitemallGoodsAttribute attribute) {
attribute.setUpdateTime(LocalDateTime.now());
goodsAttributeMapper.updateByPrimaryKeySelective(attribute);
}
} }
...@@ -57,4 +57,9 @@ public class LitemallGoodsProductService { ...@@ -57,4 +57,9 @@ public class LitemallGoodsProductService {
public int reduceStock(Integer id, Short num){ public int reduceStock(Integer id, Short num){
return goodsProductMapper.reduceStock(id, num); return goodsProductMapper.reduceStock(id, num);
} }
public void updateById(LitemallGoodsProduct product) {
product.setUpdateTime(LocalDateTime.now());
litemallGoodsProductMapper.updateByPrimaryKeySelective(product);
}
} }
\ No newline at end of file
...@@ -127,10 +127,13 @@ public class LitemallGoodsService { ...@@ -127,10 +127,13 @@ public class LitemallGoodsService {
return goodsMapper.selectByExampleSelective(example, columns); return goodsMapper.selectByExampleSelective(example, columns);
} }
public List<LitemallGoods> querySelective(String goodsSn, String name, Integer page, Integer size, String sort, String order) { public List<LitemallGoods> querySelective(Integer goodsId, String goodsSn, String name, Integer page, Integer size, String sort, String order) {
LitemallGoodsExample example = new LitemallGoodsExample(); LitemallGoodsExample example = new LitemallGoodsExample();
LitemallGoodsExample.Criteria criteria = example.createCriteria(); LitemallGoodsExample.Criteria criteria = example.createCriteria();
if (goodsId != null) {
criteria.andIdEqualTo(goodsId);
}
if (!StringUtils.isEmpty(goodsSn)) { if (!StringUtils.isEmpty(goodsSn)) {
criteria.andGoodsSnEqualTo(goodsSn); criteria.andGoodsSnEqualTo(goodsSn);
} }
......
...@@ -80,6 +80,11 @@ public class LitemallGoodsSpecificationService { ...@@ -80,6 +80,11 @@ public class LitemallGoodsSpecificationService {
return specificationVoList; return specificationVoList;
} }
public void updateById(LitemallGoodsSpecification specification) {
specification.setUpdateTime(LocalDateTime.now());
goodsSpecificationMapper.updateByPrimaryKeySelective(specification);
}
private class VO { private class VO {
private String name; private String name;
private List<LitemallGoodsSpecification> valueList; private List<LitemallGoodsSpecification> valueList;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment