| @@ -2,6 +2,7 @@ package com.simple.mapper; | |||||
| import java.util.*; | import java.util.*; | ||||
| import com.simple.common.CommonMapper; | import com.simple.common.CommonMapper; | ||||
| import com.simple.domain.po.WxCouponOrder; | |||||
| import com.simple.domain.vo.OrderVo; | import com.simple.domain.vo.OrderVo; | ||||
| import org.apache.ibatis.annotations.Param; | import org.apache.ibatis.annotations.Param; | ||||
| import com.simple.domain.po.WxOrder; | import com.simple.domain.po.WxOrder; | ||||
| @@ -14,4 +15,5 @@ public interface WxOrderMapper extends CommonMapper<WxOrder, Long> { | |||||
| Map<String,Object> queryObject(OrderVo orderVo); | Map<String,Object> queryObject(OrderVo orderVo); | ||||
| List<WxOrder> findListOfUnpaidOrderByDate(Map dateMap); | |||||
| } | } | ||||
| @@ -64,42 +64,45 @@ public class DaliyAmountSchedule { | |||||
| for (int j=0; j < merchantList.size(); j++) { | for (int j=0; j < merchantList.size(); j++) { | ||||
| merchant = merchantList.get(j); | merchant = merchantList.get(j); | ||||
| HashMap dateMap = new HashMap(); | |||||
| Map dateMap = new HashMap(); | |||||
| SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd"); | SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd"); | ||||
| String dateString = fmt.format(new Date()); | String dateString = fmt.format(new Date()); | ||||
| Date startDate = null; | |||||
| try { | try { | ||||
| Date startDate = fmt.parse(dateString); | |||||
| dateMap.put("startDate", startDate); | |||||
| dateMap.put("endDate", new Date()); | |||||
| dateMap.put("merchantID",merchant.getId()); | |||||
| List<WxCouponOrder> list = wxCouponOrderMapper.findListOfOrderedByDate(dateMap); | |||||
| logger.info("find " + list.size() + " coupon order from " + startDate + " to " + new Date()); | |||||
| int total_price = 0; | |||||
| for(WxCouponOrder couponOrder : list) { | |||||
| total_price = total_price + couponOrder.getCouponPrice(); | |||||
| } | |||||
| logger.info("\nFound " + list.size() + " coupon orders \n" + | |||||
| "for " + merchant.getId() + "\n" + | |||||
| "from " + startDate + " to " + new Date() +"\n" + | |||||
| "TOTAL ORDER=" + total_price); | |||||
| list= wxCouponOrderMapper.findListOfVerifiedByDate(dateMap); | |||||
| logger.info("find " + list.size() + " coupon order from " + startDate + " to " + new Date()); | |||||
| total_price = 0; | |||||
| for(WxCouponOrder couponOrder : list) { | |||||
| total_price = total_price + couponOrder.getCouponPrice(); | |||||
| } | |||||
| logger.info("\nFound " + list.size() + " coupon orders \n" + | |||||
| "for " + merchant.getId() + "\n" + | |||||
| "from " + startDate + " to " + new Date() +"\n" + | |||||
| "TOTAL VERIFIED=" + total_price); | |||||
| //daliy amount 落表 | |||||
| startDate = fmt.parse(dateString); | |||||
| } catch (ParseException e) { | } catch (ParseException e) { | ||||
| logger.error("Parse date string failed"); | logger.error("Parse date string failed"); | ||||
| continue; | |||||
| } | |||||
| dateMap.put("startDate", startDate); | |||||
| dateMap.put("endDate", new Date()); | |||||
| dateMap.put("merchantID",merchant.getId()); | |||||
| List<WxCouponOrder> list = wxCouponOrderMapper.findListOfOrderedByDate(dateMap); | |||||
| logger.info("find " + list.size() + " coupon order from " + startDate + " to " + new Date()); | |||||
| int total_price = 0; | |||||
| for(WxCouponOrder couponOrder : list) { | |||||
| total_price = total_price + couponOrder.getCouponPrice(); | |||||
| } | } | ||||
| logger.info("\nFound " + list.size() + " coupon orders \n" + | |||||
| "for " + merchant.getId() + "\n" + | |||||
| "from " + startDate + " to " + new Date() +"\n" + | |||||
| "TOTAL ORDER=" + total_price); | |||||
| list= wxCouponOrderMapper.findListOfVerifiedByDate(dateMap); | |||||
| logger.info("find " + list.size() + " coupon order from " + startDate + " to " + new Date()); | |||||
| total_price = 0; | |||||
| for(WxCouponOrder couponOrder : list) { | |||||
| total_price = total_price + couponOrder.getCouponPrice(); | |||||
| } | |||||
| logger.info("\nFound " + list.size() + " coupon orders \n" + | |||||
| "for " + merchant.getId() + "\n" + | |||||
| "from " + startDate + " to " + new Date() +"\n" + | |||||
| "TOTAL VERIFIED=" + total_price); | |||||
| //daliy amount 落表 | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -0,0 +1,59 @@ | |||||
| package com.simple.schedule; | |||||
| import com.simple.domain.po.WxCouponOrder; | |||||
| import com.simple.domain.po.WxMall; | |||||
| import com.simple.domain.po.WxMerchant; | |||||
| import com.simple.domain.po.WxOrder; | |||||
| import com.simple.enums.EnumOrderStatus; | |||||
| import com.simple.mapper.WxCouponOrderMapper; | |||||
| import com.simple.mapper.WxMallMapper; | |||||
| import com.simple.mapper.WxMerchantMapper; | |||||
| import com.simple.mapper.WxOrderMapper; | |||||
| import com.simple.service.WxDateAmountRecordService; | |||||
| import org.apache.log4j.Logger; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.scheduling.annotation.Scheduled; | |||||
| import org.springframework.stereotype.Component; | |||||
| import org.springframework.transaction.annotation.Propagation; | |||||
| import org.springframework.transaction.annotation.Transactional; | |||||
| import java.text.ParseException; | |||||
| import java.text.SimpleDateFormat; | |||||
| import java.util.Date; | |||||
| import java.util.HashMap; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| @Component | |||||
| public class OrderExpireSchedule { | |||||
| private final Logger logger = Logger.getLogger(OrderExpireSchedule.class); | |||||
| private final int TIME_OUT_VALUE = 15 * 60 * 1000; //15分钟 | |||||
| @Autowired | |||||
| WxOrderMapper wxOrderMapper; | |||||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||||
| @Scheduled(cron = "0 */5 * * * *?") // 每5分钟检查一次 | |||||
| //@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 | |||||
| public void orderExpireSchedule() { | |||||
| Map dateMap = new HashMap(); | |||||
| Date curDate = new Date(); | |||||
| //dateMap.put("startDate",new Date(curDate.getTime() - 2*TIME_OUT_VALUE)); | |||||
| dateMap.put("endDate", new Date(curDate.getTime() - TIME_OUT_VALUE )); | |||||
| List<WxOrder> wxOrderList = wxOrderMapper.findListOfUnpaidOrderByDate(dateMap); | |||||
| for(WxOrder wxOrder: wxOrderList){ | |||||
| wxOrder.setUpdateDate(new Date()); | |||||
| wxOrder.setOrderStatus(EnumOrderStatus.ORDER_STATUS_OVERTIME_CANCEL.getCode()); | |||||
| wxOrderMapper.updateByPrimaryKeySelective(wxOrder); | |||||
| logger.info("\nFound " + wxOrder.getId() + "\n" | |||||
| + " create at " + wxOrder.getCreateDate() +"\n" | |||||
| + " expired at " + new Date()); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -183,6 +183,18 @@ | |||||
| </otherwise> | </otherwise> | ||||
| </choose> | </choose> | ||||
| </select> | </select> | ||||
| <select id="findListOfUnpaidOrderByDate" parameterType="map" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns" /> from wx_order | |||||
| where 1=1 | |||||
| <if test="startDate != null"> | |||||
| AND create_date > #{startDate,jdbcType=TIMESTAMP} | |||||
| </if> | |||||
| <if test="startDate != null"> | |||||
| AND create_date < #{endDate,jdbcType=TIMESTAMP} | |||||
| </if> | |||||
| AND order_status = '0' | |||||
| </select> | |||||