| @@ -102,6 +102,10 @@ public class WxCardSpend implements Serializable { | |||||
| @io.swagger.annotations.ApiModelProperty(value="结束时间",name="enddate") | @io.swagger.annotations.ApiModelProperty(value="结束时间",name="enddate") | ||||
| private Date enddate; | private Date enddate; | ||||
| @Transient | |||||
| @io.swagger.annotations.ApiModelProperty(value="时段(0,工作日白天,1,工作日晚上,2周末白天,3周末晚上)",name="timeSlot") | |||||
| private Integer timeSlot; | |||||
| public String getDeductionAmountStr() { | public String getDeductionAmountStr() { | ||||
| if(getDeductionAmount()!=null) { | if(getDeductionAmount()!=null) { | ||||
| deductionAmountStr = new BigDecimal(getDeductionAmount()).divide(new BigDecimal(100)).toString(); | deductionAmountStr = new BigDecimal(getDeductionAmount()).divide(new BigDecimal(100)).toString(); | ||||
| @@ -99,6 +99,9 @@ public class WxCouponOrder extends BaseEntity{ | |||||
| @Transient | @Transient | ||||
| private Date endTime; | private Date endTime; | ||||
| @Transient | |||||
| @io.swagger.annotations.ApiModelProperty(value="时段(0,工作日白天,1,工作日晚上,2周末白天,3周末晚上)",name="timeSlot") | |||||
| private Integer timeSlot; | |||||
| public String getCouponPriceStr() { | public String getCouponPriceStr() { | ||||
| if(couponPrice!=null) { | if(couponPrice!=null) { | ||||
| @@ -260,6 +263,14 @@ public class WxCouponOrder extends BaseEntity{ | |||||
| this.endTime = endTime; | this.endTime = endTime; | ||||
| } | } | ||||
| public Integer getTimeSlot() { | |||||
| return timeSlot; | |||||
| } | |||||
| public void setTimeSlot(Integer timeSlot) { | |||||
| this.timeSlot = timeSlot; | |||||
| } | |||||
| public static enum Field { | public static enum Field { | ||||
| Id_ASC("`id` ASC"), Id_DESC("`id` DESC"), | Id_ASC("`id` ASC"), Id_DESC("`id` DESC"), | ||||
| TenantId_ASC("`tenant_id` ASC"), TenantId_DESC("`tenant_id` DESC"), | TenantId_ASC("`tenant_id` ASC"), TenantId_DESC("`tenant_id` DESC"), | ||||
| @@ -342,6 +342,11 @@ public class WxCUserTagsServiceImpl implements WxCUserTagsService { | |||||
| private List<WxTags> assignTypeId18(WxCUserBasicInfo user, WxCUser param) { | private List<WxTags> assignTypeId18(WxCUserBasicInfo user, WxCUser param) { | ||||
| List<WxTags> resList = null; | List<WxTags> 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 workDayCount = 0; | ||||
| int workNightCount = 0; | int workNightCount = 0; | ||||
| int WeekendDayCount = 0; | int WeekendDayCount = 0; | ||||
| @@ -351,47 +356,38 @@ public class WxCUserTagsServiceImpl implements WxCUserTagsService { | |||||
| Calendar startC = Calendar.getInstance(); | Calendar startC = Calendar.getInstance(); | ||||
| endC.setTime(new Date()); | endC.setTime(new Date()); | ||||
| startC.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 wxCouponOrder = new WxCouponOrder(); | ||||
| wxCouponOrder.setcUserId(param.getId()); | wxCouponOrder.setcUserId(param.getId()); | ||||
| wxCouponOrder.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USED.getCode()); | wxCouponOrder.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USED.getCode()); | ||||
| wxCouponOrder.setStartTime(startC.getTime()); | |||||
| wxCouponOrder.setEndTime(endC.getTime()); | |||||
| WxCardSpend wxCardSpend = new WxCardSpend(); | WxCardSpend wxCardSpend = new WxCardSpend(); | ||||
| wxCardSpend.setOwnerId(param.getId()); | 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 | if (workDayCount > WeekendDayCount | ||||
| && workDayCount > workNightCount | && workDayCount > workNightCount | ||||
| @@ -79,6 +79,35 @@ | |||||
| <if test=" null != startdate and null!=enddate"> | <if test=" null != startdate and null!=enddate"> | ||||
| and `create_date` between #{startdate} and #{enddate} | and `create_date` between #{startdate} and #{enddate} | ||||
| </if> | </if> | ||||
| <if test=" 0 == timeSlot"> | |||||
| 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) | |||||
| </if> | |||||
| <if test=" 1 == timeSlot"> | |||||
| 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))) | |||||
| </if> | |||||
| <if test=" 2 == timeSlot"> | |||||
| 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) | |||||
| </if> | |||||
| <if test=" 3 == timeSlot"> | |||||
| 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))) | |||||
| </if> | |||||
| <if test=" null != ids "> | <if test=" null != ids "> | ||||
| and id in | and id in | ||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | ||||
| @@ -245,13 +245,72 @@ | |||||
| <if test=" null != couponType "> | <if test=" null != couponType "> | ||||
| and coupon_type = #{couponType} | and coupon_type = #{couponType} | ||||
| </if> | </if> | ||||
| <if test=" null != startTime"> | |||||
| and create_date >= #{startTime} | |||||
| </if> | |||||
| <if test=" null != endTime"> | |||||
| and create_date <= #{endTime} | |||||
| </if> | |||||
| <if test=" 1 == couponOrderStatus"> | |||||
| <if test=" null != startTime"> | |||||
| and update_date >= #{startTime} | |||||
| </if> | |||||
| <if test=" null != endTime"> | |||||
| and update_date <= #{endTime} | |||||
| </if> | |||||
| <if test=" 0 == timeSlot"> | |||||
| 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) | |||||
| </if> | |||||
| <if test=" 1 == timeSlot"> | |||||
| 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))) | |||||
| </if> | |||||
| <if test=" 2 == timeSlot"> | |||||
| 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) | |||||
| </if> | |||||
| <if test=" 3 == timeSlot"> | |||||
| 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))) | |||||
| </if> | |||||
| </if> | |||||
| <if test=" 1 != couponOrderStatus"> | |||||
| <if test=" null != startTime"> | |||||
| and create_date >= #{startTime} | |||||
| </if> | |||||
| <if test=" null != endTime"> | |||||
| and create_date <= #{endTime} | |||||
| </if> | |||||
| <if test=" 0 == timeSlot"> | |||||
| 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) | |||||
| </if> | |||||
| <if test=" 1 == timeSlot"> | |||||
| 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))) | |||||
| </if> | |||||
| <if test=" 2 == timeSlot"> | |||||
| 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) | |||||
| </if> | |||||
| <if test=" 3 == timeSlot"> | |||||
| 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))) | |||||
| </if> | |||||
| </if> | |||||
| </select> | </select> | ||||
| <select id="queryPriceTotalGroup" resultType="com.iformall.domain.vo.CUserDateAmountVo" > | <select id="queryPriceTotalGroup" resultType="com.iformall.domain.vo.CUserDateAmountVo" > | ||||