|
|
|
@ -10,21 +10,25 @@ package co.yixiang.modules.activity.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
|
import cn.hutool.core.collection.ListUtil; |
|
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
|
import cn.hutool.core.util.NumberUtil; |
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
|
import cn.iocoder.yudao.framework.common.exception.YshopException; |
|
|
|
|
import co.yixiang.common.service.impl.BaseServiceImpl; |
|
|
|
|
import co.yixiang.common.utils.QueryHelpPlus; |
|
|
|
|
import co.yixiang.constant.ShopConstants; |
|
|
|
|
import co.yixiang.dozer.service.IGenerator; |
|
|
|
|
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.service.YxStoreSeckillService; |
|
|
|
|
import co.yixiang.modules.activity.service.dto.SeckillTimeDto; |
|
|
|
|
import co.yixiang.modules.activity.service.dto.YxStoreSeckillDto; |
|
|
|
|
import co.yixiang.modules.activity.service.dto.YxStoreSeckillQueryCriteria; |
|
|
|
|
import co.yixiang.modules.activity.service.mapper.YxStoreSeckillMapper; |
|
|
|
|
import co.yixiang.modules.activity.vo.SeckillConfigVo; |
|
|
|
|
import co.yixiang.modules.activity.vo.StoreSeckillVo; |
|
|
|
|
import co.yixiang.modules.activity.vo.YxStoreSeckillQueryVo; |
|
|
|
|
import co.yixiang.modules.product.domain.YxStoreProduct; |
|
|
|
@ -36,13 +40,18 @@ import co.yixiang.modules.product.service.dto.ProductFormatDto;
|
|
|
|
|
import co.yixiang.modules.product.service.dto.ProductResultDto; |
|
|
|
|
import co.yixiang.modules.product.service.mapper.StoreProductMapper; |
|
|
|
|
import co.yixiang.modules.product.vo.YxStoreProductAttrQueryVo; |
|
|
|
|
import co.yixiang.modules.shop.domain.YxSystemGroupData; |
|
|
|
|
import co.yixiang.modules.shop.service.YxSystemConfigService; |
|
|
|
|
import co.yixiang.modules.shop.service.YxSystemGroupDataService; |
|
|
|
|
import co.yixiang.modules.shop.service.dto.YxSystemGroupDataQueryCriteria; |
|
|
|
|
import co.yixiang.modules.template.domain.YxShippingTemplates; |
|
|
|
|
import co.yixiang.modules.template.service.YxShippingTemplatesService; |
|
|
|
|
import co.yixiang.utils.FileUtil; |
|
|
|
|
import co.yixiang.utils.OrderUtil; |
|
|
|
|
|
|
|
|
|
import co.yixiang.utils.RedisUtils; |
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
@ -55,7 +64,9 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.math.BigDecimal; |
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.concurrent.atomic.AtomicInteger; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -87,6 +98,74 @@ public class YxStoreSeckillServiceImpl extends BaseServiceImpl<YxStoreSeckillMap
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private StoreProductMapper storeProductMapper; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private YxSystemGroupDataService yxSystemGroupDataService; |
|
|
|
|
@Override |
|
|
|
|
public SeckillConfigVo getStoreSeckil() { |
|
|
|
|
//获取秒杀配置
|
|
|
|
|
AtomicInteger seckillTimeIndex = new AtomicInteger(); |
|
|
|
|
SeckillConfigVo seckillConfigVo = new SeckillConfigVo(); |
|
|
|
|
|
|
|
|
|
YxSystemGroupDataQueryCriteria queryCriteria = new YxSystemGroupDataQueryCriteria(); |
|
|
|
|
queryCriteria.setGroupName(ShopConstants.ZSW_SECKILL_TIME); |
|
|
|
|
queryCriteria.setStatus(1); |
|
|
|
|
List<YxSystemGroupData> yxSystemGroupDataList = yxSystemGroupDataService.queryAll(queryCriteria); |
|
|
|
|
|
|
|
|
|
List<SeckillTimeDto> list = new ArrayList<>(); |
|
|
|
|
int today = OrderUtil.dateToTimestampT(DateUtil.beginOfDay(new Date())); |
|
|
|
|
yxSystemGroupDataList.forEach(i -> { |
|
|
|
|
String jsonStr = i.getValue(); |
|
|
|
|
JSONObject jsonObject = JSON.parseObject(jsonStr); |
|
|
|
|
int time = Integer.valueOf(jsonObject.get("time").toString());//开启时间(几点) 5
|
|
|
|
|
int continued = Integer.valueOf(jsonObject.get("continued").toString());//活动持续事件 3
|
|
|
|
|
String rule=""; |
|
|
|
|
if (jsonObject.get("rule")!=null){ |
|
|
|
|
rule=jsonObject.get("rule").toString(); |
|
|
|
|
} |
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("HH"); |
|
|
|
|
String nowTime = sdf.format(new Date()); |
|
|
|
|
String index = nowTime.substring(0, 1); |
|
|
|
|
int currentHour = "0".equals(index) ? Integer.valueOf(nowTime.substring(1, 2)) : Integer.valueOf(nowTime); |
|
|
|
|
SeckillTimeDto seckillTimeDto = new SeckillTimeDto(); |
|
|
|
|
seckillTimeDto.setId(i.getId()); |
|
|
|
|
//活动结束时间
|
|
|
|
|
int activityEndHour = time + continued; |
|
|
|
|
if (activityEndHour > 24) { |
|
|
|
|
seckillTimeDto.setState("即将开始"); |
|
|
|
|
seckillTimeDto.setTime(jsonObject.get("time").toString().length() > 1 ? jsonObject.get("time").toString() + ":00" : "0" + jsonObject.get("time").toString() + ":00"); |
|
|
|
|
seckillTimeDto.setStatus(2); |
|
|
|
|
seckillTimeDto.setRule(rule); |
|
|
|
|
seckillTimeDto.setStop(today + activityEndHour * 3600); |
|
|
|
|
} else { |
|
|
|
|
if (currentHour >= time && currentHour < activityEndHour) { |
|
|
|
|
seckillTimeDto.setState("抢购中"); |
|
|
|
|
seckillTimeDto.setTime(jsonObject.get("time").toString().length() > 1 ? jsonObject.get("time").toString() + ":00" : "0" + jsonObject.get("time").toString() + ":00"); |
|
|
|
|
seckillTimeDto.setStatus(1); |
|
|
|
|
seckillTimeDto.setRule(rule); |
|
|
|
|
seckillTimeDto.setStop(today + activityEndHour * 3600); |
|
|
|
|
seckillTimeIndex.set(yxSystemGroupDataList.indexOf(i)); |
|
|
|
|
} else if (currentHour < time) { |
|
|
|
|
seckillTimeDto.setState("即将开始"); |
|
|
|
|
seckillTimeDto.setTime(jsonObject.get("time").toString().length() > 1 ? jsonObject.get("time").toString() + ":00" : "0" + jsonObject.get("time").toString() + ":00"); |
|
|
|
|
seckillTimeDto.setStatus(2); |
|
|
|
|
seckillTimeDto.setRule(rule); |
|
|
|
|
seckillTimeDto.setStop(OrderUtil.dateToTimestamp(new Date()) + activityEndHour * 3600); |
|
|
|
|
} else if (currentHour >= activityEndHour) { |
|
|
|
|
seckillTimeDto.setState("已结束"); |
|
|
|
|
seckillTimeDto.setTime(jsonObject.get("time").toString().length() > 1 ? jsonObject.get("time").toString() + ":00" : "0" + jsonObject.get("time").toString() + ":00"); |
|
|
|
|
seckillTimeDto.setStatus(0); |
|
|
|
|
seckillTimeDto.setRule(rule); |
|
|
|
|
seckillTimeDto.setStop(today + activityEndHour * 3600); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
list.add(seckillTimeDto); |
|
|
|
|
}); |
|
|
|
|
seckillConfigVo.setSeckillTimeIndex(seckillTimeIndex.get()); |
|
|
|
|
seckillConfigVo.setSeckillTime(list); |
|
|
|
|
return seckillConfigVo; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 产品详情 |
|
|
|
|
* @param id 砍价商品id |
|
|
|
@ -159,6 +238,18 @@ public class YxStoreSeckillServiceImpl extends BaseServiceImpl<YxStoreSeckillMap
|
|
|
|
|
}); |
|
|
|
|
return yxStoreSeckillQueryVos; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<YxStoreSeckillQueryVo> getIndexList() { |
|
|
|
|
SeckillConfigVo seckillConfigVo=this.getStoreSeckil(); |
|
|
|
|
if (seckillConfigVo.getSeckillTime().size()==0){ |
|
|
|
|
return null; |
|
|
|
|
}else { |
|
|
|
|
int timeId=seckillConfigVo.getSeckillTime().get(seckillConfigVo.getSeckillTimeIndex()).getId(); |
|
|
|
|
return this.getList(1,10,timeId); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 秒杀产品列表(首页用) |
|
|
|
|
* @param page page |
|
|
|
|