From 6d6fbaf4aae5e43dd0d7125e77b3a4cfd34fa330 Mon Sep 17 00:00:00 2001 From: hupeng Date: Fri, 10 May 2019 15:39:04 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=A0=87=E7=AD=BE][=E4=BF=AE=E6=94=B9]:?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=B6=88=E8=B4=B9=E6=97=B6=E6=AE=B5=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E7=9A=84=E8=AE=A1=E7=AE=97=E8=AF=AD=E5=8F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/iformall/domain/po/WxCardSpend.java | 4 ++ .../com/iformall/domain/po/WxCouponOrder.java | 11 +++ .../service/impl/WxCUserTagsServiceImpl.java | 64 ++++++++--------- .../resources/mapper/WxCardSpendMapper.xml | 29 ++++++++ .../resources/mapper/WxCouponOrderMapper.xml | 71 +++++++++++++++++-- 5 files changed, 139 insertions(+), 40 deletions(-) diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxCardSpend.java b/mallinkService/src/main/java/com/iformall/domain/po/WxCardSpend.java index 2d9555f50..816f64998 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxCardSpend.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxCardSpend.java @@ -102,6 +102,10 @@ public class WxCardSpend implements Serializable { @io.swagger.annotations.ApiModelProperty(value="结束时间",name="enddate") private Date enddate; + @Transient + @io.swagger.annotations.ApiModelProperty(value="时段(0,工作日白天,1,工作日晚上,2周末白天,3周末晚上)",name="timeSlot") + private Integer timeSlot; + public String getDeductionAmountStr() { if(getDeductionAmount()!=null) { deductionAmountStr = new BigDecimal(getDeductionAmount()).divide(new BigDecimal(100)).toString(); diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxCouponOrder.java b/mallinkService/src/main/java/com/iformall/domain/po/WxCouponOrder.java index 29c91ddfc..eca9cd9a4 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxCouponOrder.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxCouponOrder.java @@ -99,6 +99,9 @@ public class WxCouponOrder extends BaseEntity{ @Transient private Date endTime; + @Transient + @io.swagger.annotations.ApiModelProperty(value="时段(0,工作日白天,1,工作日晚上,2周末白天,3周末晚上)",name="timeSlot") + private Integer timeSlot; public String getCouponPriceStr() { if(couponPrice!=null) { @@ -260,6 +263,14 @@ public class WxCouponOrder extends BaseEntity{ this.endTime = endTime; } + public Integer getTimeSlot() { + return timeSlot; + } + + public void setTimeSlot(Integer timeSlot) { + this.timeSlot = timeSlot; + } + public static enum Field { Id_ASC("`id` ASC"), Id_DESC("`id` DESC"), TenantId_ASC("`tenant_id` ASC"), TenantId_DESC("`tenant_id` DESC"), diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCUserTagsServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCUserTagsServiceImpl.java index de0d6de02..77be86cb6 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCUserTagsServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCUserTagsServiceImpl.java @@ -342,6 +342,11 @@ public class WxCUserTagsServiceImpl implements WxCUserTagsService { private List assignTypeId18(WxCUserBasicInfo user, WxCUser param) { List resList = null; + final int WORK_DAY = 0; + final int WORK_NIGHT = 1; + final int WEEKEND_DAY = 2; + final int WEEKEND_NIGHT = 3; + int workDayCount = 0; int workNightCount = 0; int WeekendDayCount = 0; @@ -351,47 +356,38 @@ public class WxCUserTagsServiceImpl implements WxCUserTagsService { Calendar startC = Calendar.getInstance(); endC.setTime(new Date()); startC.setTime(new Date()); - - endC.set(Calendar.HOUR_OF_DAY, 18); - startC.set(Calendar.HOUR_OF_DAY, 6); + startC.add(Calendar.DAY_OF_YEAR, -30); WxCouponOrder wxCouponOrder = new WxCouponOrder(); wxCouponOrder.setcUserId(param.getId()); wxCouponOrder.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USED.getCode()); + wxCouponOrder.setStartTime(startC.getTime()); + wxCouponOrder.setEndTime(endC.getTime()); WxCardSpend wxCardSpend = new WxCardSpend(); wxCardSpend.setOwnerId(param.getId()); - - for (int ago = 0; ago > -30 ; ago-- ) { - wxCouponOrder.setStartTime(startC.getTime()); - wxCouponOrder.setEndTime(endC.getTime()); - wxCardSpend.setStartdate(startC.getTime()); - wxCardSpend.setEnddate(endC.getTime()); - int cardSpendCount = wxCardSpendMapper.findCount(wxCardSpend); - int verifiedCount = wxCouponOrderMapper.findCount(wxCouponOrder); - if (endC.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY - && endC.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY) { - workDayCount += verifiedCount+cardSpendCount; - } else { - WeekendDayCount += verifiedCount+cardSpendCount; - } - - endC.add(Calendar.DAY_OF_YEAR, -1); - wxCouponOrder.setStartTime(endC.getTime()); - wxCouponOrder.setEndTime(startC.getTime()); - wxCardSpend.setStartdate(endC.getTime()); - wxCardSpend.setEnddate(startC.getTime()); - cardSpendCount = wxCardSpendMapper.findCount(wxCardSpend); - verifiedCount = wxCouponOrderMapper.findCount(wxCouponOrder); - if (endC.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY - && endC.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY) { - workNightCount += verifiedCount+cardSpendCount; - } else { - WeekendNightCount += verifiedCount+cardSpendCount; - } - - startC.add(Calendar.DAY_OF_YEAR, -1); - } + wxCardSpend.setStartdate(startC.getTime()); + wxCardSpend.setEnddate(endC.getTime()); + + wxCardSpend.setTimeSlot(WORK_DAY); + wxCouponOrder.setTimeSlot(WORK_DAY); + workDayCount = wxCardSpendMapper.findCount(wxCardSpend); + workDayCount += wxCouponOrderMapper.findCount(wxCouponOrder); + + wxCardSpend.setTimeSlot(WORK_NIGHT); + wxCouponOrder.setTimeSlot(WORK_NIGHT); + workNightCount = wxCardSpendMapper.findCount(wxCardSpend); + workNightCount += wxCouponOrderMapper.findCount(wxCouponOrder); + + wxCardSpend.setTimeSlot(WEEKEND_DAY); + wxCouponOrder.setTimeSlot(WEEKEND_DAY); + WeekendDayCount = wxCardSpendMapper.findCount(wxCardSpend); + WeekendDayCount += wxCouponOrderMapper.findCount(wxCouponOrder); + + wxCardSpend.setTimeSlot(WEEKEND_NIGHT); + wxCouponOrder.setTimeSlot(WEEKEND_NIGHT); + WeekendNightCount = wxCardSpendMapper.findCount(wxCardSpend); + WeekendNightCount += wxCouponOrderMapper.findCount(wxCouponOrder); if (workDayCount > WeekendDayCount && workDayCount > workNightCount diff --git a/mallinkService/src/main/resources/mapper/WxCardSpendMapper.xml b/mallinkService/src/main/resources/mapper/WxCardSpendMapper.xml index 16ee7258a..0a60309a0 100644 --- a/mallinkService/src/main/resources/mapper/WxCardSpendMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCardSpendMapper.xml @@ -79,6 +79,35 @@ and `create_date` between #{startdate} and #{enddate} + + + and date_format(create_date,'%H:%m') >= '06:00' + and date_format(create_date,'%H:%m') < '18:00' + and date_format(create_date,'%w') in (1,2,3,4,5) + + + + and ((date_format(create_date,'%H:%m') >= '18:00' + and date_format(create_date,'%w') in (1,2,3,4)) + or + ((date_format(create_date,'%H:%m') < '06:00') + and date_format(create_date,'%w') in (1,2,3,4,5))) + + + + and date_format(create_date,'%H:%m') >= '06:00' + and date_format(create_date,'%H:%m') < '18:00' + and date_format(create_date,'%w') in (0,6) + + + + and ((date_format(create_date,'%H:%m') >= '18:00' + and date_format(create_date,'%w') in (5,6,0)) + or + ((date_format(create_date,'%H:%m') < '06:00') + and date_format(create_date,'%w') in (6,0))) + + and id in diff --git a/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml index 2b0bb4b18..3085b6339 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml @@ -245,13 +245,72 @@ and coupon_type = #{couponType} - - and create_date >= #{startTime} - - - and create_date <= #{endTime} - + + + and update_date >= #{startTime} + + + and update_date <= #{endTime} + + + and date_format(update_date,'%H:%m') >= '06:00' + and date_format(update_date,'%H:%m') < '18:00' + and date_format(update_date,'%w') in (1,2,3,4,5) + + + and ((date_format(update_date,'%H:%m') >= '18:00' + and date_format(update_date,'%w') in (1,2,3,4)) + or + ((date_format(update_date,'%H:%m') < '06:00') + and date_format(update_date,'%w') in (1,2,3,4,5))) + + + and date_format(update_date,'%H:%m') >= '06:00' + and date_format(update_date,'%H:%m') < '18:00' + and date_format(update_date,'%w') in (0,6) + + + and ((date_format(update_date,'%H:%m') >= '18:00' + and date_format(update_date,'%w') in (5,6,0)) + or + ((date_format(update_date,'%H:%m') < '06:00') + and date_format(update_date,'%w') in (6,0))) + + + + + + and create_date >= #{startTime} + + + and create_date <= #{endTime} + + + and date_format(create_date,'%H:%m') >= '06:00' + and date_format(create_date,'%H:%m') < '18:00' + and date_format(create_date,'%w') in (1,2,3,4,5) + + + and ((date_format(create_date,'%H:%m') >= '18:00' + and date_format(create_date,'%w') in (1,2,3,4)) + or + ((date_format(create_date,'%H:%m') < '06:00') + and date_format(create_date,'%w') in (1,2,3,4,5))) + + + and date_format(create_date,'%H:%m') >= '06:00' + and date_format(create_date,'%H:%m') < '18:00' + and date_format(create_date,'%w') in (0,6) + + + and ((date_format(create_date,'%H:%m') >= '18:00' + and date_format(create_date,'%w') in (5,6,0)) + or + ((date_format(create_date,'%H:%m') < '06:00') + and date_format(create_date,'%w') in (6,0))) + +