食堂客户分类报表修改,增加自动清除餐补任务
diff --git a/config/application-devel-pg.properties b/config/application-devel-pg.properties
index 28f9f94..cf4f1be 100644
--- a/config/application-devel-pg.properties
+++ b/config/application-devel-pg.properties
@@ -32,4 +32,6 @@
 
 
 cron.offlinedtl= 0 0/5 * * * ?
-payapi.logintime= 0 0/5 * * * ? 
\ No newline at end of file
+payapi.logintime= 0 0/5 * * * ? 
+
+restaurant.check_discount_expire.cron= 0 0/2 * * * ?
\ No newline at end of file
diff --git a/src/main/java/com/supwisdom/dlpay/api/service/impl/PosPayServiceImpl.java b/src/main/java/com/supwisdom/dlpay/api/service/impl/PosPayServiceImpl.java
index f2a34a2..104c421 100644
--- a/src/main/java/com/supwisdom/dlpay/api/service/impl/PosPayServiceImpl.java
+++ b/src/main/java/com/supwisdom/dlpay/api/service/impl/PosPayServiceImpl.java
@@ -76,6 +76,8 @@
     private CardDao cardDao;
     @Autowired
     private CardverDao cardverDao;
+    @Autowired
+    private CustTypeDao custTypeDao;
 
 
     @Override
@@ -427,6 +429,7 @@
             Double amount = amt/ 100.0;
             Double cntamount = 0.0;
             logger.info("交易号:" + tTransdtl.getBillno() + ",,,交易金额:" + req.getAmount());
+
             DiscountBean bean = deviceDiscountRuleService.getCustomerDiscount(tDevice.getId(), req.getTermtime(), cus.getCustid());
             if (null != bean) {
                 cntamount = getDiscountAmount(req.getTermdate(), cus.getCustid(), amount, bean);
diff --git a/src/main/java/com/supwisdom/dlpay/framework/util/DateUtil.java b/src/main/java/com/supwisdom/dlpay/framework/util/DateUtil.java
index 93a4244..fffc97f 100644
--- a/src/main/java/com/supwisdom/dlpay/framework/util/DateUtil.java
+++ b/src/main/java/com/supwisdom/dlpay/framework/util/DateUtil.java
@@ -349,4 +349,17 @@
     public static String getUTCTime() {
         return getUTCTime(System.currentTimeMillis());
     }
+
+    public static void main(String[] args) {
+        String c=getNow("yyyyMMdd");
+        String c2=getNow();
+        String i=getNewDay(c,30);
+        String c3=c2.substring(0,8);
+        System.out.println(c3);
+        System.out.println(i);
+
+        int x=compareDatetime(c,i,"yyyyMMdd");
+
+        System.out.println(x);
+    }
 }
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/bean/CustomerExportBean.java b/src/main/java/com/supwisdom/dlpay/restaurant/bean/CustomerExportBean.java
index e2f504c..1509dc6 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/bean/CustomerExportBean.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/bean/CustomerExportBean.java
@@ -7,7 +7,7 @@
     private String phone;
     private String cardno;
     private String bankcardno;
-    private String deptcode;
+    private String deptname;
 
     public String getCustname() {
         return custname;
@@ -41,11 +41,11 @@
         this.bankcardno = bankcardno;
     }
 
