Authored by mingdan.ge

cps5时间判断

... ... @@ -14,7 +14,7 @@ public enum ShareOrdersKeyEnum {
SETTLEMENT_LIST("yh:union:share:settlementList:","key:{}:page:{}:limit:{}",600,"提现列表"),
UNION_TYPE("yh:union:share:unionType:","key:{}",600,"用户登录时获取对应的渠道号"),
RECENTLY_ORDER_LIMIT_TEN("yh:union:share:recentlyOrderLimitTen:","key:{}",600,"用户前台获取个人推广近期订单(10个)"),
ACTIVITY_ING_LIST("yh:union:share:activity:ing:list",null,120,"进行中的活动"),
ACTIVITY_ING_LIST("yh:union:share:activity:ing:list:",null,120,"某天进行中的活动"),
ACTIVITY("yh:union:share:activity:","type:{}:id:{}",120,"活动"),
ORDER_STATISTICS_INFO("yh:union:share:statisticsInfo:","uid:{}:queryTimeType:{}",600,"统计数据"),
RANK_LIST("yh:union:share:ranklist:","type:{}:start:{}:limit:{}",86400,"达人排行榜"),
... ...
... ... @@ -6,6 +6,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import com.yoho.unions.server.task.CpsNewUserActivityTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -56,7 +57,6 @@ import com.yoho.unions.server.task.CpsOrderExtraActivityTask;
/**
* Created by mingdan.ge on 2018/5/14.
* 接口在nginx内做了限制,只可以内部ip访问
*/
@Controller
@RequestMapping("/UnionShareRest")
... ... @@ -71,6 +71,9 @@ public class UnionShareRest {
@Autowired
CpsOrderExtraActivityTask cpsOrderExtraActivityTask;
@Autowired
CpsNewUserActivityTask cpsNewUserActivityTask;
@RequestMapping("/getShareInfoByUid")
@ResponseBody
public ShareUserSettlementInfoBo getShareInfoByUid(@RequestBody int uid){
... ... @@ -407,6 +410,17 @@ public class UnionShareRest {
}
/**
* 手动执行一次新人活动奖励发放
* */
@RequestMapping("/dealNewUserActivityTask")
@ResponseBody
public UnionResponse dealNewUserActivityTask(){
log.info("UnionShareRest.dealNewUserActivityTask.");
cpsNewUserActivityTask.run();
return new UnionResponse(200, "dealNewUserActivityTask success");
}
/**
* 清活动缓存
* */
@RequestMapping("/clearActivity")
... ...
... ... @@ -1592,26 +1592,27 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
return activities;
}
//查询进行中的活动
private List<UnionShareOrdersActivity> queryActivity() {
logger.info("queryActivity.");
String activitiesCache = redisValueCache.get(ShareOrdersKeyEnum.ACTIVITY_ING_LIST.getPreKey(), String.class);
//查询某时间为进行中的活动
private List<UnionShareOrdersActivity> queryActivityByDate(int date) {
logger.info("queryActivityByDate.date is {}.",date);
String dateStr=DateUtil.getDateStrBySecond(date, "yyyyMMdd");
String activitiesCache = redisValueCache.get(ShareOrdersKeyEnum.ACTIVITY_ING_LIST.getPreKey()+dateStr, String.class);
List<UnionShareOrdersActivity> activities;
if (activitiesCache != null) {
activities = JSONObject.parseArray(activitiesCache, UnionShareOrdersActivity.class);
if (CollectionUtils.isNotEmpty(activities)) {
logger.info("queryActivity.get chache {}",activities);
logger.info("queryActivityByDate.date is {},dateStr is {},get chache {}",date,dateStr,activities);
return activities;
}
}
activities=unionShareOrdersActivityMapper.selectByDate(DateUtil.getCurrentTimeSecond());
activities=unionShareOrdersActivityMapper.selectByDate(date);
if (CollectionUtils.isEmpty(activities)) {
return new ArrayList<>();
}
logger.info("queryActivity.add to redis.value is {}",activities);
redisValueCache.set(ShareOrdersKeyEnum.ACTIVITY_ING_LIST.getPreKey(),activities,ShareOrdersKeyEnum.ACTIVITY_ING_LIST.getCacheTime(),TimeUnit.SECONDS);
logger.info("queryActivityByDate.add to redis.value is {}",activities);
redisValueCache.set(ShareOrdersKeyEnum.ACTIVITY_ING_LIST.getPreKey()+dateStr,activities,ShareOrdersKeyEnum.ACTIVITY_ING_LIST.getCacheTime(),TimeUnit.SECONDS);
return activities;
}
//获取某时间段可参与活动的单数
... ... @@ -1984,7 +1985,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
unionShareOrdersMapper.insertSelective(insertReq);
//活动返利
try {
List<UnionShareOrdersActivity> activityList = queryActivity();
List<UnionShareOrdersActivity> activityList = queryActivityByDate(bo.getOrderTime());
for (UnionShareOrdersActivity a :activityList ) {
if(participateActivity(insertReq,a)) {
//参加了活动,参加一个加返活动就可以了
... ... @@ -2252,8 +2253,7 @@ public class UnionShareServiceImpl implements IUnionShareService,IBusinessExport
bo.setOrderCodes(orderCodes);
bo.setOrderList(orderList);
bo.setActivities(activityBos);
System.out.println(JsonUtil.objectToJSON(bo));
mqLog.info("relateSettlementAndOrder,send mq {} to erp,uid is {},settlementCode is {},bo is {}", SETTLEMENT_TOPIC, uid, settlementCode, bo);
mqLog.info("relateSettlementAndOrder,send mq {} to erp,uid is {},settlementCode is {},bo is {}", SETTLEMENT_TOPIC, uid, settlementCode, JsonUtil.objectToJSON(bo));
yhProducer.send(SETTLEMENT_TOPIC, bo);
settlementLog.info("relateSettlementAndOrder,send mq {} to erp success,uid is {},settlementCode is {},bo is {}", SETTLEMENT_TOPIC, uid, settlementCode, bo);
return totalAmount;
... ...