wangli пре 4 година
родитељ
комит
89e93b5789

+ 30 - 0
smart-city-platform/src/main/java/com/bz/smart_city/controller/pay/PayMessagesendrecordController.java

@@ -4,8 +4,10 @@ import com.bz.smart_city.commom.model.AjaxMessage;
 import com.bz.smart_city.commom.model.Pagination;
 import com.bz.smart_city.commom.model.ResultStatus;
 import com.bz.smart_city.dto.pay.PayDebtMessageDto;
+import com.bz.smart_city.dto.pay.PayDebtPushMessageDto;
 import com.bz.smart_city.dto.pay.PayMessageTemplateDto;
 import com.bz.smart_city.dto.pay.PayMessagesendrecordDto;
+import com.bz.smart_city.entity.pay.PayControlRule;
 import com.bz.smart_city.service.pay.PayMessagesendrecordService;
 import com.bz.smart_city.service.pay.PayMessagetemplateService;
 import io.swagger.annotations.Api;
@@ -142,4 +144,32 @@ public class PayMessagesendrecordController {
         }
         return payMessagesendrecordService.sendMessageByUser( condition,  beginDebtFee,  endDebtFee,  arrayList);
     }
+
+
+//    public List<PayDebtPushMessageDto> findPayDebtPushMessages();
+    @GetMapping(value = "/findPayDebtPushMessages")
+    @ApiOperation("获取催缴客户信息")
+    public AjaxMessage<Pagination<PayDebtPushMessageDto>> findPayDebtPushMessages(
+            @ApiParam(value = "客户编码/客户名称/手机号码", required = false) @RequestParam(required = false) String condition ,
+            @ApiParam(value = "查询类型:2欠费金额,3预存金额,4用水余额,1欠费天数", required = false) @RequestParam(required = false) Integer searchType,
+            @ApiParam(value = "数据左界值", required = false) @RequestParam(required = false) BigDecimal beginDebtFee,
+            @ApiParam(value = "数据右界值", required = false) @RequestParam(required = false) BigDecimal endDebtFee,
+            @ApiParam(value = "页数,非必传,默认第一页", required = false, defaultValue = "1") @RequestParam(required = false, defaultValue = "1") int pageNum,
+            @ApiParam(value = "条数,非必传,默认10条", required = false, defaultValue = "10") @RequestParam(required = false, defaultValue = "10") int pageSize
+    ){
+
+        return new AjaxMessage<>(ResultStatus.OK,payMessagesendrecordService.findPayDebtPushMessages(condition,searchType,beginDebtFee,endDebtFee,pageNum,pageSize));
+    }
+
+    @GetMapping(value = "/findPayDebtPushMessagesExport")
+    @ApiOperation("导出催缴客户信息")
+    public void findPayDebtPushMessagesExport(
+            @ApiParam(value = "客户编码/客户名称/手机号码", required = false) @RequestParam(required = false) String condition ,
+            @ApiParam(value = "查询类型:2欠费金额,3预存金额,4用水余额,1欠费天数", required = false) @RequestParam(required = false) Integer searchType,
+            @ApiParam(value = "欠费总额左界值", required = false) @RequestParam(required = false) BigDecimal beginDebtFee,
+            @ApiParam(value = "欠费总额右界值", required = false) @RequestParam(required = false) BigDecimal endDebtFee,
+            HttpServletResponse httpServletResponse
+    ){
+        payMessagesendrecordService.findPayDebtPushMessagesExport(condition,searchType,beginDebtFee,endDebtFee,httpServletResponse);
+    }
 }

+ 9 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dao/pay/PayFeeMapper.java

@@ -2,6 +2,7 @@ package com.bz.smart_city.dao.pay;
 
 import com.bz.smart_city.dto.pay.PayAgenttransactionDto;
 import com.bz.smart_city.dto.pay.PayCustomRechargeDto;