-    public String getDeptcode() {
-        return deptcode;
+    public String getDeptname() {
+        return deptname;
     }
 
-    public void setDeptcode(String deptcode) {
-        this.deptcode = deptcode;
+    public void setDeptname(String deptname) {
+        this.deptname = deptname;
     }
 }
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/bean/DiscountBean.java b/src/main/java/com/supwisdom/dlpay/restaurant/bean/DiscountBean.java
index 20ae7a9..d03e3b3 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/bean/DiscountBean.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/bean/DiscountBean.java
@@ -9,6 +9,7 @@
     private String rulemode;
     private String starttime;
     private String endtime;
+    private String importdate;
 
     public DiscountBean(){
 
@@ -79,4 +80,12 @@
     public void setEndtime(String endtime) {
         this.endtime = endtime;
     }
+
+    public String getImportdate() {
+        return importdate;
+    }
+
+    public void setImportdate(String importdate) {
+        this.importdate = importdate;
+    }
 }
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/dao/CustTypeDao.java b/src/main/java/com/supwisdom/dlpay/restaurant/dao/CustTypeDao.java
index 7beb09c..2f3946c 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/dao/CustTypeDao.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/dao/CustTypeDao.java
@@ -11,5 +11,6 @@
 public interface CustTypeDao extends JpaRepository<TCustType, Integer> {
     Page<TCustType> findAllByCusttypenameContaining(String custtypename,Pageable pageable);
 
+    TCustType findByCusttypeid(Integer custtypeid);
 
 }
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/service/DeviceDiscountRuleService.java b/src/main/java/com/supwisdom/dlpay/restaurant/service/DeviceDiscountRuleService.java
index c64a79e..7d938a1 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/service/DeviceDiscountRuleService.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/service/DeviceDiscountRuleService.java
@@ -23,6 +23,8 @@
   @Transactional(rollbackFor = Exception.class)
   boolean deleteDiscountRule(int ruleid)throws WebCheckException;
 
+  @Transactional(rollbackFor = Exception.class, readOnly = true)
+  public List<TDiscountDetail> getExpiredDisCountDetail(Integer custtypeid);
 
   @Transactional(rollbackFor = Exception.class)
   public boolean changeDiscountRuleLimitCnt(int ruleid,int limitcnt) throws WebCheckException;
@@ -73,6 +75,10 @@
   @Transactional(rollbackFor = Exception.class)
   boolean saveDiscountDetails(int ruleid, List<String> custids ) throws WebCheckException;
 
+  @Transactional(rollbackFor = Exception.class)
+  boolean updateDiscountDetail(TDiscountDetail detail ) ;
+
+
   @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class,readOnly = true)
   List<ZTreeNode> getUserDiscount(String custid);
 
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/CustomerServiceImpl.java b/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/CustomerServiceImpl.java
index 33d8674..36eb00e 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/CustomerServiceImpl.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/CustomerServiceImpl.java
@@ -311,7 +311,7 @@
 
     @Override
     public JsonResult export(HttpServletRequest request, HttpServletResponse response) {
-        String[] titles0 = {"市民卡号", "姓名", "联系电话", "银行卡号"
+        String[] titles0 = {"市民卡号", "姓名", "联系电话", "银行卡号","部门"
         }; //表头
         String fileName0 = "客户名单";// 保存数据
         String[][] info0 = {{}};
@@ -319,7 +319,6 @@
 
         Integer cnt = dtl.size();
         if (cnt > 0) {
-            System.out.println("---init here---");
             info0 = new String[cnt][titles0.length];
 
             for (int i = 0; i < cnt; i++) {
@@ -328,6 +327,7 @@
                 info0[i][1] = t.getCustname();
                 info0[i][2] = t.getPhone();
                 info0[i][3] = t.getBankcardno();
+                info0[i][4] = t.getDeptname();
 
             }
         }
@@ -345,7 +345,7 @@
         StringBuffer querySql = new StringBuffer(
                 "select c.custname,c.phone,t.cardno,t.bankcardno,d.deptname from tb_card t" +
                         " left join tb_customer c on t.custid=c.custid" +
-                        "left join tb_dept d on c.deptcode=d.deptcode");
+                        " left join tb_dept d on c.deptcode=d.deptcode");
 
         Query query = entityManager.createNativeQuery(querySql.toString());
         query.unwrap(NativeQueryImpl.class).setResultTransformer(Transformers.aliasToBean(CustomerExportBean.class));
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/CusttypeReportServiceImpl.java b/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/CusttypeReportServiceImpl.java
index 1b6cd72..a09d7a1 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/CusttypeReportServiceImpl.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/CusttypeReportServiceImpl.java
@@ -1,6 +1,5 @@
 package com.supwisdom.dlpay.restaurant.service.impl;
 
-import com.supwisdom.dlpay.framework.dao.OperatorDao;
 import com.supwisdom.dlpay.framework.domain.TOperator;
 import com.supwisdom.dlpay.framework.service.SystemUtilService;
 import com.supwisdom.dlpay.framework.util.DateUtil;
@@ -8,14 +7,7 @@
 import com.supwisdom.dlpay.framework.util.StringUtil;
 import com.supwisdom.dlpay.restaurant.bean.CusttypeReportShowBean;
 import com.supwisdom.dlpay.restaurant.bean.DailyReportSearchBean;
-import com.supwisdom.dlpay.restaurant.bean.DailyReportSearchData;
-import com.supwisdom.dlpay.restaurant.bean.DailyReportShowBean;
-import com.supwisdom.dlpay.restaurant.dao.CheckCtlDao;
-import com.supwisdom.dlpay.restaurant.dao.DeviceGroupDao;
-import com.supwisdom.dlpay.restaurant.dao.MealTypeDao;
-import com.supwisdom.dlpay.restaurant.dao.MealsdtlDao;
 import com.supwisdom.dlpay.restaurant.service.CusttypeReportService;
-import com.supwisdom.dlpay.restaurant.service.DailyReportService;
 import com.supwisdom.dlpay.restaurant.util.ExcelPoiUtil;
 import org.apache.poi.hssf.usermodel.HSSFCellStyle;
 import org.apache.poi.hssf.usermodel.HSSFRow;
@@ -34,7 +26,6 @@
 import javax.persistence.Query;
 import javax.servlet.http.HttpServletResponse;
 import java.io.OutputStream;
-import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -44,11 +35,6 @@
 
     @Autowired
     private SystemUtilService systemUtilService;
-    @Autowired
-    private CheckCtlDao checkCtlDao;
-    @Autowired
-    private OperatorDao operatorDao;
-
 
     @PersistenceContext
     private EntityManager entityManager;
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/DeviceDiscountRuleServiceImpl.java b/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/DeviceDiscountRuleServiceImpl.java
index 7617bb7..48604ea 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/DeviceDiscountRuleServiceImpl.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/DeviceDiscountRuleServiceImpl.java
@@ -7,6 +7,7 @@
 import com.supwisdom.dlpay.framework.domain.TPermission;
 import com.supwisdom.dlpay.framework.domain.TRoleFunction;
 import com.supwisdom.dlpay.framework.service.SystemUtilService;
+import com.supwisdom.dlpay.framework.util.DateUtil;
 import com.supwisdom.dlpay.framework.util.ImportExcelUtil;
 import com.supwisdom.dlpay.framework.util.PageResult;
 import com.supwisdom.dlpay.framework.util.StringUtil;
@@ -53,16 +54,12 @@
     private DiscountDetailDao discountDetailDao;
     @Autowired
     private SystemUtilService systemUtilService;
-
     @Autowired
     private DeviceDao deviceDao;
-
     @Autowired
     private CustomerListService customerListService;
-
     @Autowired
     private CustomerService customerService;
-
     @Autowired
     private CardService cardService;
 
@@ -131,7 +128,7 @@
     }
 
     @Override
