|
@@ -21,6 +21,7 @@ import com.yami.shop.bean.dto.SearchProdDto;
|
|
|
import com.yami.shop.bean.model.ChannelProd;
|
|
import com.yami.shop.bean.model.ChannelProd;
|
|
|
import com.yami.shop.bean.model.Product;
|
|
import com.yami.shop.bean.model.Product;
|
|
|
import com.yami.shop.bean.model.Sku;
|
|
import com.yami.shop.bean.model.Sku;
|
|
|
|
|
+import com.yami.shop.bean.param.CategoryProductParam;
|
|
|
import com.yami.shop.bean.vo.SimilarProdListVo;
|
|
import com.yami.shop.bean.vo.SimilarProdListVo;
|
|
|
import com.yami.shop.bean.vo.SkuBuyTogetherOftenVo;
|
|
import com.yami.shop.bean.vo.SkuBuyTogetherOftenVo;
|
|
|
import com.yami.shop.bean.model.UserShopBehavior;
|
|
import com.yami.shop.bean.model.UserShopBehavior;
|
|
@@ -92,26 +93,31 @@ public class ProdController {
|
|
|
}
|
|
}
|
|
|
if (user != null) {
|
|
if (user != null) {
|
|
|
String userId = user.getUserId();
|
|
String userId = user.getUserId();
|
|
|
|
|
+ if (channelId == null){
|
|
|
|
|
+ channelId = 3L;
|
|
|
|
|
+ }
|
|
|
if (StringUtils.isNotEmpty(userId)) {
|
|
if (StringUtils.isNotEmpty(userId)) {
|
|
|
UserShopBehavior userShopBehavior = null;
|
|
UserShopBehavior userShopBehavior = null;
|
|
|
- userShopBehavior = userShopBehaviorService.findByUserIdAndProd(userId, prodId);
|
|
|
|
|
|
|
+ userShopBehavior = userShopBehaviorService.findByUserIdAndProd(userId,shopId, prodId,channelId);
|
|
|
if (userShopBehavior == null) {
|
|
if (userShopBehavior == null) {
|
|
|
int num = userShopBehaviorService.findByUserIdCount(userId);
|
|
int num = userShopBehaviorService.findByUserIdCount(userId);
|
|
|
if (num < 6) {
|
|
if (num < 6) {
|
|
|
userShopBehavior = new UserShopBehavior();
|
|
userShopBehavior = new UserShopBehavior();
|
|
|
userShopBehavior.setUserId(userId);
|
|
userShopBehavior.setUserId(userId);
|
|
|
userShopBehavior.setShopId(shopId);
|
|
userShopBehavior.setShopId(shopId);
|
|
|
|
|
+ userShopBehavior.setChannelId(channelId);
|
|
|
userShopBehavior.setProdId(prodId);
|
|
userShopBehavior.setProdId(prodId);
|
|
|
userShopBehavior.setCreateTime(new Date());
|
|
userShopBehavior.setCreateTime(new Date());
|
|
|
userShopBehaviorService.save(userShopBehavior);
|
|
userShopBehaviorService.save(userShopBehavior);
|
|
|
} else {
|
|
} else {
|
|
|
- List<UserShopBehavior> userShopBehaviors = userShopBehaviorService.findByUserId(userId, 1);
|
|
|
|
|
|
|
+ List<UserShopBehavior> userShopBehaviors = userShopBehaviorService.findByUserId(userId, 1, shopId,channelId);
|
|
|
if (userShopBehaviors != null && !userShopBehaviors.isEmpty()) {
|
|
if (userShopBehaviors != null && !userShopBehaviors.isEmpty()) {
|
|
|
userShopBehavior = userShopBehaviors.get(0);
|
|
userShopBehavior = userShopBehaviors.get(0);
|
|
|
}
|
|
}
|
|
|
if (userShopBehavior != null) {
|
|
if (userShopBehavior != null) {
|
|
|
userShopBehavior.setProdId(prodId);
|
|
userShopBehavior.setProdId(prodId);
|
|
|
userShopBehavior.setShopId(shopId);
|
|
userShopBehavior.setShopId(shopId);
|
|
|
|
|
+ userShopBehavior.setChannelId(channelId);
|
|
|
userShopBehavior.setCreateTime(new Date());
|
|
userShopBehavior.setCreateTime(new Date());
|
|
|
userShopBehaviorService.updateById(userShopBehavior);
|
|
userShopBehaviorService.updateById(userShopBehavior);
|
|
|
}
|
|
}
|
|
@@ -210,13 +216,13 @@ public class ProdController {
|
|
|
|
|
|
|
|
@PostMapping("/listProdByCategoryIdAndShopId")
|
|
@PostMapping("/listProdByCategoryIdAndShopId")
|
|
|
@ApiOperation(value = "根据分类ID、商户ID查询归属的所有商品")
|
|
@ApiOperation(value = "根据分类ID、商户ID查询归属的所有商品")
|
|
|
- public ResponseEntity<IPage<Product>> listProdByCategoryIdAndShopId(@RequestBody ProdByCategoryIdAndShopIdDTO prodByCategoryIdAndShopIdDTO) {
|
|
|
|
|
|
|
+ public ResponseEntity<IPage<CategoryProductParam>> listProdByCategoryIdAndShopId(@RequestBody ProdByCategoryIdAndShopIdDTO prodByCategoryIdAndShopIdDTO) {
|
|
|
return ResponseEntity.ok(prodService.listProdByCategoryIdAndShopId(prodByCategoryIdAndShopIdDTO));
|
|
return ResponseEntity.ok(prodService.listProdByCategoryIdAndShopId(prodByCategoryIdAndShopIdDTO));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@GetMapping("/prodRecommended")
|
|
@GetMapping("/prodRecommended")
|
|
|
@ApiOperation(value = "为你推荐", notes = "为你推荐")
|
|
@ApiOperation(value = "为你推荐", notes = "为你推荐")
|
|
|
- public ResponseEntity<IPage<SearchProdDto>> getProdRecommended(PageParam<SearchProdDto> page) {
|
|
|
|
|
|
|
+ public ResponseEntity<IPage<SearchProdDto>> getProdRecommended(PageParam<SearchProdDto> page,@RequestParam("shopId") Long shopId,@RequestParam("channelId") Long channelId) {
|
|
|
IPage<SearchProdDto> searchProdDtos = page;
|
|
IPage<SearchProdDto> searchProdDtos = page;
|
|
|
List<ProductDto> productDtos = new ArrayList<>();
|
|
List<ProductDto> productDtos = new ArrayList<>();
|
|
|
YamiUser user = null;
|
|
YamiUser user = null;
|
|
@@ -229,9 +235,12 @@ public class ProdController {
|
|
|
if (user != null) {
|
|
if (user != null) {
|
|
|
String userId = user.getUserId();
|
|
String userId = user.getUserId();
|
|
|
if (StringUtils.isNotEmpty(userId)) {
|
|
if (StringUtils.isNotEmpty(userId)) {
|
|
|
- List<UserShopBehavior> byUserId = userShopBehaviorService.findByUserId(userId, 5);
|
|
|
|
|
|
|
+ if (channelId == null){
|
|
|
|
|
+ channelId = 3L;
|
|
|
|
|
+ }
|
|
|
|
|
+ List<UserShopBehavior> byUserId = userShopBehaviorService.findByUserId(userId, 5,shopId,channelId);
|
|
|
for (UserShopBehavior userShopBehavior : byUserId) {
|
|
for (UserShopBehavior userShopBehavior : byUserId) {
|
|
|
- ChannelProd channelProd = userShopBehaviorService.findByProdId(userShopBehavior.getProdId(), userShopBehavior.getShopId());
|
|
|
|
|
|
|
+ ChannelProd channelProd = userShopBehaviorService.findByProdId(userShopBehavior.getProdId(), userShopBehavior.getShopId(),channelId);
|
|
|
if (channelProd != null) {
|
|
if (channelProd != null) {
|
|
|
BigDecimal channelProdPrice = channelProd.getChannelProdPrice();
|
|
BigDecimal channelProdPrice = channelProd.getChannelProdPrice();
|
|
|
if (channelProdPrice != null) {
|
|
if (channelProdPrice != null) {
|
|
@@ -239,7 +248,7 @@ public class ProdController {
|
|
|
.setScale(2, RoundingMode.HALF_UP);
|
|
.setScale(2, RoundingMode.HALF_UP);
|
|
|
BigDecimal decreased = channelProdPrice.multiply(new BigDecimal("0.90"))
|
|
BigDecimal decreased = channelProdPrice.multiply(new BigDecimal("0.90"))
|
|
|
.setScale(2, RoundingMode.HALF_UP);
|
|
.setScale(2, RoundingMode.HALF_UP);
|
|
|
- List<ProductDto> productDtoList = userShopBehaviorService.findByProdIdAndShopIdAndPrice(userShopBehavior.getProdId(), userShopBehavior.getShopId(), increased, decreased);
|
|
|
|
|
|
|
+ List<ProductDto> productDtoList = userShopBehaviorService.findByProdIdAndShopIdAndPrice(userShopBehavior.getProdId(), userShopBehavior.getShopId(),channelId, increased, decreased);
|
|
|
if (productDtoList != null && !productDtoList.isEmpty()) {
|
|
if (productDtoList != null && !productDtoList.isEmpty()) {
|
|
|
productDtos.addAll(productDtoList);
|
|
productDtos.addAll(productDtoList);
|
|
|
}
|
|
}
|
|
@@ -262,7 +271,7 @@ public class ProdController {
|
|
|
@ApiOperation(value = "相似商品", notes = "传入商品id")
|
|
@ApiOperation(value = "相似商品", notes = "传入商品id")
|
|
|
public R<IPage<SimilarProdListVo>> similarProdList(PageParam<Product> page, Long prodId, Long shopId, Long channelId,String userId) {
|
|
public R<IPage<SimilarProdListVo>> similarProdList(PageParam<Product> page, Long prodId, Long shopId, Long channelId,String userId) {
|
|
|
if (channelId == null){
|
|
if (channelId == null){
|
|
|
- channelId = 1L;
|
|
|
|
|
|
|
+ channelId = 3L;
|
|
|
}
|
|
}
|
|
|
return R.SUCCESS(prodService.similarProdList(page, prodId , shopId, channelId, userId));
|
|
return R.SUCCESS(prodService.similarProdList(page, prodId , shopId, channelId, userId));
|
|
|
}
|
|
}
|