冻结退款金额
parent
81f60e05be
commit
8323695197
|
|
@ -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" +
|
||||
|
|
|
|||
|
|
@ -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()); // 客户发票类型
|
||||
|
|
|
|||
|
|
@ -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<RefundDetail> 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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue