| @@ -64,7 +64,7 @@ public class AiOrderSchedule { | |||||
| private List<WxMall> getMalls() { | private List<WxMall> getMalls() { | ||||
| WxMall wxMall = new WxMall(); | WxMall wxMall = new WxMall(); | ||||
| wxMall.setTenantId("789"); | |||||
| //wxMall.setTenantId("789"); | |||||
| return wxMallMapper.findList(wxMall); | return wxMallMapper.findList(wxMall); | ||||
| } | } | ||||
| @@ -73,7 +73,6 @@ public class AiOrderSchedule { | |||||
| //@Scheduled(cron = "0 */5 * * * ?") // 每天凌晨00:50 | //@Scheduled(cron = "0 */5 * * * ?") // 每天凌晨00:50 | ||||
| @Scheduled(cron = "0 53 0 * * *?")// 每天凌晨00:53 | @Scheduled(cron = "0 53 0 * * *?")// 每天凌晨00:53 | ||||
| public void updateWxCouponOrderSchedule() { | public void updateWxCouponOrderSchedule() { | ||||
| System.out.println(">>>>> updateWxCouponOrderSchedule"); | |||||
| List<WxMall> malls = getMalls(); | List<WxMall> malls = getMalls(); | ||||
| for (WxMall mall : malls) { | for (WxMall mall : malls) { | ||||
| @@ -86,6 +85,8 @@ public class AiOrderSchedule { | |||||
| List<AiOrder> aiOrderList = aiOrderService.list(ao); | List<AiOrder> aiOrderList = aiOrderService.list(ao); | ||||
| if (null != aiOrderList && aiOrderList.size() > 0 ) { | if (null != aiOrderList && aiOrderList.size() > 0 ) { | ||||
| Map<Long, WxBrand> brandMap = wxBrandService.getAllMap(mall); | |||||
| Map<Integer, WxBusiness> businessMap = wxBusinessService.findAllMap(mall); | |||||
| for (AiOrder _ao : aiOrderList) { | for (AiOrder _ao : aiOrderList) { | ||||
| try { | try { | ||||
| WxCouponOrder co = new WxCouponOrder(); | WxCouponOrder co = new WxCouponOrder(); | ||||
| @@ -113,6 +114,7 @@ public class AiOrderSchedule { | |||||
| _ao.setOwnerNickName(cui.getNickName()); | _ao.setOwnerNickName(cui.getNickName()); | ||||
| } | } | ||||
| _ao.setCouponOrderStatus(wco.getCouponOrderStatus()); | _ao.setCouponOrderStatus(wco.getCouponOrderStatus()); | ||||
| updateVerifyInfo(_ao,wco,brandMap,businessMap); | |||||
| aiOrderService.saveOrUpdate(_ao); | aiOrderService.saveOrUpdate(_ao); | ||||
| }else { | }else { | ||||
| //因为昨天未支付的订单现在肯定是已作废状态了 | //因为昨天未支付的订单现在肯定是已作废状态了 | ||||
| @@ -144,7 +146,6 @@ public class AiOrderSchedule { | |||||
| Map<Long, WxBrand> brandMap = wxBrandService.getAllMap(mall); | Map<Long, WxBrand> brandMap = wxBrandService.getAllMap(mall); | ||||
| Map<Integer, WxBusiness> businessMap = wxBusinessService.findAllMap(mall); | Map<Integer, WxBusiness> businessMap = wxBusinessService.findAllMap(mall); | ||||
| for (AiOrder _ao : aiOrderList) { | for (AiOrder _ao : aiOrderList) { | ||||
| try { | try { | ||||
| WxCouponOrder co = new WxCouponOrder(); | WxCouponOrder co = new WxCouponOrder(); | ||||
| @@ -153,45 +154,7 @@ public class AiOrderSchedule { | |||||
| List<WxCouponOrder> colist = wxCouponOrderMapper.findList(co); | List<WxCouponOrder> colist = wxCouponOrderMapper.findList(co); | ||||
| if (null != colist && colist.size() > 0) { | if (null != colist && colist.size() > 0) { | ||||
| WxCouponOrder wco = colist.get(0); | WxCouponOrder wco = colist.get(0); | ||||
| if (null != wco.getBUserId()) { | |||||
| _ao.setBUserId(wco.getBUserId()); | |||||
| WxMerchantBUser mbu = wxMerchantBUserMapper.selectById(wco.getBUserId()); | |||||
| if (null != mbu) { | |||||
| _ao.setBUserPhone(mbu.getPhone()); | |||||
| } | |||||
| _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()); | |||||
| updateVerifyInfo(_ao,wco,brandMap,businessMap); | |||||
| aiOrderService.saveOrUpdate(_ao); | aiOrderService.saveOrUpdate(_ao); | ||||
| } | } | ||||
| }catch(Exception e) { | }catch(Exception e) { | ||||
| @@ -204,5 +167,50 @@ public class AiOrderSchedule { | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| 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()); | |||||
| } | |||||
| } | } | ||||