Blame view

parking-module-pay/src/main/java/com/zteits/pay/biz/TdACardCouponsServiceImpl.java 2.56 KB
55f68655   王彪总   新项目
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
  package com.zteits.pay.biz;
  
  import java.text.ParseException;
  import java.text.SimpleDateFormat;
  import java.util.ArrayList;
  import java.util.Date;
  import java.util.List;
  
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Component;
  
  import com.zteits.clouds.api.apibase.bean.BizResult;
  import com.zteits.clouds.api.dto.pay.TdACardCouponsOutDTO;
  import com.zteits.clouds.api.dto.pay.param.TdACardCouponsOutRequest;
  import com.zteits.clouds.api.service.pay.TdACardCouponsService;
  import com.zteits.pay.dao.TdACardCouponsDao;
  import com.zteits.pay.domain.TdACardCoupons;
  
  /**
   * 会员卡查询服务实现(存量 `zteits-pay` 的 `TdACardCouponsServiceImpl`,
   * 随注释代码一起被删;本次按原实现搬运 `queryCardCouponsByCarNumbers`)。
   *
   * <p>行为逐行照搬存量:<br>
   * ① `cardTime` 为空时取「当前时间格式化到秒」再解析回来(截掉毫秒);<br>
   * ② 对每个车牌查一次库(存量就是 N 次查询,**照搬,不合并**);<br>
   * ③ 查到任意一条即 `coupons="1"`,否则 `"0"`。</p>
   */
  @Component
  public class TdACardCouponsServiceImpl implements TdACardCouponsService {
  
      private static final Logger logger = LoggerFactory.getLogger(TdACardCouponsServiceImpl.class);
  
      @Autowired
      private TdACardCouponsDao tdACardCouponsDao;
  
      @Override
      public BizResult<List<TdACardCouponsOutDTO>> queryCardCouponsByCarNumbers(TdACardCouponsOutRequest request)
          throws ParseException {
          List<TdACardCouponsOutDTO> dtolist = new ArrayList<>();
          SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
          if (request != null) {
              if (null == request.getCardTime()) {
                  request.setCardTime(format.parse(format.format(new Date())));
              }
              List<String> carNumbers = request.getCarNumbers();
              if (carNumbers != null) {
                  for (String carNumber : carNumbers) {
                      TdACardCouponsOutDTO tdACardCouponsOutDTO = new TdACardCouponsOutDTO();
                      List<TdACardCoupons> list = tdACardCouponsDao.queryCardCouponsByCarNumbers(carNumber,
                          request.getCardTime());
                      tdACardCouponsOutDTO.setCarNumber(carNumber);
                      tdACardCouponsOutDTO.setCoupons((list.size() > 0) ? "1" : "0");
                      dtolist.add(tdACardCouponsOutDTO);
                  }
              }
          }
  
          return new BizResult<List<TdACardCouponsOutDTO>>(dtolist);
      }
  }