+import com.bz.smart_city.dto.pay.PayDebtPushMessageDto;
 import com.bz.smart_city.dto.pay.PayInvoiceDto;
 import com.bz.smart_city.dto.pay.payfee.*;
 import com.bz.smart_city.entity.ProgramItem;
@@ -75,4 +76,12 @@ public interface PayFeeMapper {
     Integer deleteControlValveInfoByDevice(@Param("list")List<BigInteger> list);
 
     List<PayControlRule> getValveRulesByType(@Param("action")Integer action ,@Param("types")List<Integer> types,@Param("siteId")Integer siteId, @Param("customer")Integer customer);
+
+    List<PayDebtPushMessageDto> findPayDebtPushMessages(
+            @Param("condition")String condition , @Param("searchType")Integer searchType,
+            @Param("beginDebtFee")BigDecimal beginDebtFee, @Param("endDebtFee")BigDecimal endDebtFee,
+            @Param("customerId")Integer customerId,@Param("siteId")Integer siteId,
+            @Param("payControlRules") List<PayControlRule> payControlRules,
+            @Param("programItems") List<ProgramItem> programItems );
+
 }

+ 60 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/PayDebtPushMessageDto.java

@@ -0,0 +1,60 @@
+package com.bz.smart_city.dto.pay;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+import java.util.Date;
+
+/**
+ * @description
+ * @auto wangli
+ * @data 2021/2/3 14:59
+ */
+@Api("短信推送实体")
+@Data
+public class PayDebtPushMessageDto implements Serializable {
+
+    private static final long serialVersionUID = 5740302347387682596L;
+
+    @ApiModelProperty("客户id")
+    private String accountId;
+    @ApiModelProperty("客户编码")
+    private String accountnumber;
+    @ApiModelProperty("客户名称")
+    private String accountname;
+    @ApiModelProperty("电话")
+    private String mobilephone;
+    @ApiModelProperty("当前读数")
+    private BigDecimal reading;
+    @ApiModelProperty("欠费金额(总共)")
+    private BigDecimal debt;
+    @ApiModelProperty("基础欠费(不含违约金)")
+    private BigDecimal waterfee;
+    @ApiModelProperty("违约金")
+    private BigDecimal penaltyfee;
+    @ApiModelProperty("账户余额")
+    private BigDecimal remaining;
+    @ApiModelProperty("预计费")
+    private BigDecimal balance;
+    @ApiModelProperty("欠费天数")
+    private Integer days;
+    @ApiModelProperty("催缴次数")
+    private Integer sendNum;
+    @ApiModelProperty("上次催缴时间")
+    private LocalDateTime lastSendTime;
+
+    @ApiModelProperty(value = "是否欠费规则",hidden = true)
+    private Integer  isDebt;
+    @ApiModelProperty(value =" 是否欠费天数规则",hidden = true)
+    private Integer isDays;
+    @ApiModelProperty(value = "是否预存规则",hidden = true)
+    private Integer isRemaining;
+    @ApiModelProperty(value = "是否预计费规则",hidden = true)
+    private Integer isBalance;
+
+
+}

+ 6 - 3
smart-city-platform/src/main/java/com/bz/smart_city/dto/pay/PayMessageTemplateDto.java

