|
@@ -307,9 +307,9 @@ public class rebateaccounthead extends Controller {
|
|
|
|
|
|
|
|
BigDecimal saorderamount=CalculateAmount(begindate, enddate, row.getLong("sys_enterpriseid"), itemclsids,agentitemclsnums, itemids);
|
|
BigDecimal saorderamount=CalculateAmount(begindate, enddate, row.getLong("sys_enterpriseid"), itemclsids,agentitemclsnums, itemids);
|
|
|
if(balance.compareTo(saorderamount.multiply(brate))>=0) {
|
|
if(balance.compareTo(saorderamount.multiply(brate))>=0) {
|
|
|
- sqlList.add("update sa_rebateaccount set rebateamount="+saorderamount.multiply(brate)+",accumulatedamount="+saorderamount+" where sa_rebateaccountid="+row.getLong("sa_rebateaccountid"));
|
|
|
|
|
|
|
+ sqlList.add("update sa_rebateaccount set approvedamount="+saorderamount.multiply(brate)+",rebateamount="+saorderamount.multiply(brate)+",accumulatedamount="+saorderamount+" where sa_rebateaccountid="+row.getLong("sa_rebateaccountid"));
|
|
|
}else if(balance.compareTo(BigDecimal.ZERO)>0) {
|
|
}else if(balance.compareTo(BigDecimal.ZERO)>0) {
|
|
|
- sqlList.add("update sa_rebateaccount set rebateamount="+balance+",accumulatedamount="+saorderamount+" where sa_rebateaccountid="+row.getLong("sa_rebateaccountid"));
|
|
|
|
|
|
|
+ sqlList.add("update sa_rebateaccount set approvedamount="+balance+",rebateamount="+balance+",accumulatedamount="+saorderamount+" where sa_rebateaccountid="+row.getLong("sa_rebateaccountid"));
|
|
|
}
|
|
}
|
|
|
sqlList.add("update sa_orderitems set decorationrebateflag=1,rebatesourceid="+rows.get(0).getLong("sa_rebateaccountheadid")+",rebatesourceobject='sa_rebateaccounthead' where sa_orderitemsid in"+QuerySaorderDetailId(begindate, enddate, row.getLong("sys_enterpriseid"), itemclsids,agentitemclsnums, itemids));
|
|
sqlList.add("update sa_orderitems set decorationrebateflag=1,rebatesourceid="+rows.get(0).getLong("sa_rebateaccountheadid")+",rebatesourceobject='sa_rebateaccounthead' where sa_orderitemsid in"+QuerySaorderDetailId(begindate, enddate, row.getLong("sys_enterpriseid"), itemclsids,agentitemclsnums, itemids));
|
|
|
|
|
|
|
@@ -375,6 +375,36 @@ public class rebateaccounthead extends Controller {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @API(title = "更新核准金额", apiversion = R.ID20230920134403.v1.class)
|
|
|
|
|
+ @CACHEING_CLEAN(apiClass = {rebateaccounthead.class})
|
|
|
|
|
+ public String updateapprovedamount() throws YosException {
|
|
|
|
|
+ Long sa_rebateaccountheadid = content.getLong("sa_rebateaccountheadid");
|
|
|
|
|
+ JSONArray rebateaccountinfos = content.getJSONArray("rebateaccountinfos");
|
|
|
|
|
+ Rows rows = dbConnect.runSqlQuery(
|
|
|
|
|
+ "select t1.* from sa_rebateaccounthead t1 where t1.sa_rebateaccountheadid ='" + sa_rebateaccountheadid + "' and t1.siteid='" + siteid + "'");
|
|
|
|
|
+ if (rows.isEmpty()) {
|
|
|
|
|
+ return getErrReturnObject().setErrMsg("该返利结算单不存在").toString();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (!rows.get(0).getString("status").equals("结算")) {
|
|
|
|
|
+ return getErrReturnObject().setErrMsg("单号为:【" + rows.get(0).getString("billno") + "】的返利结算单为非结算状态,无法更新")
|
|
|
|
|
+ .toString();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ ArrayList<String> sqlList = new ArrayList<>();
|
|
|
|
|
+ for (Object obj : rebateaccountinfos) {
|
|
|
|
|
+ JSONObject rebateaccountinfo = (JSONObject)obj;
|
|
|
|
|
+ Long sa_rebateaccountid = rebateaccountinfo.getLong("sa_rebateaccountid");
|
|
|
|
|
+ BigDecimal approvedamount = rebateaccountinfo.getBigDecimalValue("approvedamount");
|
|
|
|
|
+ sqlList.add("update sa_rebateaccount set approvedamount="+approvedamount+" where sa_rebateaccountid="+sa_rebateaccountid);
|
|
|
|
|
+ sqlList.add(DataContrlLog.createLog(this, "sa_rebateaccount", sa_rebateaccountid, "更新核准金额", "核准金额更新为"+approvedamount).getSQL());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
|
|
+
|
|
|
|
|
+ return getSucReturnObject().toString();
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@API(title = "审核反审核", apiversion = R.ID20230627092103.v1.class)
|
|
@API(title = "审核反审核", apiversion = R.ID20230627092103.v1.class)
|
|
|
@CACHEING_CLEAN(apiClass = {rebateaccounthead.class})
|
|
@CACHEING_CLEAN(apiClass = {rebateaccounthead.class})
|
|
|
public String check() throws YosException {
|
|
public String check() throws YosException {
|
|
@@ -423,31 +453,31 @@ public class rebateaccounthead extends Controller {
|
|
|
|
|
|
|
|
if (ischeck) {
|
|
if (ischeck) {
|
|
|
for (Row row :rebateaccounts) {
|
|
for (Row row :rebateaccounts) {
|
|
|
- if(row.getBigDecimal("rebateamount").compareTo(BigDecimal.ZERO)>0){
|
|
|
|
|
|
|
+ if(row.getBigDecimal("approvedamount").compareTo(BigDecimal.ZERO)>0){
|
|
|
CashbillEntity entity = new CashbillEntity();
|
|
CashbillEntity entity = new CashbillEntity();
|
|
|
- entity.setAmount(row.getBigDecimal("rebateamount"));
|
|
|
|
|
|
|
+ entity.setAmount(row.getBigDecimal("approvedamount"));
|
|
|
entity.setOwnerid(row.getLong("sa_rebateaccountid"));
|
|
entity.setOwnerid(row.getLong("sa_rebateaccountid"));
|
|
|
entity.setOwnertable("sa_rebateaccount");
|
|
entity.setOwnertable("sa_rebateaccount");
|
|
|
entity.setSource("返利");
|
|
entity.setSource("返利");
|
|
|
entity.setSourcenote(row.getString("billno")+"结算单返利");
|
|
entity.setSourcenote(row.getString("billno")+"结算单返利");
|
|
|
entity.setRemarks(row.getString("billno")+"结算单装修补贴返利");
|
|
entity.setRemarks(row.getString("billno")+"结算单装修补贴返利");
|
|
|
sqlList.addAll(Accountbalance.createCashbillIncome(this, row.getLong("sys_enterpriseid"),sa_accountclassid,entity,true));
|
|
sqlList.addAll(Accountbalance.createCashbillIncome(this, row.getLong("sys_enterpriseid"),sa_accountclassid,entity,true));
|
|
|
- sqlList.addAll(Accountbalance.rebateupdate(this, row.getLong("sys_enterpriseid"), true, row.getBigDecimal("rebateamount")));
|
|
|
|
|
|
|
+ sqlList.addAll(Accountbalance.rebateupdate(this, row.getLong("sys_enterpriseid"), true, row.getBigDecimal("approvedamount")));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
}else{
|
|
}else{
|
|
|
for (Row row :rebateaccounts) {
|
|
for (Row row :rebateaccounts) {
|
|
|
- if(row.getBigDecimal("rebateamount").compareTo(BigDecimal.ZERO)>0){
|
|
|
|
|
|
|
+ if(row.getBigDecimal("approvedamount").compareTo(BigDecimal.ZERO)>0){
|
|
|
CashbillEntity entity = new CashbillEntity();
|
|
CashbillEntity entity = new CashbillEntity();
|
|
|
- entity.setAmount(row.getBigDecimal("rebateamount").negate());
|
|
|
|
|
|
|
+ entity.setAmount(row.getBigDecimal("approvedamount").negate());
|
|
|
entity.setOwnerid(row.getLong("sa_rebateaccountid"));
|
|
entity.setOwnerid(row.getLong("sa_rebateaccountid"));
|
|
|
entity.setOwnertable("sa_rebateaccount");
|
|
entity.setOwnertable("sa_rebateaccount");
|
|
|
entity.setSource("返利");
|
|
entity.setSource("返利");
|
|
|
entity.setSourcenote(row.getString("billno")+"结算单反审核");
|
|
entity.setSourcenote(row.getString("billno")+"结算单反审核");
|
|
|
entity.setRemarks("装修补贴返利反审核生成");
|
|
entity.setRemarks("装修补贴返利反审核生成");
|
|
|
sqlList.addAll(Accountbalance.createCashbillIncome(this, row.getLong("sys_enterpriseid"),sa_accountclassid,entity,true));
|
|
sqlList.addAll(Accountbalance.createCashbillIncome(this, row.getLong("sys_enterpriseid"),sa_accountclassid,entity,true));
|
|
|
- sqlList.addAll(Accountbalance.rebateupdate(this, row.getLong("sys_enterpriseid"), false, row.getBigDecimal("rebateamount")));
|
|
|
|
|
|
|
+ sqlList.addAll(Accountbalance.rebateupdate(this, row.getLong("sys_enterpriseid"), false, row.getBigDecimal("approvedamount")));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|