Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wwwanlingxiao
mall
Commits
17e6a32d
"JeeSpringCloud/vscode:/vscode.git/clone" did not exist on "b3d52ed163a7ffb9c46b677051ab9e8927d151be"
Commit
17e6a32d
authored
Apr 27, 2018
by
zhh
Browse files
添加商品查询、添加、修改功能
parent
edc71542
Changes
25
Expand all
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
17e6a32d
...
@@ -33,7 +33,7 @@ SpringAOP通用验证失败结果返回 | ✔
...
@@ -33,7 +33,7 @@ SpringAOP通用验证失败结果返回 | ✔
CommonResult对通用返回结果进行封装 | ✔
CommonResult对通用返回结果进行封装 | ✔
SpringSecurity登录改为Restful形式 | ✔
SpringSecurity登录改为Restful形式 | ✔
JWT登录、注册、获取token | ✔
JWT登录、注册、获取token | ✔
JTA事务处理 |
JTA事务处理 |
✔
集成单元测试 | ✔
集成单元测试 | ✔
### 功能完善
### 功能完善
...
@@ -65,7 +65,7 @@ JTA事务处理 |
...
@@ -65,7 +65,7 @@ JTA事务处理 |
##### 商品管理
##### 商品管理
###### 添加商品
###### 添加商品
(完成)
-
选择商品分类:根据商品分类id查找分类
-
选择商品分类:根据商品分类id查找分类
-
选择品牌:查询全部品牌
-
选择品牌:查询全部品牌
-
选择运费模版:查询全部运费模版
-
选择运费模版:查询全部运费模版
...
@@ -81,6 +81,23 @@ JTA事务处理 |
...
@@ -81,6 +81,23 @@ JTA事务处理 |
-
关联专题:参数传入List
<CmsSubjectProductRelation>
关系
-
关联专题:参数传入List
<CmsSubjectProductRelation>
关系
-
关联优选:参数传入List
<CmsPrefrenceAreaProductRelation>
关系
-
关联优选:参数传入List
<CmsPrefrenceAreaProductRelation>
关系
###### 修改商品(完成)
-
根据商品id查询商品信息
-
查询商品基本信息:商品分类名称、品牌名称、运费模版名称
-
查询商品促销信息:商品的会员价格、阶梯价格、满减价格
-
查询商品属性信息:商品属性类别名称、sku库存信息、属性分类对应规格和参数值
-
查询商品关联信息:商品关联专题和关联优选
-
修改商品信息:商品属性分类及规格不可修改,只支持单个sku的修改、删除、新增;商品属性分类及规格可以修改:修改后同时显示原sku库存及属性分类
###### 商品分页查询
-
商品的状态:全部商品、已上架、未上架、待审核、未通过 (publishStatus verifyStatus)
-
商品名称(%name%)
-
商品货号(productSn)
-
商品分类id(productCategoryId)
-
商品品牌id(brandId)
-
批量操作:上下架、推荐、新品、转移分类、放入回收站、审核
-
查看记录:审核记录,操作日志
-
sku:根据产品及sku编号获取sku信息,批量修改sku信息
#### 促销管理
#### 促销管理
#### 内容管理
#### 内容管理
...
...
document/pdm/mall.pdb
View file @
17e6a32d
This diff is collapsed.
Click to expand it.
document/pdm/mall.pdm
View file @
17e6a32d
This diff is collapsed.
Click to expand it.
mall-admin/src/main/java/com/macro/mall/controller/PmsBrandController.java
View file @
17e6a32d
...
@@ -51,7 +51,7 @@ public class PmsBrandController {
...
@@ -51,7 +51,7 @@ public class PmsBrandController {
@ApiOperation
(
value
=
"更新品牌"
)
@ApiOperation
(
value
=
"更新品牌"
)
@RequestMapping
(
value
=
"/update/{id}"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/update/{id}"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
@ResponseBody
public
Object
update
Brand
(
@PathVariable
(
"id"
)
Long
id
,
public
Object
update
(
@PathVariable
(
"id"
)
Long
id
,
@Validated
@RequestBody
PmsBrandParam
pmsBrandParam
,
@Validated
@RequestBody
PmsBrandParam
pmsBrandParam
,
BindingResult
result
)
{
BindingResult
result
)
{
CommonResult
commonResult
;
CommonResult
commonResult
;
...
...
mall-admin/src/main/java/com/macro/mall/controller/PmsProductController.java
View file @
17e6a32d
...
@@ -2,16 +2,19 @@ package com.macro.mall.controller;
...
@@ -2,16 +2,19 @@ package com.macro.mall.controller;
import
com.macro.mall.dto.CommonResult
;
import
com.macro.mall.dto.CommonResult
;
import
com.macro.mall.dto.PmsProductParam
;
import
com.macro.mall.dto.PmsProductParam
;
import
com.macro.mall.dto.PmsProductQueryParam
;
import
com.macro.mall.dto.PmsProductResult
;
import
com.macro.mall.model.PmsProduct
;
import
com.macro.mall.model.PmsProductVertifyRecord
;
import
com.macro.mall.service.PmsProductService
;
import
com.macro.mall.service.PmsProductService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
java.util.List
;
import
org.springframework.web.bind.annotation.ResponseBody
;
/**
/**
* 商品管理Controller
* 商品管理Controller
...
@@ -35,4 +38,48 @@ public class PmsProductController {
...
@@ -35,4 +38,48 @@ public class PmsProductController {
return
new
CommonResult
().
failed
();
return
new
CommonResult
().
failed
();
}
}
}
}
@ApiOperation
(
"根据商品id获取商品编辑信息"
)
@RequestMapping
(
value
=
"/updateInfo/{id}"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
public
Object
getUpdateInfo
(
@PathVariable
Long
id
)
{
PmsProductResult
productResult
=
productService
.
getUpdateInfo
(
id
);
return
new
CommonResult
().
success
(
productResult
);
}
@ApiOperation
(
"更新商品"
)
@RequestMapping
(
value
=
"/update/{id}"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
Object
update
(
@PathVariable
Long
id
,
@RequestBody
PmsProductParam
productParam
,
BindingResult
bindingResult
)
{
int
count
=
productService
.
update
(
id
,
productParam
);
if
(
count
>
0
)
{
return
new
CommonResult
().
success
(
count
);
}
else
{
return
new
CommonResult
().
failed
();
}
}
@ApiOperation
(
"查询商品"
)
@RequestMapping
(
value
=
"list"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
public
Object
getList
(
PmsProductQueryParam
productQueryParam
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"5"
)
Integer
pageSize
,
@RequestParam
(
value
=
"pageNum"
,
defaultValue
=
"1"
)
Integer
pageNum
)
{
List
<
PmsProduct
>
productList
=
productService
.
list
(
productQueryParam
,
pageSize
,
pageNum
);
return
new
CommonResult
().
pageSuccess
(
productList
);
}
@ApiOperation
(
"批量修改审核状态"
)
@RequestMapping
(
value
=
"/update/verifyStatus"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
Object
updateVerifyStatus
(
@RequestParam
(
"ids"
)
List
<
Long
>
ids
,
@RequestParam
(
"verifyStatus"
)
Integer
verifyStatus
,
@RequestParam
(
"detail"
)
String
detail
)
{
int
count
=
productService
.
updateVerifyStatus
(
ids
,
verifyStatus
,
detail
);
if
(
count
>
0
)
{
return
new
CommonResult
().
success
(
count
);
}
else
{
return
new
CommonResult
().
failed
();
}
}
}
}
mall-admin/src/main/java/com/macro/mall/controller/PmsSkuStockController.java
0 → 100644
View file @
17e6a32d
package
com.macro.mall.controller
;
import
com.macro.mall.dto.CommonResult
;
import
com.macro.mall.model.PmsSkuStock
;
import
com.macro.mall.service.PmsSkuStockService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
java.util.List
;
/**
* sku库存Controller
* Created by macro on 2018/4/27.
*/
@Api
(
"sku商品库存管理"
)
@Controller
@RequestMapping
(
"/sku"
)
public
class
PmsSkuStockController
{
@Autowired
private
PmsSkuStockService
skuStockService
;
@ApiOperation
(
"根据商品编号及编号模糊搜索sku库存"
)
@RequestMapping
(
"/{id}"
)
@ResponseBody
public
Object
getList
(
@PathVariable
Long
id
,
@RequestParam
(
"keyword"
)
String
keyword
){
List
<
PmsSkuStock
>
skuStockList
=
skuStockService
.
getList
(
id
,
keyword
);
return
new
CommonResult
().
success
(
skuStockList
);
}
}
mall-admin/src/main/java/com/macro/mall/dao/PmsProductDao.java
0 → 100644
View file @
17e6a32d
package
com.macro.mall.dao
;
import
com.macro.mall.dto.PmsProductResult
;
import
org.apache.ibatis.annotations.Param
;
/**
* 商品自定义Dao
* Created by macro on 2018/4/26.
*/
public
interface
PmsProductDao
{
/**
* 获取商品编辑信息
*/
PmsProductResult
getUpdateInfo
(
@Param
(
"id"
)
Long
id
);
}
mall-admin/src/main/java/com/macro/mall/dao/PmsProductVertifyRecordDao.java
0 → 100644
View file @
17e6a32d
package
com.macro.mall.dao
;
import
com.macro.mall.model.PmsProductVertifyRecord
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
/**
* 商品审核日志自定义dao
* Created by macro on 2018/4/27.
*/
public
interface
PmsProductVertifyRecordDao
{
int
insertList
(
@Param
(
"list"
)
List
<
PmsProductVertifyRecord
>
list
);
}
mall-admin/src/main/java/com/macro/mall/dto/PmsProductParam.java
View file @
17e6a32d
...
@@ -3,17 +3,13 @@ package com.macro.mall.dto;
...
@@ -3,17 +3,13 @@ package com.macro.mall.dto;
import
com.macro.mall.model.*
;
import
com.macro.mall.model.*
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
javax.validation.constraints.NotNull
;
import
java.util.List
;
import
java.util.List
;
/**
/**
* 创建和修改商品时使用的参数
* 创建和修改商品时使用的参数
* Created by macro on 2018/4/26.
* Created by macro on 2018/4/26.
*/
*/
public
class
PmsProductParam
{
public
class
PmsProductParam
extends
PmsProduct
{
@ApiModelProperty
(
"商品信息"
)
@NotNull
(
message
=
"商品信息不能为空"
)
private
PmsProduct
product
;
@ApiModelProperty
(
"商品阶梯价格设置"
)
@ApiModelProperty
(
"商品阶梯价格设置"
)
private
List
<
PmsProductLadder
>
productLadderList
;
private
List
<
PmsProductLadder
>
productLadderList
;
@ApiModelProperty
(
"商品满减价格设置"
)
@ApiModelProperty
(
"商品满减价格设置"
)
...
@@ -29,14 +25,6 @@ public class PmsProductParam {
...
@@ -29,14 +25,6 @@ public class PmsProductParam {
@ApiModelProperty
(
"优选专区和商品的关系"
)
@ApiModelProperty
(
"优选专区和商品的关系"
)
private
List
<
CmsPrefrenceAreaProductRelation
>
prefrenceAreaProductRelationList
;
private
List
<
CmsPrefrenceAreaProductRelation
>
prefrenceAreaProductRelationList
;
public
PmsProduct
getProduct
()
{
return
product
;
}
public
void
setProduct
(
PmsProduct
product
)
{
this
.
product
=
product
;
}
public
List
<
PmsProductLadder
>
getProductLadderList
()
{
public
List
<
PmsProductLadder
>
getProductLadderList
()
{
return
productLadderList
;
return
productLadderList
;
}
}
...
...
mall-admin/src/main/java/com/macro/mall/dto/PmsProductQueryParam.java
0 → 100644
View file @
17e6a32d
package
com.macro.mall.dto
;
import
io.swagger.annotations.ApiModelProperty
;
/**
* 产品查询参数
* Created by macro on 2018/4/27.
*/
public
class
PmsProductQueryParam
{
@ApiModelProperty
(
"上架状态"
)
private
Integer
publishStatus
;
@ApiModelProperty
(
"审核状态"
)
private
Integer
verifyStatus
;
@ApiModelProperty
(
"商品名称模糊关键字"
)
private
String
keyword
;
@ApiModelProperty
(
"商品货号"
)
private
String
productSn
;
@ApiModelProperty
(
"商品分类编号"
)
private
Long
productCategoryId
;
@ApiModelProperty
(
"商品品牌编号"
)
private
Long
brandId
;
public
Integer
getPublishStatus
()
{
return
publishStatus
;
}
public
void
setPublishStatus
(
Integer
publishStatus
)
{
this
.
publishStatus
=
publishStatus
;
}
public
Integer
getVerifyStatus
()
{
return
verifyStatus
;
}
public
void
setVerifyStatus
(
Integer
verifyStatus
)
{
this
.
verifyStatus
=
verifyStatus
;
}
public
String
getKeyword
()
{
return
keyword
;
}
public
void
setKeyword
(
String
keyword
)
{
this
.
keyword
=
keyword
;
}
public
String
getProductSn
()
{
return
productSn
;
}
public
void
setProductSn
(
String
productSn
)
{
this
.
productSn
=
productSn
;
}
public
Long
getProductCategoryId
()
{
return
productCategoryId
;
}
public
void
setProductCategoryId
(
Long
productCategoryId
)
{
this
.
productCategoryId
=
productCategoryId
;
}
public
Long
getBrandId
()
{
return
brandId
;
}
public
void
setBrandId
(
Long
brandId
)
{
this
.
brandId
=
brandId
;
}
}
mall-admin/src/main/java/com/macro/mall/dto/PmsProductResult.java
0 → 100644
View file @
17e6a32d
package
com.macro.mall.dto
;
import
com.macro.mall.model.CmsPrefrenceArea
;
import
com.macro.mall.model.CmsSubject
;
import
java.util.List
;
/**
* 查询单个产品进行修改时返回的结果
* Created by macro on 2018/4/26.
*/
public
class
PmsProductResult
extends
PmsProductParam
{
private
String
feightTemplateName
;
private
String
productAttributeCategoryName
;
private
List
<
CmsSubject
>
subjectList
;
private
List
<
CmsPrefrenceArea
>
prefrenceAreaList
;
public
String
getFeightTemplateName
()
{
return
feightTemplateName
;
}
public
void
setFeightTemplateName
(
String
feightTemplateName
)
{
this
.
feightTemplateName
=
feightTemplateName
;
}
public
String
getProductAttributeCategoryName
()
{
return
productAttributeCategoryName
;
}
public
void
setProductAttributeCategoryName
(
String
productAttributeCategoryName
)
{
this
.
productAttributeCategoryName
=
productAttributeCategoryName
;
}
public
List
<
CmsSubject
>
getSubjectList
()
{
return
subjectList
;
}
public
void
setSubjectList
(
List
<
CmsSubject
>
subjectList
)
{
this
.
subjectList
=
subjectList
;
}
public
List
<
CmsPrefrenceArea
>
getPrefrenceAreaList
()
{
return
prefrenceAreaList
;
}
public
void
setPrefrenceAreaList
(
List
<
CmsPrefrenceArea
>
prefrenceAreaList
)
{
this
.
prefrenceAreaList
=
prefrenceAreaList
;
}
}
mall-admin/src/main/java/com/macro/mall/service/PmsBrandService.java
View file @
17e6a32d
...
@@ -2,6 +2,7 @@ package com.macro.mall.service;
...
@@ -2,6 +2,7 @@ package com.macro.mall.service;
import
com.macro.mall.dto.PmsBrandParam
;
import
com.macro.mall.dto.PmsBrandParam
;
import
com.macro.mall.model.PmsBrand
;
import
com.macro.mall.model.PmsBrand
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
import
java.util.List
;
...
@@ -13,7 +14,7 @@ public interface PmsBrandService {
...
@@ -13,7 +14,7 @@ public interface PmsBrandService {
List
<
PmsBrand
>
listAllBrand
();
List
<
PmsBrand
>
listAllBrand
();
int
createBrand
(
PmsBrandParam
pmsBrandParam
);
int
createBrand
(
PmsBrandParam
pmsBrandParam
);
@Transactional
int
updateBrand
(
Long
id
,
PmsBrandParam
pmsBrandParam
);
int
updateBrand
(
Long
id
,
PmsBrandParam
pmsBrandParam
);
int
deleteBrand
(
Long
id
);
int
deleteBrand
(
Long
id
);
...
...
mall-admin/src/main/java/com/macro/mall/service/PmsProductCategoryService.java
View file @
17e6a32d
...
@@ -14,7 +14,7 @@ import java.util.List;
...
@@ -14,7 +14,7 @@ import java.util.List;
*/
*/
public
interface
PmsProductCategoryService
{
public
interface
PmsProductCategoryService
{
int
create
(
PmsProductCategoryParam
pmsProductCategoryParam
);
int
create
(
PmsProductCategoryParam
pmsProductCategoryParam
);
@Transactional
int
update
(
Long
id
,
PmsProductCategoryParam
pmsProductCategoryParam
);
int
update
(
Long
id
,
PmsProductCategoryParam
pmsProductCategoryParam
);
List
<
PmsProductCategory
>
getList
(
Long
parentId
,
Integer
pageSize
,
Integer
pageNum
);
List
<
PmsProductCategory
>
getList
(
Long
parentId
,
Integer
pageSize
,
Integer
pageNum
);
...
...
mall-admin/src/main/java/com/macro/mall/service/PmsProductService.java
View file @
17e6a32d
package
com.macro.mall.service
;
package
com.macro.mall.service
;
import
com.macro.mall.dto.PmsProductParam
;
import
com.macro.mall.dto.PmsProductParam
;
import
com.macro.mall.dto.PmsProductQueryParam
;
import
com.macro.mall.dto.PmsProductResult
;
import
com.macro.mall.model.PmsProduct
;
import
org.springframework.transaction.annotation.Isolation
;
import
org.springframework.transaction.annotation.Isolation
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
/**
/**
* 商品管理Service
* 商品管理Service
* Created by macro on 2018/4/26.
* Created by macro on 2018/4/26.
...
@@ -15,4 +20,29 @@ public interface PmsProductService {
...
@@ -15,4 +20,29 @@ public interface PmsProductService {
*/
*/
@Transactional
(
isolation
=
Isolation
.
DEFAULT
,
propagation
=
Propagation
.
REQUIRED
)
@Transactional
(
isolation
=
Isolation
.
DEFAULT
,
propagation
=
Propagation
.
REQUIRED
)
int
create
(
PmsProductParam
productParam
);
int
create
(
PmsProductParam
productParam
);
/**
* 根据商品编号获取更新信息
*/
PmsProductResult
getUpdateInfo
(
Long
id
);
/**
* 更新商品
*/
@Transactional
int
update
(
Long
id
,
PmsProductParam
productParam
);
/**
* 分页查询商品
*/
List
<
PmsProduct
>
list
(
PmsProductQueryParam
productQueryParam
,
Integer
pageSize
,
Integer
pageNum
);
/**
* 批量修改审核状态
* @param ids 产品id
* @param verifyStatus 审核状态
* @param detail 审核详情
*/
@Transactional
int
updateVerifyStatus
(
List
<
Long
>
ids
,
Integer
verifyStatus
,
String
detail
);
}
}
mall-admin/src/main/java/com/macro/mall/service/PmsSkuStockService.java
0 → 100644
View file @
17e6a32d
package
com.macro.mall.service
;
import
com.macro.mall.model.PmsSkuStock
;
import
java.util.List
;
/**
* sku商品库存管理Service
* Created by macro on 2018/4/27.
*/
public
interface
PmsSkuStockService
{
/**
* 根据产品id和skuCode模糊搜索
*/
List
<
PmsSkuStock
>
getList
(
Long
pid
,
String
keyword
);
}
mall-admin/src/main/java/com/macro/mall/service/impl/PmsBrandServiceImpl.java
View file @
17e6a32d
...
@@ -3,8 +3,11 @@ package com.macro.mall.service.impl;
...
@@ -3,8 +3,11 @@ package com.macro.mall.service.impl;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageHelper
;
import
com.macro.mall.dto.PmsBrandParam
;
import
com.macro.mall.dto.PmsBrandParam
;
import
com.macro.mall.mapper.PmsBrandMapper
;
import
com.macro.mall.mapper.PmsBrandMapper
;
import
com.macro.mall.mapper.PmsProductMapper
;
import
com.macro.mall.model.PmsBrand
;
import
com.macro.mall.model.PmsBrand
;
import
com.macro.mall.model.PmsBrandExample
;
import
com.macro.mall.model.PmsBrandExample
;
import
com.macro.mall.model.PmsProduct
;
import
com.macro.mall.model.PmsProductExample
;
import
com.macro.mall.service.PmsBrandService
;
import
com.macro.mall.service.PmsBrandService
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -21,6 +24,8 @@ import java.util.List;
...
@@ -21,6 +24,8 @@ import java.util.List;
public
class
PmsBrandServiceImpl
implements
PmsBrandService
{
public
class
PmsBrandServiceImpl
implements
PmsBrandService
{
@Autowired
@Autowired
private
PmsBrandMapper
brandMapper
;
private
PmsBrandMapper
brandMapper
;
@Autowired
private
PmsProductMapper
productMapper
;
@Override
@Override
public
List
<
PmsBrand
>
listAllBrand
()
{
public
List
<
PmsBrand
>
listAllBrand
()
{
...
@@ -47,6 +52,12 @@ public class PmsBrandServiceImpl implements PmsBrandService {
...
@@ -47,6 +52,12 @@ public class PmsBrandServiceImpl implements PmsBrandService {
if
(
StringUtils
.
isEmpty
(
pmsBrand
.
getFirstLetter
()))
{
if
(
StringUtils
.
isEmpty
(
pmsBrand
.
getFirstLetter
()))
{
pmsBrand
.
setFirstLetter
(
pmsBrand
.
getName
().
substring
(
0
,
1
));
pmsBrand
.
setFirstLetter
(
pmsBrand
.
getName
().
substring
(
0
,
1
));
}
}
//更新品牌时要更新商品中的品牌名称
PmsProduct
product
=
new
PmsProduct
();
product
.
setBrandName
(
pmsBrand
.
getName
());
PmsProductExample
example
=
new
PmsProductExample
();
example
.
createCriteria
().
andBrandIdEqualTo
(
id
);
productMapper
.
updateByExampleSelective
(
product
,
example
);
return
brandMapper
.
updateByPrimaryKeySelective
(
pmsBrand
);
return
brandMapper
.
updateByPrimaryKeySelective
(
pmsBrand
);
}
}
...
...
mall-admin/src/main/java/com/macro/mall/service/impl/PmsProductCategoryServiceImpl.java
View file @
17e6a32d
...
@@ -3,8 +3,11 @@ package com.macro.mall.service.impl;
...
@@ -3,8 +3,11 @@ package com.macro.mall.service.impl;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageHelper
;
import
com.macro.mall.dto.PmsProductCategoryParam
;
import
com.macro.mall.dto.PmsProductCategoryParam
;
import
com.macro.mall.mapper.PmsProductCategoryMapper
;
import
com.macro.mall.mapper.PmsProductCategoryMapper
;
import
com.macro.mall.mapper.PmsProductMapper
;
import
com.macro.mall.model.PmsProduct
;
import
com.macro.mall.model.PmsProductCategory
;
import
com.macro.mall.model.PmsProductCategory
;
import
com.macro.mall.model.PmsProductCategoryExample
;
import
com.macro.mall.model.PmsProductCategoryExample
;
import
com.macro.mall.model.PmsProductExample
;
import
com.macro.mall.service.PmsProductCategoryService
;
import
com.macro.mall.service.PmsProductCategoryService
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -20,6 +23,8 @@ import java.util.List;
...
@@ -20,6 +23,8 @@ import java.util.List;
public
class
PmsProductCategoryServiceImpl
implements
PmsProductCategoryService
{
public
class
PmsProductCategoryServiceImpl
implements
PmsProductCategoryService
{
@Autowired
@Autowired
private
PmsProductCategoryMapper
productCategoryMapper
;
private
PmsProductCategoryMapper
productCategoryMapper
;
@Autowired
private
PmsProductMapper
productMapper
;
@Override
@Override
public
int
create
(
PmsProductCategoryParam
pmsProductCategoryParam
)
{
public
int
create
(
PmsProductCategoryParam
pmsProductCategoryParam
)
{
...
@@ -36,6 +41,12 @@ public class PmsProductCategoryServiceImpl implements PmsProductCategoryService
...
@@ -36,6 +41,12 @@ public class PmsProductCategoryServiceImpl implements PmsProductCategoryService
productCategory
.
setId
(
id
);
productCategory
.
setId
(
id
);
BeanUtils
.
copyProperties
(
pmsProductCategoryParam
,
productCategory
);
BeanUtils
.
copyProperties
(
pmsProductCategoryParam
,
productCategory
);
setCategoryLevel
(
productCategory
);
setCategoryLevel
(
productCategory
);
//更新商品分类时要更新商品中的名称
PmsProduct
product
=
new
PmsProduct
();
product
.
setProductCategoryName
(
productCategory
.
getName
());
PmsProductExample
example
=
new
PmsProductExample
();
example
.
createCriteria
().
andProductCategoryIdEqualTo
(
id
);
productMapper
.
updateByExampleSelective
(
product
,
example
);
return
productCategoryMapper
.
updateByPrimaryKeySelective
(
productCategory
);
return
productCategoryMapper
.
updateByPrimaryKeySelective
(
productCategory
);
}
}
...
...
mall-admin/src/main/java/com/macro/mall/service/impl/PmsProductServiceImpl.java
View file @
17e6a32d
package
com.macro.mall.service.impl
;
package
com.macro.mall.service.impl
;
import
com.github.pagehelper.PageHelper
;
import
com.macro.mall.dao.*
;
import
com.macro.mall.dao.*
;
import
com.macro.mall.dto.PmsProductParam
;
import
com.macro.mall.dto.PmsProductParam
;
import
com.macro.mall.mapper.PmsProductMapper
;
import
com.macro.mall.dto.PmsProductQueryParam
;
import
com.macro.mall.dto.PmsProductResult
;
import
com.macro.mall.mapper.*
;
import
com.macro.mall.model.*
;
import
com.macro.mall.model.*
;
import
com.macro.mall.service.PmsProductService
;
import
com.macro.mall.service.PmsProductService
;
import
io.swagger.annotations.Example
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.StringUtils
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Method
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
@@ -26,23 +33,41 @@ public class PmsProductServiceImpl implements PmsProductService {
...
@@ -26,23 +33,41 @@ public class PmsProductServiceImpl implements PmsProductService {
@Autowired
@Autowired
private
PmsMemberPriceDao
memberPriceDao
;
private
PmsMemberPriceDao
memberPriceDao
;
@Autowired
@Autowired
private
PmsMemberPriceMapper
memberPriceMapper
;
@Autowired
private
PmsProductLadderDao
productLadderDao
;
private
PmsProductLadderDao
productLadderDao
;
@Autowired
@Autowired
private
PmsProductLadderMapper
productLadderMapper
;
@Autowired
private
PmsProductFullReductionDao
productFullReductionDao
;
private
PmsProductFullReductionDao
productFullReductionDao
;
@Autowired
@Autowired
private
PmsProductFullReductionMapper
productFullReductionMapper
;
@Autowired
private
PmsSkuStockDao
skuStockDao
;
private
PmsSkuStockDao
skuStockDao
;
@Autowired
@Autowired
private
PmsSkuStockMapper
skuStockMapper
;
@Autowired
private
PmsProductAttributeValueDao
productAttributeValueDao
;
private
PmsProductAttributeValueDao
productAttributeValueDao
;
@Autowired
@Autowired
private
PmsProductAttributeValueMapper
productAttributeValueMapper
;
@Autowired
private
CmsSubjectProductRelationDao
subjectProductRelationDao
;
private
CmsSubjectProductRelationDao
subjectProductRelationDao
;
@Autowired
@Autowired
private
CmsSubjectProductRelationMapper
subjectProductRelationMapper
;
@Autowired
private
CmsPrefrenceAreaProductRelationDao
prefrenceAreaProductRelationDao
;
private
CmsPrefrenceAreaProductRelationDao
prefrenceAreaProductRelationDao
;
@Autowired
private
CmsPrefrenceAreaProductRelationMapper
prefrenceAreaProductRelationMapper
;
@Autowired
private
PmsProductDao
productDao
;
@Autowired
private
PmsProductVertifyRecordDao
productVertifyRecordDao
;
@Override
@Override
public
int
create
(
PmsProductParam
productParam
)
{
public
int
create
(
PmsProductParam
productParam
)
{
int
count
;
int
count
;
//创建商品
//创建商品
PmsProduct
product
=
productParam
.
getProduct
()
;
PmsProduct
product
=
productParam
;
product
.
setId
(
null
);
product
.
setId
(
null
);
productMapper
.
insertSelective
(
product
);
productMapper
.
insertSelective
(
product
);
//根据促销类型设置价格:、阶梯价格、满减价格
//根据促销类型设置价格:、阶梯价格、满减价格
...
@@ -65,6 +90,106 @@ public class PmsProductServiceImpl implements PmsProductService {
...
@@ -65,6 +90,106 @@ public class PmsProductServiceImpl implements PmsProductService {
return
count
;
return
count
;
}
}
@Override
public
PmsProductResult
getUpdateInfo
(
Long
id
)
{
return
productDao
.
getUpdateInfo
(
id
);
}
@Override
public
int
update
(
Long
id
,
PmsProductParam
productParam
)
{
int
count
;
//更新商品信息
PmsProduct
product
=
productParam
;
product
.
setId
(
id
);
productMapper
.
updateByPrimaryKeySelective
(
product
);
//会员价格
PmsMemberPriceExample
pmsMemberPriceExample
=
new
PmsMemberPriceExample
();
pmsMemberPriceExample
.
createCriteria
().
andProductIdEqualTo
(
id
);
memberPriceMapper
.
deleteByExample
(
pmsMemberPriceExample
);
relateAndInsertList
(
memberPriceDao
,
productParam
.
getMemberPriceList
(),
id
);
//阶梯价格
PmsProductLadderExample
ladderExample
=
new
PmsProductLadderExample
();
ladderExample
.
createCriteria
().
andProductIdEqualTo
(
id
);
productLadderMapper
.
deleteByExample
(
ladderExample
);
relateAndInsertList
(
productLadderDao
,
productParam
.
getProductLadderList
(),
id
);
//满减价格
PmsProductFullReductionExample
fullReductionExample
=
new
PmsProductFullReductionExample
();
fullReductionExample
.
createCriteria
().
andProductIdEqualTo
(
id
);
productFullReductionMapper
.
deleteByExample
(
fullReductionExample
);
relateAndInsertList
(
productFullReductionDao
,
productParam
.
getProductFullReductionList
(),
id
);
//修改sku库存信息
PmsSkuStockExample
skuStockExample
=
new
PmsSkuStockExample
();
skuStockExample
.
createCriteria
().
andProductIdEqualTo
(
id
);
skuStockMapper
.
deleteByExample
(
skuStockExample
);
relateAndInsertList
(
skuStockDao
,
productParam
.
getSkuStockList
(),
id
);
//修改商品参数,添加自定义商品规格
PmsProductAttributeValueExample
productAttributeValueExample
=
new
PmsProductAttributeValueExample
();
productAttributeValueExample
.
createCriteria
().
andProductIdEqualTo
(
id
);
productAttributeValueMapper
.
deleteByExample
(
productAttributeValueExample
);
relateAndInsertList
(
productAttributeValueDao
,
productParam
.
getProductAttributeValueList
(),
id
);
//关联专题
CmsSubjectProductRelationExample
subjectProductRelationExample
=
new
CmsSubjectProductRelationExample
();
subjectProductRelationExample
.
createCriteria
().
andProductIdEqualTo
(
id
);
subjectProductRelationMapper
.
deleteByExample
(
subjectProductRelationExample
);
relateAndInsertList
(
subjectProductRelationDao
,
productParam
.
getSubjectProductRelationList
(),
id
);
//关联优选
CmsPrefrenceAreaProductRelationExample
prefrenceAreaExample
=
new
CmsPrefrenceAreaProductRelationExample
();
prefrenceAreaExample
.
createCriteria
().
andProductIdEqualTo
(
id
);
prefrenceAreaProductRelationMapper
.
deleteByExample
(
prefrenceAreaExample
);
relateAndInsertList
(
prefrenceAreaProductRelationDao
,
productParam
.
getPrefrenceAreaProductRelationList
(),
id
);
count
=
1
;
return
count
;
}
@Override
public
List
<
PmsProduct
>
list
(
PmsProductQueryParam
productQueryParam
,
Integer
pageSize
,
Integer
pageNum
)
{
PageHelper
.
startPage
(
pageNum
,
pageSize
);
PmsProductExample
productExample
=
new
PmsProductExample
();
PmsProductExample
.
Criteria
criteria
=
productExample
.
createCriteria
();
criteria
.
andDeleteStatusEqualTo
(
0
);
if
(
productQueryParam
.
getPublishStatus
()!=
null
){
criteria
.
andPublishStatusEqualTo
(
productQueryParam
.
getPublishStatus
());
}
if
(
productQueryParam
.
getVerifyStatus
()!=
null
){
criteria
.
andVerifyStatusEqualTo
(
productQueryParam
.
getVerifyStatus
());
}
if
(!
StringUtils
.
isEmpty
(
productQueryParam
.
getKeyword
())){
criteria
.
andNameLike
(
"%"
+
productQueryParam
.
getKeyword
()+
"%"
);
}
if
(!
StringUtils
.
isEmpty
(
productQueryParam
.
getProductSn
())){
criteria
.
andProductSnEqualTo
(
productQueryParam
.
getProductSn
());
}
if
(
productQueryParam
.
getBrandId
()!=
null
){
criteria
.
andBrandIdEqualTo
(
productQueryParam
.
getBrandId
());
}
if
(
productQueryParam
.
getProductCategoryId
()!=
null
){
criteria
.
andProductCategoryIdEqualTo
(
productQueryParam
.
getProductCategoryId
());
}
return
productMapper
.
selectByExample
(
productExample
);
}
@Override
public
int
updateVerifyStatus
(
List
<
Long
>
ids
,
Integer
verifyStatus
,
String
detail
)
{
PmsProduct
product
=
new
PmsProduct
();
product
.
setVerifyStatus
(
verifyStatus
);
PmsProductExample
example
=
new
PmsProductExample
();
example
.
createCriteria
().
andIdIn
(
ids
);
List
<
PmsProductVertifyRecord
>
list
=
new
ArrayList
<>();
int
count
=
productMapper
.
updateByExampleSelective
(
product
,
example
);
//修改完审核状态后插入审核记录
for
(
Long
id
:
ids
)
{
PmsProductVertifyRecord
record
=
new
PmsProductVertifyRecord
();
record
.
setProductId
(
id
);
record
.
setCreateTime
(
new
Date
());
record
.
setDetail
(
detail
);
record
.
setStatus
(
verifyStatus
);
record
.
setVertifyMan
(
"test"
);
list
.
add
(
record
);
}
productVertifyRecordDao
.
insertList
(
list
);
return
count
;
}
/**
/**
* @deprecated
* @deprecated
* 旧版创建
* 旧版创建
...
@@ -72,7 +197,7 @@ public class PmsProductServiceImpl implements PmsProductService {
...
@@ -72,7 +197,7 @@ public class PmsProductServiceImpl implements PmsProductService {
public
int
createOld
(
PmsProductParam
productParam
)
{
public
int
createOld
(
PmsProductParam
productParam
)
{
int
count
;
int
count
;
//创建商品
//创建商品
PmsProduct
product
=
productParam
.
getProduct
()
;
PmsProduct
product
=
productParam
;
product
.
setId
(
null
);
product
.
setId
(
null
);
productMapper
.
insertSelective
(
product
);
productMapper
.
insertSelective
(
product
);
//根据促销类型设置价格:、阶梯价格、满减价格
//根据促销类型设置价格:、阶梯价格、满减价格
...
@@ -153,4 +278,5 @@ public class PmsProductServiceImpl implements PmsProductService {
...
@@ -153,4 +278,5 @@ public class PmsProductServiceImpl implements PmsProductService {
throw
new
RuntimeException
(
e
.
getMessage
());
throw
new
RuntimeException
(
e
.
getMessage
());
}
}
}
}
}
}
mall-admin/src/main/java/com/macro/mall/service/impl/PmsSkuStockServiceImpl.java
0 → 100644
View file @
17e6a32d
package
com.macro.mall.service.impl
;
import
com.macro.mall.mapper.PmsSkuStockMapper
;
import
com.macro.mall.model.PmsSkuStock
;
import
com.macro.mall.model.PmsSkuStockExample
;
import
com.macro.mall.service.PmsSkuStockService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
/**
* 商品sku库存管理Service实现类
* Created by macro on 2018/4/27.
*/
@Service
public
class
PmsSkuStockServiceImpl
implements
PmsSkuStockService
{
@Autowired
private
PmsSkuStockMapper
skuStockMapper
;
@Override
public
List
<
PmsSkuStock
>
getList
(
Long
pid
,
String
keyword
)
{
PmsSkuStockExample
example
=
new
PmsSkuStockExample
();
example
.
createCriteria
().
andProductIdEqualTo
(
pid
).
andSkuCodeLike
(
"%"
+
keyword
+
"%"
)
return
skuStockMapper
.
selectByExample
(
example
);
}
}
mall-admin/src/main/resources/dao/PmsProductDao.xml
0 → 100644
View file @
17e6a32d
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.macro.mall.dao.PmsProductDao"
>
<resultMap
id=
"updateInfoMap"
type=
"com.macro.mall.dto.PmsProductResult"
extends=
"com.macro.mall.mapper.PmsProductMapper.BaseResultMap"
>
<collection
property=
"productLadderList"
columnPrefix=
"ladder_"
resultMap=
"com.macro.mall.mapper.PmsProductLadderMapper.BaseResultMap"
>
</collection>
<collection
property=
"productFullReductionList"
columnPrefix=
"full_"
resultMap=
"com.macro.mall.mapper.PmsProductFullReductionMapper.BaseResultMap"
>
</collection>
<collection
property=
"memberPriceList"
columnPrefix=
"member_"
resultMap=
"com.macro.mall.mapper.PmsMemberPriceMapper.BaseResultMap"
>
</collection>
<collection
property=
"skuStockList"
columnPrefix=
"sku_"
resultMap=
"com.macro.mall.mapper.PmsSkuStockMapper.BaseResultMap"
>
</collection>
<collection
property=
"productAttributeValueList"
columnPrefix=
"attribute_"
resultMap=
"com.macro.mall.mapper.PmsProductAttributeValueMapper.BaseResultMap"
>
</collection>
<collection
property=
"subjectList"
column=
"{productId=id}"
select=
"selectSubjectByProductId"
>
</collection>
<collection
property=
"prefrenceAreaList"
column=
"{productId=id}"
select=
"selectPrefrenceAreaByProductId"
>
</collection>
</resultMap>
<select
id=
"getUpdateInfo"
resultMap=
"updateInfoMap"
>
SELECT *,
f.name feightTemplateName,
ac.name productAttributeCategoryName,
l.id ladder_id,l.discount ladder_discount,l.count ladder_count,l.price ladder_price,
pf.id full_id,pf.full_price full_full_price,pf.reduce_price full_reduce_price,
m.id member_id,m.member_level_id member_member_level_id,m.member_price member_member_price,
s.id sku_id,s.price sku_price,s.low_stock sku_low_stock,s.pic sku_pic,s.sale sku_sale,s.sku_code sku_sku_code,s.sp1 sku_sp1,s.sp2 sku_sp2,s.sp3 sku_sp3,s.stock sku_stock,
a.id attribute_id,a.product_attribute_id attribute_product_attribute_id,a.value attribute_value
FROM pms_product p
LEFT JOIN pms_feight_template f ON p.feight_template_id = f.id
LEFT JOIN pms_product_attribute_category ac ON p.product_attribute_category_id= ac.id
LEFT JOIN pms_product_ladder l ON p.id = l.product_id
LEFT JOIN pms_product_full_reduction pf ON pf.product_id=p.id
LEFT JOIN pms_member_price m ON m.product_id = p.id
LEFT JOIN pms_sku_stock s ON s.product_id = p.id
LEFT JOIN pms_product_attribute_value a ON a.product_id=p.id
WHERE p.id=#{id};
</select>
<select
id=
"selectSubjectByProductId"
resultMap=
"com.macro.mall.mapper.CmsSubjectMapper.BaseResultMap"
>
SELECT s.*
FROM cms_subject_product_relation spr
LEFT JOIN cms_subject s ON spr.subject_id = s.id
WHERE spr.product_id = #{productId}
</select>
<select
id=
"selectPrefrenceAreaByProductId"
resultMap=
"com.macro.mall.mapper.CmsPrefrenceAreaMapper.BaseResultMap"
>
SELECT p.*
FROM cms_prefrence_area_product_relation ppr
LEFT JOIN cms_prefrence_area p ON ppr.prefrence_area_id=p.id
WHERE ppr.product_id=#{productId}
</select>
</mapper>
\ No newline at end of file
Prev
1
2
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment