秒杀添加sku
This commit is contained in:
@ -114,3 +114,12 @@ INSERT INTO `menu` VALUES (245, b'0', '拼团商品修改', 'activity/combinatio
|
|||||||
-- 菜单角色的关系
|
-- 菜单角色的关系
|
||||||
INSERT INTO `roles_menus` VALUES (244, 1);
|
INSERT INTO `roles_menus` VALUES (244, 1);
|
||||||
INSERT INTO `roles_menus` VALUES (245, 1);
|
INSERT INTO `roles_menus` VALUES (245, 1);
|
||||||
|
|
||||||
|
-- 菜单
|
||||||
|
INSERT INTO `menu` VALUES (246, b'0', '秒杀商品添加', 'activity/seckill/form', 63, 999, NULL, 'secKillAdd', b'0', b'1', 'SecKillAdd', '2020-08-13 21:28:45', 'YXSTORESECKILL_EDIT', 1, '2020-08-13 21:31:26', 0);
|
||||||
|
INSERT INTO `menu` VALUES (247, b'0', '秒杀商品修改', 'activity/seckill/form', 63, 3, 'anq', 'secKillEdit/:id', b'0', b'1', 'SecKillEdit', '2019-12-24 13:02:23', 'YXSTORESECKILL_EDIT', 1, '2020-07-10 16:45:33', 0);
|
||||||
|
|
||||||
|
-- 菜单角色的关系
|
||||||
|
INSERT INTO `roles_menus` VALUES (246, 1);
|
||||||
|
INSERT INTO `roles_menus` VALUES (247, 1);
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,51 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (C) 2018-2020
|
||||||
|
* All rights reserved, Designed By www.yixiang.co
|
||||||
|
* 注意:
|
||||||
|
* 本软件为www.yixiang.co开发研制,未经购买不得使用
|
||||||
|
* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台)
|
||||||
|
* 一经发现盗用、分享等行为,将追究法律责任,后果自负
|
||||||
|
*/
|
||||||
|
package co.yixiang.modules.wechat.rest.controller;
|
||||||
|
|
||||||
|
import co.yixiang.api.ApiResult;
|
||||||
|
import co.yixiang.dozer.service.IGenerator;
|
||||||
|
import co.yixiang.logging.aop.log.Log;
|
||||||
|
import co.yixiang.modules.wechat.domain.YxWechatLive;
|
||||||
|
import co.yixiang.modules.wechat.service.YxWechatLiveService;
|
||||||
|
import co.yixiang.modules.wechat.service.dto.YxWechatLiveDto;
|
||||||
|
import co.yixiang.modules.wechat.service.dto.YxWechatLiveQueryCriteria;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hupeng
|
||||||
|
* @date 2020-08-10
|
||||||
|
*/
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Api(tags = "wxlive管理")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping
|
||||||
|
public class WechatLiveController {
|
||||||
|
|
||||||
|
private final YxWechatLiveService yxWechatLiveService;
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("yxWechatLive")
|
||||||
|
@ApiOperation("查询所有直播间")
|
||||||
|
public ApiResult<Map<String,Object>> getYxWechatLives(YxWechatLiveQueryCriteria criteria, Pageable pageable){
|
||||||
|
return ApiResult.ok(yxWechatLiveService.queryAll(criteria,pageable));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -143,6 +143,9 @@ public class YxStoreCombination extends BaseDomain {
|
|||||||
/** 单位名 */
|
/** 单位名 */
|
||||||
private String unitName;
|
private String unitName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 规格 0单 1多
|
||||||
|
*/
|
||||||
private Integer specType;
|
private Integer specType;
|
||||||
|
|
||||||
/** 运费模板ID */
|
/** 运费模板ID */
|
||||||
|
|||||||
@ -8,8 +8,11 @@ package co.yixiang.modules.activity.domain;
|
|||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.bean.copier.CopyOptions;
|
import cn.hutool.core.bean.copier.CopyOptions;
|
||||||
import co.yixiang.domain.BaseDomain;
|
import co.yixiang.domain.BaseDomain;
|
||||||
|
import co.yixiang.modules.product.service.dto.FromatDetailDto;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
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 com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
@ -20,6 +23,8 @@ import javax.validation.constraints.NotBlank;
|
|||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author hupeng
|
* @author hupeng
|
||||||
@ -141,7 +146,21 @@ public class YxStoreSeckill extends BaseDomain {
|
|||||||
/** 时间段id */
|
/** 时间段id */
|
||||||
@NotNull(message = "请选择开始时间")
|
@NotNull(message = "请选择开始时间")
|
||||||
private Integer timeId;
|
private Integer timeId;
|
||||||
|
/**
|
||||||
|
* 规格 0单 1多
|
||||||
|
*/
|
||||||
|
private Integer specType;
|
||||||
|
|
||||||
|
/** 运费模板ID */
|
||||||
|
@JsonProperty("temp_id")
|
||||||
|
private Long tempId;
|
||||||
|
//属性项目
|
||||||
|
@TableField(exist = false)
|
||||||
|
private List<FromatDetailDto> items;
|
||||||
|
|
||||||
|
//sku结果集
|
||||||
|
@TableField(exist = false)
|
||||||
|
private List<Map<String,Object>> attrs;
|
||||||
|
|
||||||
public void copy(YxStoreSeckill source){
|
public void copy(YxStoreSeckill source){
|
||||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||||
|
|||||||
@ -45,7 +45,7 @@ public interface YxStoreSeckillService extends BaseService<YxStoreSeckill>{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 产品详情
|
* 产品详情
|
||||||
* @param id 砍价商品id
|
* @param id 秒杀商品id
|
||||||
* @return StoreSeckillVo
|
* @return StoreSeckillVo
|
||||||
*/
|
*/
|
||||||
StoreSeckillVo getDetail(Long id);
|
StoreSeckillVo getDetail(Long id);
|
||||||
@ -81,4 +81,6 @@ public interface YxStoreSeckillService extends BaseService<YxStoreSeckill>{
|
|||||||
* @throws IOException /
|
* @throws IOException /
|
||||||
*/
|
*/
|
||||||
void download(List<YxStoreSeckillDto> all, HttpServletResponse response) throws IOException;
|
void download(List<YxStoreSeckillDto> all, HttpServletResponse response) throws IOException;
|
||||||
|
|
||||||
|
boolean saveSeckill(YxStoreSeckillDto resources);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -121,6 +121,9 @@ public class YxStoreCombinationDto implements Serializable {
|
|||||||
/** 规格 0单 1多 */
|
/** 规格 0单 1多 */
|
||||||
@JsonProperty("spec_type")
|
@JsonProperty("spec_type")
|
||||||
private Integer specType;
|
private Integer specType;
|
||||||
|
// 模板id
|
||||||
|
@JsonProperty("temp_id")
|
||||||
|
private Integer tempId;
|
||||||
|
|
||||||
private ProductFormatDto attr;
|
private ProductFormatDto attr;
|
||||||
//属性项目
|
//属性项目
|
||||||
|
|||||||
@ -5,17 +5,27 @@
|
|||||||
*/
|
*/
|
||||||
package co.yixiang.modules.activity.service.dto;
|
package co.yixiang.modules.activity.service.dto;
|
||||||
|
|
||||||
|
import co.yixiang.modules.product.service.dto.FromatDetailDto;
|
||||||
|
import co.yixiang.modules.product.service.dto.ProductFormatDto;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author hupeng
|
* @author hupeng
|
||||||
* @date 2020-05-13
|
* @date 2020-05-13
|
||||||
*/
|
*/
|
||||||
@Data
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@ToString
|
||||||
public class YxStoreSeckillDto implements Serializable {
|
public class YxStoreSeckillDto implements Serializable {
|
||||||
|
|
||||||
|
|
||||||
@ -31,6 +41,10 @@ public class YxStoreSeckillDto implements Serializable {
|
|||||||
// 轮播图
|
// 轮播图
|
||||||
private String images;
|
private String images;
|
||||||
|
|
||||||
|
/** 轮播图 */
|
||||||
|
@JsonProperty("slider_image")
|
||||||
|
private List<String> sliderImage;
|
||||||
|
|
||||||
// 活动标题
|
// 活动标题
|
||||||
private String title;
|
private String title;
|
||||||
|
|
||||||
@ -96,4 +110,18 @@ public class YxStoreSeckillDto implements Serializable {
|
|||||||
private String statusStr;
|
private String statusStr;
|
||||||
|
|
||||||
private Integer timeId;
|
private Integer timeId;
|
||||||
|
// 模板id
|
||||||
|
@JsonProperty("temp_id")
|
||||||
|
private Integer tempId;
|
||||||
|
/** 规格 0单 1多 */
|
||||||
|
@JsonProperty("spec_type")
|
||||||
|
private Integer specType;
|
||||||
|
|
||||||
|
private ProductFormatDto attr;
|
||||||
|
//属性项目
|
||||||
|
private List<FromatDetailDto> items;
|
||||||
|
|
||||||
|
//sku结果集
|
||||||
|
private List<Map<String,Object>> attrs;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,12 +34,14 @@ import co.yixiang.modules.activity.service.mapper.YxStorePinkMapper;
|
|||||||
import co.yixiang.modules.activity.service.mapper.YxStoreVisitMapper;
|
import co.yixiang.modules.activity.service.mapper.YxStoreVisitMapper;
|
||||||
import co.yixiang.modules.activity.vo.StoreCombinationVo;
|
import co.yixiang.modules.activity.vo.StoreCombinationVo;
|
||||||
import co.yixiang.modules.activity.vo.YxStoreCombinationQueryVo;
|
import co.yixiang.modules.activity.vo.YxStoreCombinationQueryVo;
|
||||||
|
import co.yixiang.modules.product.domain.YxStoreProductAttrValue;
|
||||||
import co.yixiang.modules.product.service.YxStoreProductAttrService;
|
import co.yixiang.modules.product.service.YxStoreProductAttrService;
|
||||||
import co.yixiang.modules.product.service.YxStoreProductAttrValueService;
|
import co.yixiang.modules.product.service.YxStoreProductAttrValueService;
|
||||||
import co.yixiang.modules.product.service.YxStoreProductReplyService;
|
import co.yixiang.modules.product.service.YxStoreProductReplyService;
|
||||||
import co.yixiang.modules.product.service.dto.FromatDetailDto;
|
import co.yixiang.modules.product.service.dto.FromatDetailDto;
|
||||||
import co.yixiang.modules.product.service.dto.ProductFormatDto;
|
import co.yixiang.modules.product.service.dto.ProductFormatDto;
|
||||||
import co.yixiang.modules.product.service.dto.ProductResultDto;
|
import co.yixiang.modules.product.service.dto.ProductResultDto;
|
||||||
|
import co.yixiang.modules.product.vo.YxStoreProductAttrQueryVo;
|
||||||
import co.yixiang.modules.template.domain.YxShippingTemplates;
|
import co.yixiang.modules.template.domain.YxShippingTemplates;
|
||||||
import co.yixiang.modules.template.service.YxShippingTemplatesService;
|
import co.yixiang.modules.template.service.YxShippingTemplatesService;
|
||||||
import co.yixiang.utils.FileUtil;
|
import co.yixiang.utils.FileUtil;
|
||||||
@ -200,7 +202,8 @@ public class YxStoreCombinationServiceImpl extends BaseServiceImpl<YxStoreCombin
|
|||||||
storeCombinationVo.setPink(pinkAllDto.getList());
|
storeCombinationVo.setPink(pinkAllDto.getList());
|
||||||
storeCombinationVo.setPinkOkList(storePinkService.getPinkOkList(uid));
|
storeCombinationVo.setPinkOkList(storePinkService.getPinkOkList(uid));
|
||||||
storeCombinationVo.setPinkOkSum(storePinkService.getPinkOkSumTotalNum());
|
storeCombinationVo.setPinkOkSum(storePinkService.getPinkOkSumTotalNum());
|
||||||
|
storeCombinationVo.setProductAttr((List<YxStoreProductAttrQueryVo>)returnMap.get("productAttr"));
|
||||||
|
storeCombinationVo.setProductValue((Map<String, YxStoreProductAttrValue>)returnMap.get("productValue"));
|
||||||
return storeCombinationVo;
|
return storeCombinationVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -8,12 +8,20 @@
|
|||||||
*/
|
*/
|
||||||
package co.yixiang.modules.activity.service.impl;
|
package co.yixiang.modules.activity.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.collection.ListUtil;
|
||||||
|
import cn.hutool.core.map.MapUtil;
|
||||||
import cn.hutool.core.util.NumberUtil;
|
import cn.hutool.core.util.NumberUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import co.yixiang.api.YshopException;
|
import co.yixiang.api.YshopException;
|
||||||
import co.yixiang.common.service.impl.BaseServiceImpl;
|
import co.yixiang.common.service.impl.BaseServiceImpl;
|
||||||
import co.yixiang.common.utils.QueryHelpPlus;
|
import co.yixiang.common.utils.QueryHelpPlus;
|
||||||
import co.yixiang.dozer.service.IGenerator;
|
import co.yixiang.dozer.service.IGenerator;
|
||||||
import co.yixiang.enums.ShopCommonEnum;
|
import co.yixiang.enums.ShopCommonEnum;
|
||||||
|
import co.yixiang.enums.SpecTypeEnum;
|
||||||
|
import co.yixiang.exception.BadRequestException;
|
||||||
|
import co.yixiang.modules.activity.domain.YxStoreSeckill;
|
||||||
import co.yixiang.modules.activity.domain.YxStoreSeckill;
|
import co.yixiang.modules.activity.domain.YxStoreSeckill;
|
||||||
import co.yixiang.modules.activity.service.YxStoreSeckillService;
|
import co.yixiang.modules.activity.service.YxStoreSeckillService;
|
||||||
import co.yixiang.modules.activity.service.dto.YxStoreSeckillDto;
|
import co.yixiang.modules.activity.service.dto.YxStoreSeckillDto;
|
||||||
@ -21,9 +29,18 @@ import co.yixiang.modules.activity.service.dto.YxStoreSeckillQueryCriteria;
|
|||||||
import co.yixiang.modules.activity.service.mapper.YxStoreSeckillMapper;
|
import co.yixiang.modules.activity.service.mapper.YxStoreSeckillMapper;
|
||||||
import co.yixiang.modules.activity.vo.StoreSeckillVo;
|
import co.yixiang.modules.activity.vo.StoreSeckillVo;
|
||||||
import co.yixiang.modules.activity.vo.YxStoreSeckillQueryVo;
|
import co.yixiang.modules.activity.vo.YxStoreSeckillQueryVo;
|
||||||
|
import co.yixiang.modules.product.domain.YxStoreProductAttrValue;
|
||||||
|
import co.yixiang.modules.product.service.YxStoreProductAttrService;
|
||||||
import co.yixiang.modules.product.service.YxStoreProductReplyService;
|
import co.yixiang.modules.product.service.YxStoreProductReplyService;
|
||||||
|
import co.yixiang.modules.product.service.dto.FromatDetailDto;
|
||||||
|
import co.yixiang.modules.product.service.dto.ProductFormatDto;
|
||||||
|
import co.yixiang.modules.product.service.dto.ProductResultDto;
|
||||||
|
import co.yixiang.modules.product.vo.YxStoreProductAttrQueryVo;
|
||||||
|
import co.yixiang.modules.template.domain.YxShippingTemplates;
|
||||||
|
import co.yixiang.modules.template.service.YxShippingTemplatesService;
|
||||||
import co.yixiang.utils.FileUtil;
|
import co.yixiang.utils.FileUtil;
|
||||||
import co.yixiang.utils.OrderUtil;
|
import co.yixiang.utils.OrderUtil;
|
||||||
|
import co.yixiang.utils.RedisUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
@ -35,11 +52,8 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.math.BigDecimal;
|
||||||
import java.util.Date;
|
import java.util.*;
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -59,7 +73,11 @@ public class YxStoreSeckillServiceImpl extends BaseServiceImpl<YxStoreSeckillMap
|
|||||||
@Autowired
|
@Autowired
|
||||||
private YxStoreProductReplyService replyService;
|
private YxStoreProductReplyService replyService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private YxStoreProductAttrService yxStoreProductAttrService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private YxShippingTemplatesService shippingTemplatesService;
|
||||||
/**
|
/**
|
||||||
* 退回库存减少销量
|
* 退回库存减少销量
|
||||||
* @param num 数量
|
* @param num 数量
|
||||||
@ -108,12 +126,31 @@ public class YxStoreSeckillServiceImpl extends BaseServiceImpl<YxStoreSeckillMap
|
|||||||
if(storeSeckill == null){
|
if(storeSeckill == null){
|
||||||
throw new YshopException("秒杀产品不存在或已下架");
|
throw new YshopException("秒杀产品不存在或已下架");
|
||||||
}
|
}
|
||||||
|
//获取商品sku
|
||||||
|
Map<String, Object> returnMap = yxStoreProductAttrService.getProductAttrDetail(storeSeckill.getProductId());
|
||||||
|
//获取运费模板名称
|
||||||
|
String storeFreePostage = RedisUtil.get("store_free_postage");
|
||||||
|
String tempName = "";
|
||||||
|
if(StrUtil.isBlank(storeFreePostage)
|
||||||
|
|| !NumberUtil.isNumber(storeFreePostage)
|
||||||
|
|| Integer.valueOf(storeFreePostage) == 0){
|
||||||
|
tempName = "全国包邮";
|
||||||
|
}else{
|
||||||
|
YxShippingTemplates shippingTemplates = shippingTemplatesService.getById(storeSeckill.getTempId());
|
||||||
|
if(ObjectUtil.isNotNull(shippingTemplates)){
|
||||||
|
tempName = shippingTemplates.getName();
|
||||||
|
}else {
|
||||||
|
throw new BadRequestException("请配置运费模板");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
return StoreSeckillVo.builder()
|
return StoreSeckillVo.builder()
|
||||||
|
.productAttr((List<YxStoreProductAttrQueryVo>)returnMap.get("productAttr"))
|
||||||
|
.productValue((Map<String, YxStoreProductAttrValue>)returnMap.get("productValue"))
|
||||||
.storeInfo(generator.convert(storeSeckill, YxStoreSeckillQueryVo.class))
|
.storeInfo(generator.convert(storeSeckill, YxStoreSeckillQueryVo.class))
|
||||||
.reply(replyService.getReply(storeSeckill.getProductId()))
|
.reply(replyService.getReply(storeSeckill.getProductId()))
|
||||||
.replyCount(replyService.productReplyCount(storeSeckill.getProductId()))
|
.replyCount(replyService.productReplyCount(storeSeckill.getProductId()))
|
||||||
|
.tempName(tempName)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,4 +237,98 @@ public class YxStoreSeckillServiceImpl extends BaseServiceImpl<YxStoreSeckillMap
|
|||||||
}
|
}
|
||||||
FileUtil.downloadExcel(list, response);
|
FileUtil.downloadExcel(list, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean saveSeckill(YxStoreSeckillDto resources) {
|
||||||
|
ProductResultDto resultDTO = this.computedProduct(resources.getAttrs());
|
||||||
|
|
||||||
|
//添加商品
|
||||||
|
YxStoreSeckill yxStoreSeckill = new YxStoreSeckill();
|
||||||
|
BeanUtil.copyProperties(resources,yxStoreSeckill,"images");
|
||||||
|
if(resources.getImages().isEmpty()) throw new YshopException("请上传轮播图");
|
||||||
|
|
||||||
|
yxStoreSeckill.setPrice(BigDecimal.valueOf(resultDTO.getMinPrice()));
|
||||||
|
yxStoreSeckill.setCost(new BigDecimal(resultDTO.getMinCost()));
|
||||||
|
yxStoreSeckill.setStock(resultDTO.getStock());
|
||||||
|
yxStoreSeckill.setImages(String.join(",", resources.getImages()));
|
||||||
|
this.saveOrUpdate(yxStoreSeckill);
|
||||||
|
|
||||||
|
//属性处理
|
||||||
|
//处理单sKu
|
||||||
|
if(SpecTypeEnum.TYPE_0.getValue().equals(resources.getSpecType())){
|
||||||
|
FromatDetailDto fromatDetailDto = FromatDetailDto.builder()
|
||||||
|
.value("规格")
|
||||||
|
.detailValue("")
|
||||||
|
.attrHidden("")
|
||||||
|
.detail(ListUtil.toList("默认"))
|
||||||
|
.build();
|
||||||
|
List<Map<String,Object>> attrs = resources.getAttrs();
|
||||||
|
Map<String,Object> map = attrs.get(0);
|
||||||
|
map.put("value1","规格");
|
||||||
|
map.put("detail", MapUtil.of(new String[][] {
|
||||||
|
{"规格", "默认"}
|
||||||
|
}));
|
||||||
|
yxStoreProductAttrService.insertYxStoreProductAttr(ListUtil.toList(fromatDetailDto),
|
||||||
|
ListUtil.toList(map),resources.getProductId());
|
||||||
|
}else{
|
||||||
|
yxStoreProductAttrService.insertYxStoreProductAttr(resources.getItems(),
|
||||||
|
resources.getAttrs(),resources.getProductId());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算产品数据
|
||||||
|
* @param attrs attrs
|
||||||
|
* @return ProductResultDto
|
||||||
|
*/
|
||||||
|
private ProductResultDto computedProduct(List<Map<String,Object>> attrs){
|
||||||
|
//取最小价格
|
||||||
|
Double minPrice = ListMapToListBean(attrs)
|
||||||
|
.stream()
|
||||||
|
.map(ProductFormatDto::getPrice)
|
||||||
|
.min(Comparator.naturalOrder())
|
||||||
|
.orElse(0d);
|
||||||
|
|
||||||
|
Double minOtPrice = ListMapToListBean(attrs)
|
||||||
|
.stream()
|
||||||
|
.map(ProductFormatDto::getOtPrice)
|
||||||
|
.min(Comparator.naturalOrder())
|
||||||
|
.orElse(0d);
|
||||||
|
|
||||||
|
Double minCost = ListMapToListBean(attrs)
|
||||||
|
.stream()
|
||||||
|
.map(ProductFormatDto::getCost)
|
||||||
|
.min(Comparator.naturalOrder())
|
||||||
|
.orElse(0d);
|
||||||
|
//计算库存
|
||||||
|
Integer stock = ListMapToListBean(attrs)
|
||||||
|
.stream()
|
||||||
|
.map(ProductFormatDto::getStock)
|
||||||
|
.reduce(Integer::sum)
|
||||||
|
.orElse(0);
|
||||||
|
|
||||||
|
if(stock <= 0) throw new YshopException("库存不能低于0");
|
||||||
|
|
||||||
|
return ProductResultDto.builder()
|
||||||
|
.minPrice(minPrice)
|
||||||
|
.minOtPrice(minOtPrice)
|
||||||
|
.minCost(minCost)
|
||||||
|
.stock(stock)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mapTobean
|
||||||
|
* @param listMap listMap
|
||||||
|
* @return list
|
||||||
|
*/
|
||||||
|
private List<ProductFormatDto> ListMapToListBean(List<Map<String, Object>> listMap){
|
||||||
|
List<ProductFormatDto> list = new ArrayList<>();
|
||||||
|
// 循环遍历出map对象
|
||||||
|
for (Map<String, Object> m : listMap) {
|
||||||
|
list.add(BeanUtil.mapToBean(m,ProductFormatDto.class,true));
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,16 @@
|
|||||||
package co.yixiang.modules.activity.vo;
|
package co.yixiang.modules.activity.vo;
|
||||||
|
|
||||||
import co.yixiang.modules.activity.service.dto.PinkDto;
|
import co.yixiang.modules.activity.service.dto.PinkDto;
|
||||||
|
import co.yixiang.modules.product.domain.YxStoreProductAttrValue;
|
||||||
|
import co.yixiang.modules.product.vo.YxStoreProductAttrQueryVo;
|
||||||
import co.yixiang.modules.product.vo.YxStoreProductReplyQueryVo;
|
import co.yixiang.modules.product.vo.YxStoreProductReplyQueryVo;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@ -38,5 +43,8 @@ public class StoreCombinationVo implements Serializable {
|
|||||||
|
|
||||||
private String tempName;
|
private String tempName;
|
||||||
|
|
||||||
|
private List<YxStoreProductAttrQueryVo> productAttr = new ArrayList();
|
||||||
|
|
||||||
|
private Map<String, YxStoreProductAttrValue> productValue = new LinkedHashMap<>();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,18 @@
|
|||||||
package co.yixiang.modules.activity.vo;
|
package co.yixiang.modules.activity.vo;
|
||||||
|
|
||||||
|
|
||||||
|
import co.yixiang.modules.product.domain.YxStoreProductAttrValue;
|
||||||
|
import co.yixiang.modules.product.vo.YxStoreProductAttrQueryVo;
|
||||||
import co.yixiang.modules.product.vo.YxStoreProductReplyQueryVo;
|
import co.yixiang.modules.product.vo.YxStoreProductReplyQueryVo;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@ -34,6 +40,11 @@ public class StoreSeckillVo implements Serializable {
|
|||||||
@ApiModelProperty(value = "秒杀产品用户是否收藏")
|
@ApiModelProperty(value = "秒杀产品用户是否收藏")
|
||||||
private Boolean userCollect = false;
|
private Boolean userCollect = false;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "模板名称")
|
||||||
|
private String tempName;
|
||||||
|
|
||||||
|
private List<YxStoreProductAttrQueryVo> productAttr = new ArrayList();
|
||||||
|
|
||||||
|
private Map<String, YxStoreProductAttrValue> productValue = new LinkedHashMap<>();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -133,7 +133,7 @@ public class YxStoreCartServiceImpl extends BaseServiceImpl<StoreCartMapper, YxS
|
|||||||
|
|
||||||
//普通商品库存
|
//普通商品库存
|
||||||
int stock = productService.getProductStock(cart.getProductId()
|
int stock = productService.getProductStock(cart.getProductId()
|
||||||
,cart.getProductAttrUnique());
|
,cart.getProductAttrUnique(),"");
|
||||||
if(stock < cartNum){
|
if(stock < cartNum){
|
||||||
throw new YshopException("该产品库存不足"+cartNum);
|
throw new YshopException("该产品库存不足"+cartNum);
|
||||||
}
|
}
|
||||||
@ -335,34 +335,31 @@ public class YxStoreCartServiceImpl extends BaseServiceImpl<StoreCartMapper, YxS
|
|||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
//拼团
|
//拼团
|
||||||
if(combinationId != null && combinationId > 0){
|
if(combinationId != null && combinationId > 0){
|
||||||
YxStoreCombination storeCombination = storeCombinationService
|
YxStoreProduct product = productService
|
||||||
.lambdaQuery().eq(YxStoreCombination::getId,combinationId)
|
.lambdaQuery().eq(YxStoreProduct::getId,productId)
|
||||||
.eq(YxStoreCombination::getIsShow, ShopCommonEnum.SHOW_1.getValue())
|
.eq(YxStoreProduct::getIsShow,ShopCommonEnum.SHOW_1.getValue())
|
||||||
.le(YxStoreCombination::getStartTime,now)
|
|
||||||
.ge(YxStoreCombination::getStopTime,now)
|
|
||||||
.one();
|
.one();
|
||||||
if(storeCombination == null) throw new YshopException("该产品已下架或删除");
|
if(product == null){
|
||||||
if(storeCombination.getStock() < cartNum) throw new YshopException("该产品库存不足");
|
|
||||||
//秒杀
|
|
||||||
}else if(seckillId != null && seckillId > 0){
|
|
||||||
YxStoreSeckill yxStoreSeckill = storeSeckillService
|
|
||||||
.lambdaQuery().eq(YxStoreSeckill::getId,seckillId)
|
|
||||||
.eq(YxStoreSeckill::getIsShow, ShopCommonEnum.SHOW_1.getValue())
|
|
||||||
.le(YxStoreSeckill::getStartTime,now)
|
|
||||||
.ge(YxStoreSeckill::getStopTime,now)
|
|
||||||
.one();
|
|
||||||
if(yxStoreSeckill == null){
|
|
||||||
throw new YshopException("该产品已下架或删除");
|
throw new YshopException("该产品已下架或删除");
|
||||||
}
|
}
|
||||||
if(yxStoreSeckill.getStock() < cartNum){
|
|
||||||
throw new YshopException("该产品库存不足");
|
int stock = productService.getProductStock(productId,productAttrUnique,"pink");
|
||||||
|
if(stock < cartNum){
|
||||||
|
throw new YshopException(product.getStoreName()+"库存不足"+cartNum);
|
||||||
}
|
}
|
||||||
int seckillOrderCount = storeOrderService.count(new QueryWrapper<YxStoreOrder>()
|
//秒杀
|
||||||
.lambda().eq(YxStoreOrder::getUid, uid)
|
}else if(seckillId != null && seckillId > 0){
|
||||||
.eq(YxStoreOrder::getPaid, OrderInfoEnum.PAY_STATUS_1.getValue())
|
YxStoreProduct product = productService
|
||||||
.eq(YxStoreOrder::getSeckillId,seckillId));
|
.lambdaQuery().eq(YxStoreProduct::getId,productId)
|
||||||
if(yxStoreSeckill.getNum() <= seckillOrderCount || yxStoreSeckill.getNum() < cartNum){
|
.eq(YxStoreProduct::getIsShow,ShopCommonEnum.SHOW_1.getValue())
|
||||||
throw new YshopException("每人限购:"+yxStoreSeckill.getNum()+"件");
|
.one();
|
||||||
|
if(product == null){
|
||||||
|
throw new YshopException("该产品已下架或删除");
|
||||||
|
}
|
||||||
|
|
||||||
|
int stock = productService.getProductStock(productId,productAttrUnique,"seckill");
|
||||||
|
if(stock < cartNum){
|
||||||
|
throw new YshopException(product.getStoreName()+"库存不足"+cartNum);
|
||||||
}
|
}
|
||||||
//砍价
|
//砍价
|
||||||
}else if(bargainId != null && bargainId > 0){
|
}else if(bargainId != null && bargainId > 0){
|
||||||
@ -388,7 +385,7 @@ public class YxStoreCartServiceImpl extends BaseServiceImpl<StoreCartMapper, YxS
|
|||||||
throw new YshopException("该产品已下架或删除");
|
throw new YshopException("该产品已下架或删除");
|
||||||
}
|
}
|
||||||
|
|
||||||
int stock = productService.getProductStock(productId,productAttrUnique);
|
int stock = productService.getProductStock(productId,productAttrUnique,"");
|
||||||
if(stock < cartNum){
|
if(stock < cartNum){
|
||||||
throw new YshopException(product.getStoreName()+"库存不足"+cartNum);
|
throw new YshopException(product.getStoreName()+"库存不足"+cartNum);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1492,6 +1492,7 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
|
|||||||
* @param cartInfo 购物车
|
* @param cartInfo 购物车
|
||||||
*/
|
*/
|
||||||
public void deStockIncSale(List<YxStoreCartQueryVo> cartInfo) {
|
public void deStockIncSale(List<YxStoreCartQueryVo> cartInfo) {
|
||||||
|
//todo 活动商品库存待处理
|
||||||
for (YxStoreCartQueryVo storeCartVO : cartInfo) {
|
for (YxStoreCartQueryVo storeCartVO : cartInfo) {
|
||||||
Long combinationId = storeCartVO.getCombinationId();
|
Long combinationId = storeCartVO.getCombinationId();
|
||||||
Long seckillId = storeCartVO.getSeckillId();
|
Long seckillId = storeCartVO.getSeckillId();
|
||||||
|
|||||||
@ -107,6 +107,7 @@ public class YxStoreProductAttrValue implements Serializable {
|
|||||||
@ApiModelProperty(value = "体积")
|
@ApiModelProperty(value = "体积")
|
||||||
private BigDecimal volume;
|
private BigDecimal volume;
|
||||||
|
|
||||||
|
|
||||||
/** 一级返佣 */
|
/** 一级返佣 */
|
||||||
@ApiModelProperty(value = "一级返佣")
|
@ApiModelProperty(value = "一级返佣")
|
||||||
private BigDecimal brokerage;
|
private BigDecimal brokerage;
|
||||||
|
|||||||
@ -60,7 +60,7 @@ public interface YxStoreProductService extends BaseService<YxStoreProduct>{
|
|||||||
* @param unique sku唯一值
|
* @param unique sku唯一值
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
int getProductStock(Long productId, String unique);
|
int getProductStock(Long productId, String unique,String type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品列表
|
* 商品列表
|
||||||
|
|||||||
@ -110,6 +110,10 @@ public class YxStoreProductAttrServiceImpl extends BaseServiceImpl<StoreProductA
|
|||||||
.brokerage(BigDecimal.valueOf(productFormatDto.getBrokerage()))
|
.brokerage(BigDecimal.valueOf(productFormatDto.getBrokerage()))
|
||||||
.brokerageTwo(BigDecimal.valueOf(productFormatDto.getBrokerageTwo()))
|
.brokerageTwo(BigDecimal.valueOf(productFormatDto.getBrokerageTwo()))
|
||||||
.stock(productFormatDto.getStock())
|
.stock(productFormatDto.getStock())
|
||||||
|
.pinkPrice(BigDecimal.valueOf(productFormatDto.getPinkPrice()==null?0:productFormatDto.getPinkPrice()))
|
||||||
|
.seckillPrice(BigDecimal.valueOf(productFormatDto.getSeckillPrice()==null?0:productFormatDto.getSeckillPrice()))
|
||||||
|
.pinkStock(productFormatDto.getPinkStock()==null?0:productFormatDto.getPinkStock())
|
||||||
|
.seckillStock(productFormatDto.getSeckillStock()==null?0:productFormatDto.getSeckillStock())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -62,6 +62,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -178,14 +179,18 @@ public class YxStoreProductServiceImpl extends BaseServiceImpl<StoreProductMappe
|
|||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int getProductStock(Long productId, String unique) {
|
public int getProductStock(Long productId, String unique, String type) {
|
||||||
YxStoreProductAttrValue storeProductAttrValue = yxStoreProductAttrValueService
|
YxStoreProductAttrValue storeProductAttrValue = yxStoreProductAttrValueService
|
||||||
.getOne(Wrappers.<YxStoreProductAttrValue>lambdaQuery()
|
.getOne(Wrappers.<YxStoreProductAttrValue>lambdaQuery()
|
||||||
.eq(YxStoreProductAttrValue::getUnique, unique)
|
.eq(YxStoreProductAttrValue::getUnique, unique)
|
||||||
.eq(YxStoreProductAttrValue::getProductId, productId));
|
.eq(YxStoreProductAttrValue::getProductId, productId));
|
||||||
|
|
||||||
if (storeProductAttrValue == null) return 0;
|
if (storeProductAttrValue == null) return 0;
|
||||||
|
if("pink".equals(type)){
|
||||||
|
return storeProductAttrValue.getPinkStock();
|
||||||
|
}else if ("seckill".equals(type)){
|
||||||
|
return storeProductAttrValue.getSeckillStock();
|
||||||
|
}
|
||||||
return storeProductAttrValue.getStock();
|
return storeProductAttrValue.getStock();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -573,7 +578,15 @@ public class YxStoreProductServiceImpl extends BaseServiceImpl<StoreProductMappe
|
|||||||
String key = "value" + (j + 1);
|
String key = "value" + (j + 1);
|
||||||
valueMap.put(key,detailValues[j]);
|
valueMap.put(key,detailValues[j]);
|
||||||
}
|
}
|
||||||
|
// /** 拼团属性对应的金额 */
|
||||||
|
// private BigDecimal pinkPrice;
|
||||||
|
//
|
||||||
|
// /** 秒杀属性对应的金额 */
|
||||||
|
// private BigDecimal seckillPrice;
|
||||||
|
// /** 拼团库存属性对应的库存 */
|
||||||
|
// private Integer pinkStock;
|
||||||
|
//
|
||||||
|
// private Integer seckillStock;
|
||||||
valueMap.put("detail",detail);
|
valueMap.put("detail",detail);
|
||||||
valueMap.put("pic","");
|
valueMap.put("pic","");
|
||||||
valueMap.put("price",0);
|
valueMap.put("price",0);
|
||||||
@ -585,6 +598,10 @@ public class YxStoreProductServiceImpl extends BaseServiceImpl<StoreProductMappe
|
|||||||
valueMap.put("volume",0);
|
valueMap.put("volume",0);
|
||||||
valueMap.put("brokerage",0);
|
valueMap.put("brokerage",0);
|
||||||
valueMap.put("brokerage_two",0);
|
valueMap.put("brokerage_two",0);
|
||||||
|
valueMap.put("pink_price",0);
|
||||||
|
valueMap.put("seckill_price",0);
|
||||||
|
valueMap.put("pink_stock",0);
|
||||||
|
valueMap.put("seckill_stock",0);
|
||||||
if(id > 0){
|
if(id > 0){
|
||||||
YxStoreProductAttrValue storeProductAttrValue = yxStoreProductAttrValueService
|
YxStoreProductAttrValue storeProductAttrValue = yxStoreProductAttrValueService
|
||||||
.getOne(Wrappers.<YxStoreProductAttrValue>lambdaQuery()
|
.getOne(Wrappers.<YxStoreProductAttrValue>lambdaQuery()
|
||||||
@ -601,6 +618,10 @@ public class YxStoreProductServiceImpl extends BaseServiceImpl<StoreProductMappe
|
|||||||
valueMap.put("volume",storeProductAttrValue.getVolume());
|
valueMap.put("volume",storeProductAttrValue.getVolume());
|
||||||
valueMap.put("brokerage",storeProductAttrValue.getBrokerage());
|
valueMap.put("brokerage",storeProductAttrValue.getBrokerage());
|
||||||
valueMap.put("brokerage_two",storeProductAttrValue.getBrokerageTwo());
|
valueMap.put("brokerage_two",storeProductAttrValue.getBrokerageTwo());
|
||||||
|
valueMap.put("pink_price",storeProductAttrValue.getPinkPrice());
|
||||||
|
valueMap.put("seckill_price",storeProductAttrValue.getSeckillPrice());
|
||||||
|
valueMap.put("pink_stock",storeProductAttrValue.getPinkStock());
|
||||||
|
valueMap.put("seckill_stock",storeProductAttrValue.getSeckillStock());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -734,25 +755,25 @@ public class YxStoreProductServiceImpl extends BaseServiceImpl<StoreProductMappe
|
|||||||
|
|
||||||
if(isActivity){
|
if(isActivity){
|
||||||
headerMap.put("title","拼团价");
|
headerMap.put("title","拼团价");
|
||||||
headerMap.put("slot", "pinkPrice");
|
headerMap.put("slot", "pink_price");
|
||||||
headerMap.put("align",align);
|
headerMap.put("align",align);
|
||||||
headerMap.put("minWidth",140);
|
headerMap.put("minWidth",140);
|
||||||
headerMapList.add(ObjectUtil.clone(headerMap));
|
headerMapList.add(ObjectUtil.clone(headerMap));
|
||||||
|
|
||||||
headerMap.put("title","拼团活动库存");
|
headerMap.put("title","拼团活动库存");
|
||||||
headerMap.put("slot", "pinkStock");
|
headerMap.put("slot", "pink_stock");
|
||||||
headerMap.put("align",align);
|
headerMap.put("align",align);
|
||||||
headerMap.put("minWidth",140);
|
headerMap.put("minWidth",140);
|
||||||
headerMapList.add(ObjectUtil.clone(headerMap));
|
headerMapList.add(ObjectUtil.clone(headerMap));
|
||||||
|
|
||||||
headerMap.put("title","秒杀价");
|
headerMap.put("title","秒杀价");
|
||||||
headerMap.put("slot", "seckillPrice");
|
headerMap.put("slot", "seckill_price");
|
||||||
headerMap.put("align",align);
|
headerMap.put("align",align);
|
||||||
headerMap.put("minWidth",140);
|
headerMap.put("minWidth",140);
|
||||||
headerMapList.add(ObjectUtil.clone(headerMap));
|
headerMapList.add(ObjectUtil.clone(headerMap));
|
||||||
|
|
||||||
headerMap.put("title","秒杀活动库存");
|
headerMap.put("title","秒杀活动库存");
|
||||||
headerMap.put("slot", "seckillStock");
|
headerMap.put("slot", "seckill_stock");
|
||||||
headerMap.put("align",align);
|
headerMap.put("align",align);
|
||||||
headerMap.put("minWidth",140);
|
headerMap.put("minWidth",140);
|
||||||
headerMapList.add(ObjectUtil.clone(headerMap));
|
headerMapList.add(ObjectUtil.clone(headerMap));
|
||||||
|
|||||||
@ -5,12 +5,26 @@
|
|||||||
*/
|
*/
|
||||||
package co.yixiang.modules.activity.rest;
|
package co.yixiang.modules.activity.rest;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import co.yixiang.enums.SpecTypeEnum;
|
||||||
import co.yixiang.logging.aop.log.Log;
|
import co.yixiang.logging.aop.log.Log;
|
||||||
import co.yixiang.modules.activity.domain.YxStoreSeckill;
|
import co.yixiang.modules.activity.domain.YxStoreSeckill;
|
||||||
|
import co.yixiang.modules.activity.domain.YxStoreSeckill;
|
||||||
import co.yixiang.modules.activity.service.YxStoreSeckillService;
|
import co.yixiang.modules.activity.service.YxStoreSeckillService;
|
||||||
|
import co.yixiang.modules.activity.service.dto.YxStoreSeckillDto;
|
||||||
|
import co.yixiang.modules.activity.service.dto.YxStoreSeckillDto;
|
||||||
import co.yixiang.modules.activity.service.dto.YxStoreSeckillQueryCriteria;
|
import co.yixiang.modules.activity.service.dto.YxStoreSeckillQueryCriteria;
|
||||||
import co.yixiang.modules.aop.ForbidSubmit;
|
import co.yixiang.modules.aop.ForbidSubmit;
|
||||||
|
import co.yixiang.modules.product.domain.YxStoreProductAttrResult;
|
||||||
|
import co.yixiang.modules.product.service.YxStoreProductAttrResultService;
|
||||||
|
import co.yixiang.modules.product.service.YxStoreProductRuleService;
|
||||||
|
import co.yixiang.modules.product.service.dto.ProductFormatDto;
|
||||||
|
import co.yixiang.modules.template.domain.YxShippingTemplates;
|
||||||
|
import co.yixiang.modules.template.service.YxShippingTemplatesService;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
@ -18,13 +32,9 @@ import org.springframework.http.HttpStatus;
|
|||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import java.util.*;
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author hupeng
|
* @author hupeng
|
||||||
@ -36,9 +46,14 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
public class StoreSeckillController {
|
public class StoreSeckillController {
|
||||||
|
|
||||||
private final YxStoreSeckillService yxStoreSeckillService;
|
private final YxStoreSeckillService yxStoreSeckillService;
|
||||||
|
private final YxShippingTemplatesService yxShippingTemplatesService;
|
||||||
public StoreSeckillController(YxStoreSeckillService yxStoreSeckillService) {
|
private final YxStoreProductRuleService yxStoreProductRuleService;
|
||||||
|
private final YxStoreProductAttrResultService yxStoreProductAttrResultService;
|
||||||
|
public StoreSeckillController(YxStoreSeckillService yxStoreSeckillService, YxShippingTemplatesService yxShippingTemplatesService, YxStoreProductRuleService yxStoreProductRuleService, YxStoreProductAttrResultService yxStoreProductAttrResultService) {
|
||||||
this.yxStoreSeckillService = yxStoreSeckillService;
|
this.yxStoreSeckillService = yxStoreSeckillService;
|
||||||
|
this.yxShippingTemplatesService = yxShippingTemplatesService;
|
||||||
|
this.yxStoreProductRuleService = yxStoreProductRuleService;
|
||||||
|
this.yxStoreProductAttrResultService = yxStoreProductAttrResultService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log("列表")
|
@Log("列表")
|
||||||
@ -73,4 +88,78 @@ public class StoreSeckillController {
|
|||||||
yxStoreSeckillService.removeById(id);
|
yxStoreSeckillService.removeById(id);
|
||||||
return new ResponseEntity(HttpStatus.OK);
|
return new ResponseEntity(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Log("新增秒杀")
|
||||||
|
@ApiOperation(value = "新增秒杀")
|
||||||
|
@PostMapping(value = "/yxStoreSeckill")
|
||||||
|
@PreAuthorize("hasAnyRole('admin','YXSTORESECKILL_ALL','YXSTORESECKILL_EDIT')")
|
||||||
|
public ResponseEntity add(@Validated @RequestBody YxStoreSeckillDto resources){
|
||||||
|
return new ResponseEntity<>(yxStoreSeckillService.saveSeckill(resources),HttpStatus.CREATED);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取商品信息")
|
||||||
|
@GetMapping(value = "/yxStoreSecKill/info/{id}")
|
||||||
|
public ResponseEntity info(@PathVariable Long id){
|
||||||
|
Map<String,Object> map = new LinkedHashMap<>(3);
|
||||||
|
|
||||||
|
//运费模板
|
||||||
|
List<YxShippingTemplates> shippingTemplatesList = yxShippingTemplatesService.list();
|
||||||
|
map.put("tempList", shippingTemplatesList);
|
||||||
|
|
||||||
|
// //商品分类
|
||||||
|
// List<YxStoreCategory> storeCategories = yxStoreCategoryService.lambdaQuery()
|
||||||
|
// .eq(YxStoreCategory::getIsShow, ShopCommonEnum.SHOW_1.getValue())
|
||||||
|
// .list();
|
||||||
|
|
||||||
|
// List<Map<String,Object>> cateList = new ArrayList<>();
|
||||||
|
// map.put("cateList", this.makeCate(storeCategories,cateList,0,1));
|
||||||
|
|
||||||
|
//商品规格
|
||||||
|
map.put("ruleList",yxStoreProductRuleService.list());
|
||||||
|
|
||||||
|
|
||||||
|
if(id == 0){
|
||||||
|
return new ResponseEntity<>(map,HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
//处理商品详情
|
||||||
|
YxStoreSeckill yxStoreSeckill = yxStoreSeckillService.getById(id);
|
||||||
|
YxStoreSeckillDto productDto = new YxStoreSeckillDto();
|
||||||
|
BeanUtil.copyProperties(yxStoreSeckill,productDto,"images");
|
||||||
|
productDto.setSliderImage(Arrays.asList(yxStoreSeckill.getImages().split(",")));
|
||||||
|
YxStoreProductAttrResult storeProductAttrResult = yxStoreProductAttrResultService
|
||||||
|
.getOne(Wrappers.<YxStoreProductAttrResult>lambdaQuery()
|
||||||
|
.eq(YxStoreProductAttrResult::getProductId,yxStoreSeckill.getProductId()).last("limit 1"));
|
||||||
|
JSONObject result = JSON.parseObject(storeProductAttrResult.getResult());
|
||||||
|
|
||||||
|
if(SpecTypeEnum.TYPE_1.getValue().equals(yxStoreSeckill.getSpecType())){
|
||||||
|
productDto.setAttr(new ProductFormatDto());
|
||||||
|
productDto.setAttrs(result.getObject("value", ArrayList.class));
|
||||||
|
productDto.setItems(result.getObject("attr",ArrayList.class));
|
||||||
|
}else{
|
||||||
|
Map<String,Object> mapAttr = (Map<String,Object>)result.getObject("value",ArrayList.class).get(0);
|
||||||
|
ProductFormatDto productFormatDto = ProductFormatDto.builder()
|
||||||
|
.pic(mapAttr.get("pic").toString())
|
||||||
|
.price(Double.valueOf(mapAttr.get("price").toString()))
|
||||||
|
.pinkPrice(Double.valueOf(mapAttr.get("pink_price").toString()))
|
||||||
|
.cost(Double.valueOf(mapAttr.get("cost").toString()))
|
||||||
|
.otPrice(Double.valueOf(mapAttr.get("ot_price").toString()))
|
||||||
|
.stock(Integer.valueOf(mapAttr.get("stock").toString()))
|
||||||
|
.pinkStock(Integer.valueOf(mapAttr.get("pink_stock").toString()))
|
||||||
|
.barCode(mapAttr.get("bar_code").toString())
|
||||||
|
.weight(Double.valueOf(mapAttr.get("weight").toString()))
|
||||||
|
.volume(Double.valueOf(mapAttr.get("volume").toString()))
|
||||||
|
.brokerage(Double.valueOf(mapAttr.get("brokerage").toString()))
|
||||||
|
.brokerageTwo(Double.valueOf(mapAttr.get("brokerage_two").toString()))
|
||||||
|
.brokerageTwo(Double.valueOf(mapAttr.get("brokerage_two").toString()))
|
||||||
|
.brokerageTwo(Double.valueOf(mapAttr.get("brokerage_two").toString()))
|
||||||
|
.build();
|
||||||
|
productDto.setAttr(productFormatDto);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
map.put("productInfo",productDto);
|
||||||
|
|
||||||
|
return new ResponseEntity<>(map,HttpStatus.OK);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user