...
|
...
|
@@ -2,11 +2,16 @@ package com.yoho.activity.service.impl; |
|
|
|
|
|
import com.yoho.activity.common.helper.SendCouponHelper;
|
|
|
import com.yoho.activity.service.IUserdaySigninService;
|
|
|
import com.yoho.core.common.utils.DateUtil;
|
|
|
import com.yoho.core.redis.YHValueOperations;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
/**
|
|
|
* 会员日,签到
|
|
|
*/
|
...
|
...
|
@@ -18,6 +23,9 @@ public class UserdaySigninServiceImpl implements IUserdaySigninService { |
|
|
@Autowired
|
|
|
private SendCouponHelper sendCouponHelper;
|
|
|
|
|
|
@Resource(name = "yhValueOperations")
|
|
|
YHValueOperations<String, String> yhValueOperations;
|
|
|
|
|
|
@Override
|
|
|
public void signin(int uid) throws Exception {
|
|
|
log.info("enter signin. param uid={}", uid);
|
...
|
...
|
@@ -27,7 +35,24 @@ public class UserdaySigninServiceImpl implements IUserdaySigninService { |
|
|
throw new Exception("参数不合法");
|
|
|
}
|
|
|
|
|
|
// (2)发送有货币,完成签到
|
|
|
// (2)校验当天是否是会员日
|
|
|
String dateStr = DateUtil.getcurrentDate();
|
|
|
if (!"28".equals(dateStr.substring(8, 10))) {
|
|
|
throw new Exception("非会员日,不允许签到");
|
|
|
}
|
|
|
|
|
|
// (3)校验用户是否已经签到
|
|
|
String key = "yh:activity:userday:" + uid + "_" + dateStr;
|
|
|
String s = yhValueOperations.get(key);
|
|
|
if ("1".equals(s)) {
|
|
|
throw new Exception("您已签过到");
|
|
|
}
|
|
|
|
|
|
// (4)发送有货币,完成签到
|
|
|
sendCouponHelper.sendYOHOBi(uid, 100, 5);
|
|
|
|
|
|
// (5)redis记录用户签到记录
|
|
|
yhValueOperations.set(key, "1", 31, TimeUnit.DAYS);
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|