fanli/src/main/java/com/yeshi/fanli/aspect/IntegralGetVersionLimitAspect.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/IntegralControllerV2.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/RecommendControllerV2.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/java/com/yeshi/fanli/dto/dataoke/DingDongTime.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/HongBaoV2ServiceImpl.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/java/com/yeshi/fanli/util/annotation/integral/IntegralGetVersionLimit.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
fanli/src/main/java/com/yeshi/fanli/util/taobao/DaTaoKeUtil.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
fanli/src/main/java/com/yeshi/fanli/aspect/IntegralGetVersionLimitAspect.java
New file @@ -0,0 +1,90 @@ package com.yeshi.fanli.aspect; import java.io.IOException; import java.lang.reflect.Method; import javax.annotation.Resource; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.Signature; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.reflect.MethodSignature; import org.springframework.core.DefaultParameterNameDiscoverer; import org.springframework.expression.EvaluationContext; import org.springframework.expression.Expression; import org.springframework.expression.ExpressionParser; import org.springframework.expression.spel.standard.SpelExpressionParser; import org.springframework.expression.spel.support.StandardEvaluationContext; import org.springframework.stereotype.Component; import org.yeshi.utils.NumberUtil; import com.yeshi.fanli.entity.bus.user.UserActiveLog; import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.service.inter.user.UserActiveLogService; import com.yeshi.fanli.util.VersionUtil; import com.yeshi.fanli.util.annotation.integral.IntegralGetVersionLimit; @Component @Aspect public class IntegralGetVersionLimitAspect { @Resource private UserActiveLogService userActiveLogService; private ExpressionParser parser = new SpelExpressionParser(); private DefaultParameterNameDiscoverer nameDiscoverer = new DefaultParameterNameDiscoverer(); public String generateKeyBySpEL(String spELString, ProceedingJoinPoint joinPoint) { MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature(); String[] paramNames = nameDiscoverer.getParameterNames(methodSignature.getMethod()); Expression expression = parser.parseExpression(spELString); EvaluationContext context = new StandardEvaluationContext(); Object[] args = joinPoint.getArgs(); for (int i = 0; i < args.length; i++) { context.setVariable(paramNames[i], args[i]); } return expression.getValue(context).toString(); } @Around("execution(public * com.yeshi.fanli.service.impl.integral.*.*(..))") public Object requestSerializable(ProceedingJoinPoint joinPoint) throws IOException { Signature signature = joinPoint.getSignature(); MethodSignature methodSignature = (MethodSignature) signature; Method targetMethod = methodSignature.getMethod(); try { Method realMethod = joinPoint.getTarget().getClass().getDeclaredMethod(joinPoint.getSignature().getName(), targetMethod.getParameterTypes()); if (realMethod.isAnnotationPresent(IntegralGetVersionLimit.class)) { IntegralGetVersionLimit rs = realMethod.getAnnotation(IntegralGetVersionLimit.class); String key = rs.uid(); String uid = generateKeyBySpEL(key, joinPoint); if (uid != null && NumberUtil.isNumeric(uid)) { UserActiveLog activeLog = userActiveLogService.getUserLatestActiveInfo(Long.parseLong(uid)); if (activeLog != null) { // 小于1.6.5版本不增加积分 if (!VersionUtil.greaterThan_1_6_5( "appstore".equalsIgnoreCase(activeLog.getChannel()) ? "ios" : "android", activeLog.getVersionCode())) return null; } } } } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } try { return joinPoint.proceed(); } catch (Throwable e) { LogHelper.errorDetailInfo(e); } finally { } return null; } } fanli/src/main/java/com/yeshi/fanli/controller/client/v2/IntegralControllerV2.java
@@ -11,6 +11,7 @@ import java.util.Set; import javax.annotation.Resource; import javax.servlet.http.HttpSession; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; fanli/src/main/java/com/yeshi/fanli/controller/client/v2/RecommendControllerV2.java
@@ -53,6 +53,7 @@ import com.yeshi.fanli.util.VersionUtil; import com.yeshi.fanli.util.factory.MonitorFactory; import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory; import com.yeshi.fanli.util.taobao.DaTaoKeUtil; import com.yeshi.fanli.util.taobao.TaoBaoUtil; import com.yeshi.fanli.util.taobao.TaoKeApiUtil; import com.yeshi.fanli.vo.goods.GoodsDetailVO; @@ -194,23 +195,25 @@ } private JSONObject getSpikeGoodsContent(AcceptData acceptData) { List<String> dtoList = daTaoKeGoodsDetailV2Service.getDingDongQiangTime(); List<String> dtoList = DaTaoKeUtil.getDingDongQiangTime(); long nowTime = System.currentTimeMillis(); int dateNum = Integer.parseInt(TimeUtil.getGernalTime(nowTime, "ddHH")); String timeStr = null; int nextPos = 0; for (int i = 0; i < dtoList.size(); i++) { if (dateNum <= Integer.parseInt(dtoList.get(i))) { for (int i = 0; i < dtoList.size() - 1; i++) { if (dateNum >= Integer.parseInt(dtoList.get(i)) && dateNum < Integer.parseInt(dtoList.get(i + 1))) { timeStr = dtoList.get(i); nextPos = i + 1; break; } } if (timeStr == null) timeStr = dtoList.get(dtoList.size() - 1); long nextTime = nowTime + 1000 * 60 * 60L;// 默认为1小时 if (nextPos < dtoList.size()) { nextTime = TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(nowTime, "MM") + dtoList.get(nextPos), "MMddHH"); nextTime = TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(nowTime, "yyyyMM") + dtoList.get(nextPos), "yyyyMMddHH"); } JSONArray array = null; fanli/src/main/java/com/yeshi/fanli/dto/dataoke/DingDongTime.java
New file @@ -0,0 +1,39 @@ package com.yeshi.fanli.dto.dataoke; public class DingDongTime { private String key; private String value; private String time; public String getTime() { return time; } public void setTime(String time) { this.time = time; } public DingDongTime(String key, String value) { this.key = key; this.value = value; } public DingDongTime() { } public String getKey() { return key; } public void setKey(String key) { this.key = key; } public String getValue() { return value; } public void setValue(String value) { this.value = value; } } fanli/src/main/java/com/yeshi/fanli/service/impl/hongbao/HongBaoV2ServiceImpl.java
@@ -301,14 +301,17 @@ hongBao.setState(HongBaoV2.STATE_KELINGQU); hongBao.setMoney( MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), fanliRate.divide(new BigDecimal(100)))); hongBao.setPreGetTime(new Date(commonOrder.getSettleTime().getTime() + 1000 * 60 * 60 * 24 * 15L)); if (commonOrder.getSourceType() == Constant.SOURCE_TYPE_PDD)// 拼多多15天半到账 hongBao.setPreGetTime(new Date( commonOrder.getSettleTime().getTime() + 1000 * 60 * 60 * 24 * 15L + 1000 * 60 * 60 * 12L)); else hongBao.setPreGetTime(new Date(commonOrder.getSettleTime().getTime() + 1000 * 60 * 60 * 24 * 15L)); if (mianDan) hongBao.setMoney(commonOrder.getSettlement().compareTo(commonOrder.getPayment()) <= 0 ? commonOrder.getSettlement() : commonOrder.getPayment());// 返利结算与付款较小的金额 } else if (commonOrder.getState() == CommonOrder.STATE_SX) { hongBao.setState(HongBaoV2.STATE_SHIXIAO); hongBao.setMoney(new BigDecimal(0)); } // 新老红包状态一致不处理 @@ -673,7 +676,11 @@ hongBao.setState(HongBaoV2.STATE_KELINGQU); hongBao.setMoney( MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), fanliRate.divide(new BigDecimal(100)))); hongBao.setPreGetTime(new Date(commonOrder.getSettleTime().getTime() + 1000 * 60 * 60 * 24 * 15L)); if (commonOrder.getSourceType() == Constant.SOURCE_TYPE_PDD)// 拼多多15天半到账 hongBao.setPreGetTime(new Date( commonOrder.getSettleTime().getTime() + 1000 * 60 * 60 * 24 * 15L + 1000 * 60 * 60 * 12L)); else hongBao.setPreGetTime(new Date(commonOrder.getSettleTime().getTime() + 1000 * 60 * 60 * 24 * 15L)); } else if (commonOrder.getState() == CommonOrder.STATE_SX) { hongBao.setState(HongBaoV2.STATE_SHIXIAO); hongBao.setMoney(new BigDecimal(0)); fanli/src/main/java/com/yeshi/fanli/util/annotation/integral/IntegralGetVersionLimit.java
New file @@ -0,0 +1,22 @@ package com.yeshi.fanli.util.annotation.integral; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * 金币获得版本控制器 * * @author Administrator * */ @Documented @Target(ElementType.METHOD) @Inherited @Retention(RetentionPolicy.RUNTIME) public @interface IntegralGetVersionLimit { String uid(); } fanli/src/main/java/com/yeshi/fanli/util/taobao/DaTaoKeUtil.java
@@ -5,6 +5,7 @@ import java.math.BigDecimal; import java.net.URLEncoder; import java.util.ArrayList; import java.util.Calendar; import java.util.Iterator; import java.util.List; @@ -18,6 +19,7 @@ import org.jsoup.select.Elements; import com.yeshi.fanli.dto.dataoke.DingDongQiangDTO; import com.yeshi.fanli.dto.dataoke.DingDongTime; import com.yeshi.fanli.entity.bus.clazz.GoodsClass; import com.yeshi.fanli.entity.taobao.TaoBaoCoupon; import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; @@ -577,4 +579,69 @@ return detail; } public static List<String> getDingDongQiangTime() { // 获取当前的小时数 DingDongTime[] times = new DingDongTime[] { new DingDongTime("0", "00:00"), new DingDongTime("8", "08:00"), new DingDongTime("10", "10:00"), new DingDongTime("13", "13:00"), new DingDongTime("15", "15:00"), new DingDongTime("17", "17:00"), new DingDongTime("19", "19:00"), new DingDongTime("20", "20:00"), new DingDongTime("21", "21:00") }; Calendar nowDate = Calendar.getInstance(); Calendar preDate = Calendar.getInstance(); preDate.setTimeInMillis(nowDate.getTimeInMillis() - 24 * 60 * 60 * 1000L); Calendar nextDate = Calendar.getInstance(); nextDate.setTimeInMillis(nowDate.getTimeInMillis() + 24 * 60 * 60 * 1000L); String preDay = (preDate.get(Calendar.DAY_OF_MONTH) + "").length() < 2 ? "0" + preDate.get(Calendar.DAY_OF_MONTH) : preDate.get(Calendar.DAY_OF_MONTH) + ""; String nextDay = (nextDate.get(Calendar.DAY_OF_MONTH) + "").length() < 2 ? "0" + nextDate.get(Calendar.DAY_OF_MONTH) : nextDate.get(Calendar.DAY_OF_MONTH) + ""; String nowDay = (nowDate.get(Calendar.DAY_OF_MONTH) + "").length() < 2 ? "0" + nowDate.get(Calendar.DAY_OF_MONTH) : nowDate.get(Calendar.DAY_OF_MONTH) + ""; int hour = nowDate.get(Calendar.HOUR_OF_DAY); int pos = 0; for (int i = 0; i < times.length - 1; i++) { if (hour >= Integer.parseInt(times[i].getKey()) && hour < Integer.parseInt(times[i + 1].getKey())) { pos = i; break; } } List<DingDongTime> list = new ArrayList<>(); for (int i = 5; i >= 0; i--) { int p = pos - i < 0 ? (times.length + pos - i) : pos - i; DingDongTime itemData = new DingDongTime(times[p].getKey(), times[p].getValue()); if (pos - i < 0) itemData.setTime( preDay + "" + (itemData.getKey().length() < 2 ? ("0" + itemData.getKey()) : itemData.getKey())); else itemData.setTime( nowDay + "" + (itemData.getKey().length() < 2 ? ("0" + itemData.getKey()) : itemData.getKey())); list.add(itemData); } if (pos + 1 < times.length) for (int i = pos + 1; i < times.length; i++) { DingDongTime itemData = new DingDongTime(times[i].getKey(), times[i].getValue()); itemData.setTime( nowDay + "" + (itemData.getKey().length() < 2 ? ("0" + itemData.getKey()) : itemData.getKey())); list.add(itemData); } if (times.length - (pos + 1) < 2) { DingDongTime itemData = new DingDongTime(times[0].getKey(), times[0].getValue()); itemData.setTime( nextDay + "" + (itemData.getKey().length() < 2 ? ("0" + itemData.getKey()) : itemData.getKey())); list.add(itemData); } List<String> finalTimeList = new ArrayList<>(); for (DingDongTime time : list) finalTimeList.add(time.getTime()); return finalTimeList; } }