| @@ -68,149 +68,149 @@ public class AiOrderSchedule { | |||
| return wxMallMapper.findList(wxMall); | |||
| } | |||
| //查询新创建的订单,增量同步wxCouponOrder.因为中间有些订单有付了款,有没付款 | |||
| @Async | |||
| //@Scheduled(cron = "0 */5 * * * ?") // 每天凌晨00:50 | |||
| @Scheduled(cron = "0 53 0 * * *?")// 每天凌晨00:53 | |||
| public void updateWxCouponOrderSchedule() { | |||
| List<WxMall> malls = getMalls(); | |||
| for (WxMall mall : malls) { | |||
| AiOrder ao = new AiOrder(); | |||
| ao.updateTenantInfo(mall); | |||
| //没有couponOrder的同步 | |||
| ao.setNoCouponOrder(EnumYesOrNo.YES.getCode()); | |||
| ao.setNoCouponOrderStatus(EnumYesOrNo.YES.getCode()); | |||
| ao.setLastCreateDate(DateUtils.getDayBegin(new Date())); | |||
| List<AiOrder> aiOrderList = aiOrderService.list(ao); | |||
| if (null != aiOrderList && aiOrderList.size() > 0 ) { | |||
| Map<Long, WxBrand> brandMap = wxBrandService.getAllMap(mall); | |||
| Map<Integer, WxBusiness> businessMap = wxBusinessService.findAllMap(mall); | |||
| for (AiOrder _ao : aiOrderList) { | |||
| try { | |||
| WxCouponOrder co = new WxCouponOrder(); | |||
| co.updateTenantInfo(_ao); | |||
| co.setOrderId(_ao.getOrderId()); | |||
| List<WxCouponOrder> colist = wxCouponOrderMapper.findList(co); | |||
| if (null != colist && colist.size() > 0) { | |||
| WxCouponOrder wco = colist.get(0); | |||
| _ao.setCouponOrderId(wco.getId()); | |||
| _ao.setCouponId(wco.getCouponId()); | |||
| _ao.setCouponType(wco.getCouponType()); | |||
| WxCoupon coupon = wxCouponMapper.selectById(wco.getCouponId(), _ao.getTenantId()); | |||
| if (null != coupon) { | |||
| _ao.setCouponTitle(coupon.getTitle()); | |||
| _ao.setCouponPrice(coupon.getPrice()); | |||
| } | |||
| _ao.setCouponSalePrice(wco.getCouponPrice()); | |||
| _ao.setCouponSubsidy(wco.getSubsidy()); | |||
| _ao.setExpiredTime(wco.getExpiredTime()); | |||
| _ao.setOwnerId(wco.getOwnerId()); | |||
| WxCUserBasicInfo cui = wxCUserBasicInfoMapper.selectById(wco.getOwnerId(), _ao.getTenantId()); | |||
| if (null != cui) { | |||
| _ao.setOwnerPhone(cui.getPhone()); | |||
| _ao.setOwnerNickName(cui.getNickName()); | |||
| } | |||
| _ao.setCouponOrderStatus(wco.getCouponOrderStatus()); | |||
| updateVerifyInfo(_ao,wco,brandMap,businessMap); | |||
| aiOrderService.saveOrUpdate(_ao); | |||
| }else { | |||
| //因为昨天未支付的订单现在肯定是已作废状态了 | |||
| _ao.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_INVALID.getCode()); | |||
| aiOrderService.saveOrUpdate(_ao); | |||
| } | |||
| }catch(Exception e) { | |||
| logger.error("aiOrder updateWxCouponOrderSchedule error:"+_ao.getId(),e); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| //更新coupon_order_status==0或者为空的订单, 因为订单可能被核销等操作会变更一些数据 | |||
| @Async | |||
| @Scheduled(cron = "0 0 */2 * * ?") // 每2个小时执行一次 | |||
| public void updateOrderSchedule() { | |||
| List<WxMall> malls = getMalls(); | |||
| for (WxMall mall : malls) { | |||
| try { | |||
| AiOrder ao = new AiOrder(); | |||
| ao.updateTenantInfo(mall); | |||
| ao.setHasCouponOrder(EnumYesOrNo.YES.getCode()); | |||
| ao.setNeedUpdateCouponOrderStatus(EnumYesOrNo.YES.getCode()); | |||
| List<AiOrder> aiOrderList = aiOrderService.list(ao); | |||
| if (null != aiOrderList && aiOrderList.size() > 0 ) { | |||
| Map<Long, WxBrand> brandMap = wxBrandService.getAllMap(mall); | |||
| Map<Integer, WxBusiness> businessMap = wxBusinessService.findAllMap(mall); | |||
| for (AiOrder _ao : aiOrderList) { | |||
| try { | |||
| WxCouponOrder co = new WxCouponOrder(); | |||
| co.updateTenantInfo(_ao); | |||
| co.setOrderId(_ao.getOrderId()); | |||
| List<WxCouponOrder> colist = wxCouponOrderMapper.findList(co); | |||
| if (null != colist && colist.size() > 0) { | |||
| WxCouponOrder wco = colist.get(0); | |||
| updateVerifyInfo(_ao,wco,brandMap,businessMap); | |||
| aiOrderService.saveOrUpdate(_ao); | |||
| } | |||
| }catch(Exception e) { | |||
| logger.error("aiOrder updateOrderSchedule error.mall:"+mall.getTenantId(),e); | |||
| } | |||
| } | |||
| } | |||
| }catch(Exception e) { | |||
| logger.error("aiOrder updateOrderSchedule error.mall:"+mall.getTenantId(),e); | |||
| } | |||
| } | |||
| } | |||
| private void updateVerifyInfo(AiOrder _ao,WxCouponOrder wco,Map<Long, WxBrand> brandMap,Map<Integer, WxBusiness> businessMap) { | |||
| if (null != wco.getBUserId()) { | |||
| _ao.setBUserId(wco.getBUserId()); | |||
| WxMerchantBUser mbu = wxMerchantBUserMapper.selectById(wco.getBUserId()); | |||
| if (null != mbu) { | |||
| _ao.setBUserPhone(mbu.getPhone()); | |||
| } | |||
| } | |||
| if (null != wco.getBMerchantId()){ | |||
| _ao.setBMerchantId(wco.getBMerchantId()); | |||
| WxMerchant merchant = wxMerchantMapper.selectById(wco.getBMerchantId()); | |||
| if (null != merchant) { | |||
| _ao.setBMerchantName(merchant.getName()); | |||
| _ao.setBrandId(merchant.getBrand()); | |||
| if (null != merchant.getBrand() && null != brandMap) { | |||
| WxBrand brand = brandMap.get(merchant.getBrand()); | |||
| if (null != brand) { | |||
| _ao.setBrandName(brand.getName()); | |||
| } | |||
| } | |||
| _ao.setBussiness(merchant.getBusinessId()); | |||
| if (null != merchant.getBusinessId() && null != businessMap) { | |||
| WxBusiness business = businessMap.get(merchant.getBusinessId()); | |||
| if (null != business) { | |||
| _ao.setBussinessName(business.getTitle()); | |||
| } | |||
| } | |||
| //_ao.setShopNumber(); | |||
| } | |||
| } | |||
| _ao.setSendMerchantId(wco.getSendMerchantId()); | |||
| if (null != wco.getSendMerchantId()) { | |||
| WxMerchant smerchant = wxMerchantMapper.selectById(wco.getSendMerchantId()); | |||
| if (null != smerchant) { | |||
| _ao.setSendMerchantName(smerchant.getName()); | |||
| } | |||
| } | |||
| if (wco.getCouponOrderStatus().intValue() == EnumCouponOrderStatus.COUPON_ORDER_USED.getCode().intValue()) { | |||
| _ao.setVerifyTime(wco.getUpdateDate()); | |||
| } | |||
| _ao.setCouponOrderStatus(wco.getCouponOrderStatus()); | |||
| } | |||
| // //查询新创建的订单,增量同步wxCouponOrder.因为中间有些订单有付了款,有没付款 | |||
| // @Async | |||
| // //@Scheduled(cron = "0 */5 * * * ?") // 每天凌晨00:50 | |||
| // @Scheduled(cron = "0 53 0 * * *?")// 每天凌晨00:53 | |||
| // public void updateWxCouponOrderSchedule() { | |||
| // List<WxMall> malls = getMalls(); | |||
| // for (WxMall mall : malls) { | |||
| // | |||
| // AiOrder ao = new AiOrder(); | |||
| // ao.updateTenantInfo(mall); | |||
| // //没有couponOrder的同步 | |||
| // ao.setNoCouponOrder(EnumYesOrNo.YES.getCode()); | |||
| // ao.setNoCouponOrderStatus(EnumYesOrNo.YES.getCode()); | |||
| // ao.setLastCreateDate(DateUtils.getDayBegin(new Date())); | |||
| // | |||
| // List<AiOrder> aiOrderList = aiOrderService.list(ao); | |||
| // if (null != aiOrderList && aiOrderList.size() > 0 ) { | |||
| // Map<Long, WxBrand> brandMap = wxBrandService.getAllMap(mall); | |||
| // Map<Integer, WxBusiness> businessMap = wxBusinessService.findAllMap(mall); | |||
| // for (AiOrder _ao : aiOrderList) { | |||
| // try { | |||
| // WxCouponOrder co = new WxCouponOrder(); | |||
| // co.updateTenantInfo(_ao); | |||
| // co.setOrderId(_ao.getOrderId()); | |||
| // List<WxCouponOrder> colist = wxCouponOrderMapper.findList(co); | |||
| // if (null != colist && colist.size() > 0) { | |||
| // WxCouponOrder wco = colist.get(0); | |||
| // _ao.setCouponOrderId(wco.getId()); | |||
| // _ao.setCouponId(wco.getCouponId()); | |||
| // _ao.setCouponType(wco.getCouponType()); | |||
| // WxCoupon coupon = wxCouponMapper.selectById(wco.getCouponId(), _ao.getTenantId()); | |||
| // if (null != coupon) { | |||
| // _ao.setCouponTitle(coupon.getTitle()); | |||
| // _ao.setCouponPrice(coupon.getPrice()); | |||
| // } | |||
| // _ao.setCouponSalePrice(wco.getCouponPrice()); | |||
| // _ao.setCouponSubsidy(wco.getSubsidy()); | |||
| // _ao.setExpiredTime(wco.getExpiredTime()); | |||
| // | |||
| // _ao.setOwnerId(wco.getOwnerId()); | |||
| // WxCUserBasicInfo cui = wxCUserBasicInfoMapper.selectById(wco.getOwnerId(), _ao.getTenantId()); | |||
| // if (null != cui) { | |||
| // _ao.setOwnerPhone(cui.getPhone()); | |||
| // _ao.setOwnerNickName(cui.getNickName()); | |||
| // } | |||
| // _ao.setCouponOrderStatus(wco.getCouponOrderStatus()); | |||
| // updateVerifyInfo(_ao,wco,brandMap,businessMap); | |||
| // aiOrderService.saveOrUpdate(_ao); | |||
| // }else { | |||
| // //因为昨天未支付的订单现在肯定是已作废状态了 | |||
| // _ao.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_INVALID.getCode()); | |||
| // aiOrderService.saveOrUpdate(_ao); | |||
| // } | |||
| // }catch(Exception e) { | |||
| // logger.error("aiOrder updateWxCouponOrderSchedule error:"+_ao.getId(),e); | |||
| // } | |||
| // } | |||
| // } | |||
| // } | |||
| // } | |||
| // | |||
| // //更新coupon_order_status==0或者为空的订单, 因为订单可能被核销等操作会变更一些数据 | |||
| // @Async | |||
| // @Scheduled(cron = "0 0 */2 * * ?") // 每2个小时执行一次 | |||
| // public void updateOrderSchedule() { | |||
| // List<WxMall> malls = getMalls(); | |||
| // for (WxMall mall : malls) { | |||
| // try { | |||
| // | |||
| // AiOrder ao = new AiOrder(); | |||
| // ao.updateTenantInfo(mall); | |||
| // ao.setHasCouponOrder(EnumYesOrNo.YES.getCode()); | |||
| // ao.setNeedUpdateCouponOrderStatus(EnumYesOrNo.YES.getCode()); | |||
| // List<AiOrder> aiOrderList = aiOrderService.list(ao); | |||
| // if (null != aiOrderList && aiOrderList.size() > 0 ) { | |||
| // Map<Long, WxBrand> brandMap = wxBrandService.getAllMap(mall); | |||
| // Map<Integer, WxBusiness> businessMap = wxBusinessService.findAllMap(mall); | |||
| // | |||
| // for (AiOrder _ao : aiOrderList) { | |||
| // try { | |||
| // WxCouponOrder co = new WxCouponOrder(); | |||
| // co.updateTenantInfo(_ao); | |||
| // co.setOrderId(_ao.getOrderId()); | |||
| // List<WxCouponOrder> colist = wxCouponOrderMapper.findList(co); | |||
| // if (null != colist && colist.size() > 0) { | |||
| // WxCouponOrder wco = colist.get(0); | |||
| // updateVerifyInfo(_ao,wco,brandMap,businessMap); | |||
| // aiOrderService.saveOrUpdate(_ao); | |||
| // } | |||
| // }catch(Exception e) { | |||
| // logger.error("aiOrder updateOrderSchedule error.mall:"+mall.getTenantId(),e); | |||
| // } | |||
| // } | |||
| // } | |||
| // }catch(Exception e) { | |||
| // logger.error("aiOrder updateOrderSchedule error.mall:"+mall.getTenantId(),e); | |||
| // } | |||
| // } | |||
| // } | |||
| // | |||
| // private void updateVerifyInfo(AiOrder _ao,WxCouponOrder wco,Map<Long, WxBrand> brandMap,Map<Integer, WxBusiness> businessMap) { | |||
| // if (null != wco.getBUserId()) { | |||
| // _ao.setBUserId(wco.getBUserId()); | |||
| // WxMerchantBUser mbu = wxMerchantBUserMapper.selectById(wco.getBUserId()); | |||
| // if (null != mbu) { | |||
| // _ao.setBUserPhone(mbu.getPhone()); | |||
| // } | |||
| // } | |||
| // | |||
| // if (null != wco.getBMerchantId()){ | |||
| // _ao.setBMerchantId(wco.getBMerchantId()); | |||
| // WxMerchant merchant = wxMerchantMapper.selectById(wco.getBMerchantId()); | |||
| // if (null != merchant) { | |||
| // _ao.setBMerchantName(merchant.getName()); | |||
| // _ao.setBrandId(merchant.getBrand()); | |||
| // if (null != merchant.getBrand() && null != brandMap) { | |||
| // WxBrand brand = brandMap.get(merchant.getBrand()); | |||
| // if (null != brand) { | |||
| // _ao.setBrandName(brand.getName()); | |||
| // } | |||
| // } | |||
| // | |||
| // _ao.setBussiness(merchant.getBusinessId()); | |||
| // if (null != merchant.getBusinessId() && null != businessMap) { | |||
| // WxBusiness business = businessMap.get(merchant.getBusinessId()); | |||
| // if (null != business) { | |||
| // _ao.setBussinessName(business.getTitle()); | |||
| // } | |||
| // } | |||
| // //_ao.setShopNumber(); | |||
| // } | |||
| // } | |||
| // _ao.setSendMerchantId(wco.getSendMerchantId()); | |||
| // if (null != wco.getSendMerchantId()) { | |||
| // WxMerchant smerchant = wxMerchantMapper.selectById(wco.getSendMerchantId()); | |||
| // if (null != smerchant) { | |||
| // _ao.setSendMerchantName(smerchant.getName()); | |||
| // } | |||
| // } | |||
| // if (wco.getCouponOrderStatus().intValue() == EnumCouponOrderStatus.COUPON_ORDER_USED.getCode().intValue()) { | |||
| // _ao.setVerifyTime(wco.getUpdateDate()); | |||
| // } | |||
| // _ao.setCouponOrderStatus(wco.getCouponOrderStatus()); | |||
| // } | |||
| } | |||