From c4426095b5604a5225438f931ba56d92ce0de9ac Mon Sep 17 00:00:00 2001 From: hupeng Date: Mon, 11 Mar 2019 15:46:45 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=9C=BA=E6=99=AF][=E4=BF=AE=E6=94=B9]:?= =?UTF-8?q?=E5=9C=BA=E6=99=AF=E5=8F=91=E5=88=B8=E5=A2=9E=E5=8A=A0=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/WxCouponSendServiceImpl.java | 47 ++++++++++++++++--- 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponSendServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponSendServiceImpl.java index 3819540ea..a3974c5f4 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponSendServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponSendServiceImpl.java @@ -11,7 +11,9 @@ import com.iformall.exception.MallinkException; import com.iformall.mapper.WxCouponOrderMapper; import com.iformall.mapper.WxCouponSendConfigMapper; import com.iformall.mapper.WxCouponSendMapper; +import com.iformall.mapper.WxMerchantBUserMapper; import com.iformall.service.*; +import com.iformall.utils.DateUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -41,6 +43,8 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { @Autowired WxCouponOrderMapper wxCouponOrderMapper; @Autowired + WxMerchantBUserMapper wxMerchantBUserMapper; + @Autowired PushLimitService pushLimitService; @@ -80,24 +84,55 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { JSONObject jo = JSONObject.parseObject(wxCouponSend.getConditions()); if (wxOrder.getProductId().equals(jo.getLong("id"))) return true; - else - return false; } catch (Exception e) { - return false; + logger.error("交易发券条件判断错误:ID=" + wxCouponSend.getId() + e.getMessage()); } + return false; } else if (wxCouponSend.getSendType().equals(EnumCouponSendSendType.CAR_STOP.getCode())){ + try { + JSONObject jo = JSONObject.parseObject(wxCouponSend.getConditions()); + + if (DateUtils.isInDate(new Date(), jo.getString("startTime"), jo.getString("endTime"))){ + return true; + } + + } catch (Exception e) { + logger.error("停车发券条件判断错误:ID=" + wxCouponSend.getId() + e.getMessage()); + } - return true; + return false; }else if (wxCouponSend.getSendType().equals(EnumCouponSendSendType.B_MICROPAY.getCode())){ + WxOrder wxOrder = (WxOrder)param; + + try { + JSONObject jo = JSONObject.parseObject(wxCouponSend.getConditions()); + WxMerchantBUser wxMerchantBUser = wxMerchantBUserMapper.selectByPrimaryKey(wxOrder.getProductId()); + + if (wxMerchantBUser.getMerchantId()!= null + && wxMerchantBUser.getMerchantId().equals(jo.getLong("id"))) { + return true; + } + } catch (Exception e) { + logger.error("收银发券条件判断错误:ID=" + wxCouponSend.getId() + e.getMessage()); + } + return false; - return true; }else if (wxCouponSend.getSendType().equals(EnumCouponSendSendType.COUPON_VERIFY.getCode())){ + WxOrder wxOrder = (WxOrder)param; + try { + JSONObject jo = JSONObject.parseObject(wxCouponSend.getConditions()); + if (wxOrder.getProductId().equals(jo.getLong("id"))) { + return true; + } + } catch (Exception e) { + logger.error("核销发券条件判断错误:ID=" + wxCouponSend.getId() + e.getMessage()); + } + return false; - return true; }else { return false; }