添加购物车
parent
bef7a05ae6
commit
7bad69d731
|
@ -22,12 +22,12 @@ public abstract class AtomicSequenceCacheAbs<K> implements AtomicSequenceCache<K
|
|||
@Override
|
||||
public Long get (K key) {
|
||||
Long cacheValue = this.redisService.getCacheObject(encode(key));
|
||||
if (cacheValue == null ){
|
||||
if (cacheValue == null){
|
||||
Long data = getData(key);
|
||||
cacheValue = data == null ? 0L : data;
|
||||
this.redisService.setCacheObject(encode(key), cacheValue);
|
||||
}
|
||||
return redisService.increment(encode(key), cacheValue);
|
||||
return cacheValue;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,10 +4,7 @@ import com.muyu.common.cache.HashCache;
|
|||
import com.muyu.common.redis.service.RedisService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
|
@ -22,7 +19,9 @@ public abstract class HashCacheAbs<K, HK, HV> implements HashCache<K, HK, HV> {
|
|||
|
||||
/**
|
||||
* 编码
|
||||
*
|
||||
* @param key ID
|
||||
*
|
||||
* @return 键
|
||||
*/
|
||||
@Override
|
||||
|
@ -166,14 +165,14 @@ public abstract class HashCacheAbs<K, HK, HV> implements HashCache<K, HK, HV> {
|
|||
}
|
||||
|
||||
/**
|
||||
* 判断reids中hashKey是否存在
|
||||
* @param key redis键
|
||||
* 判断redis中hashKey是否存在
|
||||
*
|
||||
* @param key redis键
|
||||
* @param hashKey hash键
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean hasKey(K key, HK hashKey) {
|
||||
return redisService.hasKey(encode(key),encodeHashKey(hashKey));
|
||||
public boolean hasKey (K key, HK hashKey) {
|
||||
return redisService.hashKey(encode(key), encodeHashKey(hashKey));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,37 +1,20 @@
|
|||
package com.muyu.product.cache;
|
||||
|
||||
import com.muyu.common.cache.HashCache;
|
||||
import com.muyu.common.cache.abs.CacheAbs;
|
||||
import com.muyu.common.core.text.Convert;
|
||||
import com.muyu.product.cache.datasource.ProjectInfoData;
|
||||
import com.muyu.product.domain.ProjectInfo;
|
||||
import com.muyu.product.domain.ProjectSkuInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author yangle
|
||||
* @author DongZl
|
||||
* @description: 商品缓存
|
||||
* @Date 2024-3-27 下午 03:30
|
||||
*/
|
||||
@Component
|
||||
public class ProjectInfoCache extends CacheAbs<Long, ProjectInfo> {
|
||||
|
||||
public static void main (String[] args) {
|
||||
Long projectId = 10L;
|
||||
HashCache<Long, Long, ProjectSkuInfo> hashCache = null;
|
||||
List<ProjectSkuInfo> projectSkuInfoList = new ArrayList<>(){{
|
||||
add(new ProjectSkuInfo());
|
||||
add(new ProjectSkuInfo());
|
||||
}};
|
||||
hashCache.put(projectId, projectSkuInfoList, ProjectSkuInfo::getProjectId);
|
||||
Long[] longArr = new Long[]{10L,11L,12L,13L,14L,15L};
|
||||
hashCache.get(projectId, longArr);
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private ProjectInfoData projectInfoData;
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author yangle
|
||||
* @author DongZl
|
||||
* @description: 商品sku基本信息
|
||||
* @Date 2024-3-29 下午 03:06
|
||||
*/
|
||||
|
|
|
@ -8,7 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author yangle
|
||||
* @author DongZl
|
||||
* @description: 商品SKU库存缓存
|
||||
* @Date 2024-3-29 下午 03:06
|
||||
*/
|
||||
|
|
|
@ -7,43 +7,23 @@ import com.muyu.product.cache.model.RuleCacheModel;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* 规格缓存 RuleInfoCache
|
||||
*
|
||||
* @author LeYang
|
||||
* on 2024/4/8
|
||||
* @author DongZl
|
||||
* @description: 规格缓存
|
||||
* @Date 2024/4/7 下午8:29
|
||||
*/
|
||||
public class RuleInfoCache extends CacheAbs<Long, RuleCacheModel> {
|
||||
|
||||
public class RuleInfoCache extends CacheAbs<Long, RuleCacheModel> {
|
||||
@Autowired
|
||||
private RuleCacheData ruleCacheData;
|
||||
|
||||
/**
|
||||
* 从数据库获取数据
|
||||
* @param key ID
|
||||
* @return 缓存对象
|
||||
* key前缀
|
||||
*
|
||||
* @return key前缀
|
||||
*/
|
||||
@Override
|
||||
public RuleCacheModel getData(Long key) {
|
||||
return ruleCacheData.getRulerCacheModel(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认值
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public RuleCacheModel defaultValue() {
|
||||
return new RuleCacheModel();
|
||||
}
|
||||
|
||||
/**
|
||||
* 前缀
|
||||
* @return key 前缀
|
||||
*/
|
||||
|
||||
@Override
|
||||
public String keyPre() {
|
||||
return "rule:info";
|
||||
public String keyPre () {
|
||||
return "rule:info:";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -52,7 +32,29 @@ public class RuleInfoCache extends CacheAbs<Long, RuleCacheModel> {
|
|||
* @return ID
|
||||
*/
|
||||
@Override
|
||||
public Long decode(String redisKey) {
|
||||
public Long decode (String redisKey) {
|
||||
return Convert.toLong(redisKey.replace(keyPre(), ""));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 从数据库获取数据
|
||||
*
|
||||
* @param key ID
|
||||
*
|
||||
* @return 缓存对象
|
||||
*/
|
||||
@Override
|
||||
public RuleCacheModel getData (Long key) {
|
||||
return ruleCacheData.getRuleCacheModel(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认值
|
||||
*/
|
||||
@Override
|
||||
public RuleCacheModel defaultValue () {
|
||||
return new RuleCacheModel();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.muyu.product.cache.datasource;
|
|||
import com.muyu.product.domain.ProjectInfo;
|
||||
|
||||
/**
|
||||
* @author yangle
|
||||
* @author DongZl
|
||||
* @description: 缓存数据获取
|
||||
* @Date 2024-3-27 下午 03:34
|
||||
*/
|
||||
|
|
|
@ -5,7 +5,7 @@ import com.muyu.product.domain.ProjectSkuInfo;
|
|||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author yangle
|
||||
* @author DongZl
|
||||
* @description: 商品SKU数据库读取
|
||||
* @Date 2024-4-1 上午 11:35
|
||||
*/
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.muyu.product.cache.datasource;
|
|||
import com.muyu.product.cache.key.SkuStockKey;
|
||||
|
||||
/**
|
||||
* @author yangle
|
||||
* @author DongZl
|
||||
* @description: SKU库存
|
||||
* @Date 2024-4-2 上午 10:52
|
||||
*/
|
||||
|
|
|
@ -3,14 +3,11 @@ package com.muyu.product.cache.datasource;
|
|||
import com.muyu.product.cache.model.RuleCacheModel;
|
||||
|
||||
/**
|
||||
* 规格缓存数据获取 RuleCacheData
|
||||
*
|
||||
* @author LeYang
|
||||
* on 2024/4/8
|
||||
* @author DongZl
|
||||
* @description: 规格缓存数据获取
|
||||
* @Date 2024/4/7 下午8:31
|
||||
*/
|
||||
|
||||
public interface RuleCacheData {
|
||||
|
||||
public RuleCacheModel getRulerCacheModel(Long ruleId);
|
||||
|
||||
public RuleCacheModel getRuleCacheModel(Long ruleId);
|
||||
}
|
||||
|
|
|
@ -1,24 +1,14 @@
|
|||
package com.muyu.product.cache.datasource.impl;
|
||||
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
|
||||
import com.muyu.product.cache.datasource.ProjectInfoData;
|
||||
import com.muyu.product.cache.datasource.ProjectSkuData;
|
||||
import com.muyu.product.domain.ProjectInfo;
|
||||
import com.muyu.product.domain.ProjectSkuInfo;
|
||||
import com.muyu.product.remote.RemoteProjectInfoService;
|
||||
import com.muyu.product.remote.RemoteProjectSkuService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author yangle
|
||||
* @author DongZl
|
||||
* @description: 缓存数据获取
|
||||
* @Date 2024-3-27 下午 03:37
|
||||
*/
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
package com.muyu.product.cache.datasource.impl;
|
||||
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.product.cache.datasource.ProjectInfoData;
|
||||
import com.muyu.product.cache.datasource.ProjectSkuData;
|
||||
import com.muyu.product.domain.ProjectInfo;
|
||||
import com.muyu.product.domain.ProjectSkuInfo;
|
||||
import com.muyu.product.remote.RemoteProjectInfoService;
|
||||
import com.muyu.product.remote.RemoteProjectSkuService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -17,7 +13,7 @@ import java.util.Map;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author yangle
|
||||
* @author DongZl
|
||||
* @description: 商品SKU实现类
|
||||
* @Date 2024-4-1 上午 11:38
|
||||
*/
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.muyu.product.cache.datasource.impl;
|
||||
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.product.cache.datasource.ProjectSkuStockData;
|
||||
import com.muyu.product.cache.key.SkuStockKey;
|
||||
|
@ -12,7 +11,7 @@ import org.springframework.stereotype.Service;
|
|||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author yangle
|
||||
* @author DongZl
|
||||
* @description: sku库存实现类
|
||||
* @Date 2024-4-2 上午 10:53
|
||||
*/
|
||||
|
|
|
@ -13,10 +13,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 规格数据获取实现层 默认就读远程调用 RuleCacheDataImpl
|
||||
*
|
||||
* @author LeYang
|
||||
* on 2024/4/8
|
||||
* @author DongZl
|
||||
* @description: 规格数据获取实现层 默认就读取远程调用
|
||||
* @Date 2024/4/7 下午8:32
|
||||
*/
|
||||
public class RuleCacheDataRemoteImpl implements RuleCacheData {
|
||||
|
||||
|
@ -26,10 +25,8 @@ public class RuleCacheDataRemoteImpl implements RuleCacheData {
|
|||
@Autowired
|
||||
private RemoteRuleAttrService remoteRuleAttrService;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public RuleCacheModel getRulerCacheModel(Long ruleId) {
|
||||
public RuleCacheModel getRuleCacheModel (Long ruleId) {
|
||||
Result<RuleInfo> ruleInfoResult = remoteRuleService.getInfo(ruleId);
|
||||
Result<List<RuleAttrInfo>> ruleAttrResult = remoteRuleAttrService.getInfoByRuleId(ruleId);
|
||||
if (Result.isError(ruleInfoResult) || Result.isError(ruleAttrResult)) {
|
||||
|
|
|
@ -6,7 +6,7 @@ import lombok.Data;
|
|||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author yangle
|
||||
* @author DongZl
|
||||
* @description: 商品SKU库存Key
|
||||
* @Date 2024-4-2 上午 10:41
|
||||
*/
|
||||
|
|
|
@ -10,16 +10,16 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 规格类型缓存模型
|
||||
*
|
||||
* @author LeYang
|
||||
* on 2024/4/8
|
||||
* @author DongZl
|
||||
* @description: 规格类型缓存模型
|
||||
* @Date 2024/4/7 下午8:41
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class RuleAttrCacheModel {
|
||||
|
||||
/**
|
||||
* 类目名称
|
||||
*/
|
||||
|
@ -28,15 +28,12 @@ public class RuleAttrCacheModel {
|
|||
/**
|
||||
* 规格值
|
||||
*/
|
||||
private List<String> attrValueList;
|
||||
private List<String> attrValueList;
|
||||
|
||||
public static RuleAttrCacheModel ruleAttrBuild(RuleAttrInfo ruleAttrInfo){
|
||||
public static RuleAttrCacheModel ruleAttrBuild (RuleAttrInfo ruleAttrInfo) {
|
||||
return RuleAttrCacheModel.builder()
|
||||
.attrName(ruleAttrInfo.getName())
|
||||
.attrValueList(Arrays.stream(ruleAttrInfo.getAttrValue().split(",")).toList())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -8,20 +8,21 @@ import lombok.NoArgsConstructor;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 规格缓存模型 RuleCacheModel
|
||||
*
|
||||
* @author LeYang
|
||||
* on 2024/4/8
|
||||
* @author DongZl
|
||||
* @description: 规格缓存模型
|
||||
* @Date 2024/4/7 下午8:27
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class RuleCacheModel {
|
||||
|
||||
/**
|
||||
* 规格名称
|
||||
*/
|
||||
private String ruleName;
|
||||
|
||||
/**
|
||||
* 规格缓存模型
|
||||
*/
|
||||
|
|
|
@ -4,18 +4,15 @@ import com.muyu.common.core.constant.ServiceNameConstants;
|
|||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.product.domain.ProjectInfo;
|
||||
import com.muyu.product.remote.factory.RemoteProjectInfoFactory;
|
||||
import com.muyu.product.remote.factory.RemoteProjectSkuFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
/**
|
||||
* 规格远程调用业务层
|
||||
*
|
||||
* @author LeYang
|
||||
* on 2024/4/8
|
||||
* @author DongZl
|
||||
* @description: 规格远程调用业务层
|
||||
* @Date 2024-4-7 上午 10:58
|
||||
*/
|
||||
|
||||
@FeignClient(
|
||||
contextId = "remoteProjectInfoService",
|
||||
value = ServiceNameConstants.PRODUCT_SERVICE,
|
||||
|
@ -26,7 +23,7 @@ public interface RemoteProjectInfoService {
|
|||
/**
|
||||
* 获取商品信息详细信息
|
||||
*/
|
||||
@GetMapping(value = "/{id}")
|
||||
public Result<ProjectInfo> getInfo(@PathVariable("id") Long id);
|
||||
@GetMapping(value = "/{id}")
|
||||
public Result<ProjectInfo> getInfo(@PathVariable("id") Long id) ;
|
||||
|
||||
}
|
||||
|
|
|
@ -11,10 +11,9 @@ import org.springframework.web.bind.annotation.PathVariable;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 远程调用业务层 RemoteProjectSkuService
|
||||
*
|
||||
* @author LeYang
|
||||
* on 2024/4/7
|
||||
* @author DongZl
|
||||
* @description: 远程调用业务层
|
||||
* @Date 2024-4-7 上午 10:58
|
||||
*/
|
||||
@FeignClient(
|
||||
contextId = "remoteProjectSkuService",
|
||||
|
@ -23,21 +22,21 @@ import java.util.List;
|
|||
path = "/sku"
|
||||
)
|
||||
public interface RemoteProjectSkuService {
|
||||
|
||||
/**
|
||||
* 通过商品ID和sku获取sku信息
|
||||
* @param projectId 商品id
|
||||
* @param projectSku 商品sku
|
||||
* @return 商品sku信息
|
||||
* 通过商品ID和SKU获取SKU信息
|
||||
* @param projectId 商品ID
|
||||
* @param projectSku 商品SKU
|
||||
* @return 商品SKU信息
|
||||
*/
|
||||
@GetMapping("/info/{projectId}/{projectSku}")
|
||||
public Result<ProjectSkuInfo> getInfoByProjectIdAndSku(@PathVariable("projectId") Long projectId,
|
||||
@PathVariable("projectSku") String projectSku);
|
||||
|
||||
/**
|
||||
* 通过商品ID获取SKU集合
|
||||
* 通过商品ID和SKU获取SKU信息
|
||||
* @param projectId 商品ID
|
||||
* @return 商品SKU信息
|
||||
*/
|
||||
@GetMapping("/list/{projectId}")
|
||||
public Result<List<ProjectSkuInfo>> listByProjectId(@PathVariable("projectId")Long projectId);
|
||||
public Result<List<ProjectSkuInfo>> listByProjectId(@PathVariable("projectId") Long projectId);
|
||||
}
|
||||
|
|
|
@ -2,8 +2,12 @@ package com.muyu.product.remote;
|
|||
|
||||
import com.muyu.common.core.constant.ServiceNameConstants;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.product.domain.ProjectSkuInfo;
|
||||
import com.muyu.product.domain.RuleAttrInfo;
|
||||
import com.muyu.product.remote.factory.RemoteProjectSkuFactory;
|
||||
import com.muyu.product.remote.factory.RemoteRuleAttrFactory;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
@ -11,10 +15,9 @@ import org.springframework.web.bind.annotation.PathVariable;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 规格信息远程调用业务层
|
||||
*
|
||||
* @author LeYang
|
||||
* on 2024/4/8
|
||||
* @author DongZl
|
||||
* @description: 规格信息远程调用业务层
|
||||
* @Date 2024-4-7 上午 10:58
|
||||
*/
|
||||
@FeignClient(
|
||||
contextId = "remoteRuleAttrService",
|
||||
|
@ -23,6 +26,9 @@ import java.util.List;
|
|||
path = "/ruleAttr"
|
||||
)
|
||||
public interface RemoteRuleAttrService {
|
||||
/**
|
||||
* 获取规格详情详细信息
|
||||
*/
|
||||
@GetMapping(value = "/list/ruleId/{ruleId}")
|
||||
public Result<List<RuleAttrInfo>> getInfoByRuleId(@PathVariable("id") Long id);
|
||||
public Result<List<RuleAttrInfo>> getInfoByRuleId(@PathVariable("ruleId") Long id);
|
||||
}
|
||||
|
|
|
@ -2,17 +2,20 @@ package com.muyu.product.remote;
|
|||
|
||||
import com.muyu.common.core.constant.ServiceNameConstants;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.product.domain.ProjectSkuInfo;
|
||||
import com.muyu.product.domain.RuleInfo;
|
||||
import com.muyu.product.remote.factory.RemoteProjectSkuFactory;
|
||||
import com.muyu.product.remote.factory.RemoteRuleFactory;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
/**
|
||||
* 规格远程调用业务层
|
||||
*
|
||||
* @author LeYang
|
||||
* on 2024/4/8
|
||||
* @author DongZl
|
||||
* @description: 规格远程调用业务层
|
||||
* @Date 2024-4-7 上午 10:58
|
||||
*/
|
||||
@FeignClient(
|
||||
contextId = "remoteRuleService",
|
||||
|
@ -22,8 +25,8 @@ import org.springframework.web.bind.annotation.PathVariable;
|
|||
)
|
||||
public interface RemoteRuleService {
|
||||
/**
|
||||
* 获取商品规格详情信息
|
||||
* 获取商品规格详细信息
|
||||
*/
|
||||
@GetMapping(value = "/{id}")
|
||||
public Result<RuleInfo> getInfo(@PathVariable("id") Long id );
|
||||
@GetMapping(value = "/{id}")
|
||||
public Result<RuleInfo> getInfo(@PathVariable("id") Long id);
|
||||
}
|
||||
|
|
|
@ -2,29 +2,30 @@ package com.muyu.product.remote.factory;
|
|||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.product.domain.ProjectInfo;
|
||||
import com.muyu.product.domain.RuleInfo;
|
||||
import com.muyu.product.remote.RemoteProjectInfoService;
|
||||
import com.muyu.product.remote.RemoteRuleService;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
|
||||
/**
|
||||
* 规格远程调用熔断器 RemoteProjectInfoFactory
|
||||
*
|
||||
* @author LeYang
|
||||
* on 2024/4/8
|
||||
* @author DongZl
|
||||
* @description: 规格远程调熔断器
|
||||
* @Date 2024-4-7 上午 10:59
|
||||
*/
|
||||
|
||||
public class RemoteProjectInfoFactory implements FallbackFactory<RemoteProjectInfoService> {
|
||||
@Override
|
||||
public RemoteProjectInfoService create(Throwable cause) {
|
||||
return new RemoteProjectInfoService() {
|
||||
/**
|
||||
* 获取商品详情信息
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Result<ProjectInfo> getInfo(Long id) {
|
||||
return Result.error(cause.getMessage());
|
||||
}
|
||||
};
|
||||
public RemoteProjectInfoService create (Throwable cause) {
|
||||
return new RemoteProjectInfoService() {
|
||||
|
||||
/**
|
||||
* 获取商品规格详细信息
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
@Override
|
||||
public Result<ProjectInfo> getInfo (Long id) {
|
||||
return Result.error(cause.getMessage());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,31 +5,31 @@ import com.muyu.product.domain.ProjectSkuInfo;
|
|||
import com.muyu.product.remote.RemoteProjectSkuService;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
|
||||
import java.rmi.Remote;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 远城调熔断器 RemoteProjectSkuFactory
|
||||
*
|
||||
* @author LeYang
|
||||
* on 2024/4/7
|
||||
* @author DongZl
|
||||
* @description: 远程调熔断器
|
||||
* @Date 2024-4-7 上午 10:59
|
||||
*/
|
||||
public class RemoteProjectSkuFactory implements FallbackFactory<RemoteProjectSkuService> {
|
||||
@Override
|
||||
public RemoteProjectSkuService create(Throwable cause) {
|
||||
public RemoteProjectSkuService create (Throwable cause) {
|
||||
return new RemoteProjectSkuService() {
|
||||
@Override
|
||||
public Result<ProjectSkuInfo> getInfoByProjectIdAndSku(Long projectId, String projectSku) {
|
||||
public Result<ProjectSkuInfo> getInfoByProjectIdAndSku (Long projectId, String projectSku) {
|
||||
return Result.error(cause.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过商品ID和sku获取sku信息
|
||||
* 通过商品ID和SKU获取SKU信息
|
||||
*
|
||||
* @param projectId 商品ID
|
||||
* @return 商品sku信息
|
||||
*
|
||||
* @return 商品SKU信息
|
||||
*/
|
||||
@Override
|
||||
public Result<List<ProjectSkuInfo>> listByProjectId(Long projectId) {
|
||||
public Result<List<ProjectSkuInfo>> listByProjectId (Long projectId) {
|
||||
return Result.error(cause.getMessage());
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,29 +1,32 @@
|
|||
package com.muyu.product.remote.factory;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.product.domain.ProjectSkuInfo;
|
||||
import com.muyu.product.domain.RuleAttrInfo;
|
||||
import com.muyu.product.remote.RemoteProjectSkuService;
|
||||
import com.muyu.product.remote.RemoteRuleAttrService;
|
||||
import com.muyu.product.remote.RemoteRuleService;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 规格详情远程调用熔断器 RemoteRuleAttrFactory
|
||||
*
|
||||
* @author LeYang
|
||||
* on 2024/4/8
|
||||
* @author DongZl
|
||||
* @description: 规格详情远程调熔断器
|
||||
* @Date 2024-4-7 上午 10:59
|
||||
*/
|
||||
public class RemoteRuleAttrFactory implements FallbackFactory<RemoteRuleAttrService> {
|
||||
@Override
|
||||
public RemoteRuleAttrService create(Throwable cause) {
|
||||
public RemoteRuleAttrService create (Throwable cause) {
|
||||
return new RemoteRuleAttrService() {
|
||||
|
||||
/**
|
||||
* 获取规格详情信息
|
||||
* 获取规格详情详细信息
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Result<List<RuleAttrInfo>> getInfoByRuleId(Long id) {
|
||||
public Result<List<RuleAttrInfo>> getInfoByRuleId (Long id) {
|
||||
return Result.error(cause.getMessage());
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,28 +1,29 @@
|
|||
package com.muyu.product.remote.factory;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.product.domain.ProjectSkuInfo;
|
||||
import com.muyu.product.domain.RuleInfo;
|
||||
import com.muyu.product.remote.RemoteProjectSkuService;
|
||||
import com.muyu.product.remote.RemoteRuleService;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
|
||||
/**
|
||||
* 规格远程调用熔断器
|
||||
*
|
||||
* @author LeYang
|
||||
* on 2024/4/8
|
||||
* @author DongZl
|
||||
* @description: 规格远程调熔断器
|
||||
* @Date 2024-4-7 上午 10:59
|
||||
*/
|
||||
|
||||
public class RemoteRuleFactory implements FallbackFactory<RemoteRuleService> {
|
||||
@Override
|
||||
public RemoteRuleService create(Throwable cause) {
|
||||
public RemoteRuleService create (Throwable cause) {
|
||||
return new RemoteRuleService() {
|
||||
|
||||
/**
|
||||
* 获取商品规格详情信息
|
||||
* 获取商品规格详细信息
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Result<RuleInfo> getInfo(Long id) {
|
||||
public Result<RuleInfo> getInfo (Long id) {
|
||||
return Result.error(cause.getMessage());
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
com.muyu.product.remote.factory.RemoteRuleFactory
|
||||
com.muyu.product.remote.factory.RemoteRuleAttrFactory
|
||||
com.muyu.product.remote.factory.RemoteProjectInfoFactory
|
||||
com.muyu.product.remote.factory.RemoteProjectSkuFactory
|
||||
com.muyu.product.remote.factory.RemoteRuleAttrFactory
|
||||
com.muyu.product.remote.factory.RemoteRuleFactory
|
||||
com.muyu.product.remote.factory.RemoteProjectInfoFactory
|
||||
|
|
|
@ -5,10 +5,9 @@ import com.muyu.common.security.annotation.EnableMyFeignClients;
|
|||
import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
/**
|
||||
* @author yangle
|
||||
* @author DongZl
|
||||
* @description: 商品启动类
|
||||
* @Date 2024-2-26 下午 04:07
|
||||
*/
|
||||
|
|
|
@ -8,7 +8,7 @@ import org.springframework.context.annotation.Primary;
|
|||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author yangle
|
||||
* @author DongZl
|
||||
* @description: 缓存数据获取
|
||||
* @Date 2024-3-27 下午 03:37
|
||||
*/
|
||||
|
|
|
@ -13,7 +13,7 @@ import java.util.Map;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author yangle
|
||||
* @author DongZl
|
||||
* @description: 商品SKU实现类
|
||||
* @Date 2024-4-1 上午 11:38
|
||||
*/
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.springframework.context.annotation.Primary;
|
|||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author yangle
|
||||
* @author DongZl
|
||||
* @description: sku库存实现类
|
||||
* @Date 2024-4-2 上午 10:53
|
||||
*/
|
||||
|
|
|
@ -31,7 +31,7 @@ import com.muyu.common.core.web.page.TableDataInfo;
|
|||
/**
|
||||
* 属性组Controller
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
@Api(tags = "属性组")
|
||||
|
|
|
@ -29,7 +29,7 @@ import com.muyu.common.core.web.page.TableDataInfo;
|
|||
/**
|
||||
* 商品属性Controller
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
@Api(tags = "商品属性")
|
||||
|
|
|
@ -30,7 +30,7 @@ import com.muyu.common.core.web.page.TableDataInfo;
|
|||
/**
|
||||
* 品牌信息Controller
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
@Api(tags = "品牌信息")
|
||||
|
|
|
@ -36,7 +36,7 @@ import com.muyu.product.service.CategoryInfoService;
|
|||
/**
|
||||
* 品类信息Controller
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
@Api(tags = "品类信息")
|
||||
|
@ -116,20 +116,18 @@ public class CategoryInfoController extends BaseController {
|
|||
categoryInfoService.util(id,categoryInfoEditReq);
|
||||
return toAjax(categoryInfoService.updateById(CategoryInfo.editBuild(id,categoryInfoEditReq)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除品类信息
|
||||
*/
|
||||
@RequiresPermissions("product:category:remove")
|
||||
@Log(title = "品类信息", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
@DeleteMapping("/{ids}")
|
||||
@ApiOperation("删除品类信息")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4")
|
||||
public Result<String> remove(@PathVariable List<Long> ids) {
|
||||
categoryInfoService.removeBatchById(ids);
|
||||
return toAjax(categoryInfoService.removeBatchByIds(ids));
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* 通过品类ID获取父级以上的属性、属性组、品牌集合
|
||||
* @param categoryId 品类ID
|
||||
|
|
|
@ -29,7 +29,7 @@ import com.muyu.common.core.web.page.TableDataInfo;
|
|||
/**
|
||||
* 商品评论Controller
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
@Api(tags = "商品评论")
|
||||
|
|
|
@ -29,7 +29,7 @@ import com.muyu.common.core.web.page.TableDataInfo;
|
|||
/**
|
||||
* 评论点赞Controller
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
@Api(tags = "评论点赞")
|
||||
|
|
|
@ -4,13 +4,17 @@ import java.util.List;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.muyu.product.cache.ProjectInfoCache;
|
||||
import com.muyu.product.domain.AsProductAttributeInfo;
|
||||
import com.muyu.product.domain.ProjectSkuInfo;
|
||||
import com.muyu.product.domain.model.CategoryInfoSaveModel;
|
||||
import com.muyu.product.domain.model.ProductSkuModel;
|
||||
import com.muyu.product.domain.model.ProjectAddModel;
|
||||
import com.muyu.product.domain.resp.ProjectDetailResp;
|
||||
import com.muyu.product.service.AsProductAttributeInfoService;
|
||||
import com.muyu.product.service.ProjectSkuInfoService;
|
||||
import io.swagger.annotations.*;
|
||||
import org.apache.commons.lang3.SystemUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
@ -36,7 +40,7 @@ import com.muyu.common.core.web.page.TableDataInfo;
|
|||
/**
|
||||
* 商品信息Controller
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
@Api(tags = "商品信息")
|
||||
|
@ -49,7 +53,8 @@ public class ProjectInfoController extends BaseController {
|
|||
private AsProductAttributeInfoService asProductAttributeInfoService;
|
||||
@Autowired
|
||||
private ProjectSkuInfoService projectSkuInfoService;
|
||||
|
||||
@Autowired
|
||||
private ProjectInfoCache projectInfoCache;
|
||||
/**
|
||||
* 查询商品信息列表
|
||||
*/
|
||||
|
@ -92,14 +97,16 @@ public class ProjectInfoController extends BaseController {
|
|||
@GetMapping(value = "/cache/{id}")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
|
||||
public Result<ProjectInfo> getCacheInfo(@PathVariable("id") Long id) {
|
||||
return Result.success(projectInfoService.getById(id));
|
||||
return Result.success(projectInfoCache.get(id));
|
||||
}
|
||||
// @Autowired
|
||||
// private ProjectInfoCache projectInfoCache;
|
||||
// @ApiOperation("获取商品信息详细信息")
|
||||
// @RequiresPermissions("product:info:query")
|
||||
// @GetMapping(value = "/{id}")
|
||||
// @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
|
||||
// public Result<ProjectInfo> getInfo(@PathVariable("id") Long id) {
|
||||
// return Result.success(projectInfoService.get(id));
|
||||
// return Result.success(projectInfoCache.get(id));
|
||||
// }
|
||||
|
||||
/**
|
||||
|
@ -114,6 +121,7 @@ public class ProjectInfoController extends BaseController {
|
|||
LambdaQueryWrapper<AsProductAttributeInfo> asProductAttributeInfoLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
asProductAttributeInfoLambdaQueryWrapper.eq(AsProductAttributeInfo::getProductId, id);
|
||||
List<AsProductAttributeInfo> list = asProductAttributeInfoService.list(asProductAttributeInfoLambdaQueryWrapper);
|
||||
|
||||
ProjectInfo projectInfo = projectInfoService.getById(id);
|
||||
LambdaQueryWrapper<ProjectSkuInfo> projectSkuInfoLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
projectSkuInfoLambdaQueryWrapper.eq(ProjectSkuInfo::getProjectId,id);
|
||||
|
@ -159,8 +167,4 @@ public class ProjectInfoController extends BaseController {
|
|||
projectInfoService.del(ids);
|
||||
return toAjax(projectInfoService.removeBatchByIds(ids));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.muyu.product.controller;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
|
@ -30,7 +29,7 @@ import com.muyu.common.core.web.page.TableDataInfo;
|
|||
/**
|
||||
* 商品SKUController
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
@Api(tags = "商品SKU")
|
||||
|
@ -55,12 +54,13 @@ public class ProjectSkuInfoController extends BaseController {
|
|||
/**
|
||||
* 通过商品ID获取SKU集合
|
||||
* @param projectId 商品ID
|
||||
* @return 商品SKU信息
|
||||
* @return 商品SKU集合
|
||||
*/
|
||||
@GetMapping("/list/{projectId}")
|
||||
public Result<List<ProjectSkuInfo>> listByProjectId(@PathVariable("projectId")Long projectId){
|
||||
public Result<List<ProjectSkuInfo>> listByProjectId(@PathVariable("projectId") Long projectId){
|
||||
return Result.success(projectSkuInfoService.listByProjectId(projectId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出商品SKU列表
|
||||
*/
|
||||
|
@ -85,17 +85,11 @@ public class ProjectSkuInfoController extends BaseController {
|
|||
return Result.success(projectSkuInfoService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过商品ID和sku获取sku信息
|
||||
* @param projectId 商品id
|
||||
* @param projectSku 商品sku
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/info/{projectId}/{projectSku}")
|
||||
public Result<ProjectSkuInfo> getInfoByProjectIdAndSku(@PathVariable("projectId")Long projectId,
|
||||
@PathVariable("projectSku") String projectSku){
|
||||
return Result.success(projectSkuInfoService.getInfoByProjectIdAndSku(projectId, projectSku));
|
||||
};
|
||||
@GetMapping("/info/{projectId}/{projectSku}")
|
||||
public Result<ProjectSkuInfo> getInfoByProjectIdAndSku(@PathVariable("projectId") Long projectId,
|
||||
@PathVariable("projectSku") String projectSku){
|
||||
return Result.success(projectSkuInfoService.getInfoByProjectIdAndSku(projectId,projectSku));
|
||||
}
|
||||
/**
|
||||
* 新增商品SKU
|
||||
*/
|
||||
|
|
|
@ -29,7 +29,7 @@ import com.muyu.common.core.web.page.TableDataInfo;
|
|||
/**
|
||||
* 规格详情Controller
|
||||
*
|
||||
* @author yangle
|
||||
* @author Leyang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
@Api(tags = "规格详情")
|
||||
|
@ -75,6 +75,14 @@ public class RuleAttrInfoController extends BaseController {
|
|||
return Result.success(ruleAttrInfoService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取规格详情详细信息
|
||||
*/
|
||||
@GetMapping(value = "/list/ruleId/{ruleId}")
|
||||
public Result<List<RuleAttrInfo>> getInfoByRuleId(@PathVariable("ruleId") Long ruleId){
|
||||
return Result.success(ruleAttrInfoService.getInfoByRuleId(ruleId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增规格详情
|
||||
*/
|
||||
|
@ -102,7 +110,7 @@ public class RuleAttrInfoController extends BaseController {
|
|||
*/
|
||||
@RequiresPermissions("product:ruleAttr:remove")
|
||||
@Log(title = "规格详情", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
@DeleteMapping("/{ids}")
|
||||
@ApiOperation("删除规格详情")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4")
|
||||
public Result<String> remove(@PathVariable List<Long> ids) {
|
||||
|
|
|
@ -6,7 +6,6 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import com.muyu.common.core.text.Convert;
|
||||
import com.muyu.product.domain.model.RuleInfoAddModel;
|
||||
import com.muyu.product.domain.resp.RuleInfoResp;
|
||||
import com.muyu.product.service.RuleAttrInfoService;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
@ -33,7 +32,7 @@ import com.muyu.common.core.web.page.TableDataInfo;
|
|||
/**
|
||||
* 商品规格Controller
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
@Api(tags = "商品规格")
|
||||
|
@ -82,9 +81,6 @@ public class RuleInfoController extends BaseController {
|
|||
return Result.success(ruleInfoService.getById(id));
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private RuleAttrInfoService ruleAttrInfoService;
|
||||
|
||||
/**
|
||||
* 新增商品规格
|
||||
*/
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.muyu.product.domain.AsAttributeGroup;
|
|||
/**
|
||||
* 属性与组中间Mapper接口
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
public interface AsAttributeGroupMapper extends BaseMapper<AsAttributeGroup> {
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.muyu.product.domain.AsBrandProject;
|
|||
/**
|
||||
* 品牌商品中间Mapper接口
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
public interface AsBrandProjectMapper extends BaseMapper<AsBrandProject> {
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.muyu.product.domain.AsCategoryAttributeGroup;
|
|||
/**
|
||||
* 品类属性组中间Mapper接口
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
public interface AsCategoryAttributeGroupMapper extends BaseMapper<AsCategoryAttributeGroup> {
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.muyu.product.domain.AsCategoryAttribute;
|
|||
/**
|
||||
* 品类属性中间Mapper接口
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
public interface AsCategoryAttributeMapper extends BaseMapper<AsCategoryAttribute> {
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.muyu.product.domain.AsCategoryBrand;
|
|||
/**
|
||||
* 品类品牌中间Mapper接口
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
public interface AsCategoryBrandMapper extends BaseMapper<AsCategoryBrand> {
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.muyu.product.domain.AsProductAttributeInfo;
|
|||
/**
|
||||
* 商品属性Mapper接口
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
public interface AsProductAttributeInfoMapper extends BaseMapper<AsProductAttributeInfo> {
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.muyu.product.domain.AttributeGroup;
|
|||
/**
|
||||
* 属性组Mapper接口
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
public interface AttributeGroupMapper extends BaseMapper<AttributeGroup> {
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.muyu.product.domain.AttributeInfo;
|
|||
/**
|
||||
* 商品属性Mapper接口
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
public interface AttributeInfoMapper extends BaseMapper<AttributeInfo> {
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.muyu.product.domain.BrandInfo;
|
|||
/**
|
||||
* 品牌信息Mapper接口
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
public interface BrandInfoMapper extends BaseMapper<BrandInfo> {
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
/**
|
||||
* 品类信息Mapper接口
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
@Mapper
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.muyu.product.domain.CommentInfo;
|
|||
/**
|
||||
* 商品评论Mapper接口
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
public interface CommentInfoMapper extends BaseMapper<CommentInfo> {
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.muyu.product.domain.CommentLikeInfo;
|
|||
/**
|
||||
* 评论点赞Mapper接口
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
public interface CommentLikeInfoMapper extends BaseMapper<CommentLikeInfo> {
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.muyu.product.domain.ProjectInfo;
|
|||
/**
|
||||
* 商品信息Mapper接口
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
public interface ProjectInfoMapper extends BaseMapper<ProjectInfo> {
|
||||
|
|
|
@ -10,7 +10,7 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
/**
|
||||
* 商品SKUMapper接口
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
@Mapper
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.muyu.product.domain.RuleAttrInfo;
|
|||
/**
|
||||
* 规格详情Mapper接口
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
public interface RuleAttrInfoMapper extends BaseMapper<RuleAttrInfo> {
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.muyu.product.domain.RuleInfo;
|
|||
/**
|
||||
* 商品规格Mapper接口
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
public interface RuleInfoMapper extends BaseMapper<RuleInfo> {
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
/**
|
||||
* 属性与组中间Service接口
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
public interface AsAttributeGroupService extends IService<AsAttributeGroup> {
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
/**
|
||||
* 品牌商品中间Service接口
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
public interface AsBrandProjectService extends IService<AsBrandProject> {
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
/**
|
||||
* 品类属性组中间Service接口
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
public interface AsCategoryAttributeGroupService extends IService<AsCategoryAttributeGroup> {
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
/**
|
||||
* 品类属性中间Service接口
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
public interface AsCategoryAttributeService extends IService<AsCategoryAttribute> {
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
/**
|
||||
* 品类品牌中间Service接口
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
public interface AsCategoryBrandService extends IService<AsCategoryBrand> {
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
/**
|
||||
* 商品属性Service接口
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
public interface AsProductAttributeInfoService extends IService<AsProductAttributeInfo> {
|
||||
|
|
|
@ -13,7 +13,7 @@ import com.muyu.product.domain.resp.AttributeGroupPageResp;
|
|||
/**
|
||||
* 属性组Service接口
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
public interface AttributeGroupService extends IService<AttributeGroup> {
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
/**
|
||||
* 商品属性Service接口
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
public interface AttributeInfoService extends IService<AttributeInfo> {
|
||||
|
|
|
@ -8,7 +8,7 @@ import com.muyu.product.domain.req.BrandInfoEditReq;
|
|||
/**
|
||||
* 品牌信息Service接口
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
public interface BrandInfoService extends IService<BrandInfo> {
|
||||
|
|
|
@ -15,7 +15,7 @@ import com.muyu.product.domain.resp.CategoryParentCommonElementResp;
|
|||
/**
|
||||
* 品类信息Service接口
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
public interface CategoryInfoService extends IService<CategoryInfo> {
|
||||
|
@ -69,7 +69,6 @@ public interface CategoryInfoService extends IService<CategoryInfo> {
|
|||
*/
|
||||
CategoryCommonElementResp getTemplateAttributeByCateGoryId (Long cateGoryId);
|
||||
|
||||
Boolean removeBatchById(List<Long> ids);
|
||||
|
||||
void util(Long id, CategoryInfoEditReq categoryInfoEditReq);
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
/**
|
||||
* 商品评论Service接口
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
public interface CommentInfoService extends IService<CommentInfo> {
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
/**
|
||||
* 评论点赞Service接口
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
public interface CommentLikeInfoService extends IService<CommentLikeInfo> {
|
||||
|
|
|
@ -12,7 +12,7 @@ import com.muyu.product.domain.resp.ProjectDetailResp;
|
|||
/**
|
||||
* 商品信息Service接口
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
public interface ProjectInfoService extends IService<ProjectInfo> {
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
/**
|
||||
* 商品SKUService接口
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
public interface ProjectSkuInfoService extends IService<ProjectSkuInfo> {
|
||||
|
@ -19,13 +19,7 @@ public interface ProjectSkuInfoService extends IService<ProjectSkuInfo> {
|
|||
*/
|
||||
public List<ProjectSkuInfo> list(ProjectSkuInfo projectSkuInfo);
|
||||
|
||||
ProjectSkuInfo getInfoByProjectIdAndSku(Long projectId,String projectSku);
|
||||
ProjectSkuInfo getInfoByProjectIdAndSku(Long projectId, String projectSku);
|
||||
|
||||
/**
|
||||
* 通过商品Id获取sku集合
|
||||
* @param projectId 商品Id
|
||||
* @return 商品SKU信息
|
||||
*/
|
||||
List<ProjectSkuInfo> listByProjectId(Long projectId);
|
||||
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||
/**
|
||||
* 规格详情Service接口
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
public interface RuleAttrInfoService extends IService<RuleAttrInfo> {
|
||||
|
@ -19,10 +19,5 @@ public interface RuleAttrInfoService extends IService<RuleAttrInfo> {
|
|||
*/
|
||||
public List<RuleAttrInfo> list(RuleAttrInfo ruleAttrInfo);
|
||||
|
||||
/**
|
||||
* 通过ruleId获取规格详情
|
||||
* @param ruleId 规格Id
|
||||
* @return 规格详情id
|
||||
*/
|
||||
List<RuleAttrInfo> getInfoByRuleId(Long ruleId);
|
||||
}
|
||||
|
|
|
@ -3,18 +3,16 @@ package com.muyu.product.service;
|
|||
import java.util.List;
|
||||
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.product.domain.RuleAttrInfo;
|
||||
import com.muyu.product.domain.RuleInfo;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.product.domain.model.RuleInfoAddModel;
|
||||
import com.muyu.product.domain.req.RuleInfoQueryReq;
|
||||
import com.muyu.product.domain.resp.RuleInfoResp;
|
||||
import org.apache.tomcat.util.digester.Rule;
|
||||
|
||||
/**
|
||||
* 商品规格Service接口
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
public interface RuleInfoService extends IService<RuleInfo> {
|
||||
|
@ -34,5 +32,4 @@ public interface RuleInfoService extends IService<RuleInfo> {
|
|||
public boolean save(RuleInfoAddModel ruleInfoAddModel);
|
||||
|
||||
TableDataInfo<RuleInfoResp> queryList (RuleInfoQueryReq ruleInfoQueryReq);
|
||||
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||
/**
|
||||
* 属性与组中间Service业务层处理
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
@Slf4j
|
||||
|
|
|
@ -14,7 +14,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||
/**
|
||||
* 品牌商品中间Service业务层处理
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
@Slf4j
|
||||
|
|
|
@ -14,7 +14,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||
/**
|
||||
* 品类属性组中间Service业务层处理
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
@Slf4j
|
||||
|
|
|
@ -14,7 +14,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||
/**
|
||||
* 品类属性中间Service业务层处理
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
@Slf4j
|
||||
|
|
|
@ -14,7 +14,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||
/**
|
||||
* 品类品牌中间Service业务层处理
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
@Slf4j
|
||||
|
|
|
@ -14,7 +14,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||
/**
|
||||
* 商品属性Service业务层处理
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
@Slf4j
|
||||
|
|
|
@ -26,7 +26,7 @@ import java.util.stream.Stream;
|
|||
/**
|
||||
* 属性组Service业务层处理
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
@Slf4j
|
||||
|
|
|
@ -18,7 +18,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||
/**
|
||||
* 商品属性Service业务层处理
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
@Slf4j
|
||||
|
|
|
@ -17,7 +17,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||
/**
|
||||
* 品牌信息Service业务层处理
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
@Slf4j
|
||||
|
|
|
@ -33,7 +33,7 @@ import java.util.stream.Stream;
|
|||
/**
|
||||
* 品类信息Service业务层处理
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
@Slf4j
|
||||
|
@ -352,7 +352,6 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
|
|||
if (asCategoryAttributeList != null && !asCategoryAttributeList.isEmpty()){
|
||||
List<Long> templateAttributeIdList = asCategoryAttributeList.stream()
|
||||
.map(AsCategoryAttribute::getAttributeId)
|
||||
.filter(templateAttributeId -> !attributeIdSet.contains(templateAttributeId))
|
||||
.toList();
|
||||
templateAttributeModelList = attributeInfoService.listByIds(templateAttributeIdList).stream()
|
||||
.map(AttributeInfo::buildTemplateModel)
|
||||
|
@ -378,33 +377,7 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
|
|||
.build();
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private AsCategoryAttributeGroupMapper asCategoryAttributeGroupMapper;
|
||||
@Autowired
|
||||
private AsCategoryAttributeMapper asCategoryAttributeMapper;
|
||||
@Autowired
|
||||
private AsCategoryBrandMapper asCategoryBrandMapper;
|
||||
/**
|
||||
* 删除中间表
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Boolean removeBatchById(List<Long> ids) {
|
||||
//删除品类属性组中间表
|
||||
LambdaQueryWrapper<AsCategoryAttributeGroup> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.in(AsCategoryAttributeGroup::getAttributeGroupId, ids);
|
||||
asCategoryAttributeGroupMapper.delete(lambdaQueryWrapper);
|
||||
//删除品类属性中间表
|
||||
LambdaQueryWrapper<AsCategoryAttribute> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.in(AsCategoryAttribute::getAttributeId, ids);
|
||||
asCategoryAttributeMapper.delete(queryWrapper);
|
||||
//删除品类品牌中间
|
||||
LambdaQueryWrapper<AsCategoryBrand> asCategoryBrandLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
asCategoryBrandLambdaQueryWrapper.in(AsCategoryBrand::getBrandId, ids);
|
||||
asCategoryBrandMapper.delete(asCategoryBrandLambdaQueryWrapper);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void util(Long id, CategoryInfoEditReq categoryInfoEditReq) {
|
||||
|
@ -413,7 +386,7 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
|
|||
List<AsCategoryAttribute> list = asCategoryAttributeService.list(asCategoryAttribute);
|
||||
ArrayList<Long> longs = new ArrayList<>();
|
||||
for (AsCategoryAttribute categoryAttribute : list) {
|
||||
longs.add(categoryAttribute.getId());
|
||||
longs.add(categoryAttribute.getId());
|
||||
}
|
||||
asCategoryAttributeService.removeBatchByIds(longs);
|
||||
List<Long> attributeGroupIdList = categoryInfoEditReq.getAttributeGroupIdList();
|
||||
|
@ -434,4 +407,3 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||
/**
|
||||
* 商品评论Service业务层处理
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
@Slf4j
|
||||
|
|
|
@ -14,7 +14,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||
/**
|
||||
* 评论点赞Service业务层处理
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
@Slf4j
|
||||
|
|
|
@ -25,7 +25,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||
/**
|
||||
* 商品信息Service业务层处理
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
@Slf4j
|
||||
|
|
|
@ -14,7 +14,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||
/**
|
||||
* 商品SKUService业务层处理
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
@Slf4j
|
||||
|
@ -59,24 +59,19 @@ public class ProjectSkuInfoServiceImpl extends ServiceImpl<ProjectSkuInfoMapper,
|
|||
return list(queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过商品Id 和sku获取sku信息
|
||||
* @param projectId 商品id
|
||||
* @param projectSku 商铺sku
|
||||
* @return 商品sku
|
||||
*/
|
||||
@Override
|
||||
public ProjectSkuInfo getInfoByProjectIdAndSku(Long projectId, String projectSku) {
|
||||
LambdaQueryWrapper<ProjectSkuInfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(ProjectSkuInfo::getProjectId, projectId);
|
||||
queryWrapper.eq(ProjectSkuInfo::getSku, projectSku);
|
||||
queryWrapper.eq(ProjectSkuInfo::getProjectId,projectId);
|
||||
queryWrapper.eq(ProjectSkuInfo::getSku,projectSku);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProjectSkuInfo> listByProjectId(Long projectId) {
|
||||
LambdaQueryWrapper<ProjectSkuInfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(ProjectSkuInfo::getProjectId, projectId);
|
||||
queryWrapper.eq(ProjectSkuInfo::getProjectId,projectId);
|
||||
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||
/**
|
||||
* 规格详情Service业务层处理
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
@Slf4j
|
||||
|
@ -44,13 +44,18 @@ public class RuleAttrInfoServiceImpl extends ServiceImpl<RuleAttrInfoMapper, Rul
|
|||
queryWrapper.eq(RuleAttrInfo::getAttrValue, ruleAttrInfo.getAttrValue());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RuleAttrInfo> getInfoByRuleId(Long ruleId) {
|
||||
LambdaQueryWrapper<RuleAttrInfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(RuleAttrInfo::getRuleId, ruleId);
|
||||
queryWrapper.eq(RuleAttrInfo::getRuleId,ruleId);
|
||||
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||
/**
|
||||
* 商品规格Service业务层处理
|
||||
*
|
||||
* @author yangle
|
||||
* @author DongZeLiang
|
||||
* @date 2024-02-27
|
||||
*/
|
||||
@Slf4j
|
||||
|
@ -102,6 +102,4 @@ public class RuleInfoServiceImpl extends ServiceImpl<RuleInfoMapper, RuleInfo>
|
|||
.total(isPage ? new PageInfo<>(list).getTotal() : 0)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -10,12 +10,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="groupId" column="group_id" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updataBy" column="updata_by" />
|
||||
<result property="updataTime" column="updata_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectAttributeInfoVo">
|
||||
select id, name, group_id, create_by, create_time, updata_by, updata_time, remark from attribute_info
|
||||
select id, name, group_id, create_by, create_time, update_time, update_time, remark from attribute_info
|
||||
</sql>
|
||||
</mapper>
|
||||
|
|
|
@ -13,20 +13,23 @@ import org.springframework.stereotype.Component;
|
|||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 购物车缓存
|
||||
*
|
||||
* @author LeYang
|
||||
* on 2024/4/2
|
||||
* @author yangle
|
||||
* @description: 购物车缓存
|
||||
* @Date 2024-4-2 上午 11:23
|
||||
*/
|
||||
|
||||
@Component
|
||||
public class CartCache extends HashCacheAbs<Long, CartHashKey , CartInfo> {
|
||||
@Autowired
|
||||
private CartData cartData;
|
||||
public class CartCache extends HashCacheAbs<Long, CartHashKey, CartInfo> {
|
||||
|
||||
@Autowired
|
||||
private CartData cartData;
|
||||
|
||||
/**
|
||||
* key前缀
|
||||
* @return key前缀
|
||||
*/
|
||||
@Override
|
||||
public String keyPre() {
|
||||
return "cart:info";
|
||||
public String keyPre () {
|
||||
return "cart:info:";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -35,17 +38,29 @@ public class CartCache extends HashCacheAbs<Long, CartHashKey , CartInfo> {
|
|||
* @return ID
|
||||
*/
|
||||
@Override
|
||||
public Long decode(String redisKey) {
|
||||
return Convert.toLong(redisKey.replace(keyPre(),""));
|
||||
public Long decode (String redisKey) {
|
||||
return Convert.toLong(redisKey.replace(keyPre(), ""));
|
||||
}
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*
|
||||
* @param hashKey ID
|
||||
*
|
||||
* @return 键
|
||||
*/
|
||||
@Override
|
||||
public String encodeHashKey (CartHashKey hashKey) {
|
||||
return hashKey.getProjectId()+":"+hashKey.getProjectSku();
|
||||
}
|
||||
|
||||
/**
|
||||
* 解码
|
||||
* @param redisHashKey 数据库键
|
||||
* @return ID
|
||||
* @return ID
|
||||
*/
|
||||
@Override
|
||||
public CartHashKey decodeHashKey(String redisHashKey) {
|
||||
public CartHashKey decodeHashKey (String redisHashKey) {
|
||||
String[] split = redisHashKey.split(":");
|
||||
return CartHashKey.builder()
|
||||
.projectId(Convert.toLong(split[0]))
|
||||
|
@ -59,30 +74,34 @@ public class CartCache extends HashCacheAbs<Long, CartHashKey , CartInfo> {
|
|||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map<CartHashKey, CartInfo> getData(Long key) {
|
||||
public Map<CartHashKey, CartInfo> getData (Long key) {
|
||||
return cartData.getData(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过缓存键和hash键获取hash值
|
||||
* @param key 缓存键
|
||||
*
|
||||
* @param key 缓存键
|
||||
* @param hashKey hash键
|
||||
* @return
|
||||
*
|
||||
* @return hash值
|
||||
*/
|
||||
@Override
|
||||
public CartInfo getData(Long key, CartHashKey hashKey) {
|
||||
return cartData.getData(key,hashKey);
|
||||
public CartInfo getData (Long key, CartHashKey hashKey) {
|
||||
return cartData.getData(key, hashKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认值
|
||||
*/
|
||||
@Override
|
||||
public Map<CartHashKey, CartInfo> defaultValue () {
|
||||
throw new ServiceException("购物车无数据", Result.SUCCESS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<CartHashKey, CartInfo> defaultValue() {
|
||||
throw new ServiceException("购物车无数据",Result.SUCCESS);
|
||||
public CartInfo defaultHashValue () {
|
||||
throw new ServiceException("购物车无数据", Result.SUCCESS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CartInfo defaultHashValue() {
|
||||
throw new ServiceException("购物车无数据",Result.SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -5,13 +5,10 @@ import lombok.Builder;
|
|||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* 购物车HashKey
|
||||
*
|
||||
* @author LeYang
|
||||
* on 2024/4/2
|
||||
* @author yangle
|
||||
* @description: 购物车HashKey
|
||||
* @Date 2024-4-2 上午 11:25
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
|
@ -22,10 +19,10 @@ public class CartHashKey {
|
|||
/**
|
||||
* 商品ID
|
||||
*/
|
||||
private Long projectId;
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 商品sku
|
||||
* 商品SKU
|
||||
*/
|
||||
private String projectSku;
|
||||
|
||||
}
|
||||
|
|
|
@ -6,24 +6,26 @@ import com.muyu.shop.cart.domain.CartInfo;
|
|||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 购物车源数据获取 CartData
|
||||
*
|
||||
* @author LeYang
|
||||
* on 2024/4/2
|
||||
* @author yangle
|
||||
* @description: 购物车源数据获取
|
||||
* @Date 2024-4-2 上午 11:49
|
||||
*/
|
||||
public interface CartData {
|
||||
/**
|
||||
* 通过键获取所有的hash数据
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public Map<CartHashKey, CartInfo> getData(Long key);
|
||||
|
||||
/**
|
||||
* 通过缓存和hash键获取hash值
|
||||
* @param key 缓存键
|
||||
* @param cartHashKey hash值
|
||||
* 通过键获取所有的hash数据
|
||||
* @param key 键
|
||||
* @return
|
||||
*/
|
||||
public Map<CartHashKey, CartInfo> getData (Long key);
|
||||
|
||||
/**
|
||||
* 通过缓存键和hash键获取hash值
|
||||
*
|
||||
* @param key 缓存键
|
||||
* @param hashKey hash键
|
||||
*
|
||||
* @return hash值
|
||||
*/
|
||||
public CartInfo getData(Long key,CartHashKey cartHashKey);
|
||||
public CartInfo getData (Long key, CartHashKey hashKey);
|
||||
}
|
||||
|
|
|
@ -32,6 +32,10 @@ public class CartSkuModel {
|
|||
* 商品ID
|
||||
*/
|
||||
private Long projectId;
|
||||
/**
|
||||
* 商品sku
|
||||
*/
|
||||
private String projectSku;
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
|
|
|
@ -22,25 +22,15 @@ import com.muyu.common.core.web.domain.BaseEntity;
|
|||
public class CartInfoSaveReq extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
/** 商品 */
|
||||
|
||||
@ApiModelProperty(name = "商品", value = "商品", required = true)
|
||||
private Long projectId;
|
||||
|
||||
/** sku */
|
||||
|
||||
@ApiModelProperty(name = "sku", value = "sku", required = true)
|
||||
/** SKU */
|
||||
@ApiModelProperty(name = "SKU", value = "SKU", required = true)
|
||||
private String projectSku;
|
||||
|
||||
|
||||
|
||||
/** 数量 */
|
||||
|
||||
@ApiModelProperty(name = "数量", value = "数量", required = true)
|
||||
private Long num;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import java.util.List;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.muyu.product.domain.ProjectSkuInfo;
|
||||
import com.muyu.shop.cart.domain.req.CartDetailResp;
|
||||
import com.muyu.shop.cart.domain.req.*;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
@ -22,9 +22,6 @@ import com.muyu.common.log.annotation.Log;
|
|||
import com.muyu.common.log.enums.BusinessType;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import com.muyu.shop.cart.domain.CartInfo;
|
||||
import com.muyu.shop.cart.domain.req.CartInfoQueryReq;
|
||||
import com.muyu.shop.cart.domain.req.CartInfoSaveReq;
|
||||
import com.muyu.shop.cart.domain.req.CartInfoEditReq;
|
||||
import com.muyu.shop.cart.service.CartInfoService;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
|
||||
|
@ -36,7 +33,7 @@ import com.muyu.common.core.web.page.TableDataInfo;
|
|||
*/
|
||||
@Api(tags = "购物车")
|
||||
@RestController
|
||||
@RequestMapping("/info")
|
||||
@RequestMapping("/Info")
|
||||
public class CartInfoController extends BaseController {
|
||||
@Autowired
|
||||
private CartInfoService cartInfoService;
|
||||
|
@ -45,7 +42,7 @@ public class CartInfoController extends BaseController {
|
|||
* 查询购物车列表
|
||||
*/
|
||||
@ApiOperation("获取购物车列表")
|
||||
@RequiresPermissions("shopCart:info:list")
|
||||
@RequiresPermissions("shopCart:Info:list")
|
||||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<CartInfo>> list(CartInfoQueryReq cartInfoQueryReq) {
|
||||
startPage();
|
||||
|
@ -57,7 +54,7 @@ public class CartInfoController extends BaseController {
|
|||
* 导出购物车列表
|
||||
*/
|
||||
@ApiOperation("导出购物车列表")
|
||||
@RequiresPermissions("shopCart:info:export")
|
||||
@RequiresPermissions("shopCart:Info:export")
|
||||
@Log(title = "购物车", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, CartInfo cartInfo) {
|
||||
|
@ -70,13 +67,14 @@ public class CartInfoController extends BaseController {
|
|||
* 获取购物车详细信息
|
||||
*/
|
||||
@ApiOperation("获取购物车详细信息")
|
||||
@RequiresPermissions("shopCart:info:query")
|
||||
@RequiresPermissions("shopCart:Info:query")
|
||||
@GetMapping(value = "/{id}")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
|
||||
public Result<CartInfo> getInfo(@PathVariable("id") Long id) {
|
||||
return Result.success(cartInfoService.getById(id));
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/detail")
|
||||
public Result<CartDetailResp> detail(){
|
||||
return Result.success(cartInfoService.detail());
|
||||
|
@ -85,7 +83,7 @@ public class CartInfoController extends BaseController {
|
|||
/**
|
||||
* 新增购物车
|
||||
*/
|
||||
@RequiresPermissions("shopCart:info:add")
|
||||
@RequiresPermissions("shopCart:Info:add")
|
||||
@Log(title = "购物车", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
@ApiOperation("新增购物车")
|
||||
|
@ -96,7 +94,7 @@ public class CartInfoController extends BaseController {
|
|||
/**
|
||||
* 修改购物车
|
||||
*/
|
||||
@RequiresPermissions("shopCart:info:edit")
|
||||
@RequiresPermissions("shopCart:Info:edit")
|
||||
@Log(title = "购物车", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/{id}")
|
||||
@ApiOperation("修改购物车")
|
||||
|
@ -104,15 +102,48 @@ public class CartInfoController extends BaseController {
|
|||
return toAjax(cartInfoService.updateById(CartInfo.editBuild(id,cartInfoEditReq)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 购物车状态修改
|
||||
* @param cartInfoIsSelectedUpdReqList
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/selected")
|
||||
public Result<String> cartInfoIsSelected(@RequestBody List<CartInfoIsSelectedUpdReq> cartInfoIsSelectedUpdReqList){
|
||||
cartInfoService.cartInfoIsSelected(cartInfoIsSelectedUpdReqList);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改购物车内数量
|
||||
* @param cartInfoEditNumReq
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/num")
|
||||
public Result<String> cartInfoEditNum(@RequestBody CartInfoEditNumReq cartInfoEditNumReq){
|
||||
cartInfoService.CartInfoEditNum(cartInfoEditNumReq);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除购物车
|
||||
*/
|
||||
@RequiresPermissions("shopCart:info:remove")
|
||||
@RequiresPermissions("shopCart:Info:remove")
|
||||
@Log(title = "购物车", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
@DeleteMapping("/{ids}")
|
||||
@ApiOperation("删除购物车")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4")
|
||||
public Result<String> remove(@PathVariable List<Long> ids) {
|
||||
public Result<String> removeByIds(@PathVariable List<Long> ids) {
|
||||
return toAjax(cartInfoService.removeBatchByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除购物车
|
||||
*/
|
||||
@RequiresPermissions("shopCart:Info:remove")
|
||||
@DeleteMapping("/remove")
|
||||
@ApiOperation("删除购物车")
|
||||
public Result<String> remove(@RequestBody List<RemoveCartProjectReq> removeCartProjectReqList) {
|
||||
cartInfoService.removeByRemoveCartProjectList(removeCartProjectReqList);
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,9 @@ import java.util.List;
|
|||
import com.muyu.shop.cart.domain.CartInfo;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.shop.cart.domain.req.CartDetailResp;
|
||||
import com.muyu.shop.cart.domain.req.CartInfoEditNumReq;
|
||||
import com.muyu.shop.cart.domain.req.CartInfoIsSelectedUpdReq;
|
||||
import com.muyu.shop.cart.domain.req.RemoveCartProjectReq;
|
||||
|
||||
/**
|
||||
* 购物车Service接口
|
||||
|
@ -29,4 +32,10 @@ public interface CartInfoService extends IService<CartInfo> {
|
|||
|
||||
CartDetailResp detail();
|
||||
|
||||
void CartInfoEditNum(CartInfoEditNumReq cartInfoEditNumReq);
|
||||
|
||||
void removeByRemoveCartProjectList(List<RemoveCartProjectReq> removeCartProjectReqs);
|
||||
|
||||
void cartInfoIsSelected(List<CartInfoIsSelectedUpdReq> cartInfoIsSelectedUpdReqList);
|
||||
|
||||
}
|
||||
|
|
|
@ -5,9 +5,11 @@ import java.util.ArrayList;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.muyu.common.core.exception.ServiceException;
|
||||
import com.muyu.common.core.text.Convert;
|
||||
import com.muyu.common.core.utils.ObjUtils;
|
||||
import com.muyu.common.core.utils.ServletUtils;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.product.cache.ProjectInfoCache;
|
||||
import com.muyu.product.cache.ProjectSkuCache;
|
||||
|
@ -24,6 +26,9 @@ import com.muyu.shop.cart.domain.model.CartSkuModel;
|
|||
import com.muyu.shop.cart.domain.model.SkuRuleModel;
|
||||
import com.muyu.shop.cart.domain.model.StatisticsCartModel;
|
||||
import com.muyu.shop.cart.domain.req.CartDetailResp;
|
||||
import com.muyu.shop.cart.domain.req.CartInfoEditNumReq;
|
||||
import com.muyu.shop.cart.domain.req.CartInfoIsSelectedUpdReq;
|
||||
import com.muyu.shop.cart.domain.req.RemoveCartProjectReq;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.SystemUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -33,6 +38,7 @@ import com.muyu.shop.cart.domain.CartInfo;
|
|||
import com.muyu.shop.cart.service.CartInfoService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 购物车Service业务层处理
|
||||
|
@ -47,6 +53,18 @@ public class CartInfoServiceImpl extends ServiceImpl<CartInfoMapper, CartInfo>
|
|||
@Autowired
|
||||
private CartCache cartCache;
|
||||
|
||||
@Autowired
|
||||
private ProjectSkuCache projectSkuCache;
|
||||
|
||||
@Autowired
|
||||
private ProjectInfoCache projectInfoCache;
|
||||
|
||||
@Autowired
|
||||
private ProjectSkuStockCache projectSkuStockCache;
|
||||
|
||||
@Autowired
|
||||
private RuleInfoCache ruleInfoCache;
|
||||
|
||||
/**
|
||||
* 查询购物车列表
|
||||
*
|
||||
|
@ -77,20 +95,22 @@ public class CartInfoServiceImpl extends ServiceImpl<CartInfoMapper, CartInfo>
|
|||
if (ObjUtils.notNull(cartInfo.getIsSelected())){
|
||||
queryWrapper.eq(CartInfo::getIsSelected, cartInfo.getIsSelected());
|
||||
}
|
||||
|
||||
return list(queryWrapper);
|
||||
}
|
||||
@Autowired
|
||||
private ProjectSkuStockCache projectSkuStockCache;
|
||||
|
||||
/**
|
||||
* 添加购物车
|
||||
* @param cartInfo 购物车
|
||||
* @return
|
||||
*
|
||||
* @param cartInfo 购物车信息
|
||||
*
|
||||
* @return 是否添加成功
|
||||
*/
|
||||
@Override
|
||||
public boolean add(CartInfo cartInfo) {
|
||||
public boolean add (CartInfo cartInfo) {
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
CartHashKey cartHashKey = CartHashKey.builder()
|
||||
.projectId(cartInfo.getUserId())
|
||||
.projectId(cartInfo.getProjectId())
|
||||
.projectSku(cartInfo.getProjectSku())
|
||||
.build();
|
||||
SkuStockKey skuStockKey = SkuStockKey.builder()
|
||||
|
@ -98,68 +118,72 @@ private ProjectSkuStockCache projectSkuStockCache;
|
|||
.sku(cartInfo.getProjectSku())
|
||||
.build();
|
||||
Long skuStock = Convert.toLong(projectSkuStockCache.get(skuStockKey), -1L);
|
||||
if (cartCache.hasKey(userId, cartHashKey)) {
|
||||
//取出来修改
|
||||
if (cartCache.hasKey(userId, cartHashKey)){
|
||||
// 取出来修改
|
||||
CartInfo cartInfoCache = cartCache.get(userId, cartHashKey);
|
||||
cartInfoCache.setNum(cartInfoCache.getNum()+ cartInfo.getNum());
|
||||
if (skuStock<cartInfoCache.getNum()){
|
||||
throw new ServiceException("当前库存不足");
|
||||
cartInfoCache.setNum( cartInfoCache.getNum() + cartInfo.getNum());
|
||||
if (skuStock < cartInfoCache.getNum()){
|
||||
throw new ServiceException("当前库存不足");
|
||||
}
|
||||
LambdaQueryWrapper<CartInfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(CartInfo::getNum,cartInfoCache.getNum());
|
||||
queryWrapper.eq(CartInfo::getId, cartInfoCache.getId());
|
||||
this.update(queryWrapper);
|
||||
this.cartCache.put(userId, cartHashKey,cartInfoCache);
|
||||
LambdaUpdateWrapper<CartInfo> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.set(CartInfo::getNum, cartInfoCache.getNum());
|
||||
updateWrapper.eq(CartInfo::getId, cartInfoCache.getId());
|
||||
this.update(updateWrapper);
|
||||
this.cartCache.put(userId, cartHashKey, cartInfoCache);
|
||||
}else {
|
||||
//存进去
|
||||
// 存进去
|
||||
if (skuStock < cartInfo.getNum()){
|
||||
throw new ServiceException("当前库存不足");
|
||||
}
|
||||
cartInfo.setIsSelected("Y");
|
||||
cartInfo.setUserId(userId);
|
||||
cartInfo.setCreateBy(SecurityUtils.getUsername());
|
||||
cartInfo.setCreateTime(new Date());
|
||||
this.save(cartInfo);
|
||||
this.cartCache.put(userId, cartHashKey,cartInfo);
|
||||
this.cartCache.put(userId, cartHashKey, cartInfo);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@Autowired
|
||||
private ProjectSkuCache projectSkuCache;
|
||||
@Autowired
|
||||
private ProjectInfoCache projectInfoCache;
|
||||
@Autowired
|
||||
private RuleInfoCache ruleInfoCache;
|
||||
@Override
|
||||
public CartDetailResp detail() {
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
List<CartInfo> cacheToList = this.cartCache.getToList(userId);
|
||||
|
||||
List<CartSkuModel> cartSkuModelList = cacheToList.stream()
|
||||
/**
|
||||
* 获取购物车详情
|
||||
*
|
||||
* @return 购物车详情
|
||||
*/
|
||||
@Override
|
||||
public CartDetailResp detail () {
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
List<CartInfo> cartInfoList = cartCache.getToList(userId);
|
||||
// CartInfo -> CartSkuModel
|
||||
List<CartSkuModel> cartSkuModelList = cartInfoList.stream()
|
||||
.map(cartInfo -> {
|
||||
ProjectSkuInfo projectSkuInfo =
|
||||
projectSkuCache.get(cartInfo.getProjectId(), cartInfo.getProjectSku());
|
||||
ProjectInfo projectInfo = projectInfoCache.get(cartInfo.getProjectId());
|
||||
ProjectSkuInfo projectSkuInfo
|
||||
= projectSkuCache.get(cartInfo.getProjectId(), cartInfo.getProjectSku());
|
||||
ProjectInfo projectInfo
|
||||
= projectInfoCache.get(cartInfo.getProjectId());
|
||||
Long stock = projectSkuStockCache.get(
|
||||
SkuStockKey.builder()
|
||||
.projectId(cartInfo.getProjectId())
|
||||
.sku(cartInfo.getProjectSku())
|
||||
.build()
|
||||
);
|
||||
RuleCacheModel ruleInfoCacheData = ruleInfoCache.getData(projectInfo.getRuleId());
|
||||
List<RuleAttrCacheModel> ruleAttrModelList = ruleInfoCacheData.getRuleAttrModelList();
|
||||
// RuleCache
|
||||
RuleCacheModel ruleInfoCacheModel = ruleInfoCache.getData(projectInfo.getRuleId());
|
||||
List<RuleAttrCacheModel> ruleAttrModelList = ruleInfoCacheModel.getRuleAttrModelList();
|
||||
List<SkuRuleModel> ruleModelList = new ArrayList<>();
|
||||
String projectSku = cartInfo.getProjectSku();
|
||||
String[] skuArr = projectSku.split("-");
|
||||
for (int index = 0; index < skuArr.length; index++) {
|
||||
for (int index = 0 ; index < skuArr.length ; index++) {
|
||||
ruleModelList.add(
|
||||
SkuRuleModel.builder().
|
||||
ruleName(ruleAttrModelList.get(index).getAttrName())
|
||||
SkuRuleModel.builder()
|
||||
.ruleName(ruleAttrModelList.get(index).getAttrName())
|
||||
.ruleValue(skuArr[index])
|
||||
.build()
|
||||
.build()
|
||||
);
|
||||
}
|
||||
return CartSkuModel.builder()
|
||||
.projectId(cartInfo.getProjectId())
|
||||
.projectSku(cartInfo.getProjectSku())
|
||||
.name(projectInfo.getName())
|
||||
.image(projectSkuInfo.getImage())
|
||||
.stock(stock)
|
||||
|
@ -171,35 +195,107 @@ private ProjectSkuCache projectSkuCache;
|
|||
.isSelected(cartInfo.getIsSelected())
|
||||
.build();
|
||||
}).toList();
|
||||
List<CartSkuModel> cartSkuList = new ArrayList<>();
|
||||
|
||||
|
||||
StatisticsCartModel statisticsCartModel = StatisticsCartModel.builder()
|
||||
.total(cartSkuModelList.stream()
|
||||
.mapToLong(CartSkuModel::getNum)
|
||||
.sum()
|
||||
.total(
|
||||
cartSkuModelList.stream()
|
||||
.filter(cartSkuModel -> cartSkuModel.getStock() > 0)
|
||||
.mapToLong(CartSkuModel::getNum)
|
||||
.sum()
|
||||
)
|
||||
.selectTotal(
|
||||
cartSkuModelList.stream()
|
||||
.filter(cartSkuModel -> "Y".equals(cartSkuModel.getIsSelected()))
|
||||
.filter(cartSkuModel -> cartSkuModel.getStock() > 0)
|
||||
.mapToLong(CartSkuModel::getNum)
|
||||
.sum()
|
||||
)
|
||||
.priceTotal(
|
||||
cartSkuModelList.stream()
|
||||
.filter(cartSkuModel -> "Y".equals(cartSkuModel.getIsSelected()))
|
||||
.filter(cartSkuModel -> cartSkuModel.getStock() > 0)
|
||||
.map(CartSkuModel::getSubtotal)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add)
|
||||
)
|
||||
.actualTotal(
|
||||
cartSkuModelList.stream()
|
||||
.filter(cartSkuModel -> "Y".equals(cartSkuModel.getIsSelected()))
|
||||
.filter(cartSkuModel -> cartSkuModel.getStock() > 0)
|
||||
.map(CartSkuModel::getSubtotal)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add)
|
||||
).build();
|
||||
)
|
||||
.build();
|
||||
return CartDetailResp.builder()
|
||||
.cartSkuList(cartSkuModelList)
|
||||
.statisticsCart(statisticsCartModel)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改状态
|
||||
*
|
||||
* @param cartInfoIsSelectedUpdReqList
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void cartInfoIsSelected (List<CartInfoIsSelectedUpdReq> cartInfoIsSelectedUpdReqList) {
|
||||
for (CartInfoIsSelectedUpdReq cartInfoIsSelectedUpdReq : cartInfoIsSelectedUpdReqList) {
|
||||
LambdaUpdateWrapper<CartInfo> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.set(CartInfo::getIsSelected, cartInfoIsSelectedUpdReq.getIsSelected());
|
||||
updateWrapper.eq(CartInfo::getProjectId, cartInfoIsSelectedUpdReq.getProjectId());
|
||||
updateWrapper.eq(CartInfo::getProjectSku, cartInfoIsSelectedUpdReq.getProjectSku());
|
||||
this.update(updateWrapper);
|
||||
CartHashKey cartHashKey = CartHashKey.builder()
|
||||
.projectId(cartInfoIsSelectedUpdReq.getProjectId())
|
||||
.projectSku(cartInfoIsSelectedUpdReq.getProjectSku())
|
||||
.build();
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
CartInfo cartInfo = this.cartCache.get(userId, cartHashKey);
|
||||
cartInfo.setIsSelected(cartInfoIsSelectedUpdReq.getIsSelected());
|
||||
this.cartCache.put(userId, cartHashKey, cartInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void CartInfoEditNum (CartInfoEditNumReq cartInfoEditNumReq) {
|
||||
LambdaUpdateWrapper<CartInfo> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.set(CartInfo::getIsSelected, cartInfoEditNumReq.getNum());
|
||||
updateWrapper.eq(CartInfo::getProjectId, cartInfoEditNumReq.getProjectId());
|
||||
updateWrapper.eq(CartInfo::getProjectSku, cartInfoEditNumReq.getProjectSku());
|
||||
this.update(updateWrapper);
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
CartHashKey cartHashKey = CartHashKey.builder()
|
||||
.projectId(cartInfoEditNumReq.getProjectId())
|
||||
.projectSku(cartInfoEditNumReq.getProjectSku())
|
||||
.build();
|
||||
CartInfo cartInfo = this.cartCache.get(userId, cartHashKey);
|
||||
cartInfo.setNum(cartInfoEditNumReq.getNum());
|
||||
this.cartCache.put(userId, cartHashKey, cartInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param removeCartProjectReqList
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void removeByRemoveCartProjectList (List<RemoveCartProjectReq> removeCartProjectReqList) {
|
||||
this.removeByIds(
|
||||
removeCartProjectReqList.stream()
|
||||
.map(RemoveCartProjectReq::getCartInfoId)
|
||||
.toList()
|
||||
);
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
removeCartProjectReqList.stream()
|
||||
.map(removeCartProjectReq -> CartHashKey.builder()
|
||||
.projectId(removeCartProjectReq.getProjectId())
|
||||
.projectSku(removeCartProjectReq.getProjectSku())
|
||||
.build()
|
||||
).forEach(hk -> this.cartCache.remove(userId, hk));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue