diff --git a/hai-schedule/src/main/java/com/hai/schedule/HighDiscountSchedule.java b/hai-schedule/src/main/java/com/hai/schedule/HighDiscountSchedule.java index 0c3eb470..92908b3e 100644 --- a/hai-schedule/src/main/java/com/hai/schedule/HighDiscountSchedule.java +++ b/hai-schedule/src/main/java/com/hai/schedule/HighDiscountSchedule.java @@ -1,9 +1,9 @@ package com.hai.schedule; -import com.hai.entity.HighDiscountAgentCode; -import com.hai.entity.HighDiscountUserRel; -import com.hai.entity.HighOrder; +import com.hai.entity.*; +import com.hai.service.BsTemporaryServices; import com.hai.service.HighDiscountAgentCodeService; +import com.hai.service.HighDiscountPackageAgentService; import com.hai.service.HighDiscountUserRelService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -11,6 +11,8 @@ import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.annotation.Scheduled; import javax.annotation.Resource; +import java.util.Date; +import java.util.HashMap; import java.util.List; /** @@ -29,6 +31,12 @@ public class HighDiscountSchedule { @Resource private HighDiscountAgentCodeService highDiscountAgentCodeService; + @Resource + private BsTemporaryServices bsTemporaryServices; + + @Resource + private HighDiscountPackageAgentService discountPackageAgentService; + /** * @Author 胡锐 * @Description 处理过期的优惠券 @@ -55,4 +63,23 @@ public class HighDiscountSchedule { } } + + @Scheduled(cron = "0 5 0 * * ?") // 每日凌晨00:00:5执行一次 + public void deleteOilNo() { + List list = bsTemporaryServices.getList(new HashMap<>()); + + for (BsTemporary bsTemporary : list) { + + HighDiscountPackageAgentCode discountPackageAgentCode = discountPackageAgentService.findDiscountPackageAgentCode(bsTemporary.getCode()); + discountPackageAgentCode.setStatus(1); + discountPackageAgentCode.setUpdateTime(new Date()); + discountPackageAgentService.updateDiscountPackageAgentCode(discountPackageAgentCode); + bsTemporary.setStatus(0); + bsTemporary.setUpdateTime(new Date()); + bsTemporaryServices.update(bsTemporary); + + } + + } + } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageAgentServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageAgentServiceImpl.java index 1f498174..5a425322 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageAgentServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighDiscountPackageAgentServiceImpl.java @@ -154,11 +154,12 @@ public class HighDiscountPackageAgentServiceImpl implements HighDiscountPackageA HighDiscountPackageAgentCode discountPackageAgentCode ; mapCode.put("type" , "DISCOUNT_PACKAGE"); int percent; + int num = object.getInteger("num"); - for (int i = 0; i <= object.getInteger("num"); i++) { + for (int i = 0; i < object.getInteger("num"); i++) { // 生成百分比 - percent = i*100/object.getInteger("num"); + percent = i*100/(num -1); redisUtil.set(object.getString("serialNumber") , percent , 3600); HighDiscountPackageActual discountPackageActual = discountPackageActualList.get(i); diff --git a/hai-service/src/main/java/com/hai/service/impl/HighDiscountUserRelServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighDiscountUserRelServiceImpl.java index ee8e1e14..f392b619 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighDiscountUserRelServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighDiscountUserRelServiceImpl.java @@ -279,8 +279,8 @@ public class HighDiscountUserRelServiceImpl implements HighDiscountUserRelServic if (MapUtils.getLong(map, "agentId") != null) { criteria.andAgentIdEqualTo(MapUtils.getLong(map, "agentId")); } - if (MapUtils.getLong(map, "discountName") != null) { - criteria.andDiscountNameLike(MapUtils.getString(map, "discountName")); + if (MapUtils.getString(map, "discountName") != null) { + criteria.andDiscountNameLike("%" + MapUtils.getString(map, "discountName") + "%"); } if (MapUtils.getInteger(map, "discountPlatform") != null) {