| @@ -2,6 +2,7 @@ package com.iformall.schedule; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.vo.WxMerchantProductVo; | |||
| import com.iformall.enums.EnumDateAmtType; | |||
| import com.iformall.enums.EnumMerchantStatus; | |||
| import com.iformall.mapper.*; | |||
| @@ -41,22 +42,38 @@ public class DaliyAmountSchedule { | |||
| @Autowired | |||
| WxMerchantBUserMapper wxMerchantBUserMapper; | |||
| @Autowired | |||
| WxCouponMerchantMapper wxCouponMerchantMapper; | |||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||
| public void daliyAmountMerchant(Date startDate,Date endDate,Calendar cal,WxMerchant merchant){ | |||
| Map dateMap = new HashMap(); | |||
| dateMap.put("startDate", startDate); | |||
| dateMap.put("endDate", endDate); | |||
| dateMap.put("merchantId", merchant.getId()); | |||
| dateMap.put("tenantId", merchant.getTenantId()); | |||
| WxMerchantBUser merchantBUserQ = new WxMerchantBUser(); | |||
| merchantBUserQ.updateTenantInfo(merchant); | |||
| merchantBUserQ.setMerchantId(merchant.getId()); | |||
| List<Long> bUserIds = wxMerchantBUserMapper.findIdList(merchantBUserQ); | |||
| dateMap.put("bUserIdList", bUserIds); | |||
| List<WxCouponOrder> list = wxCouponOrderMapper.findListOfOrderedByDate(dateMap); | |||
| Map orderdateMap = new HashMap(); | |||
| orderdateMap.put("startDateTimes", startDate.getTime()); | |||
| orderdateMap.put("endDateTimes", endDate.getTime()); | |||
| orderdateMap.put("merchantId", merchant.getId()); | |||
| orderdateMap.put("tenantId", merchant.getTenantId()); | |||
| List<Long> merchantIdList = new ArrayList<Long>(); | |||
| merchantIdList.add(merchant.getId()); | |||
| List<WxMerchantProductVo> merchantProductVos = wxCouponMerchantMapper.findOnlyMerchantProduct(merchant.getTenantId(), merchantIdList); | |||
| boolean hasCoupons = true; | |||
| if (null != merchantProductVos && merchantProductVos.size() > 0 ){ | |||
| List<Long> couponIds = new ArrayList<Long>(); | |||
| for (int i = 0 ; i < merchantProductVos.size(); i ++) { | |||
| WxMerchantProductVo mp = merchantProductVos.get(i); | |||
| if (!couponIds.contains(mp.getProductId())) { | |||
| couponIds.add(mp.getProductId()); | |||
| } | |||
| } | |||
| if (couponIds.size() > 0 ) { | |||
| orderdateMap.put("couponIds", couponIds); | |||
| }else { | |||
| return; | |||
| } | |||
| } | |||
| List<WxCouponOrder> list = wxCouponOrderMapper.findListOfOrderedByDate(orderdateMap); | |||
| logger.info("find " + list.size() + " coupon order from " + startDate + " to " + endDate); | |||
| int total_price = list.stream().mapToInt(p -> p.getCouponPrice()).sum(); | |||
| @@ -77,6 +94,16 @@ public class DaliyAmountSchedule { | |||
| wxDateAmountRecordService.saveAmount(dateAmountRecord); | |||
| Map dateMap = new HashMap(); | |||
| dateMap.put("startDate", startDate); | |||
| dateMap.put("endDate", endDate); | |||
| dateMap.put("merchantId", merchant.getId()); | |||
| dateMap.put("tenantId", merchant.getTenantId()); | |||
| WxMerchantBUser merchantBUserQ = new WxMerchantBUser(); | |||
| merchantBUserQ.updateTenantInfo(merchant); | |||
| merchantBUserQ.setMerchantId(merchant.getId()); | |||
| List<Long> bUserIds = wxMerchantBUserMapper.findIdList(merchantBUserQ); | |||
| dateMap.put("bUserIdList", bUserIds); | |||
| list = wxCouponOrderMapper.findListOfVerifiedByDate(dateMap); | |||
| if (null != list && list.size() > 0) { | |||
| logger.info("\nfind " + list.size() + " coupon order from " + startDate + " to " + endDate); | |||