package com.tenwa.flow.action.comm; import java.math.BigDecimal; import java.util.HashMap; import java.util.List; import java.util.Map; import jbo.com.tenwa.entity.comm.flow.D_DEPOSITCHARGE_INFO; import jbo.com.tenwa.entity.comm.flow.D_DEPOSITRETURN_INFO; import com.amarsoft.are.jbo.BizObject; import com.amarsoft.are.jbo.BizObjectManager; import com.amarsoft.are.jbo.JBOException; import com.amarsoft.are.jbo.JBOFactory; import com.amarsoft.are.jbo.JBOTransaction; import com.amarsoft.awe.util.Transaction; import com.tenwa.comm.util.jboutil.DataOperatorUtil; public class SelectBalance { private String distributor_no; private String caution_money; public String getDistributor_no() { return distributor_no; } public void setDistributor_no(String distributor_no) { this.distributor_no = distributor_no; } public String getCaution_money() { return caution_money; } public void setCaution_money(String caution_money) { this.caution_money = caution_money; } public String runs(JBOTransaction tx) throws Exception{ Transaction scql=Transaction.createTransaction(tx); String money=""; Map params= new HashMap(); params.put("distributor_id", distributor_no); //params.put("caution_money", caution_money); String sql="select (IFNULL(dp.CAUTION_MONEY,0) - IFNULL(de.CAUTION_MONEY,0)) as money FROM (SELECT SUM(IFNULL(CAUTION_MONEY,0)) CAUTION_MONEY,DISTRIBUTOR_ID FROM D_DEPOSITCHARGE_INFO GROUP BY DISTRIBUTOR_ID ) dp LEFT JOIN (SELECT SUM(IFNULL(CAUTION_MONEY,0)) CAUTION_MONEY,DISTRIBUTOR_ID FROM D_DEPOSITRETURN_INFO GROUP BY DISTRIBUTOR_ID) de ON de.DISTRIBUTOR_ID = dp.DISTRIBUTOR_ID where dp.DISTRIBUTOR_ID=:distributor_id "; List> getSql = DataOperatorUtil.getDataBySql(scql, sql, params); BigDecimal mm = new BigDecimal("0"); if(getSql.size()>0){ money=getSql.get(0).get("money"); if("".equals(money)||money==null){ return "ERROR@经销商没有保证金"; } mm = mm.add(new BigDecimal(money)); if(mm.subtract(new BigDecimal(caution_money)).doubleValue()>=0){ return "SUCCESS@"+mm.subtract(new BigDecimal(caution_money)).doubleValue(); }else{ return "ERROR@剩余额度不足"; } } return "ERROR@网络异常……"; } }