From 8323695197f2584873adc65fa0d6b48cf5af1ddc Mon Sep 17 00:00:00 2001 From: xiaocui <1334950895@qq.com> Date: Fri, 26 Mar 2021 09:27:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=86=BB=E7=BB=93=E9=80=80=E6=AC=BE=E9=87=91?= =?UTF-8?q?=E9=A2=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cowr/ssjygl/customer/CustomerService.java | 12 +++++++++++- .../com/cowr/ssjygl/prepay/PrepayService.java | 7 +++++-- .../refunddetail/RefundDetailService.java | 18 ++++++++++++++++++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/customer/CustomerService.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/customer/CustomerService.java index 02b369d..93c9c5b 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/customer/CustomerService.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/customer/CustomerService.java @@ -78,7 +78,17 @@ public class CustomerService extends BaseService { " ) a on a.customer_id = t.id\n" + " \n" + " left join (\n" + - " select t.* from prepay_customer t\n" + + " select t.id,"+ + " t.customer_id,\n"+ + " t.supermarket_id,\n"+ + "t.recharge_time,\n"+ + " t.spend_time,\n"+ + "t.first_recharge_time,\n"+ + " t.threshold,\n"+ + " t.notice,\n"+ + " (t.surplus-ifnull(m.amount,0)) surplus from prepay_customer t\n"+ + "left join (select customer_id,ifnull(sum(amount),0) amount from refund_detail where state<3 group by customer_id) m\n"+ + " on t.customer_id=m.customer_id\n"+ " left join (\n" + " select max(t.id) prepay_customer_id, t.customer_id from prepay_customer t\n" + " group by t.customer_id\n" + diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/prepay/PrepayService.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/prepay/PrepayService.java index 10425ea..d99c41d 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/prepay/PrepayService.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/prepay/PrepayService.java @@ -11,6 +11,7 @@ import com.cowr.common.enums.OrderStateEnum; import com.cowr.ssjygl.customer.receiver.CustomerReceiverService; import com.cowr.ssjygl.order.ordercluster.truck.OrderclusterTruckService; import com.cowr.ssjygl.prepay.prepaycustomer.PrepayCustomerService; +import com.cowr.ssjygl.prepay.refunddetail.RefundDetailService; import com.jfinal.kit.StrKit; import com.jfinal.log.Log; import com.jfinal.plugin.activerecord.Db; @@ -20,6 +21,7 @@ import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.Comparator; import java.util.List; @@ -137,7 +139,8 @@ public class PrepayService { } Record out = new Record(); - + //获取账户可用余额 + BigDecimal availableBalance = RefundDetailService.me.getAvailableBalance(prepayCustomer.getCustomerId(), prepayCustomer.getSurplus()); out.set("prepay_truck", true); out.set("prepay_threshold", prepayCustomer.getThreshold()); out.set("prepay_truck_type", OrderTypeEnum.TEMP.getTypeid()); // 浠水固定只有外销 @@ -145,7 +148,7 @@ public class PrepayService { out.set("prepay_customer_name", customer.getName()); out.set("prepay_contact_name", pd.getContactName()); out.set("prepay_contact_phone", pd.getContactPhone()); - out.set("prepay_surplus", prepayCustomer.getSurplus()); + out.set("prepay_surplus", availableBalance); out.set("prepay_customer", customer); out.set("prepay_customer_info", prepayCustomer); out.set("prepay_customer_invoice_type", customer.getInvoiceType()); // 客户发票类型 diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/prepay/refunddetail/RefundDetailService.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/prepay/refunddetail/RefundDetailService.java index f3a3964..713c637 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/prepay/refunddetail/RefundDetailService.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/prepay/refunddetail/RefundDetailService.java @@ -12,6 +12,7 @@ import com.jfinal.plugin.activerecord.Db; import com.jfinal.plugin.activerecord.Page; import com.jfinal.plugin.activerecord.Record; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; @@ -89,4 +90,21 @@ public class RefundDetailService extends BaseService { public List list() { return RefundDetail.dao.find("select * from refund_detail"); } + + /** + * 获取账户可用余额 + * @param customer_id 客户ID + * @param surplus 账户余额 + * @return + */ + public BigDecimal getAvailableBalance(Integer customer_id,BigDecimal surplus){ + Record record = Db.findFirst("select ifnull(sum(amount),0) amount from refund_detail where state<3 and customer_id=? limit 1", customer_id); + BigDecimal amount = record.getBigDecimal("amount"); + if(surplus==null){ + surplus=new BigDecimal('0'); + } + return surplus.subtract(amount); + } + + }