-    public boolean changeDiscountRuleLimitCnt(int ruleid,int limitcnt) throws WebCheckException {
+    public boolean changeDiscountRuleLimitCnt(int ruleid, int limitcnt) throws WebCheckException {
         TDiscountRule rule = discountRuleDao.findByRuleid(ruleid);
         if (null == rule) {
             throw new WebCheckException("餐补规则不存在!");
@@ -192,8 +189,23 @@
     }
 
     @Override
+    public List<TDiscountDetail> getExpiredDisCountDetail(Integer custtypeid) {
+        StringBuffer sb = new StringBuffer("select t.* from tb_discount_detail t " +
+                "left join tb_customer c " +
+                "on t.userid=c.custid " +
+                "where c.custtype=:custtypeid " +
+                "and t.status='normal'");
+        Query query = entityManager.createNativeQuery(sb.toString());
+        query.setParameter("custtypeid", custtypeid);
+        query.unwrap(NativeQueryImpl.class).setResultTransformer(Transformers.aliasToBean(TDiscountDetail.class));
+        List<TDiscountDetail> list = query.getResultList();
+        if (null != list) return list;
+        return new ArrayList<>(0);
+    }
+
+    @Override
     public boolean saveNewDiscountRule(String rulename, String ruletype, String starttime,
-                                       String endtime, Double amount, Integer limitcnt, String listid, TOperator oper,String rulemode) throws Exception {
+                                       String endtime, Double amount, Integer limitcnt, String listid, TOperator oper, String rulemode) throws Exception {
         TDiscountRule rule = new TDiscountRule();
         if (discountRuleDao.checkRulenameExists(rulename) > 0) {
             throw new WebCheckException("餐补名称已经存在!");
@@ -420,7 +432,7 @@
 
     @Override
     public DiscountBean getCustomerDiscount(Integer deviceid, String termtime, String custid) {
-        StringBuffer sql = new StringBuffer("select d.limitcnt,d.ruletype,d.amount,d.ruleid,d.starttime,d.endtime,d.rulemode from  tb_discount_rule d " +
+        StringBuffer sql = new StringBuffer("select d.limitcnt,d.ruletype,d.amount,d.ruleid,d.starttime,d.endtime,d.rulemode,substr(c.lastsaved, 1, 8) as importdate from  tb_discount_rule d " +
                 "left join tb_discount_devbind t on t.ruleid=d.ruleid " +
                 "left join tb_discount_detail c on t.ruleid=c.ruleid " +
                 "where d.status='normal' and t.deviceid=:deviceid " +
@@ -536,9 +548,8 @@
     }
 
 
-
     @Override
-    public boolean saveDiscountDetails(int ruleid, List<String> custids ) throws WebCheckException {
+    public boolean saveDiscountDetails(int ruleid, List<String> custids) throws WebCheckException {
         TDiscountRule rule = discountRuleDao.findByRuleid(ruleid);
         String systime = systemUtilService.getSysdatetime().getHostdatetime();
 
@@ -549,7 +560,7 @@
         }
 
         for (String id : custids) {
-            DiscountDetailAddBean bean=getDiscountDetailForAdd(id);
+            DiscountDetailAddBean bean = getDiscountDetailForAdd(id);
             if (null == bean) {
                 throw new WebCheckException("客户号为[" + id + "]的客户不存在");
             }
@@ -566,9 +577,15 @@
     }
 
     @Override
+    public boolean updateDiscountDetail(TDiscountDetail detail) {
+        discountDetailDao.save(detail);
+        return true;
+    }
+
+    @Override
     public List<ZTreeNode> getUserDiscount(String custid) {
         List<NodeData> nodeData = discountRuleDao.findDiscountRuleNode();
-        List<TDiscountDetail> details=discountDetailDao.findAllByUserid(custid);
+        List<TDiscountDetail> details = discountDetailDao.findAllByUserid(custid);
         List<ZTreeNode> ret = new ArrayList<>();
         ZTreeNode zTreeNode = new ZTreeNode();
         zTreeNode.setpId("-1");
@@ -584,8 +601,8 @@
             zTreeNode.setId(data.getId());
             zTreeNode.setName(data.getName());
             zTreeNode.setChecked(false);
-            for(TDiscountDetail detail:details){
-                if(detail.getRuleid().toString().equals(data.getId())){
+            for (TDiscountDetail detail : details) {
+                if (detail.getRuleid().toString().equals(data.getId())) {
                     zTreeNode.setChecked(true);
                 }
             }
@@ -597,15 +614,15 @@
 
     @Override
     public JsonResult saveDiscountDetails(String custid, String rules) {
-        TCustomer customer=customerService.getCustomerByCustid(custid);
-        if(null==customer){
+        TCustomer customer = customerService.getCustomerByCustid(custid);
+        if (null == customer) {
             return JsonResult.error("客户不存在");
         }
-        TCard card=cardService.getNormalCardByCustid(custid);
+        TCard card = cardService.getNormalCardByCustid(custid);
         discountDetailDao.deleteByUserid(custid);
         String[] datas = rules.split(",");
         for (String rule : datas) {
-            if("0".equals(rule)){
+            if ("0".equals(rule)) {
                 continue;
             }
             TDiscountDetail detail = new TDiscountDetail();
@@ -621,7 +638,7 @@
 
     }
 
-    private DiscountDetailAddBean getDiscountDetailForAdd(String custid){
+    private DiscountDetailAddBean getDiscountDetailForAdd(String custid) {
         StringBuffer querySql = new StringBuffer("select t.custid,t.custname,c.cardno from tb_customer t " +
                 "left join tb_card c on t.custid=c.custid where  t.custid=:custid ");
         Query query = entityManager.createNativeQuery(querySql.toString());
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/task/RestaurantTask.java b/src/main/java/com/supwisdom/dlpay/restaurant/task/RestaurantTask.java
index 1144a89..d34def5 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/task/RestaurantTask.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/task/RestaurantTask.java
@@ -6,14 +6,10 @@
 import com.supwisdom.dlpay.paysdk.proxy.UserProxy;
 import com.supwisdom.dlpay.restaurant.bean.CustomerSearchBean;
 import com.supwisdom.dlpay.restaurant.bean.CustomerShowBean;
+import com.supwisdom.dlpay.restaurant.dao.CustTypeDao;
 import com.supwisdom.dlpay.restaurant.dao.CustomerDao;
-import com.supwisdom.dlpay.restaurant.domain.TCard;
-import com.supwisdom.dlpay.restaurant.domain.TCustomer;
-import com.supwisdom.dlpay.restaurant.domain.TOfflineTransDtl;
-import com.supwisdom.dlpay.restaurant.service.CardService;
-import com.supwisdom.dlpay.restaurant.service.CustomerService;
-import com.supwisdom.dlpay.restaurant.service.OfflineTransDtlService;
-import com.supwisdom.dlpay.restaurant.service.TransDtlService;
+import com.supwisdom.dlpay.restaurant.domain.*;
+import com.supwisdom.dlpay.restaurant.service.*;
 import com.supwisdom.dlpay.restaurant.util.RestaurantConstant;
 import com.supwisdom.dlpay.tenant.service.MultiTenantService;
 import com.supwisdom.multitenant.TenantContextHolder;
@@ -33,74 +29,107 @@
 @Configuration
 @EnableScheduling
 public class RestaurantTask {
-  private static final Logger logger = LoggerFactory.getLogger(RestaurantTask.class);
+    private static final Logger logger = LoggerFactory.getLogger(RestaurantTask.class);
 
-  @Autowired
-  private MultiTenantService multiTenantService;
-  @Autowired
-  private CardService cardService;
-  @Autowired
-  private CustomerService customerService;
-  @Autowired
-  private CustomerDao customerDao;
-  @Autowired
-  private UserProxy userProxy;
+    @Autowired
+    private MultiTenantService multiTenantService;
+    @Autowired
+    private CardService cardService;
+    @Autowired
+    private DeviceDiscountRuleService deviceDiscountRuleService;
+    @Autowired
+    private CustomerService customerService;
+    @Autowired
+    private CustomerDao customerDao;
+    @Autowired
+    private CustTypeDao custTypeDao;
+    @Autowired
+    private UserProxy userProxy;
 
-  @Scheduled(cron = "${restaurant.customercheck.cron}")
-  @SchedulerLock(name = "RestaurantCheckCustomerTask", lockAtMostForString = "PT20M")
-  public void doCustomerCheckTask() {
-    long t1 = System.currentTimeMillis();
-    logger.debug("=================== 客户信息校验任务开始: ===================");
+    @Scheduled(cron = "${restaurant.customercheck.cron}")
+    @SchedulerLock(name = "RestaurantCheckCustomerTask", lockAtMostForString = "PT20M")
+    public void doCustomerCheckTask() {
+        long t1 = System.currentTimeMillis();
+        logger.debug("=================== 客户信息校验任务开始: ===================");
 
-    List<TenantDetails> multiTenantSchemas = multiTenantService.getSystemAllTenantDetails();
-    for (TenantDetails schema : multiTenantSchemas) {
-      TenantContextHolder.getContext().setTenant(schema);  //切换schema
-      logger.debug("开始执行schema=[" + schema.getDbSchema() + "]的客户信息校验任务:");
-      dealCustomerCheckTask(); //TODO:执行task
-    }
-
-    long t2 = System.currentTimeMillis();
-    logger.debug("=================== 客户信息校验任务结束,耗时 " + (t2 - t1) + " ms ===================");
-  }
-
-  private void dealCustomerCheckTask() {
-    try {
-      CustomerSearchBean searchBean = new CustomerSearchBean();
-      searchBean.setCheckstatus(RestaurantConstant.STATUS_CHECKSTATUS_UNCHECK);
-
-      List<CustomerShowBean> dtls = customerService.getCustomerPage(searchBean).getData();
-      logger.debug("正同步" + dtls.size() + "名人员");
-      if (dtls.size() > 0) {
-        for (CustomerShowBean dtl : dtls) {
-          QueryUserParam param = new QueryUserParam();
-          param.setCitizencardno(dtl.getCardno());
-          UserInforResponse resp = userProxy.querybycardno(param);
-          TCustomer customer = customerService.getCustomerByCustid(dtl.getCustid());
-
-          if (resp.getRetcode() == 0) {
-            TCard card = cardService.getCardByCardno(dtl.getCardno());
-            if (null != card) {
-              card.setCardphyid(resp.getCardphyid());
-              card.setExpiredate(resp.getExpiredate());
-              card.setBankcardno(resp.getBankcardno());
-              card.setStatus(resp.getCardstatus());
-              card.setTransstatus(resp.getTransstatus());
-              cardService.updateCard(card);
-            }
-            customer.setPhone(resp.getPhone());
-            customer.setCheckstatus(RestaurantConstant.STATUS_CHECKSTATUS_NORMAL);
-            customer.setStatus(RestaurantConstant.STATUS_CARD_NORMAL);
-          } else {
-            customer.setCheckstatus(RestaurantConstant.STATUS_CHECKSTATUS_FAIL);
-            customer.setStatus(RestaurantConstant.STATUS_CHECKSTATUS_FAIL);
-          }
-          customerDao.save(customer);
+        List<TenantDetails> multiTenantSchemas = multiTenantService.getSystemAllTenantDetails();
+        for (TenantDetails schema : multiTenantSchemas) {
+            TenantContextHolder.getContext().setTenant(schema);  //切换schema
+            logger.debug("开始执行schema=[" + schema.getDbSchema() + "]的客户信息校验任务:");
+            dealCustomerCheckTask(); //TODO:执行task
         }
-      }
-    } catch (Exception e) {
-      e.printStackTrace();
+
+        long t2 = System.currentTimeMillis();
+        logger.debug("=================== 客户信息校验任务结束,耗时 " + (t2 - t1) + " ms ===================");
     }
-  }
+
+    private void dealCustomerCheckTask() {
+        try {
+            CustomerSearchBean searchBean = new CustomerSearchBean();
+            searchBean.setCheckstatus(RestaurantConstant.STATUS_CHECKSTATUS_UNCHECK);
+
+            List<CustomerShowBean> dtls = customerService.getCustomerPage(searchBean).getData();
+            logger.debug("正同步" + dtls.size() + "名人员");
+            if (dtls.size() > 0) {
+                for (CustomerShowBean dtl : dtls) {
+                    QueryUserParam param = new QueryUserParam();
+                    param.setCitizencardno(dtl.getCardno());
+                    UserInforResponse resp = userProxy.querybycardno(param);
+                    TCustomer customer = customerService.getCustomerByCustid(dtl.getCustid());
+
+                    if (resp.getRetcode() == 0) {
+                        TCard card = cardService.getCardByCardno(dtl.getCardno());
+                        if (null != card) {
+                            card.setCardphyid(resp.getCardphyid());
+                            card.setExpiredate(resp.getExpiredate());
+                            card.setBankcardno(resp.getBankcardno());
+                            card.setStatus(resp.getCardstatus());
+                            card.setTransstatus(resp.getTransstatus());
+                            cardService.updateCard(card);
+                        }
+                        customer.setPhone(resp.getPhone());
+                        customer.setCheckstatus(RestaurantConstant.STATUS_CHECKSTATUS_NORMAL);
+                        customer.setStatus(RestaurantConstant.STATUS_CARD_NORMAL);
+                    } else {
+                        customer.setCheckstatus(RestaurantConstant.STATUS_CHECKSTATUS_FAIL);
+                        customer.setStatus(RestaurantConstant.STATUS_CHECKSTATUS_FAIL);
+                    }
+                    customerDao.save(customer);
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+
+    @Scheduled(cron = "${restaurant.check_discount_expire.cron}")
+    @SchedulerLock(name = "RestaurantCheckCustomerTask", lockAtMostForString = "PT20M")
+    public void checkDiscountExpire() {
+        long t1 = System.currentTimeMillis();
+        logger.info("=================== 检查餐补过期任务开始: ===================");
+        List<TCustType> custTypes=custTypeDao.findAll();
+        for(TCustType custType:custTypes){
+            Integer expireday = custType.getExpireday();
+            if (null != expireday ) {
+                if(0 != expireday){
+                    List<TDiscountDetail> details=deviceDiscountRuleService.getExpiredDisCountDetail(custType.getCusttypeid());
+                    for(TDiscountDetail detail:details){
+                        String importdate = detail.getLastsaved().substring(0,8);
+                        String datenow = DateUtil.getNow("yyyyMMdd");
+                        String expiredate = DateUtil.getNewDay(importdate, expireday);
+                        if (DateUtil.compareDatetime(expiredate,datenow,"yyyyMMdd")<0){
+                            detail.setStatus(RestaurantConstant.STATUS_DISCOUNTRULE_CLOSED);
+                            deviceDiscountRuleService.updateDiscountDetail(detail);
+                        }
+                    }
+                }
+            }
+        }
+
+        long t2 = System.currentTimeMillis();
+        logger.info("=================== 检查餐补过期任务结束,耗时 " + (t2 - t1) + " ms ===================");
+    }
 
 //    //TODO
 //    @Scheduled(cron = "0 0/1 * * * ? ")