mirror of
https://github.com/kirklin/kkmall.git
synced 2024-09-20 06:46:15 +08:00
商品服务API-> 平台属性,新增商品,商品管理
This commit is contained in:
parent
caaf701723
commit
b5ce8c530d
|
@ -80,5 +80,6 @@
|
||||||
<orderEntry type="library" name="Maven: com.google.protobuf:protobuf-java:3.11.4" level="project" />
|
<orderEntry type="library" name="Maven: com.google.protobuf:protobuf-java:3.11.4" level="project" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.servlet:servlet-api:2.5" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.servlet:servlet-api:2.5" level="project" />
|
||||||
<orderEntry type="library" name="Maven: javax.validation:validation-api:2.0.1.Final" level="project" />
|
<orderEntry type="library" name="Maven: javax.validation:validation-api:2.0.1.Final" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.alibaba:fastjson:1.2.72" level="project" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
|
@ -89,5 +89,11 @@
|
||||||
<artifactId>validation-api</artifactId>
|
<artifactId>validation-api</artifactId>
|
||||||
<version>2.0.1.Final</version>
|
<version>2.0.1.Final</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>fastjson</artifactId>
|
||||||
|
<version>1.2.72</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
|
@ -0,0 +1,12 @@
|
||||||
|
package name.lkk.common.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Title: AuthServerConstant</p>
|
||||||
|
* Description:
|
||||||
|
* date:2020/6/25 16:03
|
||||||
|
*/
|
||||||
|
public class AuthServerConstant {
|
||||||
|
public static final String SMS_CODE_CACHE_PREFIX = "sms:code:";
|
||||||
|
public static final String LOGIN_USER = "loginUser";
|
||||||
|
public static final String NOT_LOGIN = "请先进行登录";
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package name.lkk.common.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Title: CartConstant</p>
|
||||||
|
* Description:
|
||||||
|
* date:2020/6/27 22:37
|
||||||
|
*/
|
||||||
|
public class CartConstant {
|
||||||
|
|
||||||
|
public static final String TEMP_USER_COOKIE_NAME = "user-key";
|
||||||
|
|
||||||
|
public static final int TEMP_USER_COOKIE_TIME_OUT = 60 * 60 * 24 * 30;
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
package name.lkk.common.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Title: ProductConstant</p>
|
||||||
|
* Description:给销售属性用来区分保存与修改 根据情况看是否需要保存关联属性
|
||||||
|
* date:2020/6/2 23:45
|
||||||
|
*/
|
||||||
|
public class ProductConstant {
|
||||||
|
|
||||||
|
public enum AttrEnum {
|
||||||
|
ATTR_TYPE_BASE(1, "基本属性"), ATTR_TYPE_SALE(0, "销售属性");
|
||||||
|
|
||||||
|
private int code;
|
||||||
|
|
||||||
|
private String msg;
|
||||||
|
|
||||||
|
AttrEnum(int code, String msg) {
|
||||||
|
this.code = code;
|
||||||
|
this.msg = msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMsg() {
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum StatusEnum {
|
||||||
|
SPU_NEW(0, "新建"), SPU_UP(1, "上架"), SPU_DOWN(2, "下架");
|
||||||
|
|
||||||
|
private int code;
|
||||||
|
|
||||||
|
private String msg;
|
||||||
|
|
||||||
|
StatusEnum(int code, String msg) {
|
||||||
|
this.code = code;
|
||||||
|
this.msg = msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMsg() {
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
package name.lkk.common.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kirklin
|
||||||
|
*/
|
||||||
|
public class WareConstant {
|
||||||
|
|
||||||
|
public enum PurchaseStatusEnum{
|
||||||
|
CREATED(0,"新建"),ASSIGNED(1,"已分配"),
|
||||||
|
RECEIVE(2,"已领取"),FINISH(3,"已完成"),
|
||||||
|
HASERROR(4,"有异常");
|
||||||
|
private int code;
|
||||||
|
private String msg;
|
||||||
|
|
||||||
|
PurchaseStatusEnum(int code,String msg){
|
||||||
|
this.code = code;
|
||||||
|
this.msg = msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMsg() {
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public enum PurchaseDetailStatusEnum{
|
||||||
|
CREATED(0,"新建"),ASSIGNED(1,"已分配"),
|
||||||
|
BUYING(2,"正在采购"),FINISH(3,"已完成"),
|
||||||
|
HASERROR(4,"采购失败");
|
||||||
|
private int code;
|
||||||
|
private String msg;
|
||||||
|
|
||||||
|
PurchaseDetailStatusEnum(int code,String msg){
|
||||||
|
this.code = code;
|
||||||
|
this.msg = msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMsg() {
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package name.lkk.common.to;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class MemberPrice {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
private String name;
|
||||||
|
private BigDecimal price;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
package name.lkk.common.to;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Title: SkuReductionTO</p>
|
||||||
|
* Description:
|
||||||
|
* date:2020/6/5 17:33
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class SkuReductionTO {
|
||||||
|
|
||||||
|
private Long skuId;
|
||||||
|
|
||||||
|
/***
|
||||||
|
* fullCount、discount、countStatus 打折信息
|
||||||
|
*/
|
||||||
|
private int fullCount;
|
||||||
|
|
||||||
|
private BigDecimal discount;
|
||||||
|
|
||||||
|
private int countStatus;
|
||||||
|
|
||||||
|
private BigDecimal fullPrice;
|
||||||
|
|
||||||
|
private BigDecimal reducePrice;
|
||||||
|
|
||||||
|
private int priceStatus;
|
||||||
|
|
||||||
|
private List<MemberPrice> memberPrice;
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package name.lkk.common.to;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Title: SpuBoundTO</p>
|
||||||
|
* Description:远程调用对象 成长积分、购物积分
|
||||||
|
* date:2020/6/5 17:12
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class SpuBoundTO {
|
||||||
|
|
||||||
|
private Long spuId;
|
||||||
|
|
||||||
|
private BigDecimal buyBounds;
|
||||||
|
|
||||||
|
private BigDecimal growBounds;
|
||||||
|
}
|
|
@ -1,13 +1,8 @@
|
||||||
/**
|
|
||||||
* Copyright (c) 2016-2019 人人开源 All rights reserved.
|
|
||||||
*
|
|
||||||
* https://www.renren.io
|
|
||||||
*
|
|
||||||
* 版权所有,侵权必究!
|
|
||||||
*/
|
|
||||||
|
|
||||||
package name.lkk.common.utils;
|
package name.lkk.common.utils;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.TypeReference;
|
||||||
import org.apache.http.HttpStatus;
|
import org.apache.http.HttpStatus;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -15,18 +10,40 @@ import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回数据
|
* 返回数据
|
||||||
*
|
* R 继承了 HashMap 则不能继续使用泛型数据了 必须全是hashMap数据
|
||||||
*/
|
*/
|
||||||
public class R extends HashMap<String, Object> {
|
public class R extends HashMap<String, Object> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param key 获取指定key的名字
|
||||||
|
*/
|
||||||
|
public <T> T getData(String key, TypeReference<T> typeReference){
|
||||||
|
// get("data") 默认是map类型 所以再由map转成string再转json
|
||||||
|
Object data = get(key);
|
||||||
|
return JSON.parseObject(JSON.toJSONString(data), typeReference);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 复杂类型转换 TypeReference
|
||||||
|
*/
|
||||||
|
public <T> T getData(TypeReference<T> typeReference){
|
||||||
|
// get("data") 默认是map类型 所以再由map转成string再转json
|
||||||
|
Object data = get("data");
|
||||||
|
return JSON.parseObject(JSON.toJSONString(data), typeReference);
|
||||||
|
}
|
||||||
|
|
||||||
|
public R setData(Object data){
|
||||||
|
put("data", data);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
public R() {
|
public R() {
|
||||||
put("code", 0);
|
put("code", 0);
|
||||||
put("msg", "success");
|
put("msg", "success");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static R error() {
|
public static R error() {
|
||||||
return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, "未知异常,请联系管理员");
|
return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, "未知异常,请联系FIRENAY");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static R error(String msg) {
|
public static R error(String msg) {
|
||||||
|
@ -60,4 +77,8 @@ public class R extends HashMap<String, Object> {
|
||||||
super.put(key, value);
|
super.put(key, value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getCode() {
|
||||||
|
return (Integer) this.get("code");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,16 @@
|
||||||
package name.lkk.kkmall.coupon.controller;
|
package name.lkk.kkmall.coupon.controller;
|
||||||
|
|
||||||
|
import name.lkk.common.to.SkuReductionTO;
|
||||||
|
import name.lkk.common.utils.PageUtils;
|
||||||
|
import name.lkk.common.utils.R;
|
||||||
|
import name.lkk.kkmall.coupon.entity.SkuFullReductionEntity;
|
||||||
|
import name.lkk.kkmall.coupon.service.SkuFullReductionService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Map;
|
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 name.lkk.kkmall.coupon.entity.SkuFullReductionEntity;
|
|
||||||
import name.lkk.kkmall.coupon.service.SkuFullReductionService;
|
|
||||||
import name.lkk.common.utils.PageUtils;
|
|
||||||
import name.lkk.common.utils.R;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,6 +26,13 @@ public class SkuFullReductionController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private SkuFullReductionService skuFullReductionService;
|
private SkuFullReductionService skuFullReductionService;
|
||||||
|
|
||||||
|
@PostMapping("/saveinfo")
|
||||||
|
public R saveInfo(@RequestBody SkuReductionTO reductionTo){
|
||||||
|
|
||||||
|
skuFullReductionService.saveSkuReduction(reductionTo);
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 列表
|
* 列表
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,20 +1,15 @@
|
||||||
package name.lkk.kkmall.coupon.controller;
|
package name.lkk.kkmall.coupon.controller;
|
||||||
|
|
||||||
|
import name.lkk.common.utils.PageUtils;
|
||||||
|
import name.lkk.common.utils.R;
|
||||||
|
import name.lkk.kkmall.coupon.entity.SpuBoundsEntity;
|
||||||
|
import name.lkk.kkmall.coupon.service.SpuBoundsService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Map;
|
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 name.lkk.kkmall.coupon.entity.SpuBoundsEntity;
|
|
||||||
import name.lkk.kkmall.coupon.service.SpuBoundsService;
|
|
||||||
import name.lkk.common.utils.PageUtils;
|
|
||||||
import name.lkk.common.utils.R;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,13 +48,13 @@ public class SpuBoundsController {
|
||||||
return R.ok().put("spuBounds", spuBounds);
|
return R.ok().put("spuBounds", spuBounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存
|
* 保存
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/save")
|
@PostMapping("/save")
|
||||||
//@RequiresPermissions("coupon:spubounds:save")
|
|
||||||
public R save(@RequestBody SpuBoundsEntity spuBounds){
|
public R save(@RequestBody SpuBoundsEntity spuBounds){
|
||||||
spuBoundsService.save(spuBounds);
|
spuBoundsService.save(spuBounds);
|
||||||
|
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package name.lkk.kkmall.coupon.service;
|
package name.lkk.kkmall.coupon.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import name.lkk.common.to.SkuReductionTO;
|
||||||
import name.lkk.common.utils.PageUtils;
|
import name.lkk.common.utils.PageUtils;
|
||||||
import name.lkk.kkmall.coupon.entity.SkuFullReductionEntity;
|
import name.lkk.kkmall.coupon.entity.SkuFullReductionEntity;
|
||||||
|
|
||||||
|
@ -16,5 +17,7 @@ import java.util.Map;
|
||||||
public interface SkuFullReductionService extends IService<SkuFullReductionEntity> {
|
public interface SkuFullReductionService extends IService<SkuFullReductionEntity> {
|
||||||
|
|
||||||
PageUtils queryPage(Map<String, Object> params);
|
PageUtils queryPage(Map<String, Object> params);
|
||||||
|
|
||||||
|
void saveSkuReduction(SkuReductionTO reductionTo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,39 @@
|
||||||
package name.lkk.kkmall.coupon.service.impl;
|
package name.lkk.kkmall.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.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import name.lkk.common.to.MemberPrice;
|
||||||
|
import name.lkk.common.to.SkuReductionTO;
|
||||||
import name.lkk.common.utils.PageUtils;
|
import name.lkk.common.utils.PageUtils;
|
||||||
import name.lkk.common.utils.Query;
|
import name.lkk.common.utils.Query;
|
||||||
|
|
||||||
import name.lkk.kkmall.coupon.dao.SkuFullReductionDao;
|
import name.lkk.kkmall.coupon.dao.SkuFullReductionDao;
|
||||||
|
import name.lkk.kkmall.coupon.entity.MemberPriceEntity;
|
||||||
import name.lkk.kkmall.coupon.entity.SkuFullReductionEntity;
|
import name.lkk.kkmall.coupon.entity.SkuFullReductionEntity;
|
||||||
|
import name.lkk.kkmall.coupon.entity.SkuLadderEntity;
|
||||||
|
import name.lkk.kkmall.coupon.service.MemberPriceService;
|
||||||
import name.lkk.kkmall.coupon.service.SkuFullReductionService;
|
import name.lkk.kkmall.coupon.service.SkuFullReductionService;
|
||||||
|
import name.lkk.kkmall.coupon.service.SkuLadderService;
|
||||||
|
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")
|
@Service("skuFullReductionService")
|
||||||
public class SkuFullReductionServiceImpl extends ServiceImpl<SkuFullReductionDao, SkuFullReductionEntity> implements SkuFullReductionService {
|
public class SkuFullReductionServiceImpl extends ServiceImpl<SkuFullReductionDao, SkuFullReductionEntity> implements SkuFullReductionService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SkuLadderService skuLadderService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
|
||||||
|
private MemberPriceService memberPriceService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageUtils queryPage(Map<String, Object> params) {
|
public PageUtils queryPage(Map<String, Object> params) {
|
||||||
IPage<SkuFullReductionEntity> page = this.page(
|
IPage<SkuFullReductionEntity> page = this.page(
|
||||||
|
@ -26,4 +44,46 @@ public class SkuFullReductionServiceImpl extends ServiceImpl<SkuFullReductionDao
|
||||||
return new PageUtils(page);
|
return new PageUtils(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveSkuReduction(SkuReductionTO skuReductionTO) {
|
||||||
|
|
||||||
|
// 保存sku的优惠、满减、会员价格等信息 [跨库] sms_sku_ladder
|
||||||
|
SkuLadderEntity skuLadderEntity = new SkuLadderEntity();
|
||||||
|
skuLadderEntity.setSkuId(skuReductionTO.getSkuId());
|
||||||
|
skuLadderEntity.setFullCount(skuReductionTO.getFullCount());
|
||||||
|
skuLadderEntity.setDiscount(skuReductionTO.getDiscount());
|
||||||
|
// 是否参加其他优惠
|
||||||
|
skuLadderEntity.setAddOther(skuReductionTO.getCountStatus());
|
||||||
|
// 有的满减条件才保存
|
||||||
|
if (skuReductionTO.getFullCount() > 0) {
|
||||||
|
skuLadderService.save(skuLadderEntity);
|
||||||
|
}
|
||||||
|
skuLadderService.save(skuLadderEntity);
|
||||||
|
|
||||||
|
// sms_sku_full_reduction
|
||||||
|
SkuFullReductionEntity skuFullReductionEntity = new SkuFullReductionEntity();
|
||||||
|
BeanUtils.copyProperties(skuReductionTO, skuFullReductionEntity);
|
||||||
|
if ((skuFullReductionEntity.getFullPrice().compareTo(new BigDecimal("0")) == 1)) {
|
||||||
|
this.save(skuFullReductionEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
// sms_member_price 保存价格等属性
|
||||||
|
List<MemberPrice> memberPrice = skuReductionTO.getMemberPrice();
|
||||||
|
List<MemberPriceEntity> collect = memberPrice.stream().map(m -> {
|
||||||
|
MemberPriceEntity priceEntity = new MemberPriceEntity();
|
||||||
|
priceEntity.setSkuId(skuReductionTO.getSkuId());
|
||||||
|
priceEntity.setMemberLevelId(m.getId());
|
||||||
|
priceEntity.setMemberLevelName(m.getName());
|
||||||
|
priceEntity.setMemberPrice(m.getPrice());
|
||||||
|
priceEntity.setAddOther(1);
|
||||||
|
|
||||||
|
return priceEntity;
|
||||||
|
|
||||||
|
}).filter(item ->
|
||||||
|
// 输入的商品价格必须要大于0才保存
|
||||||
|
(item.getMemberPrice().compareTo(new BigDecimal("0")) > 0)
|
||||||
|
).collect(Collectors.toList());
|
||||||
|
memberPriceService.saveBatch(collect);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -4,6 +4,7 @@ import org.mybatis.spring.annotation.MapperScan;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||||
|
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author: kirklin
|
* @author: kirklin
|
||||||
|
@ -13,6 +14,7 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||||
@MapperScan("name.lkk.kkmall.product.dao")
|
@MapperScan("name.lkk.kkmall.product.dao")
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@EnableDiscoveryClient
|
@EnableDiscoveryClient
|
||||||
|
@EnableFeignClients(basePackages = "name.lkk.kkmall.product.feign")
|
||||||
public class KkmallProductApplication {
|
public class KkmallProductApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
|
@ -1,19 +1,18 @@
|
||||||
package name.lkk.kkmall.product.controller;
|
package name.lkk.kkmall.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 name.lkk.kkmall.product.entity.AttrEntity;
|
|
||||||
import name.lkk.kkmall.product.service.AttrService;
|
|
||||||
import name.lkk.common.utils.PageUtils;
|
import name.lkk.common.utils.PageUtils;
|
||||||
import name.lkk.common.utils.R;
|
import name.lkk.common.utils.R;
|
||||||
|
import name.lkk.kkmall.product.entity.ProductAttrValueEntity;
|
||||||
|
import name.lkk.kkmall.product.service.AttrService;
|
||||||
|
import name.lkk.kkmall.product.service.ProductAttrValueService;
|
||||||
|
import name.lkk.kkmall.product.vo.AttrRespVo;
|
||||||
|
import name.lkk.kkmall.product.vo.AttrVo;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,6 +29,31 @@ public class AttrController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private AttrService attrService;
|
private AttrService attrService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ProductAttrValueService productAttrValueService;
|
||||||
|
|
||||||
|
@PostMapping("/update/{spuId}")
|
||||||
|
public R updateSpiAttr(@PathVariable("spuId") Long spuId, @RequestBody List<ProductAttrValueEntity> entities){
|
||||||
|
productAttrValueService.updateSpuAttr(spuId, entities);
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询属性规格
|
||||||
|
*/
|
||||||
|
@GetMapping("/base/listforspu/{spuId}")
|
||||||
|
public R baseAttrListForSpu(@PathVariable("spuId") Long spuId){
|
||||||
|
List<ProductAttrValueEntity> entities = productAttrValueService.baseAttrListForSpu(spuId);
|
||||||
|
return R.ok().put("data", entities);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/{attrType}/list/{catelogId}")
|
||||||
|
public R baseAttrList(@RequestParam Map<String, Object> params ,@PathVariable("catelogId") Long catelogId, @PathVariable("attrType") String attrType){
|
||||||
|
|
||||||
|
PageUtils page = attrService.queryBaseAttrPage(params, catelogId, attrType);
|
||||||
|
return R.ok().put("page", page);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 列表
|
* 列表
|
||||||
*/
|
*/
|
||||||
|
@ -46,32 +70,28 @@ public class AttrController {
|
||||||
* 信息
|
* 信息
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/info/{attrId}")
|
@RequestMapping("/info/{attrId}")
|
||||||
//@RequiresPermissions("product:attr:info")
|
|
||||||
public R info(@PathVariable("attrId") Long attrId){
|
public R info(@PathVariable("attrId") Long attrId){
|
||||||
AttrEntity attr = attrService.getById(attrId);
|
AttrRespVo respVo = attrService.getAttrInfo(attrId);
|
||||||
|
return R.ok().put("data", respVo);
|
||||||
return R.ok().put("attr", attr);
|
//return R.ok().put("attr", respVo).put("data", respVo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存
|
* 保存
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/save")
|
@RequestMapping("/save")
|
||||||
//@RequiresPermissions("product:attr:save")
|
public R save(@RequestBody AttrVo attrVo){
|
||||||
public R save(@RequestBody AttrEntity attr){
|
attrService.saveAttr(attrVo);
|
||||||
attrService.save(attr);
|
|
||||||
|
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改
|
* 更改规格参数:参数名、参数id、参数、状态的一一对应
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/update")
|
@RequestMapping("/update")
|
||||||
//@RequiresPermissions("product:attr:update")
|
public R update(@RequestBody AttrVo attrVo){
|
||||||
public R update(@RequestBody AttrEntity attr){
|
attrService.updateAttr(attrVo);
|
||||||
attrService.updateById(attr);
|
|
||||||
|
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,9 +99,8 @@ public class AttrController {
|
||||||
* 删除
|
* 删除
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/delete")
|
@RequestMapping("/delete")
|
||||||
//@RequiresPermissions("product:attr:delete")
|
|
||||||
public R delete(@RequestBody Long[] attrIds){
|
public R delete(@RequestBody Long[] attrIds){
|
||||||
attrService.removeByIds(Arrays.asList(attrIds));
|
attrService.removeByIds(Arrays.asList(attrIds));
|
||||||
|
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,13 +2,19 @@ package name.lkk.kkmall.product.controller;
|
||||||
|
|
||||||
import name.lkk.common.utils.PageUtils;
|
import name.lkk.common.utils.PageUtils;
|
||||||
import name.lkk.common.utils.R;
|
import name.lkk.common.utils.R;
|
||||||
|
import name.lkk.kkmall.product.entity.AttrEntity;
|
||||||
import name.lkk.kkmall.product.entity.AttrGroupEntity;
|
import name.lkk.kkmall.product.entity.AttrGroupEntity;
|
||||||
|
import name.lkk.kkmall.product.service.AttrAttrgroupRelationService;
|
||||||
import name.lkk.kkmall.product.service.AttrGroupService;
|
import name.lkk.kkmall.product.service.AttrGroupService;
|
||||||
|
import name.lkk.kkmall.product.service.AttrService;
|
||||||
import name.lkk.kkmall.product.service.CategoryService;
|
import name.lkk.kkmall.product.service.CategoryService;
|
||||||
|
import name.lkk.kkmall.product.vo.AttrGroupRelationVo;
|
||||||
|
import name.lkk.kkmall.product.vo.AttrGroupWithAttrsVo;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,19 +35,41 @@ public class AttrGroupController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private CategoryService categoryService;
|
private CategoryService categoryService;
|
||||||
|
|
||||||
/**
|
@Autowired
|
||||||
* 列表
|
private AttrService attrService;
|
||||||
*/
|
|
||||||
@RequestMapping("/list")
|
|
||||||
//@RequiresPermissions("product:attrgroup:list")
|
|
||||||
public R list(@RequestParam Map<String, Object> params){
|
|
||||||
PageUtils page = attrGroupService.queryPage(params);
|
|
||||||
|
|
||||||
return R.ok().put("page", page);
|
@Autowired
|
||||||
|
private AttrAttrgroupRelationService relationService;
|
||||||
|
|
||||||
|
@PostMapping("/attr/relation")
|
||||||
|
public R addRelation(@RequestBody List<AttrGroupRelationVo> vos){
|
||||||
|
relationService.saveBatch(vos);
|
||||||
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/{catelogId}/withattr")
|
||||||
|
public R getAttrGroupWithAttrs(@PathVariable("catelogId") Long catelogId){
|
||||||
|
// 1.查询当前分类下的所有属性分组
|
||||||
|
List<AttrGroupWithAttrsVo> vos = attrGroupService.getAttrGroupWithAttrByCatelogId(catelogId);
|
||||||
|
// 2.查询每个分组的所有信息
|
||||||
|
return R.ok().put("data", vos);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/{attrgroupId}/attr/relation")
|
||||||
|
public R attrRelation(@PathVariable("attrgroupId") Long attrgroupId){
|
||||||
|
// 获取当前分组关联的所有属性
|
||||||
|
List<AttrEntity> entities = attrService.getRelationAttr(attrgroupId);
|
||||||
|
return R.ok().put("data", entities);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/{attrgroupId}/noattr/relation")
|
||||||
|
public R attrNoRelation(@RequestParam Map<String, Object> params, @PathVariable("attrgroupId") Long attrgroupId){
|
||||||
|
// 传入所有分页信息 、分组id
|
||||||
|
PageUtils page = attrService.getNoRelationAttr(params, attrgroupId);
|
||||||
|
return R.ok().put("data", page);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 列表的属性分组
|
* 列表
|
||||||
* http://127.0.0.1:88/api/product/attrgroup/list/1?page=1&key=aa
|
* http://127.0.0.1:88/api/product/attrgroup/list/1?page=1&key=aa
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/list/{catelogId}")
|
@RequestMapping("/list/{catelogId}")
|
||||||
|
@ -68,8 +96,7 @@ public class AttrGroupController {
|
||||||
@RequestMapping("/save")
|
@RequestMapping("/save")
|
||||||
//@RequiresPermissions("product:attrgroup:save")
|
//@RequiresPermissions("product:attrgroup:save")
|
||||||
public R save(@RequestBody AttrGroupEntity attrGroup){
|
public R save(@RequestBody AttrGroupEntity attrGroup){
|
||||||
attrGroupService.save(attrGroup);
|
attrGroupService.save(attrGroup);
|
||||||
|
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +106,7 @@ public class AttrGroupController {
|
||||||
@RequestMapping("/update")
|
@RequestMapping("/update")
|
||||||
//@RequiresPermissions("product:attrgroup:update")
|
//@RequiresPermissions("product:attrgroup:update")
|
||||||
public R update(@RequestBody AttrGroupEntity attrGroup){
|
public R update(@RequestBody AttrGroupEntity attrGroup){
|
||||||
attrGroupService.updateById(attrGroup);
|
attrGroupService.updateById(attrGroup);
|
||||||
|
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
@ -88,11 +115,17 @@ public class AttrGroupController {
|
||||||
* 删除
|
* 删除
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/delete")
|
@RequestMapping("/delete")
|
||||||
//@RequiresPermissions("product:attrgroup:delete")
|
//@RequiresPermissions("${moduleNamez}:attrgroup:delete")
|
||||||
public R delete(@RequestBody Long[] attrGroupIds){
|
public R delete(@RequestBody Long[] attrGroupIds){
|
||||||
attrGroupService.removeByIds(Arrays.asList(attrGroupIds));
|
attrGroupService.removeByIds(Arrays.asList(attrGroupIds));
|
||||||
|
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/attr/relation/delete")
|
||||||
|
public R deleteRelation(@RequestBody AttrGroupRelationVo[] vos){
|
||||||
|
attrService.deleteRelation(vos);
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,15 +3,17 @@ package name.lkk.kkmall.product.controller;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import name.lkk.common.utils.PageUtils;
|
import name.lkk.common.utils.PageUtils;
|
||||||
import name.lkk.common.utils.R;
|
import name.lkk.common.utils.R;
|
||||||
|
import name.lkk.kkmall.product.entity.BrandEntity;
|
||||||
import name.lkk.kkmall.product.entity.CategoryBrandRelationEntity;
|
import name.lkk.kkmall.product.entity.CategoryBrandRelationEntity;
|
||||||
import name.lkk.kkmall.product.service.CategoryBrandRelationService;
|
import name.lkk.kkmall.product.service.CategoryBrandRelationService;
|
||||||
|
import name.lkk.kkmall.product.vo.BrandVo;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,7 +30,19 @@ public class CategoryBrandRelationController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private CategoryBrandRelationService categoryBrandRelationService;
|
private CategoryBrandRelationService categoryBrandRelationService;
|
||||||
|
|
||||||
|
@GetMapping("/brands/list")
|
||||||
|
public R relationBrandsList(@RequestParam(value = "catId",required = true,defaultValue = "-1") Long catId){
|
||||||
|
List<BrandEntity> vos = categoryBrandRelationService.getBrandsByCatId(catId);
|
||||||
|
List<BrandVo> collect = vos.stream().map(item -> {
|
||||||
|
BrandVo vo = new BrandVo();
|
||||||
|
vo.setBrandId(item.getBrandId());
|
||||||
|
vo.setBrandName(item.getName());
|
||||||
|
|
||||||
|
return vo;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
|
return R.ok().put("data", collect);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前品牌的所有分类列表
|
* 获取当前品牌的所有分类列表
|
||||||
|
|
|
@ -1,20 +1,15 @@
|
||||||
package name.lkk.kkmall.product.controller;
|
package name.lkk.kkmall.product.controller;
|
||||||
|
|
||||||
|
import name.lkk.common.utils.PageUtils;
|
||||||
|
import name.lkk.common.utils.R;
|
||||||
|
import name.lkk.kkmall.product.entity.SkuImagesEntity;
|
||||||
|
import name.lkk.kkmall.product.service.SkuImagesService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Map;
|
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 name.lkk.kkmall.product.entity.SkuImagesEntity;
|
|
||||||
import name.lkk.kkmall.product.service.SkuImagesService;
|
|
||||||
import name.lkk.common.utils.PageUtils;
|
|
||||||
import name.lkk.common.utils.R;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,7 +21,7 @@ import name.lkk.common.utils.R;
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("product/skuimages")
|
@RequestMapping("product/skuimages")
|
||||||
public class SkuImagesController {
|
public class SkuImagesController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private SkuImagesService skuImagesService;
|
private SkuImagesService skuImagesService;
|
||||||
|
|
||||||
|
@ -57,10 +52,9 @@ public class SkuImagesController {
|
||||||
* 保存
|
* 保存
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/save")
|
@RequestMapping("/save")
|
||||||
//@RequiresPermissions("product:skuimages:save")
|
|
||||||
public R save(@RequestBody SkuImagesEntity skuImages){
|
public R save(@RequestBody SkuImagesEntity skuImages){
|
||||||
skuImagesService.save(skuImages);
|
skuImages.setImgSort(0);
|
||||||
|
skuImagesService.save(skuImages);
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,15 @@
|
||||||
package name.lkk.kkmall.product.controller;
|
package name.lkk.kkmall.product.controller;
|
||||||
|
|
||||||
|
import name.lkk.common.utils.PageUtils;
|
||||||
|
import name.lkk.common.utils.R;
|
||||||
|
import name.lkk.kkmall.product.entity.SkuInfoEntity;
|
||||||
|
import name.lkk.kkmall.product.service.SkuInfoService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Map;
|
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 name.lkk.kkmall.product.entity.SkuInfoEntity;
|
|
||||||
import name.lkk.kkmall.product.service.SkuInfoService;
|
|
||||||
import name.lkk.common.utils.PageUtils;
|
|
||||||
import name.lkk.common.utils.R;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,25 +25,30 @@ public class SkuInfoController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private SkuInfoService skuInfoService;
|
private SkuInfoService skuInfoService;
|
||||||
|
|
||||||
|
@GetMapping("/{skuId}/price")
|
||||||
|
public R getPrice(@PathVariable("skuId") Long skuId){
|
||||||
|
|
||||||
|
SkuInfoEntity byId = skuInfoService.getById(skuId);
|
||||||
|
return R.ok().setData(byId.getPrice().toString());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 列表
|
* SKU查询
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/list")
|
@RequestMapping("/list")
|
||||||
//@RequiresPermissions("product:skuinfo:list")
|
|
||||||
public R list(@RequestParam Map<String, Object> params){
|
public R list(@RequestParam Map<String, Object> params){
|
||||||
PageUtils page = skuInfoService.queryPage(params);
|
PageUtils page = skuInfoService.queryPageByCondition(params);
|
||||||
|
|
||||||
return R.ok().put("page", page);
|
return R.ok().put("page", page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 信息
|
* 信息
|
||||||
|
* 库存保存的时候会远程调用这个接口
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/info/{skuId}")
|
@RequestMapping("/info/{skuId}")
|
||||||
//@RequiresPermissions("product:skuinfo:info")
|
|
||||||
public R info(@PathVariable("skuId") Long skuId){
|
public R info(@PathVariable("skuId") Long skuId){
|
||||||
SkuInfoEntity skuInfo = skuInfoService.getById(skuId);
|
SkuInfoEntity skuInfo = skuInfoService.getById(skuId);
|
||||||
|
|
||||||
return R.ok().put("skuInfo", skuInfo);
|
return R.ok().put("skuInfo", skuInfo);
|
||||||
}
|
}
|
||||||
|
@ -57,9 +57,8 @@ public class SkuInfoController {
|
||||||
* 保存
|
* 保存
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/save")
|
@RequestMapping("/save")
|
||||||
//@RequiresPermissions("product:skuinfo:save")
|
|
||||||
public R save(@RequestBody SkuInfoEntity skuInfo){
|
public R save(@RequestBody SkuInfoEntity skuInfo){
|
||||||
skuInfoService.save(skuInfo);
|
skuInfoService.save(skuInfo);
|
||||||
|
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
@ -68,9 +67,8 @@ public class SkuInfoController {
|
||||||
* 修改
|
* 修改
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/update")
|
@RequestMapping("/update")
|
||||||
//@RequiresPermissions("product:skuinfo:update")
|
|
||||||
public R update(@RequestBody SkuInfoEntity skuInfo){
|
public R update(@RequestBody SkuInfoEntity skuInfo){
|
||||||
skuInfoService.updateById(skuInfo);
|
skuInfoService.updateById(skuInfo);
|
||||||
|
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
@ -79,11 +77,11 @@ public class SkuInfoController {
|
||||||
* 删除
|
* 删除
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/delete")
|
@RequestMapping("/delete")
|
||||||
//@RequiresPermissions("product:skuinfo:delete")
|
//@RequiresPermissions("${moduleNamez}:skuinfo:delete")
|
||||||
public R delete(@RequestBody Long[] skuIds){
|
public R delete(@RequestBody Long[] skuIds){
|
||||||
skuInfoService.removeByIds(Arrays.asList(skuIds));
|
skuInfoService.removeByIds(Arrays.asList(skuIds));
|
||||||
|
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,15 @@
|
||||||
package name.lkk.kkmall.product.controller;
|
package name.lkk.kkmall.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 name.lkk.kkmall.product.entity.SkuSaleAttrValueEntity;
|
|
||||||
import name.lkk.kkmall.product.service.SkuSaleAttrValueService;
|
|
||||||
import name.lkk.common.utils.PageUtils;
|
import name.lkk.common.utils.PageUtils;
|
||||||
import name.lkk.common.utils.R;
|
import name.lkk.common.utils.R;
|
||||||
|
import name.lkk.kkmall.product.entity.SkuSaleAttrValueEntity;
|
||||||
|
import name.lkk.kkmall.product.service.SkuSaleAttrValueService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,28 +23,32 @@ import name.lkk.common.utils.R;
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("product/skusaleattrvalue")
|
@RequestMapping("product/skusaleattrvalue")
|
||||||
public class SkuSaleAttrValueController {
|
public class SkuSaleAttrValueController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SkuSaleAttrValueService skuSaleAttrValueService;
|
private SkuSaleAttrValueService skuSaleAttrValueService;
|
||||||
|
|
||||||
|
@GetMapping("/stringlist/{skuId}")
|
||||||
|
public List<String> getSkuSaleAttrValues(@PathVariable("skuId") Long skuId){
|
||||||
|
|
||||||
|
return skuSaleAttrValueService.getSkuSaleAttrValuesAsStringList(skuId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 列表
|
* 列表
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/list")
|
@RequestMapping("/list")
|
||||||
//@RequiresPermissions("product:skusaleattrvalue:list")
|
|
||||||
public R list(@RequestParam Map<String, Object> params){
|
public R list(@RequestParam Map<String, Object> params){
|
||||||
PageUtils page = skuSaleAttrValueService.queryPage(params);
|
PageUtils page = skuSaleAttrValueService.queryPage(params);
|
||||||
|
|
||||||
return R.ok().put("page", page);
|
return R.ok().put("page", page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 信息
|
* 信息
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/info/{id}")
|
@RequestMapping("/info/{id}")
|
||||||
//@RequiresPermissions("product:skusaleattrvalue:info")
|
|
||||||
public R info(@PathVariable("id") Long id){
|
public R info(@PathVariable("id") Long id){
|
||||||
SkuSaleAttrValueEntity skuSaleAttrValue = skuSaleAttrValueService.getById(id);
|
SkuSaleAttrValueEntity skuSaleAttrValue = skuSaleAttrValueService.getById(id);
|
||||||
|
|
||||||
return R.ok().put("skuSaleAttrValue", skuSaleAttrValue);
|
return R.ok().put("skuSaleAttrValue", skuSaleAttrValue);
|
||||||
}
|
}
|
||||||
|
@ -57,10 +57,9 @@ public class SkuSaleAttrValueController {
|
||||||
* 保存
|
* 保存
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/save")
|
@RequestMapping("/save")
|
||||||
//@RequiresPermissions("product:skusaleattrvalue:save")
|
|
||||||
public R save(@RequestBody SkuSaleAttrValueEntity skuSaleAttrValue){
|
public R save(@RequestBody SkuSaleAttrValueEntity skuSaleAttrValue){
|
||||||
skuSaleAttrValueService.save(skuSaleAttrValue);
|
skuSaleAttrValue.setAttrSort(0);
|
||||||
|
skuSaleAttrValueService.save(skuSaleAttrValue);
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,9 +67,8 @@ public class SkuSaleAttrValueController {
|
||||||
* 修改
|
* 修改
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/update")
|
@RequestMapping("/update")
|
||||||
//@RequiresPermissions("product:skusaleattrvalue:update")
|
|
||||||
public R update(@RequestBody SkuSaleAttrValueEntity skuSaleAttrValue){
|
public R update(@RequestBody SkuSaleAttrValueEntity skuSaleAttrValue){
|
||||||
skuSaleAttrValueService.updateById(skuSaleAttrValue);
|
skuSaleAttrValueService.updateById(skuSaleAttrValue);
|
||||||
|
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
@ -79,11 +77,10 @@ public class SkuSaleAttrValueController {
|
||||||
* 删除
|
* 删除
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/delete")
|
@RequestMapping("/delete")
|
||||||
//@RequiresPermissions("product:skusaleattrvalue:delete")
|
|
||||||
public R delete(@RequestBody Long[] ids){
|
public R delete(@RequestBody Long[] ids){
|
||||||
skuSaleAttrValueService.removeByIds(Arrays.asList(ids));
|
skuSaleAttrValueService.removeByIds(Arrays.asList(ids));
|
||||||
|
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,16 @@
|
||||||
package name.lkk.kkmall.product.controller;
|
package name.lkk.kkmall.product.controller;
|
||||||
|
|
||||||
|
import name.lkk.common.utils.PageUtils;
|
||||||
|
import name.lkk.common.utils.R;
|
||||||
|
import name.lkk.kkmall.product.entity.SpuInfoEntity;
|
||||||
|
import name.lkk.kkmall.product.service.SpuInfoService;
|
||||||
|
import name.lkk.kkmall.product.vo.SpuSaveVo;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Map;
|
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 name.lkk.kkmall.product.entity.SpuInfoEntity;
|
|
||||||
import name.lkk.kkmall.product.service.SpuInfoService;
|
|
||||||
import name.lkk.common.utils.PageUtils;
|
|
||||||
import name.lkk.common.utils.R;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,40 +23,44 @@ import name.lkk.common.utils.R;
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("product/spuinfo")
|
@RequestMapping("product/spuinfo")
|
||||||
public class SpuInfoController {
|
public class SpuInfoController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SpuInfoService spuInfoService;
|
private SpuInfoService spuInfoService;
|
||||||
|
|
||||||
|
@GetMapping("/skuId/{id}")
|
||||||
|
public R getSkuInfoBySkuId(@PathVariable("id") Long skuId){
|
||||||
|
|
||||||
|
SpuInfoEntity entity = spuInfoService.getSpuInfoBySkuId(skuId);
|
||||||
|
return R.ok().setData(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 列表
|
* spu管理的查询
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/list")
|
@RequestMapping("/list")
|
||||||
//@RequiresPermissions("product:spuinfo:list")
|
|
||||||
public R list(@RequestParam Map<String, Object> params){
|
public R list(@RequestParam Map<String, Object> params){
|
||||||
PageUtils page = spuInfoService.queryPage(params);
|
PageUtils page = spuInfoService.queryPageByCondition(params);
|
||||||
|
|
||||||
return R.ok().put("page", page);
|
return R.ok().put("page", page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 信息
|
* 信息
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/info/{id}")
|
@RequestMapping("/info/{id}")
|
||||||
//@RequiresPermissions("product:spuinfo:info")
|
|
||||||
public R info(@PathVariable("id") Long id){
|
public R info(@PathVariable("id") Long id){
|
||||||
SpuInfoEntity spuInfo = spuInfoService.getById(id);
|
SpuInfoEntity spuInfo = spuInfoService.getById(id);
|
||||||
|
|
||||||
return R.ok().put("spuInfo", spuInfo);
|
return R.ok().put("spuInfo", spuInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存
|
* 大保存
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/save")
|
@RequestMapping("/save")
|
||||||
//@RequiresPermissions("product:spuinfo:save")
|
public R save(@RequestBody SpuSaveVo vo){
|
||||||
public R save(@RequestBody SpuInfoEntity spuInfo){
|
spuInfoService.saveSpuInfo(vo);
|
||||||
spuInfoService.save(spuInfo);
|
|
||||||
|
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,9 +68,8 @@ public class SpuInfoController {
|
||||||
* 修改
|
* 修改
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/update")
|
@RequestMapping("/update")
|
||||||
//@RequiresPermissions("product:spuinfo:update")
|
|
||||||
public R update(@RequestBody SpuInfoEntity spuInfo){
|
public R update(@RequestBody SpuInfoEntity spuInfo){
|
||||||
spuInfoService.updateById(spuInfo);
|
spuInfoService.updateById(spuInfo);
|
||||||
|
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
@ -79,9 +78,9 @@ public class SpuInfoController {
|
||||||
* 删除
|
* 删除
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/delete")
|
@RequestMapping("/delete")
|
||||||
//@RequiresPermissions("product:spuinfo:delete")
|
//@RequiresPermissions("${moduleNamez}:spuinfo:delete")
|
||||||
public R delete(@RequestBody Long[] ids){
|
public R delete(@RequestBody Long[] ids){
|
||||||
spuInfoService.removeByIds(Arrays.asList(ids));
|
spuInfoService.removeByIds(Arrays.asList(ids));
|
||||||
|
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
package name.lkk.kkmall.product.dao;
|
package name.lkk.kkmall.product.dao;
|
||||||
|
|
||||||
import name.lkk.kkmall.product.entity.AttrAttrgroupRelationEntity;
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import name.lkk.kkmall.product.entity.AttrAttrgroupRelationEntity;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 属性&属性分组关联
|
* 属性&属性分组关联
|
||||||
|
@ -13,5 +16,5 @@ import org.apache.ibatis.annotations.Mapper;
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface AttrAttrgroupRelationDao extends BaseMapper<AttrAttrgroupRelationEntity> {
|
public interface AttrAttrgroupRelationDao extends BaseMapper<AttrAttrgroupRelationEntity> {
|
||||||
|
void deleteBatchRelation(@Param("entities") List<AttrAttrgroupRelationEntity> entities);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
package name.lkk.kkmall.product.dao;
|
package name.lkk.kkmall.product.dao;
|
||||||
|
|
||||||
import name.lkk.kkmall.product.entity.AttrEntity;
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import name.lkk.kkmall.product.entity.AttrEntity;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品属性
|
* 商品属性
|
||||||
|
@ -14,4 +17,6 @@ import org.apache.ibatis.annotations.Mapper;
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface AttrDao extends BaseMapper<AttrEntity> {
|
public interface AttrDao extends BaseMapper<AttrEntity> {
|
||||||
|
|
||||||
|
List<Long> selectSearchAttrIds(@Param("attrIds") List<Long> attrIds);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
package name.lkk.kkmall.product.dao;
|
package name.lkk.kkmall.product.dao;
|
||||||
|
|
||||||
import name.lkk.kkmall.product.entity.AttrGroupEntity;
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import name.lkk.kkmall.product.entity.AttrGroupEntity;
|
||||||
|
import name.lkk.kkmall.product.vo.SpuItemAttrGroup;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 属性分组
|
* 属性分组
|
||||||
|
@ -14,4 +18,5 @@ import org.apache.ibatis.annotations.Mapper;
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface AttrGroupDao extends BaseMapper<AttrGroupEntity> {
|
public interface AttrGroupDao extends BaseMapper<AttrGroupEntity> {
|
||||||
|
|
||||||
|
List<SpuItemAttrGroup> getAttrGroupWithAttrsBySpuId(@Param("spuId") Long spuId, @Param("catalogId") Long catalogId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
package name.lkk.kkmall.product.dao;
|
package name.lkk.kkmall.product.dao;
|
||||||
|
|
||||||
import name.lkk.kkmall.product.entity.SkuSaleAttrValueEntity;
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import name.lkk.kkmall.product.entity.SkuSaleAttrValueEntity;
|
||||||
|
import name.lkk.kkmall.product.vo.ItemSaleAttrVo;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sku销售属性&值
|
* sku销售属性&值
|
||||||
|
@ -14,4 +18,7 @@ import org.apache.ibatis.annotations.Mapper;
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface SkuSaleAttrValueDao extends BaseMapper<SkuSaleAttrValueEntity> {
|
public interface SkuSaleAttrValueDao extends BaseMapper<SkuSaleAttrValueEntity> {
|
||||||
|
|
||||||
|
List<ItemSaleAttrVo> getSaleAttrsBuSpuId(@Param("spuId") Long spuId);
|
||||||
|
|
||||||
|
List<String> getSkuSaleAttrValuesAsStringList(@Param("skuId") Long skuId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,9 @@ package name.lkk.kkmall.product.entity;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品属性
|
* 商品属性
|
||||||
|
@ -32,6 +31,10 @@ public class AttrEntity implements Serializable {
|
||||||
* 是否需要检索[0-不需要,1-需要]
|
* 是否需要检索[0-不需要,1-需要]
|
||||||
*/
|
*/
|
||||||
private Integer searchType;
|
private Integer searchType;
|
||||||
|
/**
|
||||||
|
* 值类型[0-为单个值,1-可以选择多个值]
|
||||||
|
*/
|
||||||
|
private Integer valueType;
|
||||||
/**
|
/**
|
||||||
* 属性图标
|
* 属性图标
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package name.lkk.kkmall.product.entity;
|
package name.lkk.kkmall.product.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* spu信息介绍
|
* spu信息介绍
|
||||||
|
@ -22,7 +22,7 @@ public class SpuInfoDescEntity implements Serializable {
|
||||||
/**
|
/**
|
||||||
* 商品id
|
* 商品id
|
||||||
*/
|
*/
|
||||||
@TableId
|
@TableId(type = IdType.INPUT)
|
||||||
private Long spuId;
|
private Long spuId;
|
||||||
/**
|
/**
|
||||||
* 商品介绍
|
* 商品介绍
|
||||||
|
|
|
@ -19,7 +19,7 @@ import java.util.Map;
|
||||||
* @author kirklin
|
* @author kirklin
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RestControllerAdvice(basePackages = "com.firenay.mall.product.controller")
|
@RestControllerAdvice(basePackages = "name.lkk.kkmall.product.controller")
|
||||||
public class MallExceptionControllerAdvice {
|
public class MallExceptionControllerAdvice {
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package name.lkk.kkmall.product.feign;
|
||||||
|
|
||||||
|
|
||||||
|
import name.lkk.common.to.SkuReductionTO;
|
||||||
|
import name.lkk.common.to.SpuBoundTO;
|
||||||
|
import name.lkk.common.utils.R;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Title: CouponFeignService</p>
|
||||||
|
* Description:远程调用优惠券服务
|
||||||
|
* date:2020/6/5 17:06
|
||||||
|
*/
|
||||||
|
@FeignClient("kkmall-coupon")
|
||||||
|
public interface CouponFeignService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @RequestBody 将对象转换为json 将上一步的json放在请求体位置 发送请求
|
||||||
|
*
|
||||||
|
* 对方服务收到请求。 收到的是请求体里的json数据 那边用 @RequestBody 对SpuBoundsEntity进行封装
|
||||||
|
*
|
||||||
|
* 只要 JSON 数据模型是兼容的 双方服务无需使用同一个 TO 对象
|
||||||
|
*/
|
||||||
|
@PostMapping("/coupon/spubounds/save")
|
||||||
|
R saveSpuBounds(@RequestBody SpuBoundTO spuBoundTo);
|
||||||
|
|
||||||
|
@PostMapping("/coupon/skufullreduction/saveinfo")
|
||||||
|
R saveSkuReduction(@RequestBody SkuReductionTO skuReductionTo);
|
||||||
|
}
|
|
@ -3,7 +3,9 @@ package name.lkk.kkmall.product.service;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import name.lkk.common.utils.PageUtils;
|
import name.lkk.common.utils.PageUtils;
|
||||||
import name.lkk.kkmall.product.entity.AttrAttrgroupRelationEntity;
|
import name.lkk.kkmall.product.entity.AttrAttrgroupRelationEntity;
|
||||||
|
import name.lkk.kkmall.product.vo.AttrGroupRelationVo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,5 +18,7 @@ import java.util.Map;
|
||||||
public interface AttrAttrgroupRelationService extends IService<AttrAttrgroupRelationEntity> {
|
public interface AttrAttrgroupRelationService extends IService<AttrAttrgroupRelationEntity> {
|
||||||
|
|
||||||
PageUtils queryPage(Map<String, Object> params);
|
PageUtils queryPage(Map<String, Object> params);
|
||||||
|
|
||||||
|
void saveBatch(List<AttrGroupRelationVo> vos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,10 @@ package name.lkk.kkmall.product.service;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import name.lkk.common.utils.PageUtils;
|
import name.lkk.common.utils.PageUtils;
|
||||||
import name.lkk.kkmall.product.entity.AttrGroupEntity;
|
import name.lkk.kkmall.product.entity.AttrGroupEntity;
|
||||||
|
import name.lkk.kkmall.product.vo.AttrGroupWithAttrsVo;
|
||||||
|
import name.lkk.kkmall.product.vo.SpuItemAttrGroup;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,5 +22,8 @@ public interface AttrGroupService extends IService<AttrGroupEntity> {
|
||||||
|
|
||||||
PageUtils queryPage(Map<String, Object> params, Long catelogId);
|
PageUtils queryPage(Map<String, Object> params, Long catelogId);
|
||||||
|
|
||||||
|
List<AttrGroupWithAttrsVo> getAttrGroupWithAttrByCatelogId(Long catelogId);
|
||||||
|
|
||||||
|
List<SpuItemAttrGroup> getAttrGroupWithAttrsBySpuId(Long spuId, Long catalogId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,11 @@ package name.lkk.kkmall.product.service;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import name.lkk.common.utils.PageUtils;
|
import name.lkk.common.utils.PageUtils;
|
||||||
import name.lkk.kkmall.product.entity.AttrEntity;
|
import name.lkk.kkmall.product.entity.AttrEntity;
|
||||||
|
import name.lkk.kkmall.product.vo.AttrGroupRelationVo;
|
||||||
|
import name.lkk.kkmall.product.vo.AttrRespVo;
|
||||||
|
import name.lkk.kkmall.product.vo.AttrVo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,5 +20,34 @@ import java.util.Map;
|
||||||
public interface AttrService extends IService<AttrEntity> {
|
public interface AttrService extends IService<AttrEntity> {
|
||||||
|
|
||||||
PageUtils queryPage(Map<String, Object> params);
|
PageUtils queryPage(Map<String, Object> params);
|
||||||
|
|
||||||
|
void saveAttr(AttrVo attrVo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 规格参数的分页模糊查询
|
||||||
|
*/
|
||||||
|
PageUtils queryBaseAttrPage(Map<String, Object> params, Long catelogId, String attrType);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
AttrRespVo getAttrInfo(Long attrId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更改规格参数:参数名、参数id、参数、状态的一一对应
|
||||||
|
*/
|
||||||
|
void updateAttr(AttrVo attrVo);
|
||||||
|
|
||||||
|
List<AttrEntity> getRelationAttr(Long attrgroupId);
|
||||||
|
|
||||||
|
void deleteRelation(AttrGroupRelationVo[] vos);
|
||||||
|
|
||||||
|
PageUtils getNoRelationAttr(Map<String, Object> params, Long attrgroupId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在指定的集合里面挑出可检索的属性
|
||||||
|
*/
|
||||||
|
List<Long> selectSearchAttrIds(List<Long> attrIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,10 @@ package name.lkk.kkmall.product.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import name.lkk.common.utils.PageUtils;
|
import name.lkk.common.utils.PageUtils;
|
||||||
|
import name.lkk.kkmall.product.entity.BrandEntity;
|
||||||
import name.lkk.kkmall.product.entity.CategoryBrandRelationEntity;
|
import name.lkk.kkmall.product.entity.CategoryBrandRelationEntity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,5 +24,7 @@ public interface CategoryBrandRelationService extends IService<CategoryBrandRela
|
||||||
void saveDetail(CategoryBrandRelationEntity categoryBrandRelation);
|
void saveDetail(CategoryBrandRelationEntity categoryBrandRelation);
|
||||||
|
|
||||||
void updateCategory(Long catId, String name);
|
void updateCategory(Long catId, String name);
|
||||||
|
|
||||||
|
List<BrandEntity> getBrandsByCatId(Long catId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import name.lkk.common.utils.PageUtils;
|
import name.lkk.common.utils.PageUtils;
|
||||||
import name.lkk.kkmall.product.entity.ProductAttrValueEntity;
|
import name.lkk.kkmall.product.entity.ProductAttrValueEntity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,5 +17,17 @@ import java.util.Map;
|
||||||
public interface ProductAttrValueService extends IService<ProductAttrValueEntity> {
|
public interface ProductAttrValueService extends IService<ProductAttrValueEntity> {
|
||||||
|
|
||||||
PageUtils queryPage(Map<String, Object> params);
|
PageUtils queryPage(Map<String, Object> params);
|
||||||
|
|
||||||
|
void saveProductAttr(List<ProductAttrValueEntity> collect);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询规格属性
|
||||||
|
*/
|
||||||
|
List<ProductAttrValueEntity> baseAttrListForSpu(Long spuId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新属性的规格
|
||||||
|
*/
|
||||||
|
void updateSpuAttr(Long spuId, List<ProductAttrValueEntity> entities);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import name.lkk.common.utils.PageUtils;
|
import name.lkk.common.utils.PageUtils;
|
||||||
import name.lkk.kkmall.product.entity.SkuImagesEntity;
|
import name.lkk.kkmall.product.entity.SkuImagesEntity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,5 +17,7 @@ import java.util.Map;
|
||||||
public interface SkuImagesService extends IService<SkuImagesEntity> {
|
public interface SkuImagesService extends IService<SkuImagesEntity> {
|
||||||
|
|
||||||
PageUtils queryPage(Map<String, Object> params);
|
PageUtils queryPage(Map<String, Object> params);
|
||||||
|
|
||||||
|
List<SkuImagesEntity> getImagesBySkuId(Long skuId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import name.lkk.common.utils.PageUtils;
|
import name.lkk.common.utils.PageUtils;
|
||||||
import name.lkk.kkmall.product.entity.SkuInfoEntity;
|
import name.lkk.kkmall.product.entity.SkuInfoEntity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,5 +17,10 @@ import java.util.Map;
|
||||||
public interface SkuInfoService extends IService<SkuInfoEntity> {
|
public interface SkuInfoService extends IService<SkuInfoEntity> {
|
||||||
|
|
||||||
PageUtils queryPage(Map<String, Object> params);
|
PageUtils queryPage(Map<String, Object> params);
|
||||||
}
|
void saveSkuInfo(SkuInfoEntity skuInfoEntity);
|
||||||
|
|
||||||
|
PageUtils queryPageByCondition(Map<String, Object> params);
|
||||||
|
|
||||||
|
List<SkuInfoEntity> getSkusBySpuId(Long spuId);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -3,7 +3,9 @@ package name.lkk.kkmall.product.service;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import name.lkk.common.utils.PageUtils;
|
import name.lkk.common.utils.PageUtils;
|
||||||
import name.lkk.kkmall.product.entity.SkuSaleAttrValueEntity;
|
import name.lkk.kkmall.product.entity.SkuSaleAttrValueEntity;
|
||||||
|
import name.lkk.kkmall.product.vo.ItemSaleAttrVo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,5 +18,8 @@ import java.util.Map;
|
||||||
public interface SkuSaleAttrValueService extends IService<SkuSaleAttrValueEntity> {
|
public interface SkuSaleAttrValueService extends IService<SkuSaleAttrValueEntity> {
|
||||||
|
|
||||||
PageUtils queryPage(Map<String, Object> params);
|
PageUtils queryPage(Map<String, Object> params);
|
||||||
|
List<ItemSaleAttrVo> getSaleAttrsBuSpuId(Long spuId);
|
||||||
|
|
||||||
|
List<String> getSkuSaleAttrValuesAsStringList(Long skuId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import name.lkk.common.utils.PageUtils;
|
import name.lkk.common.utils.PageUtils;
|
||||||
import name.lkk.kkmall.product.entity.SpuImagesEntity;
|
import name.lkk.kkmall.product.entity.SpuImagesEntity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,5 +17,6 @@ import java.util.Map;
|
||||||
public interface SpuImagesService extends IService<SpuImagesEntity> {
|
public interface SpuImagesService extends IService<SpuImagesEntity> {
|
||||||
|
|
||||||
PageUtils queryPage(Map<String, Object> params);
|
PageUtils queryPage(Map<String, Object> params);
|
||||||
}
|
|
||||||
|
|
||||||
|
void saveImages(Long id, List<String> images);
|
||||||
|
}
|
||||||
|
|
|
@ -16,5 +16,6 @@ import java.util.Map;
|
||||||
public interface SpuInfoDescService extends IService<SpuInfoDescEntity> {
|
public interface SpuInfoDescService extends IService<SpuInfoDescEntity> {
|
||||||
|
|
||||||
PageUtils queryPage(Map<String, Object> params);
|
PageUtils queryPage(Map<String, Object> params);
|
||||||
}
|
|
||||||
|
|
||||||
|
void saveSpuInfoDesc(SpuInfoDescEntity spuInfoDescEntity);
|
||||||
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package name.lkk.kkmall.product.service;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import name.lkk.common.utils.PageUtils;
|
import name.lkk.common.utils.PageUtils;
|
||||||
import name.lkk.kkmall.product.entity.SpuInfoEntity;
|
import name.lkk.kkmall.product.entity.SpuInfoEntity;
|
||||||
|
import name.lkk.kkmall.product.vo.SpuSaveVo;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -16,5 +17,20 @@ import java.util.Map;
|
||||||
public interface SpuInfoService extends IService<SpuInfoEntity> {
|
public interface SpuInfoService extends IService<SpuInfoEntity> {
|
||||||
|
|
||||||
PageUtils queryPage(Map<String, Object> params);
|
PageUtils queryPage(Map<String, Object> params);
|
||||||
|
|
||||||
|
|
||||||
|
void saveBatchSpuInfo(SpuInfoEntity spuInfoEntity);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SPU模糊查询
|
||||||
|
*/
|
||||||
|
PageUtils queryPageByCondition(Map<String, Object> params);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回一个SpuEntity
|
||||||
|
*/
|
||||||
|
SpuInfoEntity getSpuInfoBySkuId(Long skuId);
|
||||||
|
|
||||||
|
void saveSpuInfo(SpuSaveVo vo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,20 @@
|
||||||
package name.lkk.kkmall.product.service.impl;
|
package name.lkk.kkmall.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.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import name.lkk.common.utils.PageUtils;
|
import name.lkk.common.utils.PageUtils;
|
||||||
import name.lkk.common.utils.Query;
|
import name.lkk.common.utils.Query;
|
||||||
|
|
||||||
import name.lkk.kkmall.product.dao.AttrAttrgroupRelationDao;
|
import name.lkk.kkmall.product.dao.AttrAttrgroupRelationDao;
|
||||||
import name.lkk.kkmall.product.entity.AttrAttrgroupRelationEntity;
|
import name.lkk.kkmall.product.entity.AttrAttrgroupRelationEntity;
|
||||||
import name.lkk.kkmall.product.service.AttrAttrgroupRelationService;
|
import name.lkk.kkmall.product.service.AttrAttrgroupRelationService;
|
||||||
|
import name.lkk.kkmall.product.vo.AttrGroupRelationVo;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
@Service("attrAttrgroupRelationService")
|
@Service("attrAttrgroupRelationService")
|
||||||
|
@ -26,4 +30,16 @@ public class AttrAttrgroupRelationServiceImpl extends ServiceImpl<AttrAttrgroupR
|
||||||
return new PageUtils(page);
|
return new PageUtils(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveBatch(List<AttrGroupRelationVo> vos) {
|
||||||
|
// 对拷数据 然后批量保存
|
||||||
|
List<AttrAttrgroupRelationEntity> entities = vos.stream().map(item -> {
|
||||||
|
AttrAttrgroupRelationEntity entity = new AttrAttrgroupRelationEntity();
|
||||||
|
BeanUtils.copyProperties(item, entity);
|
||||||
|
entity.setAttrSort(0);
|
||||||
|
return entity;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
this.saveBatch(entities);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -6,17 +6,28 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import name.lkk.common.utils.PageUtils;
|
import name.lkk.common.utils.PageUtils;
|
||||||
import name.lkk.common.utils.Query;
|
import name.lkk.common.utils.Query;
|
||||||
import name.lkk.kkmall.product.dao.AttrGroupDao;
|
import name.lkk.kkmall.product.dao.AttrGroupDao;
|
||||||
|
import name.lkk.kkmall.product.entity.AttrEntity;
|
||||||
import name.lkk.kkmall.product.entity.AttrGroupEntity;
|
import name.lkk.kkmall.product.entity.AttrGroupEntity;
|
||||||
import name.lkk.kkmall.product.service.AttrGroupService;
|
import name.lkk.kkmall.product.service.AttrGroupService;
|
||||||
|
import name.lkk.kkmall.product.service.AttrService;
|
||||||
|
import name.lkk.kkmall.product.vo.AttrGroupWithAttrsVo;
|
||||||
|
import name.lkk.kkmall.product.vo.SpuItemAttrGroup;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
@Service("attrGroupService")
|
@Service("attrGroupService")
|
||||||
public class AttrGroupServiceImpl extends ServiceImpl<AttrGroupDao, AttrGroupEntity> implements AttrGroupService {
|
public class AttrGroupServiceImpl extends ServiceImpl<AttrGroupDao, AttrGroupEntity> implements AttrGroupService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AttrService attrService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageUtils queryPage(Map<String, Object> params) {
|
public PageUtils queryPage(Map<String, Object> params) {
|
||||||
IPage<AttrGroupEntity> page = this.page(
|
IPage<AttrGroupEntity> page = this.page(
|
||||||
|
@ -49,4 +60,35 @@ public class AttrGroupServiceImpl extends ServiceImpl<AttrGroupDao, AttrGroupEnt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据分类id 查出所有的分组以及这些组里边的属性
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<AttrGroupWithAttrsVo> getAttrGroupWithAttrByCatelogId(Long catelogId) {
|
||||||
|
|
||||||
|
// 1.查询这个品牌id下所有分组
|
||||||
|
List<AttrGroupEntity> attrGroupEntities = this.list(new QueryWrapper<AttrGroupEntity>().eq("catelog_id", catelogId));
|
||||||
|
|
||||||
|
// 2.查询所有属性
|
||||||
|
List<AttrGroupWithAttrsVo> collect = attrGroupEntities.stream().map(group ->{
|
||||||
|
// 先对拷分组数据
|
||||||
|
AttrGroupWithAttrsVo attrVo = new AttrGroupWithAttrsVo();
|
||||||
|
BeanUtils.copyProperties(group, attrVo);
|
||||||
|
// 按照分组id查询所有关联属性并封装到vo
|
||||||
|
List<AttrEntity> attrs = attrService.getRelationAttr(attrVo.getAttrGroupId());
|
||||||
|
attrVo.setAttrs(attrs);
|
||||||
|
return attrVo;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
return collect;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SpuItemAttrGroup> getAttrGroupWithAttrsBySpuId(Long spuId, Long catalogId) {
|
||||||
|
|
||||||
|
// 1.出当前Spu对应的所有属性的分组信息 以及当前分组下所有属性对应的值
|
||||||
|
// 1.1 查询所有分组
|
||||||
|
AttrGroupDao baseMapper = this.getBaseMapper();
|
||||||
|
|
||||||
|
return baseMapper.getAttrGroupWithAttrsBySpuId(spuId, catalogId);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,20 +1,50 @@
|
||||||
package name.lkk.kkmall.product.service.impl;
|
package name.lkk.kkmall.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.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import name.lkk.common.constant.ProductConstant;
|
||||||
import name.lkk.common.utils.PageUtils;
|
import name.lkk.common.utils.PageUtils;
|
||||||
import name.lkk.common.utils.Query;
|
import name.lkk.common.utils.Query;
|
||||||
|
import name.lkk.kkmall.product.dao.AttrAttrgroupRelationDao;
|
||||||
import name.lkk.kkmall.product.dao.AttrDao;
|
import name.lkk.kkmall.product.dao.AttrDao;
|
||||||
|
import name.lkk.kkmall.product.dao.AttrGroupDao;
|
||||||
|
import name.lkk.kkmall.product.dao.CategoryDao;
|
||||||
|
import name.lkk.kkmall.product.entity.AttrAttrgroupRelationEntity;
|
||||||
import name.lkk.kkmall.product.entity.AttrEntity;
|
import name.lkk.kkmall.product.entity.AttrEntity;
|
||||||
|
import name.lkk.kkmall.product.entity.AttrGroupEntity;
|
||||||
|
import name.lkk.kkmall.product.entity.CategoryEntity;
|
||||||
import name.lkk.kkmall.product.service.AttrService;
|
import name.lkk.kkmall.product.service.AttrService;
|
||||||
|
import name.lkk.kkmall.product.service.CategoryService;
|
||||||
|
import name.lkk.kkmall.product.vo.AttrGroupRelationVo;
|
||||||
|
import name.lkk.kkmall.product.vo.AttrRespVo;
|
||||||
|
import name.lkk.kkmall.product.vo.AttrVo;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
@Service("attrService")
|
@Service("attrService")
|
||||||
public class AttrServiceImpl extends ServiceImpl<AttrDao, AttrEntity> implements AttrService {
|
public class AttrServiceImpl extends ServiceImpl<AttrDao, AttrEntity> implements AttrService {
|
||||||
|
@Autowired
|
||||||
|
private AttrAttrgroupRelationDao relationDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AttrGroupDao attrGroupDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CategoryDao categoryDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CategoryService categoryService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageUtils queryPage(Map<String, Object> params) {
|
public PageUtils queryPage(Map<String, Object> params) {
|
||||||
|
@ -26,4 +56,207 @@ public class AttrServiceImpl extends ServiceImpl<AttrDao, AttrEntity> implements
|
||||||
return new PageUtils(page);
|
return new PageUtils(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@Override
|
||||||
|
public void saveAttr(AttrVo attrVo) {
|
||||||
|
AttrEntity attrEntity = new AttrEntity();
|
||||||
|
BeanUtils.copyProperties(attrVo, attrEntity);
|
||||||
|
//1、保存基本数据
|
||||||
|
this.save(attrEntity);
|
||||||
|
//2、保存关联关系
|
||||||
|
if (attrVo.getAttrType() == ProductConstant.AttrEnum.ATTR_TYPE_BASE.getCode() && attrVo.getAttrGroupId() != null) {
|
||||||
|
AttrAttrgroupRelationEntity relationEntity = new AttrAttrgroupRelationEntity();
|
||||||
|
relationEntity.setAttrGroupId(attrVo.getAttrGroupId());
|
||||||
|
relationEntity.setAttrId(attrEntity.getAttrId());
|
||||||
|
relationEntity.setAttrSort(0);
|
||||||
|
relationDao.insert(relationEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@Override
|
||||||
|
public AttrRespVo getAttrInfo(Long attrId) {
|
||||||
|
AttrRespVo respVo = new AttrRespVo();
|
||||||
|
AttrEntity attrEntity = this.getById(attrId);
|
||||||
|
BeanUtils.copyProperties(attrEntity, respVo);
|
||||||
|
|
||||||
|
// 基本类型才进行修改
|
||||||
|
if (attrEntity.getAttrType() == ProductConstant.AttrEnum.ATTR_TYPE_BASE.getCode()) {
|
||||||
|
//1、设置分组信息
|
||||||
|
AttrAttrgroupRelationEntity attrgroupRelation = relationDao.selectOne(new QueryWrapper<AttrAttrgroupRelationEntity>().eq("attr_id", attrId));
|
||||||
|
if (attrgroupRelation != null) {
|
||||||
|
respVo.setAttrGroupId(attrgroupRelation.getAttrGroupId());
|
||||||
|
AttrGroupEntity attrGroupEntity = attrGroupDao.selectById(attrgroupRelation.getAttrGroupId());
|
||||||
|
if (attrGroupEntity != null) {
|
||||||
|
respVo.setGroupName(attrGroupEntity.getAttrGroupName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//2、设置分类信息
|
||||||
|
Long catelogId = attrEntity.getCatelogId();
|
||||||
|
Long[] catelogPath = categoryService.findCateLogPath(catelogId);
|
||||||
|
respVo.setCatelogPath(catelogPath);
|
||||||
|
|
||||||
|
CategoryEntity categoryEntity = categoryDao.selectById(catelogId);
|
||||||
|
if (categoryEntity != null) {
|
||||||
|
respVo.setCatelogName(categoryEntity.getName());
|
||||||
|
}
|
||||||
|
return respVo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更改规格参数:参数名、参数id、参数、状态的一一对应
|
||||||
|
*/
|
||||||
|
@Transactional
|
||||||
|
@Override
|
||||||
|
public void updateAttr(AttrVo attrVo) {
|
||||||
|
AttrEntity attrEntity = new AttrEntity();
|
||||||
|
BeanUtils.copyProperties(attrVo, attrEntity);
|
||||||
|
this.updateById(attrEntity);
|
||||||
|
|
||||||
|
// 基本类型才进行修改
|
||||||
|
if (attrEntity.getAttrType() == ProductConstant.AttrEnum.ATTR_TYPE_BASE.getCode()) {
|
||||||
|
// 修改分组关联
|
||||||
|
AttrAttrgroupRelationEntity relationEntity = new AttrAttrgroupRelationEntity();
|
||||||
|
|
||||||
|
relationEntity.setAttrGroupId(attrVo.getAttrGroupId());
|
||||||
|
relationEntity.setAttrId(attrVo.getAttrId());
|
||||||
|
// 查询 attr_id 在 pms_attr_attrgroup_relation 表中是否已经存在 不存在返回0 表示这是添加 反之返回1 为修改 [这里的修改可以修复之前没有设置上的属性]
|
||||||
|
Integer count = relationDao.selectCount(new UpdateWrapper<AttrAttrgroupRelationEntity>().eq("attr_id", attrVo.getAttrId()));
|
||||||
|
if(count > 0){
|
||||||
|
relationDao.update(relationEntity, new UpdateWrapper<AttrAttrgroupRelationEntity>().eq("attr_id", attrVo.getAttrId()));
|
||||||
|
}else {
|
||||||
|
relationDao.insert(relationEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据分组id查找关联属性
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<AttrEntity> getRelationAttr(Long attrgroupId) {
|
||||||
|
List<AttrAttrgroupRelationEntity> entities = relationDao.selectList(new QueryWrapper<AttrAttrgroupRelationEntity>().eq("attr_group_id", attrgroupId));
|
||||||
|
List<Long> attrIds = entities.stream().map((attr) -> attr.getAttrId()).collect(Collectors.toList());
|
||||||
|
// 根据这个属性查询到的id可能是空的
|
||||||
|
if(attrIds == null || attrIds.size() == 0){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return this.listByIds(attrIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除分组关联关系
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void deleteRelation(AttrGroupRelationVo[] vos) {
|
||||||
|
// 将页面收集的数据拷到 AttrAttrgroupRelationEntity
|
||||||
|
List<AttrAttrgroupRelationEntity> entities = Arrays.asList(vos).stream().map((v) -> {
|
||||||
|
AttrAttrgroupRelationEntity relationEntity = new AttrAttrgroupRelationEntity();
|
||||||
|
BeanUtils.copyProperties(v, relationEntity);
|
||||||
|
return relationEntity;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
relationDao.deleteBatchRelation(entities);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前分组没有关联的属性
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public PageUtils getNoRelationAttr(Map<String, Object> params, Long attrgroupId) {
|
||||||
|
//1、当前分组只能关联自己所属的分类里面的所有属性
|
||||||
|
AttrGroupEntity attrGroupEntity = attrGroupDao.selectById(attrgroupId);
|
||||||
|
Long catelogId = attrGroupEntity.getCatelogId();
|
||||||
|
// 2、当前分组只能别的分组没有引用的属性 并且这个分组的id不是我当前正在查的id
|
||||||
|
//2.1)、当前分类下的其他分组
|
||||||
|
List<AttrGroupEntity> group = attrGroupDao.selectList(new QueryWrapper<AttrGroupEntity>().eq("catelog_id", catelogId));
|
||||||
|
// 得到当前分类下面的所有分组id
|
||||||
|
List<Long> collect = group.stream().map(item -> {
|
||||||
|
return item.getAttrGroupId();
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
|
//2.2)、查询这些分组关联的属性
|
||||||
|
List<AttrAttrgroupRelationEntity> groupId = relationDao.selectList(new QueryWrapper<AttrAttrgroupRelationEntity>().in("attr_group_id", collect));
|
||||||
|
// 再次获取跟这些分组有关的属性id的集合
|
||||||
|
List<Long> attrIds = groupId.stream().map(item -> {
|
||||||
|
return item.getAttrId();
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
|
//2.3)、从当前分类的所有属性中移除这些属性;[因这些分组已经存在被选了 就不用再显示了]
|
||||||
|
QueryWrapper<AttrEntity> wrapper = new QueryWrapper<AttrEntity>().eq("catelog_id", catelogId).eq("attr_type", ProductConstant.AttrEnum.ATTR_TYPE_BASE.getCode());
|
||||||
|
if(attrIds != null && attrIds.size() > 0){
|
||||||
|
wrapper.notIn("attr_id", attrIds);
|
||||||
|
}
|
||||||
|
// 当搜索框中有key并且不为空的时候 进行模糊查询
|
||||||
|
String key = (String) params.get("key");
|
||||||
|
if(!ObjectUtils.isEmpty(key)){
|
||||||
|
wrapper.and((w)->{
|
||||||
|
w.eq("attr_id",key).or().like("attr_name",key);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 将最后返回的结果进行封装
|
||||||
|
IPage<AttrEntity> page = this.page(new Query<AttrEntity>().getPage(params), wrapper);
|
||||||
|
|
||||||
|
PageUtils pageUtils = new PageUtils(page);
|
||||||
|
return pageUtils;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SELECT attr_id FROM `pms_attr` WHERE attr_id IN (?) AND search_type = 1
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<Long> selectSearchAttrIds(List<Long> attrIds) {
|
||||||
|
return baseMapper.selectSearchAttrIds(attrIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 规格参数的分页模糊查询
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public PageUtils queryBaseAttrPage(Map<String, Object> params, Long catelogId, String attrType) {
|
||||||
|
QueryWrapper<AttrEntity> waWrapper = new QueryWrapper<AttrEntity>().eq("attr_type", "base".equalsIgnoreCase(attrType)?ProductConstant.AttrEnum.ATTR_TYPE_BASE.getCode():ProductConstant.AttrEnum.ATTR_TYPE_SALE.getCode());
|
||||||
|
|
||||||
|
if (catelogId != ProductConstant.AttrEnum.ATTR_TYPE_SALE.getCode()) {
|
||||||
|
// 如果是 base 就是基本属性 插入1 否则插入0
|
||||||
|
waWrapper.eq("catelog_id", catelogId);
|
||||||
|
}
|
||||||
|
String key = (String) params.get("key");
|
||||||
|
if (!ObjectUtils.isEmpty(key)) {
|
||||||
|
waWrapper.and((w) -> {
|
||||||
|
w.eq("attr_id", key).or().like("attr_name", key);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
IPage<AttrEntity> page = this.page(
|
||||||
|
new Query<AttrEntity>().getPage(params),
|
||||||
|
waWrapper
|
||||||
|
);
|
||||||
|
PageUtils pageUtils = new PageUtils(page);
|
||||||
|
// 先查询三级分类名字、分组名字 再封装
|
||||||
|
List<AttrEntity> records = page.getRecords();
|
||||||
|
// attrRespVos 就是最终封装好的Vo
|
||||||
|
List<AttrRespVo> attrRespVos = records.stream().map((attrEntity) -> {
|
||||||
|
AttrRespVo attrRespVo = new AttrRespVo();
|
||||||
|
BeanUtils.copyProperties(attrEntity, attrRespVo);
|
||||||
|
// 1.设置分类和分组的名字 先获取中间表对象 给attrRespVo 封装分组名字
|
||||||
|
if("base".equalsIgnoreCase(attrType)){
|
||||||
|
// attr的关联关系 当它没有分组的时候就不保存了
|
||||||
|
AttrAttrgroupRelationEntity entity = relationDao.selectOne(new QueryWrapper<AttrAttrgroupRelationEntity>().eq("attr_id", attrEntity.getAttrId()));
|
||||||
|
if (entity != null && entity.getAttrGroupId() != null) {
|
||||||
|
AttrGroupEntity attrGroupEntity = attrGroupDao.selectById(entity);
|
||||||
|
attrRespVo.setGroupName(attrGroupEntity.getAttrGroupName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 2.查询分类id 给attrRespVo 封装三级分类名字
|
||||||
|
CategoryEntity categoryEntity = categoryDao.selectById(attrEntity.getCatelogId());
|
||||||
|
if (categoryEntity != null) {
|
||||||
|
attrRespVo.setCatelogName(categoryEntity.getName());
|
||||||
|
}
|
||||||
|
return attrRespVo;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
pageUtils.setList(attrRespVos);
|
||||||
|
return pageUtils;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -12,11 +12,14 @@ import name.lkk.kkmall.product.dao.CategoryDao;
|
||||||
import name.lkk.kkmall.product.entity.BrandEntity;
|
import name.lkk.kkmall.product.entity.BrandEntity;
|
||||||
import name.lkk.kkmall.product.entity.CategoryBrandRelationEntity;
|
import name.lkk.kkmall.product.entity.CategoryBrandRelationEntity;
|
||||||
import name.lkk.kkmall.product.entity.CategoryEntity;
|
import name.lkk.kkmall.product.entity.CategoryEntity;
|
||||||
|
import name.lkk.kkmall.product.service.BrandService;
|
||||||
import name.lkk.kkmall.product.service.CategoryBrandRelationService;
|
import name.lkk.kkmall.product.service.CategoryBrandRelationService;
|
||||||
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 java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
@Service("categoryBrandRelationService")
|
@Service("categoryBrandRelationService")
|
||||||
|
@ -27,6 +30,12 @@ public class CategoryBrandRelationServiceImpl extends ServiceImpl<CategoryBrandR
|
||||||
@Autowired
|
@Autowired
|
||||||
private CategoryDao categoryDao;
|
private CategoryDao categoryDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CategoryBrandRelationDao categoryBrandRelationDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BrandService brandService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageUtils queryPage(Map<String, Object> params) {
|
public PageUtils queryPage(Map<String, Object> params) {
|
||||||
IPage<CategoryBrandRelationEntity> page = this.page(
|
IPage<CategoryBrandRelationEntity> page = this.page(
|
||||||
|
@ -66,4 +75,17 @@ public class CategoryBrandRelationServiceImpl extends ServiceImpl<CategoryBrandR
|
||||||
categoryBrandRelation.setCatelogName(categoryEntity.getName());
|
categoryBrandRelation.setCatelogName(categoryEntity.getName());
|
||||||
this.save(categoryBrandRelation);
|
this.save(categoryBrandRelation);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 获取某个分类下所有品牌信息
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<BrandEntity> getBrandsByCatId(Long catId) {
|
||||||
|
List<CategoryBrandRelationEntity> catelogId = categoryBrandRelationDao.selectList(new QueryWrapper<CategoryBrandRelationEntity>().eq("catelog_id", catId));
|
||||||
|
// 根据品牌id查询详细信息
|
||||||
|
//List<Long> brandIds = catelogId.stream().map(item->{
|
||||||
|
// return item.getBrandId();
|
||||||
|
// }).collect(Collectors.toList());
|
||||||
|
List<Long> brandIds = catelogId.stream().map(CategoryBrandRelationEntity::getBrandId).collect(Collectors.toList());
|
||||||
|
return brandService.listByIds(brandIds);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,16 +1,19 @@
|
||||||
package name.lkk.kkmall.product.service.impl;
|
package name.lkk.kkmall.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.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import name.lkk.common.utils.PageUtils;
|
import name.lkk.common.utils.PageUtils;
|
||||||
import name.lkk.common.utils.Query;
|
import name.lkk.common.utils.Query;
|
||||||
|
|
||||||
import name.lkk.kkmall.product.dao.ProductAttrValueDao;
|
import name.lkk.kkmall.product.dao.ProductAttrValueDao;
|
||||||
import name.lkk.kkmall.product.entity.ProductAttrValueEntity;
|
import name.lkk.kkmall.product.entity.ProductAttrValueEntity;
|
||||||
import name.lkk.kkmall.product.service.ProductAttrValueService;
|
import name.lkk.kkmall.product.service.ProductAttrValueService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
@Service("productAttrValueService")
|
@Service("productAttrValueService")
|
||||||
|
@ -26,4 +29,29 @@ public class ProductAttrValueServiceImpl extends ServiceImpl<ProductAttrValueDao
|
||||||
return new PageUtils(page);
|
return new PageUtils(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveProductAttr(List<ProductAttrValueEntity> collect) {
|
||||||
|
this.saveBatch(collect);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@Override
|
||||||
|
public void updateSpuAttr(Long spuId, List<ProductAttrValueEntity> entities) {
|
||||||
|
// 1.删除 spuId 之前对应的属性
|
||||||
|
this.baseMapper.delete(new QueryWrapper<ProductAttrValueEntity>().eq("spu_id", spuId));
|
||||||
|
|
||||||
|
// 2.保存页面传过来的数据
|
||||||
|
List<ProductAttrValueEntity> collect = entities.stream().map(entity -> {
|
||||||
|
entity.setSpuId(spuId);
|
||||||
|
entity.setAttrSort(0);
|
||||||
|
return entity;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
this.saveBatch(collect);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ProductAttrValueEntity> baseAttrListForSpu(Long spuId) {
|
||||||
|
return this.baseMapper.selectList(new QueryWrapper<ProductAttrValueEntity>().eq("spu_id", spuId));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,21 +1,21 @@
|
||||||
package name.lkk.kkmall.product.service.impl;
|
package name.lkk.kkmall.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.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import name.lkk.common.utils.PageUtils;
|
import name.lkk.common.utils.PageUtils;
|
||||||
import name.lkk.common.utils.Query;
|
import name.lkk.common.utils.Query;
|
||||||
|
|
||||||
import name.lkk.kkmall.product.dao.SkuImagesDao;
|
import name.lkk.kkmall.product.dao.SkuImagesDao;
|
||||||
import name.lkk.kkmall.product.entity.SkuImagesEntity;
|
import name.lkk.kkmall.product.entity.SkuImagesEntity;
|
||||||
import name.lkk.kkmall.product.service.SkuImagesService;
|
import name.lkk.kkmall.product.service.SkuImagesService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
@Service("skuImagesService")
|
@Service("skuImagesService")
|
||||||
public class SkuImagesServiceImpl extends ServiceImpl<SkuImagesDao, SkuImagesEntity> implements SkuImagesService {
|
public class SkuImagesServiceImpl extends ServiceImpl<SkuImagesDao, SkuImagesEntity> implements SkuImagesService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageUtils queryPage(Map<String, Object> params) {
|
public PageUtils queryPage(Map<String, Object> params) {
|
||||||
IPage<SkuImagesEntity> page = this.page(
|
IPage<SkuImagesEntity> page = this.page(
|
||||||
|
@ -26,4 +26,10 @@ public class SkuImagesServiceImpl extends ServiceImpl<SkuImagesDao, SkuImagesEnt
|
||||||
return new PageUtils(page);
|
return new PageUtils(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SkuImagesEntity> getImagesBySkuId(Long skuId) {
|
||||||
|
|
||||||
|
SkuImagesDao dao = this.baseMapper;
|
||||||
|
return dao.selectList(new QueryWrapper<SkuImagesEntity>().eq("sku_id", skuId));
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,21 +1,39 @@
|
||||||
package name.lkk.kkmall.product.service.impl;
|
package name.lkk.kkmall.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.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import name.lkk.common.utils.PageUtils;
|
import name.lkk.common.utils.PageUtils;
|
||||||
import name.lkk.common.utils.Query;
|
import name.lkk.common.utils.Query;
|
||||||
|
|
||||||
import name.lkk.kkmall.product.dao.SkuInfoDao;
|
import name.lkk.kkmall.product.dao.SkuInfoDao;
|
||||||
import name.lkk.kkmall.product.entity.SkuInfoEntity;
|
import name.lkk.kkmall.product.entity.SkuInfoEntity;
|
||||||
import name.lkk.kkmall.product.service.SkuInfoService;
|
import name.lkk.kkmall.product.service.*;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
@Service("skuInfoService")
|
@Service("skuInfoService")
|
||||||
public class SkuInfoServiceImpl extends ServiceImpl<SkuInfoDao, SkuInfoEntity> implements SkuInfoService {
|
public class SkuInfoServiceImpl extends ServiceImpl<SkuInfoDao, SkuInfoEntity> implements SkuInfoService {
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SkuImagesService imagesService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SpuInfoDescService spuInfoDescService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AttrGroupService attrGroupService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SkuSaleAttrValueService skuSaleAttrValueService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageUtils queryPage(Map<String, Object> params) {
|
public PageUtils queryPage(Map<String, Object> params) {
|
||||||
IPage<SkuInfoEntity> page = this.page(
|
IPage<SkuInfoEntity> page = this.page(
|
||||||
|
@ -26,4 +44,64 @@ public class SkuInfoServiceImpl extends ServiceImpl<SkuInfoDao, SkuInfoEntity> i
|
||||||
return new PageUtils(page);
|
return new PageUtils(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveSkuInfo(SkuInfoEntity skuInfoEntity) {
|
||||||
|
this.baseMapper.insert(skuInfoEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SKU 区间模糊查询
|
||||||
|
* key: 华为
|
||||||
|
* catelogId: 225
|
||||||
|
* brandId: 2
|
||||||
|
* min: 2
|
||||||
|
* max: 2
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public PageUtils queryPageByCondition(Map<String, Object> params) {
|
||||||
|
|
||||||
|
QueryWrapper<SkuInfoEntity> wrapper = new QueryWrapper<>();
|
||||||
|
String key = (String) params.get("key");
|
||||||
|
if(!StringUtils.isEmpty(key)){
|
||||||
|
wrapper.and(w -> w.eq("sku_id", key).or().like("sku_name", key));
|
||||||
|
}
|
||||||
|
// 三级id没选择不应该拼这个条件 没选应该查询所有
|
||||||
|
String catelogId = (String) params.get("catelogId");
|
||||||
|
if(!StringUtils.isEmpty(catelogId) && !"0".equalsIgnoreCase(catelogId)){
|
||||||
|
wrapper.eq("catalog_id", catelogId);
|
||||||
|
}
|
||||||
|
String brandId = (String) params.get("brandId");
|
||||||
|
if(!StringUtils.isEmpty(brandId) && !"0".equalsIgnoreCase(brandId)){
|
||||||
|
wrapper.eq("brand_id", brandId);
|
||||||
|
}
|
||||||
|
String min = (String) params.get("min");
|
||||||
|
if(!StringUtils.isEmpty(min)){
|
||||||
|
// gt : 大于; ge: 大于等于
|
||||||
|
wrapper.ge("price", min);
|
||||||
|
}
|
||||||
|
String max = (String) params.get("max");
|
||||||
|
if(!StringUtils.isEmpty(max)){
|
||||||
|
try {
|
||||||
|
BigDecimal bigDecimal = new BigDecimal(max);
|
||||||
|
if(bigDecimal.compareTo(new BigDecimal("0")) == 1){
|
||||||
|
// le: 小于等于
|
||||||
|
wrapper.le("price", max);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println("name.lkk.kkmall.product.service.impl.SkuInfoServiceImpl.java:前端传来非数字字符");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
IPage<SkuInfoEntity> page = this.page(
|
||||||
|
new Query<SkuInfoEntity>().getPage(params),
|
||||||
|
wrapper
|
||||||
|
);
|
||||||
|
|
||||||
|
return new PageUtils(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SkuInfoEntity> getSkusBySpuId(Long spuId) {
|
||||||
|
return this.list(new QueryWrapper<SkuInfoEntity>().eq("spu_id", spuId));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,16 +1,18 @@
|
||||||
package name.lkk.kkmall.product.service.impl;
|
package name.lkk.kkmall.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.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import name.lkk.common.utils.PageUtils;
|
import name.lkk.common.utils.PageUtils;
|
||||||
import name.lkk.common.utils.Query;
|
import name.lkk.common.utils.Query;
|
||||||
|
|
||||||
import name.lkk.kkmall.product.dao.SkuSaleAttrValueDao;
|
import name.lkk.kkmall.product.dao.SkuSaleAttrValueDao;
|
||||||
import name.lkk.kkmall.product.entity.SkuSaleAttrValueEntity;
|
import name.lkk.kkmall.product.entity.SkuSaleAttrValueEntity;
|
||||||
import name.lkk.kkmall.product.service.SkuSaleAttrValueService;
|
import name.lkk.kkmall.product.service.SkuSaleAttrValueService;
|
||||||
|
import name.lkk.kkmall.product.vo.ItemSaleAttrVo;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
@Service("skuSaleAttrValueService")
|
@Service("skuSaleAttrValueService")
|
||||||
|
@ -26,4 +28,17 @@ public class SkuSaleAttrValueServiceImpl extends ServiceImpl<SkuSaleAttrValueDao
|
||||||
return new PageUtils(page);
|
return new PageUtils(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ItemSaleAttrVo> getSaleAttrsBuSpuId(Long spuId) {
|
||||||
|
|
||||||
|
SkuSaleAttrValueDao dao = this.baseMapper;
|
||||||
|
return dao.getSaleAttrsBuSpuId(spuId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getSkuSaleAttrValuesAsStringList(Long skuId) {
|
||||||
|
|
||||||
|
SkuSaleAttrValueDao dao = this.baseMapper;
|
||||||
|
return dao.getSkuSaleAttrValuesAsStringList(skuId);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,21 +1,26 @@
|
||||||
package name.lkk.kkmall.product.service.impl;
|
package name.lkk.kkmall.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.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import name.lkk.common.utils.PageUtils;
|
import name.lkk.common.utils.PageUtils;
|
||||||
import name.lkk.common.utils.Query;
|
import name.lkk.common.utils.Query;
|
||||||
|
|
||||||
import name.lkk.kkmall.product.dao.SpuImagesDao;
|
import name.lkk.kkmall.product.dao.SpuImagesDao;
|
||||||
import name.lkk.kkmall.product.entity.SpuImagesEntity;
|
import name.lkk.kkmall.product.entity.SpuImagesEntity;
|
||||||
import name.lkk.kkmall.product.service.SpuImagesService;
|
import name.lkk.kkmall.product.service.SpuImagesService;
|
||||||
|
import org.jboss.logging.Logger;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
@Service("spuImagesService")
|
@Service("spuImagesService")
|
||||||
public class SpuImagesServiceImpl extends ServiceImpl<SpuImagesDao, SpuImagesEntity> implements SpuImagesService {
|
public class SpuImagesServiceImpl extends ServiceImpl<SpuImagesDao, SpuImagesEntity> implements SpuImagesService {
|
||||||
|
|
||||||
|
private Logger logger = Logger.getLogger(SpuImagesServiceImpl.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageUtils queryPage(Map<String, Object> params) {
|
public PageUtils queryPage(Map<String, Object> params) {
|
||||||
IPage<SpuImagesEntity> page = this.page(
|
IPage<SpuImagesEntity> page = this.page(
|
||||||
|
@ -25,5 +30,21 @@ public class SpuImagesServiceImpl extends ServiceImpl<SpuImagesDao, SpuImagesEnt
|
||||||
|
|
||||||
return new PageUtils(page);
|
return new PageUtils(page);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public void saveImages(Long id, List<String> images) {
|
||||||
|
if(images == null || images.size() == 0){
|
||||||
|
logger.warn("图片为空");
|
||||||
|
}else{
|
||||||
|
// 保存所有图片
|
||||||
|
List<SpuImagesEntity> collect = images.stream().map(img -> {
|
||||||
|
SpuImagesEntity imagesEntity = new SpuImagesEntity();
|
||||||
|
imagesEntity.setSpuId(id);
|
||||||
|
imagesEntity.setImgUrl(img);
|
||||||
|
|
||||||
|
return imagesEntity;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
this.saveBatch(collect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,16 +1,16 @@
|
||||||
package name.lkk.kkmall.product.service.impl;
|
package name.lkk.kkmall.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.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import name.lkk.common.utils.PageUtils;
|
import name.lkk.common.utils.PageUtils;
|
||||||
import name.lkk.common.utils.Query;
|
import name.lkk.common.utils.Query;
|
||||||
|
|
||||||
import name.lkk.kkmall.product.dao.SpuInfoDescDao;
|
import name.lkk.kkmall.product.dao.SpuInfoDescDao;
|
||||||
import name.lkk.kkmall.product.entity.SpuInfoDescEntity;
|
import name.lkk.kkmall.product.entity.SpuInfoDescEntity;
|
||||||
import name.lkk.kkmall.product.service.SpuInfoDescService;
|
import name.lkk.kkmall.product.service.SpuInfoDescService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
@Service("spuInfoDescService")
|
@Service("spuInfoDescService")
|
||||||
|
@ -25,5 +25,10 @@ public class SpuInfoDescServiceImpl extends ServiceImpl<SpuInfoDescDao, SpuInfoD
|
||||||
|
|
||||||
return new PageUtils(page);
|
return new PageUtils(page);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public void saveSpuInfoDesc(SpuInfoDescEntity spuInfoDescEntity) {
|
||||||
|
|
||||||
|
this.baseMapper.insert(spuInfoDescEntity);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,21 +1,64 @@
|
||||||
package name.lkk.kkmall.product.service.impl;
|
package name.lkk.kkmall.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.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import name.lkk.common.to.SkuReductionTO;
|
||||||
|
import name.lkk.common.to.SpuBoundTO;
|
||||||
import name.lkk.common.utils.PageUtils;
|
import name.lkk.common.utils.PageUtils;
|
||||||
import name.lkk.common.utils.Query;
|
import name.lkk.common.utils.Query;
|
||||||
|
import name.lkk.common.utils.R;
|
||||||
import name.lkk.kkmall.product.dao.SpuInfoDao;
|
import name.lkk.kkmall.product.dao.SpuInfoDao;
|
||||||
import name.lkk.kkmall.product.entity.SpuInfoEntity;
|
import name.lkk.kkmall.product.entity.*;
|
||||||
import name.lkk.kkmall.product.service.SpuInfoService;
|
import name.lkk.kkmall.product.feign.CouponFeignService;
|
||||||
|
import name.lkk.kkmall.product.service.*;
|
||||||
|
import name.lkk.kkmall.product.vo.*;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kirklin
|
||||||
|
*/
|
||||||
@Service("spuInfoService")
|
@Service("spuInfoService")
|
||||||
public class SpuInfoServiceImpl extends ServiceImpl<SpuInfoDao, SpuInfoEntity> implements SpuInfoService {
|
public class SpuInfoServiceImpl extends ServiceImpl<SpuInfoDao, SpuInfoEntity> implements SpuInfoService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SpuInfoDescService spuInfoDescService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SpuImagesService spuImagesService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AttrService attrService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ProductAttrValueService attrValueService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SkuInfoService skuInfoService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SkuImagesService skuImagesService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SkuSaleAttrValueService skuSaleAttrValueService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* feign 远程调用优惠券服务
|
||||||
|
*/
|
||||||
|
@Autowired
|
||||||
|
private CouponFeignService couponFeignService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageUtils queryPage(Map<String, Object> params) {
|
public PageUtils queryPage(Map<String, Object> params) {
|
||||||
IPage<SpuInfoEntity> page = this.page(
|
IPage<SpuInfoEntity> page = this.page(
|
||||||
|
@ -26,4 +69,163 @@ public class SpuInfoServiceImpl extends ServiceImpl<SpuInfoDao, SpuInfoEntity> i
|
||||||
return new PageUtils(page);
|
return new PageUtils(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveBatchSpuInfo(SpuInfoEntity spuInfoEntity) {
|
||||||
|
this.baseMapper.insert(spuInfoEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* spu管理模糊查询
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public PageUtils queryPageByCondition(Map<String, Object> params) {
|
||||||
|
|
||||||
|
QueryWrapper<SpuInfoEntity> wrapper = new QueryWrapper<>();
|
||||||
|
|
||||||
|
// 根据 spu管理带来的条件进行叠加模糊查询
|
||||||
|
String key = (String) params.get("key");
|
||||||
|
if(!ObjectUtils.isEmpty(key)){
|
||||||
|
wrapper.and(w -> w.eq("id", key).or().like("spu_name",key));
|
||||||
|
}
|
||||||
|
|
||||||
|
String status = (String) params.get("status");
|
||||||
|
if(!ObjectUtils.isEmpty(status)){
|
||||||
|
wrapper.eq("publish_status", status);
|
||||||
|
}
|
||||||
|
|
||||||
|
String brandId = (String) params.get("brandId");
|
||||||
|
if(!ObjectUtils.isEmpty(brandId) && !"0".equalsIgnoreCase(brandId)){
|
||||||
|
wrapper.eq("brand_id", brandId);
|
||||||
|
}
|
||||||
|
|
||||||
|
String catelogId = (String) params.get("catelogId");
|
||||||
|
if(!ObjectUtils.isEmpty(catelogId) && !"0".equalsIgnoreCase(catelogId)){
|
||||||
|
wrapper.eq("catalog_id", catelogId);
|
||||||
|
}
|
||||||
|
|
||||||
|
IPage<SpuInfoEntity> page = this.page(
|
||||||
|
new Query<SpuInfoEntity>().getPage(params),
|
||||||
|
wrapper
|
||||||
|
);
|
||||||
|
return new PageUtils(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SpuInfoEntity getSpuInfoBySkuId(Long skuId) {
|
||||||
|
|
||||||
|
return getById(skuInfoService.getById(skuId).getSpuId());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存所有数据
|
||||||
|
*/
|
||||||
|
@Transactional
|
||||||
|
@Override
|
||||||
|
public void saveSpuInfo(SpuSaveVo vo) {
|
||||||
|
|
||||||
|
// 1.保存spu基本信息 pms_sku_info
|
||||||
|
SpuInfoEntity spuInfoEntity = new SpuInfoEntity();
|
||||||
|
spuInfoEntity.setCreateTime(new Date());
|
||||||
|
spuInfoEntity.setUpdateTime(new Date());
|
||||||
|
BeanUtils.copyProperties(vo, spuInfoEntity);
|
||||||
|
this.saveBatchSpuInfo(spuInfoEntity);
|
||||||
|
// 2.保存spu的表述图片 pms_spu_info_desc
|
||||||
|
List<String> describe = vo.getDecript();
|
||||||
|
SpuInfoDescEntity spuInfoDescEntity = new SpuInfoDescEntity();
|
||||||
|
spuInfoDescEntity.setSpuId(spuInfoEntity.getId());
|
||||||
|
// String join 的方式将它们用逗号分隔
|
||||||
|
spuInfoDescEntity.setDecript(String.join(",", describe));
|
||||||
|
spuInfoDescService.saveSpuInfoDesc(spuInfoDescEntity);
|
||||||
|
// 3.保存spu的图片集 pms_sku_images
|
||||||
|
// 先获取所有图片
|
||||||
|
List<String> images = vo.getImages();
|
||||||
|
// 保存图片的时候 并且保存这个是那个spu的图片
|
||||||
|
spuImagesService.saveImages(spuInfoEntity.getId() ,images);
|
||||||
|
// 4.保存spu的规格属性 pms_product_attr_value
|
||||||
|
List<BaseAttrs> baseAttrs = vo.getBaseAttrs();
|
||||||
|
List<ProductAttrValueEntity> collect = baseAttrs.stream().map(attr -> {
|
||||||
|
ProductAttrValueEntity valueEntity = new ProductAttrValueEntity();
|
||||||
|
valueEntity.setAttrId(attr.getAttrId());
|
||||||
|
// 可能页面没用传入属性名字 根据属性id查到所有属性 给名字赋值
|
||||||
|
AttrEntity attrEntity = attrService.getById(attr.getAttrId());
|
||||||
|
valueEntity.setAttrName(attrEntity.getAttrName());
|
||||||
|
valueEntity.setAttrValue(attr.getAttrValues());
|
||||||
|
valueEntity.setQuickShow(attr.getShowDesc());
|
||||||
|
valueEntity.setSpuId(spuInfoEntity.getId());
|
||||||
|
return valueEntity;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
attrValueService.saveProductAttr(collect);
|
||||||
|
// 5.保存当前spu对应所有sku信息
|
||||||
|
Bounds bounds = vo.getBounds();
|
||||||
|
SpuBoundTO spuBoundTO = new SpuBoundTO();
|
||||||
|
BeanUtils.copyProperties(bounds, spuBoundTO);
|
||||||
|
spuBoundTO.setSpuId(spuInfoEntity.getId());
|
||||||
|
R r = couponFeignService.saveSpuBounds(spuBoundTO);
|
||||||
|
if(r.getCode() != 0){
|
||||||
|
log.error("远程保存spu积分信息失败");
|
||||||
|
}
|
||||||
|
// 1).spu的积分信息 sms_spu_bounds
|
||||||
|
List<Skus> skus = vo.getSkus();
|
||||||
|
if(skus != null && skus.size() > 0){
|
||||||
|
// 提前查找默认图片
|
||||||
|
skus.forEach(item -> {
|
||||||
|
String defaultImg = "";
|
||||||
|
for (Images img : item.getImages()) {
|
||||||
|
if(img.getDefaultImg() == 1){
|
||||||
|
defaultImg = img.getImgUrl();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 2).基本信息的保存 pms_sku_info
|
||||||
|
// skuName 、price、skuTitle、skuSubtitle 这些属性需要手动保存
|
||||||
|
SkuInfoEntity skuInfoEntity = new SkuInfoEntity();
|
||||||
|
BeanUtils.copyProperties(item, skuInfoEntity);
|
||||||
|
// 设置spu的品牌id
|
||||||
|
skuInfoEntity.setBrandId(spuInfoEntity.getBrandId());
|
||||||
|
skuInfoEntity.setCatalogId(spuInfoEntity.getCatalogId());
|
||||||
|
skuInfoEntity.setSpuId(spuInfoEntity.getId());
|
||||||
|
skuInfoEntity.setSkuDefaultImg(defaultImg);
|
||||||
|
skuInfoEntity.setSaleCount((long) (Math.random()*2888));
|
||||||
|
skuInfoService.saveSkuInfo(skuInfoEntity);
|
||||||
|
|
||||||
|
// 3).保存sku的图片信息 pms_sku_images
|
||||||
|
// sku保存完毕 自增主键就出来了 收集所有图片
|
||||||
|
Long skuId = skuInfoEntity.getSkuId();
|
||||||
|
List<SkuImagesEntity> imagesEntities = item.getImages().stream().map(img -> {
|
||||||
|
SkuImagesEntity skuImagesEntity = new SkuImagesEntity();
|
||||||
|
skuImagesEntity.setId(skuId);
|
||||||
|
skuImagesEntity.setImgUrl(img.getImgUrl());
|
||||||
|
skuImagesEntity.setDefaultImg(img.getDefaultImg());
|
||||||
|
return skuImagesEntity;
|
||||||
|
}).filter(entity ->
|
||||||
|
// 返回true就会保存 返回false就会过滤
|
||||||
|
!ObjectUtils.isEmpty(entity.getImgUrl())
|
||||||
|
).collect(Collectors.toList());
|
||||||
|
skuImagesService.saveBatch(imagesEntities);
|
||||||
|
|
||||||
|
// 4).sku的销售属性 pms_sku_sale_attr_value
|
||||||
|
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.) sku的优惠、满减、会员价格等信息 [跨库]
|
||||||
|
SkuReductionTO skuReductionTO = new SkuReductionTO();
|
||||||
|
BeanUtils.copyProperties(item, skuReductionTO);
|
||||||
|
skuReductionTO.setSkuId(skuId);
|
||||||
|
if(skuReductionTO.getFullCount() > 0 || (skuReductionTO.getFullPrice().compareTo(new BigDecimal("0")) > 0)){
|
||||||
|
R r1 = couponFeignService.saveSkuReduction(skuReductionTO);
|
||||||
|
if(r1.getCode() != 0){
|
||||||
|
log.error("远程保存sku优惠信息失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package name.lkk.kkmall.product.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class Attr {
|
||||||
|
|
||||||
|
private Long attrId;
|
||||||
|
|
||||||
|
private String attrName;
|
||||||
|
|
||||||
|
private String attrValue;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package name.lkk.kkmall.product.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class AttrGroupRelationVo {
|
||||||
|
|
||||||
|
private Long attrId;
|
||||||
|
private Long attrGroupId;
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
package name.lkk.kkmall.product.vo;
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import name.lkk.kkmall.product.entity.AttrEntity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@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,13 @@
|
||||||
|
package name.lkk.kkmall.product.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class AttrRespVo extends AttrVo{
|
||||||
|
|
||||||
|
private String catelogName;
|
||||||
|
|
||||||
|
private String groupName;
|
||||||
|
|
||||||
|
private Long[] catelogPath;
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package name.lkk.kkmall.product.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class AttrValueWithSkuIdVo {
|
||||||
|
|
||||||
|
private String attrValue;
|
||||||
|
|
||||||
|
private String skuIds;
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package name.lkk.kkmall.product.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import name.lkk.kkmall.product.entity.AttrEntity;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class AttrVo extends AttrEntity {
|
||||||
|
|
||||||
|
private Long attrGroupId;
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package name.lkk.kkmall.product.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Title: BaseAttrs</p>
|
||||||
|
* Description:
|
||||||
|
* date:2020/6/5 14:58
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class BaseAttrs {
|
||||||
|
|
||||||
|
private Long attrId;
|
||||||
|
|
||||||
|
private String attrValues;
|
||||||
|
|
||||||
|
private int showDesc;
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package name.lkk.kkmall.product.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Title: AttrVo</p>
|
||||||
|
* Description:成直积分、购物积分
|
||||||
|
*
|
||||||
|
* date:2020/6/2 19:23
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class Bounds {
|
||||||
|
|
||||||
|
private BigDecimal buyBounds;
|
||||||
|
private BigDecimal growBounds;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package name.lkk.kkmall.product.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class BrandVo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "brandId": 0,
|
||||||
|
* "brandName": "string",
|
||||||
|
*/
|
||||||
|
private Long brandId;
|
||||||
|
|
||||||
|
private String brandName;
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package name.lkk.kkmall.product.vo;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Title: Catalog3Vo</p>
|
||||||
|
* Description:
|
||||||
|
* date:2020/6/9 14:42
|
||||||
|
*/
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
public class Catalog3Vo {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String catalog2Id;
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package name.lkk.kkmall.product.vo;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Title: Catelog2Vo</p>
|
||||||
|
* Description:
|
||||||
|
* date:2020/6/9 14:41
|
||||||
|
*/
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
public class Catelog2Vo implements Serializable {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String catalog1Id;
|
||||||
|
|
||||||
|
private List<Catalog3Vo> catalog3List;
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package name.lkk.kkmall.product.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class Images {
|
||||||
|
|
||||||
|
private String imgUrl;
|
||||||
|
|
||||||
|
private int defaultImg;
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package name.lkk.kkmall.product.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@ToString
|
||||||
|
@Data
|
||||||
|
public class ItemSaleAttrVo{
|
||||||
|
private Long attrId;
|
||||||
|
|
||||||
|
private String attrName;
|
||||||
|
|
||||||
|
private List<AttrValueWithSkuIdVo> attrValues;
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package name.lkk.kkmall.product.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Title: AttrRespVo</p>
|
||||||
|
* Description:会员价格
|
||||||
|
* date:2020/6/2 19:56
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class MemberPrice {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private BigDecimal price;
|
||||||
|
}
|
|
@ -0,0 +1,54 @@
|
||||||
|
package name.lkk.kkmall.product.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Title: SeckillInfoVo</p>
|
||||||
|
* Description:
|
||||||
|
* date:2020/7/9 12:32
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class SeckillInfoVo {
|
||||||
|
|
||||||
|
private Long promotionId;
|
||||||
|
/**
|
||||||
|
* 活动场次id
|
||||||
|
*/
|
||||||
|
private Long promotionSessionId;
|
||||||
|
/**
|
||||||
|
* 商品id
|
||||||
|
*/
|
||||||
|
private Long skuId;
|
||||||
|
/**
|
||||||
|
* 商品的秒杀随机码
|
||||||
|
*/
|
||||||
|
private String randomCode;
|
||||||
|
/**
|
||||||
|
* 秒杀价格
|
||||||
|
*/
|
||||||
|
private BigDecimal seckillPrice;
|
||||||
|
/**
|
||||||
|
* 秒杀总量
|
||||||
|
*/
|
||||||
|
private BigDecimal seckillCount;
|
||||||
|
/**
|
||||||
|
* 每人限购数量
|
||||||
|
*/
|
||||||
|
private BigDecimal seckillLimit;
|
||||||
|
/**
|
||||||
|
* 排序
|
||||||
|
*/
|
||||||
|
private Integer seckillSort;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品秒杀的开始时间
|
||||||
|
*/
|
||||||
|
private Long startTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品秒杀的结束时间
|
||||||
|
*/
|
||||||
|
private Long endTime;
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
package name.lkk.kkmall.product.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import name.lkk.kkmall.product.entity.SkuImagesEntity;
|
||||||
|
import name.lkk.kkmall.product.entity.SkuInfoEntity;
|
||||||
|
import name.lkk.kkmall.product.entity.SpuInfoDescEntity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Title: SkuItemVo</p>
|
||||||
|
* Description:
|
||||||
|
* date:2020/6/24 13:33
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class SkuItemVo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 基本信息
|
||||||
|
*/
|
||||||
|
SkuInfoEntity info;
|
||||||
|
|
||||||
|
boolean hasStock = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图片信息
|
||||||
|
*/
|
||||||
|
List<SkuImagesEntity> images;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 销售属性组合
|
||||||
|
*/
|
||||||
|
List<ItemSaleAttrVo> saleAttr;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 介绍
|
||||||
|
*/
|
||||||
|
SpuInfoDescEntity desc;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数规格信息
|
||||||
|
*/
|
||||||
|
List<SpuItemAttrGroup> groupAttrs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 秒杀信息
|
||||||
|
*/
|
||||||
|
SeckillInfoVo seckillInfoVo;
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
package name.lkk.kkmall.product.vo;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class Skus {
|
||||||
|
|
||||||
|
private List<Attr> attr;
|
||||||
|
|
||||||
|
private String skuName;
|
||||||
|
|
||||||
|
private BigDecimal price;
|
||||||
|
|
||||||
|
private String skuTitle;
|
||||||
|
|
||||||
|
private String skuSubtitle;
|
||||||
|
|
||||||
|
private List<Images> images;
|
||||||
|
|
||||||
|
private List<String> descar;
|
||||||
|
|
||||||
|
private int fullCount;
|
||||||
|
|
||||||
|
private BigDecimal discount;
|
||||||
|
|
||||||
|
private int countStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 满减价格
|
||||||
|
*/
|
||||||
|
private BigDecimal fullPrice;
|
||||||
|
|
||||||
|
private BigDecimal reducePrice;
|
||||||
|
|
||||||
|
private int priceStatus;
|
||||||
|
|
||||||
|
private List<MemberPrice> memberPrice;
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
package name.lkk.kkmall.product.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@ToString
|
||||||
|
@Data
|
||||||
|
public class SpuBaseAttrVo{
|
||||||
|
private String attrName;
|
||||||
|
|
||||||
|
private String attrValue;
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package name.lkk.kkmall.product.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@ToString
|
||||||
|
@Data
|
||||||
|
public class SpuItemAttrGroup{
|
||||||
|
private String groupName;
|
||||||
|
|
||||||
|
private List<SpuBaseAttrVo> attrs;
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
package name.lkk.kkmall.product.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SpuSaveVo {
|
||||||
|
|
||||||
|
private String spuName;
|
||||||
|
|
||||||
|
private String spuDescription;
|
||||||
|
|
||||||
|
private Long catalogId;
|
||||||
|
|
||||||
|
private Long brandId;
|
||||||
|
|
||||||
|
private BigDecimal weight;
|
||||||
|
|
||||||
|
private int publishStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 表述图片
|
||||||
|
*/
|
||||||
|
private List<String> decript;
|
||||||
|
|
||||||
|
private List<String> images;
|
||||||
|
|
||||||
|
private Bounds bounds;
|
||||||
|
|
||||||
|
private List<BaseAttrs> baseAttrs;
|
||||||
|
|
||||||
|
private List<Skus> skus;
|
||||||
|
|
||||||
|
}
|
|
@ -12,6 +12,9 @@ spring:
|
||||||
server-addr: localhost:8848
|
server-addr: localhost:8848
|
||||||
application:
|
application:
|
||||||
name: kkmall-product
|
name: kkmall-product
|
||||||
|
jackson:
|
||||||
|
date-format: yyyy-MM-dd HH:mm:ss
|
||||||
|
time-zone: GMT+8
|
||||||
|
|
||||||
mybatis-plus:
|
mybatis-plus:
|
||||||
mapper-locations: classpath:/mapper/**/*.xml
|
mapper-locations: classpath:/mapper/**/*.xml
|
||||||
|
|
|
@ -10,6 +10,13 @@
|
||||||
<result property="attrGroupId" column="attr_group_id"/>
|
<result property="attrGroupId" column="attr_group_id"/>
|
||||||
<result property="attrSort" column="attr_sort"/>
|
<result property="attrSort" column="attr_sort"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
<!-- 发送批量删除语句 -->
|
||||||
|
<delete id="deleteBatchRelation">
|
||||||
|
DELETE FROM `pms_attr_attrgroup_relation` WHERE
|
||||||
|
<foreach collection="entities" item="item" separator=" OR ">
|
||||||
|
(attr_id = #{item.attrId} AND attr_group_id = #{item.attrGroupId})
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
|
@ -15,6 +15,11 @@
|
||||||
<result property="catelogId" column="catelog_id"/>
|
<result property="catelogId" column="catelog_id"/>
|
||||||
<result property="showDesc" column="show_desc"/>
|
<result property="showDesc" column="show_desc"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
<select id="selectSearchAttrIds" resultType="java.lang.Long">
|
||||||
|
SELECT attr_id FROM `pms_attr` WHERE attr_id IN
|
||||||
|
<foreach collection="attrIds" item="id" separator="," open="(" close=")"> #{id} </foreach>
|
||||||
|
AND search_type = 1
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
|
@ -13,5 +13,23 @@
|
||||||
<result property="catelogId" column="catelog_id"/>
|
<result property="catelogId" column="catelog_id"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
|
<!-- 封装自定义结果集 -->
|
||||||
|
<resultMap id="SpuItemAttrGroupVo" type="name.lkk.kkmall.product.vo.SpuItemAttrGroup">
|
||||||
|
<result column="attr_group_name" property="groupName" javaType="string"></result>
|
||||||
|
<collection property="attrs" ofType="name.lkk.kkmall.product.vo.SpuBaseAttrVo">
|
||||||
|
<result column="attr_name" property="attrName" javaType="string"></result>
|
||||||
|
<result column="attr_value" property="attrValue" javaType="string"></result>
|
||||||
|
</collection>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<select id="getAttrGroupWithAttrsBySpuId" resultMap="SpuItemAttrGroupVo">
|
||||||
|
|
||||||
|
SELECT pav.`spu_id`, ag.`attr_group_name`, ag.`attr_group_id`, aar.`attr_id`, attr.`attr_name`,pav.`attr_value`
|
||||||
|
FROM `pms_attr_group` ag
|
||||||
|
LEFT JOIN `pms_attr_attrgroup_relation` aar ON aar.`attr_group_id` = ag.`attr_group_id`
|
||||||
|
LEFT JOIN `pms_attr` attr ON attr.`attr_id` = aar.`attr_id`
|
||||||
|
LEFT JOIN `pms_product_attr_value` pav ON pav.`attr_id` = attr.`attr_id`
|
||||||
|
WHERE ag.catelog_id = #{catalogId} AND pav.`spu_id` = #{spuId}
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
|
@ -13,5 +13,21 @@
|
||||||
<result property="attrSort" column="attr_sort"/>
|
<result property="attrSort" column="attr_sort"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
|
<resultMap id="SkuItemSaleAttrVo" type="name.lkk.kkmall.product.vo.ItemSaleAttrVo">
|
||||||
|
<result column="attr_id" property="attrId"></result>
|
||||||
|
<result column="attr_name" property="attrName"></result>
|
||||||
|
<collection property="attrValues" ofType="name.lkk.kkmall.product.vo.AttrValueWithSkuIdVo">
|
||||||
|
<result column="attr_value" property="attrValue"></result>
|
||||||
|
<result column="sku_ids" property="skuIds"></result>
|
||||||
|
</collection>
|
||||||
|
</resultMap>
|
||||||
|
<select id="getSaleAttrsBuSpuId" resultMap="SkuItemSaleAttrVo">
|
||||||
|
SELECT ssav.`attr_id`,ssav.`attr_name`,ssav.`attr_value`,GROUP_CONCAT(DISTINCT info.`sku_id`) sku_ids
|
||||||
|
FROM `pms_sku_info` INFO LEFT JOIN `pms_sku_sale_attr_value` ssav ON ssav.`sku_id` = info.`sku_id`
|
||||||
|
WHERE info.`spu_id` = #{spuId} GROUP BY ssav.`attr_id`,ssav.`attr_name`,ssav.`attr_value`
|
||||||
|
</select>
|
||||||
|
<select id="getSkuSaleAttrValuesAsStringList" resultType="java.lang.String">
|
||||||
|
SELECT CONCAT(attr_name,":",attr_value) FROM `pms_sku_sale_attr_value` WHERE sku_id = #{skuId};
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
|
@ -91,6 +91,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import CategoryCascader from "../common/category-cascader";
|
import CategoryCascader from "../common/category-cascader";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -214,20 +215,20 @@ export default {
|
||||||
params: this.$http.adornParams()
|
params: this.$http.adornParams()
|
||||||
}).then(({ data }) => {
|
}).then(({ data }) => {
|
||||||
if (data && data.code === 0) {
|
if (data && data.code === 0) {
|
||||||
this.dataForm.attrName = data.attr.attrName;
|
this.dataForm.attrName = data.data.attrName;
|
||||||
this.dataForm.searchType = data.attr.searchType;
|
this.dataForm.searchType = data.data.searchType;
|
||||||
this.dataForm.valueType = data.attr.valueType;
|
this.dataForm.valueType = data.data.valueType;
|
||||||
this.dataForm.icon = data.attr.icon;
|
this.dataForm.icon = data.data.icon;
|
||||||
this.dataForm.valueSelect = data.attr.valueSelect.split(";");
|
this.dataForm.valueSelect = data.data.valueSelect.split(";");
|
||||||
this.dataForm.attrType = data.attr.attrType;
|
this.dataForm.attrType = data.data.attrType;
|
||||||
this.dataForm.enable = data.attr.enable;
|
this.dataForm.enable = data.data.enable;
|
||||||
this.dataForm.catelogId = data.attr.catelogId;
|
this.dataForm.catelogId = data.data.catelogId;
|
||||||
this.dataForm.showDesc = data.attr.showDesc;
|
this.dataForm.showDesc = data.data.showDesc;
|
||||||
//attrGroupId
|
//attrGroupId
|
||||||
//catelogPath
|
//catelogPath
|
||||||
this.catelogPath = data.attr.catelogPath;
|
this.catelogPath = data.data.catelogPath;
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.dataForm.attrGroupId = data.attr.attrGroupId;
|
this.dataForm.attrGroupId = data.data.attrGroupId;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
<el-table-column prop="descript" header-align="center" align="center" label="描述"></el-table-column>
|
<el-table-column prop="descript" header-align="center" align="center" label="描述"></el-table-column>
|
||||||
<el-table-column prop="icon" header-align="center" align="center" label="组图标">
|
<el-table-column prop="icon" header-align="center" align="center" label="组图标">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<img :src="scope.row.logo" style="width: 60px; height: 60px" />
|
<img :src="scope.row.icon" style="width: 60px; height: 60px" />
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="catelogId" header-align="center" align="center" label="分类id"></el-table-column>
|
<el-table-column prop="catelogId" header-align="center" align="center" label="分类id"></el-table-column>
|
||||||
|
@ -92,6 +92,7 @@
|
||||||
import Category from "../common/category";
|
import Category from "../common/category";
|
||||||
import AddOrUpdate from "./attrgroup-add-or-update";
|
import AddOrUpdate from "./attrgroup-add-or-update";
|
||||||
import RelationUpdate from "./attr-group-relation";
|
import RelationUpdate from "./attr-group-relation";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
//import引入的组件需要注入到对象中才能使用
|
//import引入的组件需要注入到对象中才能使用
|
||||||
components: { Category, AddOrUpdate, RelationUpdate },
|
components: { Category, AddOrUpdate, RelationUpdate },
|
||||||
|
|
|
@ -56,7 +56,7 @@
|
||||||
<el-table-column prop="icon" header-align="center" align="center" label="图标">
|
<el-table-column prop="icon" header-align="center" align="center" label="图标">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<!-- 自定义表格+自定义图片 -->
|
<!-- 自定义表格+自定义图片 -->
|
||||||
<img :src="scope.row.logo" style="width: 60px; height: 60px" />
|
<img :src="scope.row.icon" style="width: 60px; height: 60px" />
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="valueSelect" header-align="center" align="center" label="可选值">
|
<el-table-column prop="valueSelect" header-align="center" align="center" label="可选值">
|
||||||
|
@ -135,6 +135,7 @@
|
||||||
<script>
|
<script>
|
||||||
import Category from "../common/category";
|
import Category from "../common/category";
|
||||||
import AddOrUpdate from "./attr-add-or-update";
|
import AddOrUpdate from "./attr-add-or-update";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
//import引入的组件需要注入到对象中才能使用
|
//import引入的组件需要注入到对象中才能使用
|
||||||
components: { Category, AddOrUpdate },
|
components: { Category, AddOrUpdate },
|
||||||
|
|
|
@ -104,6 +104,7 @@
|
||||||
<script>
|
<script>
|
||||||
import AddOrUpdate from "./brand-add-or-update";
|
import AddOrUpdate from "./brand-add-or-update";
|
||||||
import CategoryCascader from "../common/category-cascader";
|
import CategoryCascader from "../common/category-cascader";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -211,7 +212,7 @@ export default {
|
||||||
type: "success",
|
type: "success",
|
||||||
message: "状态更新成功"
|
message: "状态更新成功"
|
||||||
});
|
});
|
||||||
}).catch(() => {});;
|
}).catch(() => {});
|
||||||
},
|
},
|
||||||
// 每页数
|
// 每页数
|
||||||
sizeChangeHandle(val) {
|
sizeChangeHandle(val) {
|
||||||
|
|
Loading…
Reference in a new issue