@@ -36,18 +36,21 @@ public class PayMessageTemplateDto extends BaseDto {
     @ApiModelProperty(value = "催缴模式:0手动 1自动")
     private Integer operationType;
 
-    @ApiModelProperty(value = "欠费短信模板")
+    @ApiModelProperty(value = "无违约金欠费短信模板")
     private String Template1;
 
     @ApiModelProperty(value = "违约金短信模板")
     private String template2;
 
-    @ApiModelProperty(value = "停水短信模板")
+    @ApiModelProperty(value = "预存催缴短信模板")
     private String template3;
 
-    @ApiModelProperty(value = "预计费短信模板")
+    @ApiModelProperty(value = "用水余额短信模板")
     private String template4;
 
+    @ApiModelProperty(value = "欠费天数短信模板")
+    private String template5;
+
     @ApiModelProperty(value = "模板说明")
     private String template;
 

+ 3 - 0
smart-city-platform/src/main/java/com/bz/smart_city/entity/pay/PayControlRule.java

@@ -31,6 +31,9 @@ public class PayControlRule {
     @ApiModelProperty(example="0",notes = "运算符,[=,≠,>,<,≥,≤]对应1,2,3,4,5,6",position = 15)
     private Integer operator;
 
+    @ApiModelProperty(example="0",notes = "运算符,[=,≠,>,<,≥,≤]对应1,2,3,4,5,6",position = 15,hidden = true)
+    private String operatorString;
+
     @ApiModelProperty(example="1",notes = "条件值",position = 20)
     private String value;
 

+ 1 - 1
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PayFeeServiceImp.java

@@ -1398,7 +1398,7 @@ public class PayFeeServiceImp implements PayFeeService {
             String result = HttpRequest.doPost(url + params ,"");
 
 //            String result= HttpClientUtils.doPostWithJson(payValveCommondUrl+"/api/platform/sendCommond",context);
-            log.info("开关阀请求结果"+result);
+            log.info("开关阀请求数据: {},开关阀请求结果: {}", url + params ,result);
             JSONObject jsonObject= JSON.parseObject(result);
             Integer status= jsonObject.getInteger("status");
             if(status == 0){   //返回正常

+ 103 - 4
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PayMessagesendrecordServiceImp.java

@@ -9,15 +9,14 @@ import com.bz.smart_city.commom.util.MessageSend.SMSClient;
 import com.bz.smart_city.commom.util.MessageSend.SendReq;
 import com.bz.smart_city.commom.util.UserUtil;
 import com.bz.smart_city.dao.pay.BaseClosingAccountInfoMapper;
+import com.bz.smart_city.dao.pay.PayFeeMapper;
 import com.bz.smart_city.dao.pay.PayMessagesendrecordMapper;
 import com.bz.smart_city.dao.pay.PayMessagetemplateMapper;
 import com.bz.smart_city.dto.LoginUser;
-import com.bz.smart_city.dto.pay.BaseClosingAccountInfoDto;
-import com.bz.smart_city.dto.pay.PayDebtMessageDto;
-import com.bz.smart_city.dto.pay.PayMessageTemplateDto;
-import com.bz.smart_city.dto.pay.PayMessagesendrecordDto;
+import com.bz.smart_city.dto.pay.*;
 import com.bz.smart_city.entity.ProgramItem;
 import com.bz.smart_city.entity.pay.PayBaseAccount;
+import com.bz.smart_city.entity.pay.PayControlRule;
 import com.bz.smart_city.quartz.entity.QuartzEntity;
 import com.bz.smart_city.quartz.job.MessageSendJob;
 import com.bz.smart_city.quartz.service.JobAndTriggerService;
@@ -25,6 +24,7 @@ import com.bz.smart_city.service.pay.PayMessagesendrecordService;
 import com.bz.smart_city.service.pay.PayMessagetemplateService;
 import com.github.pagehelper.Page;
 import com.github.pagehelper.PageHelper;
+import io.swagger.annotations.ApiModelProperty;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.InitializingBean;
 import org.springframework.stereotype.Service;
@@ -65,6 +65,9 @@ public class PayMessagesendrecordServiceImp implements PayMessagesendrecordServi
     @Resource
     BaseClosingAccountInfoMapper baseClosingAccountInfoMapper;
 
+    @Resource
+    PayFeeMapper payFeeMapper;
+
 
     public void insert(PayMessagesendrecordDto payMessagesendrecordDto) {
 
@@ -500,4 +503,100 @@ public class PayMessagesendrecordServiceImp implements PayMessagesendrecordServi
         return result;
     }
 
+    public Pagination<PayDebtPushMessageDto> findPayDebtPushMessages(String condition , Integer searchType,
+                                                          BigDecimal beginDebtFee, BigDecimal endDebtFee,
+                                                          int pageNum, int pageSize){
+        LoginUser loginUser = UserUtil.getCurrentUser();
+
+        Integer siteId=null;
+        Integer customerId=null;
+        List<ProgramItem> programItems=null;
+        if( loginUser !=null){
+            //站点权限
+            siteId=loginUser.getSiteId();
+            //客户权限
+            customerId=loginUser.getCustomerId();
+            //数据权限
+            programItems=UserUtil.getCurrentSiteProgramItems(loginUser);
+        }
+
+        List<Integer> types =new ArrayList<>();
+        types.add(2);   //欠费金额
+        types.add(3);   //预存金额
+        types.add(4);   //用水余额
+        types.add(7);   //预存与欠费差额
+        List<PayControlRule> payControlRules = payFeeMapper.getValveRulesByType(0,types,siteId,customerId);
+
+        //分页
+        PageHelper.startPage(pageNum,pageSize);
+        //获取数据
+        List<PayDebtPushMessageDto> list = payFeeMapper.findPayDebtPushMessages( condition, searchType,
+                    beginDebtFee,  endDebtFee, customerId,siteId, payControlRules, programItems);
+
+        return new Pagination<>(list);
+
+    }
+
+    public void findPayDebtPushMessagesExport(String condition , Integer searchType,
+                                              BigDecimal beginDebtFee, BigDecimal endDebtFee ,HttpServletResponse httpServletResponse){
+        LoginUser loginUser = UserUtil.getCurrentUser();
+
+        Integer siteId=null;
+        Integer customerId=null;
+        List<ProgramItem> programItems=null;
+        if( loginUser !=null){
+            //站点权限
+            siteId=loginUser.getSiteId();
+            //客户权限
+            customerId=loginUser.getCustomerId();
+            //数据权限
+            programItems=UserUtil.getCurrentSiteProgramItems(loginUser);
+        }
+
+        List<Integer> types =new ArrayList<>();
+        types.add(2);   //欠费金额
+        types.add(3);   //预存金额
+        types.add(4);   //用水余额
+        types.add(7);   //预存与欠费差额
+        List<PayControlRule> payControlRules = payFeeMapper.getValveRulesByType(0,types,siteId,customerId);
+
+        //获取数据
+        List<PayDebtPushMessageDto> list = payFeeMapper.findPayDebtPushMessages( condition, searchType,
+                beginDebtFee,  endDebtFee, customerId,siteId, payControlRules, programItems);
+
+        String title = "客户催缴信息";
+
+        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        String[] rowsName = new String[]{"序号", "客户编号", "客户名称", "手机号", "当前读数", "欠费金额(元)",
+                "预存金额(元)", "用水余额(元)", "欠费天数", "累积催缴","最近一次催缴时间"};
+
+        List<Object[]> dataList = newArrayList();
+        Object[] objs;
+        int i = 0;
+        for(PayDebtPushMessageDto payDebtPushMessageDto :list){
+            objs = new Object[rowsName.length];
+            objs[0] = ++i;
+            objs[1]=payDebtPushMessageDto.getAccountnumber();
+            objs[2]=payDebtPushMessageDto.getAccountname();
+            objs[3]=payDebtPushMessageDto.getMobilephone();
+            objs[4]=payDebtPushMessageDto.getReading();
+            objs[5]=payDebtPushMessageDto.getDebt();
+            objs[6]=payDebtPushMessageDto.getRemaining();
+            objs[7]=payDebtPushMessageDto.getBalance();
+            objs[8]=payDebtPushMessageDto.getDays();
+            objs[10]=payDebtPushMessageDto.getSendNum();
+            if(payDebtPushMessageDto.getLastSendTime() != null){
+                objs[11]=df.format(payDebtPushMessageDto.getLastSendTime());
+            }
+            dataList.add(objs);
+        }
+        ExcelUtil excelUtil = new ExcelUtil(title, rowsName, dataList);
+        try {
+            excelUtil.export(httpServletResponse);
+        } catch (Exception e) {
+            throw new ServiceException(-900, "导出异常");
+        }
+
+
+    }
 }

+ 6 - 2
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PayMessagetemplateServiceImp.java

@@ -107,8 +107,10 @@ public class PayMessagetemplateServiceImp implements PayMessagetemplateService {
     public void saveDefaultTemplate( Integer siteId, Integer customerId){
          String t="字段说明:<br/>{accountname} :用户姓名,隐藏第一个字符。<br/>{accountnumber}:用户编码<br/>{address}:用户地址,*****+后五位。<br/>{debtFee}:欠费金额,精确到0.01元<br/>{penaltyFee}:违约金,精确到0.01元";
          String t1="尊敬的 {accountname} 客户您好(客户编号: {accountnumber} {address} ),您已欠自来水费为 {debtFee} 元,15日后将按日加收5‰的违约金。请您尽快缴纳水费,谢谢合作。";
-         String t2="尊敬的 {accountname} 客户您好(客户编号: {accountnumber}  {address} ),您已欠自来水费本金为 {debtFee} 元,违约金为 {penaltyFee} 元";
-         String t3="尊敬的 {accountname} 用水户(客户编号: {accountnumber}  {address} )您好,您已拖欠自来水费,根据相关供水法规,如您在7日内仍未缴纳水费,我公司将按相关规定对你户停止供水。";
+         String t2="尊敬的 {accountname} 客户您好(客户编号: {accountnumber} {address} ),您已欠自来水费本金为 {debtFee} 元,违约金为 {penaltyFee} 元";
+         String t3="尊敬的 {accountname} 客户您好(客户编号: {accountnumber} {address} ),您的当前用水余额已不足,请您尽快缴纳水费,谢谢合作。";
+         String t4="尊敬的 {accountname} 客户您好(客户编号: {accountnumber} {address} ),您的当前预存金额已不足,请您尽快缴纳水费,谢谢合作。";
+         String t5="尊敬的 {accountname} 客户您好(客户编号: {accountnumber} {address} ),您已经连续欠费超期,请您尽快缴纳水费,谢谢合作。";
         PayMessageTemplateDto payMessageTemplateDto=new PayMessageTemplateDto();
         payMessageTemplateDto.setSendType(0);
         payMessageTemplateDto.setOperationType(0);
@@ -120,6 +122,8 @@ public class PayMessagetemplateServiceImp implements PayMessagetemplateService {
         payMessageTemplateDto.setTemplate1(t1);
         payMessageTemplateDto.setTemplate2(t2);
         payMessageTemplateDto.setTemplate3(t3);
+        payMessageTemplateDto.setTemplate4(t4);
+        payMessageTemplateDto.setTemplate5(t5);
 
         LoginUser loginUser=UserUtil.getCurrentUser();
         payMessageTemplateDto.setCreateBy(BigInteger.valueOf(loginUser.getId()));

+ 12 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/pay/PayMessagesendrecordService.java

@@ -3,6 +3,7 @@ package com.bz.smart_city.service.pay;
 import com.bz.smart_city.commom.model.AjaxMessage;
 import com.bz.smart_city.commom.model.Pagination;
 import com.bz.smart_city.dto.pay.PayDebtMessageDto;
+import com.bz.smart_city.dto.pay.PayDebtPushMessageDto;
 import com.bz.smart_city.dto.pay.PayMessageTemplateDto;
 import com.bz.smart_city.dto.pay.PayMessagesendrecordDto;
 
@@ -59,5 +60,16 @@ public interface PayMessagesendrecordService {
 
     List<PayMessagesendrecordDto> findListByClossingaccount(PayMessagesendrecordDto payMessagesendrecordDto, Integer siteId, Integer customerId );
 
+
+    Pagination<PayDebtPushMessageDto> findPayDebtPushMessages(String condition ,
+                                                              Integer searchType,
+                                                              BigDecimal beginDebtFee,
+                                                              BigDecimal endDebtFee,
+                                                              int pageNum,
+                                                              int pageSize);
+    void findPayDebtPushMessagesExport(String condition , Integer searchType,
+                                              BigDecimal beginDebtFee, BigDecimal endDebtFee ,HttpServletResponse httpServletResponse);
+
+
     }
 

+ 13 - 0
smart-city-platform/src/main/resources/mapper/pay/PayMessagetemplateMapper.xml

@@ -12,6 +12,8 @@
             template1,
             template2,
             template3,
+            template4,
+            template5,
             days,
             send_time,
             send_type,
@@ -35,6 +37,8 @@
             #{template1},
             #{template2},
             #{template3},
+            #{template4},
+            #{template5},
             #{days},
             #{sendTime},
             #{sendType},
@@ -88,6 +92,12 @@
              <if test="template3 != null and template3 != ''">
                 template3 = #{template3},
              </if>
+            <if test="template4 != null and template4 != ''">
+                template4 = #{template4},
+            </if>
+            <if test="template5 != null and template5 != ''">
+                template5 = #{template5},
+            </if>
              <!--<if test="days != null and days != ''">-->
                 days = #{days},
              <!--</if>-->
@@ -128,6 +138,7 @@
             a.template2 as "template2",
             a.template3 as "template3",
             a.template4 as "template4",
+            a.template5 as "template5",
             a.days as "days",
             a.send_time as "sendTime",
             a.send_type as "sendType",
@@ -168,6 +179,8 @@
             a.template1 as "template1",
             a.template2 as "template2",
             a.template3 as "template3",
+            a.template4 as "template4",
+            a.template5 as "template5",
             a.days as "days",
             a.send_time as "sendTime",
             a.send_type as "sendType",

+ 109 - 0
smart-city-platform/src/main/resources/mapper/pay/payFeeMapper.xml

@@ -495,6 +495,16 @@
             ,operator as "operator"
             ,value as "value"
             ,action as "action"
+            ,(case when operator = 1 then '=' else
+                case when operator = 2 then '!=' else
+                    case when operator = 3 then '>' else
+                        case when operator = 4 then <![CDATA[ '<' ]]> else
+                            case when operator = 5 then '>=' else <![CDATA[ '<=' ]]>
+                             end
+                        end
+                    end
+                end
+            end) as "operatorString"
         from pay_control_rule
         where `disable` = 0  and site_id = #{siteId} and customer_id = #{customer}
         <if test="action != null">and action = #{action} </if>
@@ -506,4 +516,103 @@
         </if>
     </select>
 
+    <select id="findPayDebtPushMessages" resultType="com.bz.smart_city.dto.pay.PayDebtPushMessageDto">
+        select
+             c.account_id as "accountId"
+            ,c.accountnumber
+            ,c.accountname
+            ,a.mobilephone
+            ,ifnull(rd.reading,0)
+            ,ifnull(r.debt,0)
+            ,ifnull(r.waterfee,0)
+            ,ifnull(r.penaltyfee,0)
+            ,ifnull(rh.remaining,0)
+            ,ifnull(rh.balance,0)
+            ,TIMESTAMPDIFF(day,ifnull(r.create_date,NOW()),NOW()) as "days"
+            ,ifnull(msg.sendNum,0) as "sendNum"
+            ,msg.create_date as "lastSendTime"
+        from pay_base_customerandmeterrela c
+        left join pay_base_account a on c.account_id =a.id
+        left join (
+            select
+                account_id
+                ,sum(debt) debt
+                ,sum(case when feetype !=6  then debt else 0 end) waterfee
+                ,sum(case when feetype=6  then debt else 0 end) penaltyfee
+                ,min(create_date) create_date
+            from pay_pay_receivable
+            where debt > 0 and site_id= #{siteId}  and customer_id = #{customerId}
+            group by account_id
+        ) r on c.account_id =r.account_id
+        left join pay_pay_rechargeaccount rh on rh.account_id =c.account_id
+        left join (
+            SELECT ad.watermeter_id,ad.reading
+            FROM (
+                    SELECT watermeter_id, MAX(read_date)  read_date
+                    FROM pay_amount_waterusedamount_day
+                    where reading is not null and customer_id = #{customerId} and site_id= #{siteId}
+                    GROUP BY watermeter_id
+                ) ac
+                left join pay_amount_waterusedamount_day  ad
+                on ac.watermeter_id=ad.watermeter_id AND ac.read_date = ad.read_date
+        ) rd on rd.watermeter_id =c.watermeter_id
+        left join(
+                select account_id,
+                count(1) sendNum,
+                max(create_date) create_date
+                from pay_pay_messagesendrecord
+                where  site_id = #{siteId}  and customer_id = #{customerId}
+                group by account_id
+        ) msg on msg.account_id = c.account_id
+
+        where c.businessstate =1  and c.site_id= #{siteId} and c.customer_id = #{customerId}
+        <if test="condition != null and condition != ''">
+            and (
+                a.name like concat('%',#{condition},'%')
+                or a.accountnumber like concat('%',#{condition},'%')
+                or a.mobilephone like concat('%',#{condition},'%')
+            )
+        </if>
+        <if test="beginDebtFee != null ">
+            <if test="searchType != null and searchType == 1">and TIMESTAMPDIFF(day,ifnull(r.create_date,NOW()),NOW()) >= #{beginDebtFee}</if>
+            <if test="searchType != null and searchType == 2">and r.debt >= #{beginDebtFee}</if>
+            <if test="searchType != null and searchType == 3">and rh.remaining >= #{beginDebtFee}</if>
+            <if test="searchType != null and searchType == 4">and rh.balance >= #{beginDebtFee}</if>
+        </if>
+        <if test="endDebtFee != null">
+            <if test="searchType != null and searchType == 1">and TIMESTAMPDIFF(day,ifnull(r.create_date,NOW()),NOW()) &lt;= #{beginDebtFee}</if>
+            <if test="searchType != null and searchType == 2">and r.debt &lt;= #{beginDebtFee}</if>
+            <if test="searchType != null and searchType == 3">and rh.remaining &lt;= #{beginDebtFee}</if>
+            <if test="searchType != null and searchType == 4">and rh.balance &lt;= #{beginDebtFee}</if>
+        </if>
+
+        <if test="payControlRules == null or payControlRules.size() == 0">
+             and r.debt > 0
+        </if>
+        <if test="payControlRules != null and payControlRules.size() != 0">
+            and
+            <foreach collection="payControlRules" item="rule" open="(" separator=" or " close=")" >
+                <if test="rule.conditionId != null and rule.conditionId == 1">
+                    TIMESTAMPDIFF(day,ifnull(r.create_date,NOW()),NOW()) ${rule.operatorString} #{rule.value}
+                </if>
+                <if test="rule.conditionId != null and rule.conditionId == 2">
+                    r.debt ${rule.operatorString} #{rule.value}
+                </if>
+                <if test="rule.conditionId != null and rule.conditionId == 3">
+                    rh.remaining ${rule.operatorString} #{rule.value}
+                </if>
+                <if test="rule.conditionId != null and rule.conditionId == 4">
+                    rh.balance ${rule.operatorString} #{rule.value}
+                </if>
+            </foreach>
+        </if>
+        <if test="programItems != null and programItems.size() != 0">
+            and   <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
+            <if test="item.dimensionId == 10">
+                c.${item.dimensionCode} = #{item.dimensionValue}
+            </if>
+        </foreach>
+        </if>
+    order by c.account_id
+    </select>
 </mapper>