...
|
...
|
@@ -6,6 +6,7 @@ package com.yoho.activity.service.impl; |
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.yoho.activity.common.ApiResponse;
|
|
|
import com.yoho.activity.common.bo.ActNewBrandBo;
|
|
|
import com.yoho.activity.common.redis.CacheKeyHelper;
|
|
|
import com.yoho.activity.common.utils.BeanTool;
|
|
|
import com.yoho.activity.common.utils.DateUtils;
|
|
|
import com.yoho.activity.dal.ActNewBrandMapper;
|
...
|
...
|
@@ -14,6 +15,7 @@ import com.yoho.activity.dal.model.ActNewBrand; |
|
|
import com.yoho.activity.dal.model.ActNewBrandResult;
|
|
|
import com.yoho.activity.service.IBrandActivityService;
|
|
|
import com.yoho.activity.service.ICouponActivityService;
|
|
|
import com.yoho.core.redis.YHValueOperations;
|
|
|
import com.yoho.core.rest.client.ServiceCaller;
|
|
|
import com.yoho.error.exception.ServiceException;
|
|
|
import com.yoho.service.model.request.YohoCoinCostReqBO;
|
...
|
...
|
@@ -27,6 +29,7 @@ import org.springframework.stereotype.Service; |
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.List;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
/**
|
|
|
* 描述:品牌抽奖活动
|
...
|
...
|
@@ -51,6 +54,14 @@ public class BrandActivityServiceImpl implements IBrandActivityService { |
|
|
@Resource
|
|
|
private ServiceCaller serviceCaller;
|
|
|
|
|
|
@Resource(name = "yhValueOperations")
|
|
|
private YHValueOperations<String, String> yhValueOperations;
|
|
|
|
|
|
private static String BRAND_ACTIVITY_DRAW="yh:activity:brand:drawlist";
|
|
|
|
|
|
private static String BRAND_ACTIVITY_DRAW_DETAIL="yh:activity:brand:drawdetail:";
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 根据当前时间查询品牌活动奖项列表
|
|
|
*
|
...
|
...
|
@@ -61,15 +72,41 @@ public class BrandActivityServiceImpl implements IBrandActivityService { |
|
|
public List<ActNewBrandBo> getBrandActList() throws ServiceException {
|
|
|
//获取当前时间
|
|
|
String dt = DateUtils.getToday(DateUtils.DAY_FOMARTPATTER);
|
|
|
List<ActNewBrand> actNewBrandList = actNewBrandMapper.selectListByTime(dt);
|
|
|
logger.info("getBrandActList db res={}", JSON.toJSONString(actNewBrandList));
|
|
|
List<ActNewBrand> actNewBrandList = null;
|
|
|
try {
|
|
|
actNewBrandList= CacheKeyHelper.string2Value(yhValueOperations.get(BRAND_ACTIVITY_DRAW),List.class);
|
|
|
}catch (Exception e){
|
|
|
logger.warn("getBrandActList cache error={}", e);
|
|
|
}
|
|
|
if(actNewBrandList==null){
|
|
|
actNewBrandList = actNewBrandMapper.selectListByTime(dt);
|
|
|
try {
|
|
|
yhValueOperations.set(BRAND_ACTIVITY_DRAW, CacheKeyHelper.value2String(actNewBrandList),1, TimeUnit.MINUTES);
|
|
|
}catch (Exception e){
|
|
|
logger.warn("getBrandActList cache error={}", e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
logger.info("getBrandActList res={}", JSON.toJSONString(actNewBrandList));
|
|
|
List<ActNewBrandBo> actNewBrandBoList = BeanTool.copyList(actNewBrandList, ActNewBrandBo.class);
|
|
|
return actNewBrandBoList;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public ActNewBrandBo getBrandActInfoById(Integer id) throws ServiceException {
|
|
|
ActNewBrand actNewBrand = actNewBrandMapper.selectByPrimaryKey(id);
|
|
|
ActNewBrand actNewBrand = null;
|
|
|
try {
|
|
|
actNewBrand= CacheKeyHelper.string2Value(yhValueOperations.get(BRAND_ACTIVITY_DRAW_DETAIL),ActNewBrand.class);
|
|
|
}catch (Exception e){
|
|
|
logger.warn("getBrandActInfoById cache error={}", e);
|
|
|
}
|
|
|
if(actNewBrand==null){
|
|
|
actNewBrand = actNewBrandMapper.selectByPrimaryKey(id);
|
|
|
try {
|
|
|
yhValueOperations.set(BRAND_ACTIVITY_DRAW_DETAIL, CacheKeyHelper.value2String(actNewBrand),1, TimeUnit.MINUTES);
|
|
|
}catch (Exception e){
|
|
|
logger.warn("getBrandActList cache error={}", e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
ActNewBrandBo actNewBrandBo = BeanTool.copyObject(actNewBrand, ActNewBrandBo.class);
|
|
|
return actNewBrandBo;
|
|
|
}
|
...
|
...
|
|