Sfoglia il codice sorgente

代码优化开发20211017

MSY 3 anni fa
parent
commit
78e6174949

+ 22 - 13
src/main/java/com/jkcredit/invoice/controller/localBussiness/CustomerController.java

@@ -17,6 +17,7 @@ import com.jkcredit.invoice.util.RespR;
 import com.jkcredit.invoice.util.WordUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang.StringUtils;
 import org.apache.poi.util.IOUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -231,21 +232,29 @@ public class CustomerController {
     @ApiOperation(value="客户备案预警查询", notes="客户备案预警查询")
     @LoginRequired
     public RespR findCustomerRecTimeList(Page page, CustomerRec customerRec) {
-
-        Param param = paramService.getParamsByParamName("CUST_EARLY_WARNING");
-        IPage ipage = customerRecService.findAllCustomerRec(page, customerRec);
-        List<CustomerRec> lists = ipage.getRecords();
-        if(lists.size()>0){
-        //遍历删除
-        Iterator<CustomerRec> iterator = lists.iterator();
-        while (iterator.hasNext()) {
-            CustomerRec customerRec1 = iterator.next();
-            if (Integer.valueOf(param.getParamValue()) <= (DateUtil.daysBetween(customerRec1.getServiceEndTime(),new Date()))) {
-                iterator.remove();//使用迭代器的删除方法删除
+        IPage ipage = null;
+        if(StringUtils.isNotEmpty(customerRec.getServiceEndTime())  && !"null".equals(customerRec.getServiceEndTime())){
+            String [] res =customerRec.getServiceEndTime().split(",");
+            customerRec.setServiceEndTimeStart(res[0]);
+            customerRec.setServiceEndTimeEnd(res[1]);
+            ipage = customerRecService.findAllCustomerRec(page, customerRec);
+        }else{
+            Param param = paramService.getParamsByParamName("CUST_EARLY_WARNING");
+            ipage = customerRecService.findAllCustomerRec(page, customerRec);
+            List<CustomerRec> lists = ipage.getRecords();
+            if(lists.size()>0){
+                //遍历删除
+                Iterator<CustomerRec> iterator = lists.iterator();
+                while (iterator.hasNext()) {
+                    CustomerRec customerRec1 = iterator.next();
+                    if (Integer.valueOf(param.getParamValue()) <= (DateUtil.daysBetween(customerRec1.getServiceEndTime(),new Date()))) {
+                        iterator.remove();//使用迭代器的删除方法删除
+                    }
+                }
             }
-          }
+            ipage.setTotal(lists.size());
         }
-        ipage.setTotal(lists.size());
+
         return new RespR(ipage);
     }
 

+ 31 - 0
src/main/java/com/jkcredit/invoice/model/entity/customer/CustomerRec.java

@@ -97,6 +97,21 @@ public class CustomerRec {
      */
     private String serviceEndTime;
 
+
+
+    /**
+     * 服务结束时间开始
+     */
+    private String serviceEndTimeStart;
+
+
+
+    /**
+     * 服务结束时间结束
+     */
+    private String serviceEndTimeEnd;
+
+
     /**
      * 协议类型
      */
@@ -340,6 +355,22 @@ public class CustomerRec {
         this.lowerFileName = lowerFileName;
     }
 
+    public String getServiceEndTimeStart() {
+        return serviceEndTimeStart;
+    }
+
+    public void setServiceEndTimeStart(String serviceEndTimeStart) {
+        this.serviceEndTimeStart = serviceEndTimeStart;
+    }
+
+    public String getServiceEndTimeEnd() {
+        return serviceEndTimeEnd;
+    }
+
+    public void setServiceEndTimeEnd(String serviceEndTimeEnd) {
+        this.serviceEndTimeEnd = serviceEndTimeEnd;
+    }
+
     @Override
     public String toString() {
         return "CustomerRec{" +

+ 10 - 1
src/main/java/com/jkcredit/invoice/service/customer/impl/CustomerServiceImpl.java

@@ -62,8 +62,17 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper,Customer> im
     @Transactional(rollbackFor = Exception.class)
     public Boolean customRecharge(CustomerRecharge customerRecharge) {
         log.info("开始充值:CustomerServiceImpl.customRecharge{}",customerRecharge);
+        if(null == customerRecharge.getRechargeMony() || "".equals(customerRecharge.getRechargeMony())){
+            log.error("充值失败:CustomerServiceImpl.getRechargeMony:" + customerRecharge.getRechargeMony());
+            return false;
+        }
         Customer customer = customerMapper.selectByCustomerName(customerRecharge.getCustomerName());
-        customer.setAccountBalance(MathUtil.add(customer.getAccountBalance(),customerRecharge.getRechargeMony()));
+        Double currentMoney = MathUtil.add(customer.getAccountBalance(),customerRecharge.getRechargeMony());
+        if(currentMoney.compareTo(0.0) < 0){
+            log.error("充值失败:CustomerServiceImpl.customRecharge:" + currentMoney);
+            return false;
+        }
+        customer.setAccountBalance(currentMoney);
         customerMapper.updateByPrimaryKeySelective(customer);
         customerRecharge.setRechargeTime(DateUtil.getCurrentDateStr());
         customerRecharge.setBeforeMony(customer.getAccountBalance());

+ 2 - 2
src/main/resources/mapper/customer/CustomerRecMapper.xml

@@ -54,8 +54,8 @@
     <if test="customerRec.companyName != null and customerRec.companyName != ''">
       and company_name = #{customerRec.companyName}
     </if>
-      <if test="customerRec.serviceEndTime != null and customerRec.serviceEndTime != ''">
-        and service_endTime > #{customerRec.serviceEndTime}
+      <if test="customerRec.serviceEndTimeStart != null and customerRec.serviceEndTimeStart != ''">
+        and service_endTime BETWEEN #{customerRec.serviceEndTimeStart} and #{customerRec.serviceEndTimeEnd}
       </if>
     </where>
   </select>