|
|
@@ -24,6 +24,7 @@ import common.data.*;
|
|
|
import common.data.db.DBConnect;
|
|
|
import common.data.db.SQLiteTable;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
+import org.apache.ibatis.jdbc.SQL;
|
|
|
import restcontroller.R;
|
|
|
import restcontroller.sale.cashbill.cashbill;
|
|
|
import restcontroller.sale.promotion.promotion;
|
|
|
@@ -113,7 +114,7 @@ public class Order extends Controller {
|
|
|
//营销账户类型ID
|
|
|
OrderItemsHelper orderItemsHelper = new OrderItemsHelper(this);
|
|
|
// Long sa_accountclassid = orderItemsHelper.getAccountClassId(type);
|
|
|
- Long sa_accountclassid =content.getLong("sa_accountclassid");
|
|
|
+ Long sa_accountclassid = content.getLong("sa_accountclassid");
|
|
|
if (sa_accountclassid <= 0) {
|
|
|
return getErrReturnObject().setErrMsg("未找到扣款账户信息").toString();
|
|
|
}
|
|
|
@@ -675,8 +676,8 @@ public class Order extends Controller {
|
|
|
row.replace("defaultamount", row.getBigDecimal("defaultamount").add(costamount));
|
|
|
|
|
|
//订单套餐
|
|
|
- Rows packagetypemxrows =dbConnect.runSqlQuery("select t2.packagetypemx,min(t1.qty/t2.orderminqty) packagetypeqty from sa_orderitems t1 inner join sa_promotion_items t2 on t1.sa_promotion_itemsid=t2.sa_promotion_itemsid and t1.siteid=t2.siteid where t1.siteid='"+siteid+"' and t1.sa_orderid="+sa_orderid+" and ifnull(t2.packagetypemx,'')!='' group by t2.packagetypemx");
|
|
|
- row.put("packagetypemxrows",packagetypemxrows);
|
|
|
+ Rows packagetypemxrows = dbConnect.runSqlQuery("select t2.packagetypemx,min(t1.qty/t2.orderminqty) packagetypeqty from sa_orderitems t1 inner join sa_promotion_items t2 on t1.sa_promotion_itemsid=t2.sa_promotion_itemsid and t1.siteid=t2.siteid where t1.siteid='" + siteid + "' and t1.sa_orderid=" + sa_orderid + " and ifnull(t2.packagetypemx,'')!='' group by t2.packagetypemx");
|
|
|
+ row.put("packagetypemxrows", packagetypemxrows);
|
|
|
return getSucReturnObject().setData(row).toString();
|
|
|
}
|
|
|
|
|
|
@@ -697,16 +698,16 @@ public class Order extends Controller {
|
|
|
}
|
|
|
//状态
|
|
|
if (whereObject.containsKey("status") && !"".equals(whereObject.getString("status"))) {
|
|
|
- JSONArray jsonArray =whereObject.getJSONArray("status");
|
|
|
- if(!jsonArray.isEmpty()){
|
|
|
- StringBuffer str=new StringBuffer("(");
|
|
|
- for(Object o :jsonArray){
|
|
|
- str.append("'"+(String)o+"',");
|
|
|
+ JSONArray jsonArray = whereObject.getJSONArray("status");
|
|
|
+ if (!jsonArray.isEmpty()) {
|
|
|
+ StringBuffer str = new StringBuffer("(");
|
|
|
+ for (Object o : jsonArray) {
|
|
|
+ str.append("'" + (String) o + "',");
|
|
|
}
|
|
|
String result = str.substring(0, str.length() - 1);
|
|
|
- result=result+")";
|
|
|
+ result = result + ")";
|
|
|
where.append(" and(");
|
|
|
- where.append("t1.status in"+result);
|
|
|
+ where.append("t1.status in" + result);
|
|
|
where.append(")");
|
|
|
}
|
|
|
|
|
|
@@ -717,14 +718,14 @@ public class Order extends Controller {
|
|
|
where.append(")");
|
|
|
}
|
|
|
if (whereObject.containsKey("notclose") && !"".equals(whereObject.getString("notclose"))) {
|
|
|
- if(whereObject.getBoolean("notclose")){
|
|
|
+ if (whereObject.getBoolean("notclose")) {
|
|
|
where.append(" and(");
|
|
|
where.append("t1.status !='关闭' ");
|
|
|
where.append(")");
|
|
|
}
|
|
|
}
|
|
|
if (whereObject.containsKey("bzdd") && !"".equals(whereObject.getString("bzdd"))) {
|
|
|
- if(whereObject.getBoolean("bzdd")){
|
|
|
+ if (whereObject.getBoolean("bzdd")) {
|
|
|
where.append(" and(");
|
|
|
where.append("t1.type ='标准订单' ");
|
|
|
where.append(")");
|
|
|
@@ -845,13 +846,12 @@ public class Order extends Controller {
|
|
|
|
|
|
// SQLFactory ischangeSQl = new SQLFactory("sql:SELECT distinct sa_orderid from sa_orderitems_change WHERE siteid='" + siteid + "' and sa_orderid in $sa_orderids$ ");
|
|
|
// ischangeSQl.addParameter_in("sa_orderids", rows.toArrayList("sa_orderid"));
|
|
|
- ArrayList<Long> ischangesa_orderidList =new ArrayList<>();
|
|
|
- if(rows.toArrayList("sa_orderid").size()>0){
|
|
|
- ischangesa_orderidList = dbConnect.runSqlQuery("SELECT distinct sa_orderid from sa_orderitems_change WHERE siteid='" + siteid + "' and sa_orderid in"+rows.toArrayList("sa_orderid").toString().replace("[", "(").replace("]", ")")).toArrayList("sa_orderid", new ArrayList<>());
|
|
|
+ ArrayList<Long> ischangesa_orderidList = new ArrayList<>();
|
|
|
+ if (rows.toArrayList("sa_orderid").size() > 0) {
|
|
|
+ ischangesa_orderidList = dbConnect.runSqlQuery("SELECT distinct sa_orderid from sa_orderitems_change WHERE siteid='" + siteid + "' and sa_orderid in" + rows.toArrayList("sa_orderid").toString().replace("[", "(").replace("]", ")")).toArrayList("sa_orderid", new ArrayList<>());
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
for (Row row : rows) {
|
|
|
Long id = row.getLong("sa_orderid");
|
|
|
if (OrderAmountRowsMap.get(id.toString()).isNotEmpty()) {
|
|
|
@@ -1043,7 +1043,7 @@ public class Order extends Controller {
|
|
|
// ischangeSQl.addParameter_in("sa_orderids", rows.toArrayList("sa_orderid"));
|
|
|
ArrayList<Long> sa_orderids = rows.toArrayList("sa_orderid", new ArrayList<>());
|
|
|
sa_orderids.add(0l);
|
|
|
- ArrayList<Long> ischangesa_orderidList = dbConnect.runSqlQuery("SELECT distinct sa_orderid from sa_orderitems_change WHERE siteid='" + siteid + "' and sa_orderid in"+sa_orderids.toString().replace("[", "(").replace("]", ")")).toArrayList("sa_orderid", new ArrayList<>());
|
|
|
+ ArrayList<Long> ischangesa_orderidList = dbConnect.runSqlQuery("SELECT distinct sa_orderid from sa_orderitems_change WHERE siteid='" + siteid + "' and sa_orderid in" + sa_orderids.toString().replace("[", "(").replace("]", ")")).toArrayList("sa_orderid", new ArrayList<>());
|
|
|
|
|
|
for (Row row : rows) {
|
|
|
Long id = row.getLong("sa_orderid");
|
|
|
@@ -1212,7 +1212,7 @@ public class Order extends Controller {
|
|
|
|
|
|
// SQLFactory ischangeSQl = new SQLFactory("sql:SELECT distinct sa_orderid from sa_orderitems_change WHERE siteid='" + siteid + "' and sa_orderid in $sa_orderids$ ");
|
|
|
// ischangeSQl.addParameter_in("sa_orderids", rows.toArrayList("sa_orderid"));
|
|
|
- ArrayList<Long> ischangesa_orderidList = dbConnect.runSqlQuery("SELECT distinct sa_orderid from sa_orderitems_change WHERE siteid='" + siteid + "' and sa_orderid in "+rows.toArrayList("sa_orderid").toString().replace("[", "(").replace("]", ")")).toArrayList("sa_orderid", new ArrayList<>());
|
|
|
+ ArrayList<Long> ischangesa_orderidList = dbConnect.runSqlQuery("SELECT distinct sa_orderid from sa_orderitems_change WHERE siteid='" + siteid + "' and sa_orderid in " + rows.toArrayList("sa_orderid").toString().replace("[", "(").replace("]", ")")).toArrayList("sa_orderid", new ArrayList<>());
|
|
|
|
|
|
for (Row row : rows) {
|
|
|
Long id = row.getLong("sa_orderid");
|
|
|
@@ -1265,7 +1265,7 @@ public class Order extends Controller {
|
|
|
//查询订单列表(管理端)
|
|
|
public QuerySQL queryListManage(String where) throws YosException {
|
|
|
QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_order",
|
|
|
- "sa_orderid", "sonum", "type", "status", "submitdate", "checkdate", "remarks", "createby", "checkby", "billdate", "tradefield","rec_contactsid","delivery","tracknumber","mailno");
|
|
|
+ "sa_orderid", "sonum", "type", "status", "submitdate", "checkdate", "remarks", "createby", "checkby", "billdate", "tradefield", "rec_contactsid", "delivery", "tracknumber", "mailno");
|
|
|
|
|
|
querySQL.setTableAlias("t1");
|
|
|
querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t2", "t2.sys_enterpriseid = t1.sys_enterpriseid and t2.siteid = t1.siteid",
|
|
|
@@ -1286,7 +1286,7 @@ public class Order extends Controller {
|
|
|
|
|
|
public QuerySQL queryListManage1(String where) throws YosException {
|
|
|
QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_order",
|
|
|
- "sa_orderid", "sonum", "type", "status", "submitdate", "checkdate", "remarks", "createby", "checkby", "billdate", "tradefield","rec_contactsid","delivery","tracknumber","mailno");
|
|
|
+ "sa_orderid", "sonum", "type", "status", "submitdate", "checkdate", "remarks", "createby", "checkby", "billdate", "tradefield", "rec_contactsid", "delivery", "tracknumber", "mailno");
|
|
|
|
|
|
querySQL.setTableAlias("t1");
|
|
|
querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t2", "t2.sys_enterpriseid = t1.sys_enterpriseid and t2.siteid = t1.siteid",
|
|
|
@@ -1457,7 +1457,7 @@ public class Order extends Controller {
|
|
|
|
|
|
//查询订单列表(业务员)
|
|
|
public QuerySQL queryList(String where) throws YosException {
|
|
|
- QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_order","*");
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_order", "*");
|
|
|
querySQL.setTableAlias("t1");
|
|
|
querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t2", "t2.sys_enterpriseid = t1.sys_enterpriseid and t2.siteid = t1.siteid",
|
|
|
"enterprisename", "abbreviation");
|
|
|
@@ -1680,32 +1680,32 @@ public class Order extends Controller {
|
|
|
Row row = rows.get(0);
|
|
|
String type = row.getString("type");
|
|
|
String typemx = row.getString("typemx");
|
|
|
- ArrayList<String> sqllist= new ArrayList<>();
|
|
|
- if(type.equals("配件订单")){
|
|
|
- Rows rowsdetails=dbConnect.runSqlQuery("select t1.price,t1.amount,t1.sa_orderitemsid,t1.itemid,ifnull(t2.iswriteoff,0) iswriteoff,t3.begdate,t3.enddate from sa_orderitems t1 " +
|
|
|
+ ArrayList<String> sqllist = new ArrayList<>();
|
|
|
+ if (type.equals("配件订单")) {
|
|
|
+ Rows rowsdetails = dbConnect.runSqlQuery("select t1.price,t1.amount,t1.sa_orderitemsid,t1.itemid,ifnull(t2.iswriteoff,0) iswriteoff,t3.begdate,t3.enddate from sa_orderitems t1 " +
|
|
|
"left join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid " +
|
|
|
- "left join sa_warrantycard t3 on t1.cardno=t3.cardno and t1.siteid=t3.siteid and t3.isvoid=0 and t3.deleted=0 where t1.sa_orderid="+sa_orderid);
|
|
|
- for(Row rowsdetail :rowsdetails){
|
|
|
- String billingstatus="";
|
|
|
- BigDecimal price=rowsdetail.getBigDecimal("price");
|
|
|
- BigDecimal amount=rowsdetail.getBigDecimal("amount");
|
|
|
- String begdate=rowsdetail.getString("begdate");
|
|
|
- String enddate=rowsdetail.getString("enddate");
|
|
|
- if(StringUtils.isBlank(begdate) || StringUtils.isBlank(enddate)){
|
|
|
- billingstatus="保外收费";
|
|
|
- }else{
|
|
|
- Date date=new Date();
|
|
|
- if(date.before(rowsdetail.getDate("enddate"))){
|
|
|
- if(rowsdetail.getBoolean("iswriteoff")){
|
|
|
- billingstatus="保内收费";
|
|
|
- }else{
|
|
|
- billingstatus="保内免费";
|
|
|
- price=BigDecimal.ZERO;
|
|
|
- amount=BigDecimal.ZERO;
|
|
|
- }
|
|
|
- }
|
|
|
+ "left join sa_warrantycard t3 on t1.cardno=t3.cardno and t1.siteid=t3.siteid and t3.isvoid=0 and t3.deleted=0 where t1.sa_orderid=" + sa_orderid);
|
|
|
+ for (Row rowsdetail : rowsdetails) {
|
|
|
+ String billingstatus = "";
|
|
|
+ BigDecimal price = rowsdetail.getBigDecimal("price");
|
|
|
+ BigDecimal amount = rowsdetail.getBigDecimal("amount");
|
|
|
+ String begdate = rowsdetail.getString("begdate");
|
|
|
+ String enddate = rowsdetail.getString("enddate");
|
|
|
+ if (StringUtils.isBlank(begdate) || StringUtils.isBlank(enddate)) {
|
|
|
+ billingstatus = "保外收费";
|
|
|
+ } else {
|
|
|
+ Date date = new Date();
|
|
|
+ if (date.before(rowsdetail.getDate("enddate"))) {
|
|
|
+ if (rowsdetail.getBoolean("iswriteoff")) {
|
|
|
+ billingstatus = "保内收费";
|
|
|
+ } else {
|
|
|
+ billingstatus = "保内免费";
|
|
|
+ price = BigDecimal.ZERO;
|
|
|
+ amount = BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- sqllist.add("update sa_orderitems set price="+price+",amount="+amount+",billingstatus='"+billingstatus+"' where sa_orderitemsid="+rowsdetail.getLong("sa_orderitemsid"));
|
|
|
+ sqllist.add("update sa_orderitems set price=" + price + ",amount=" + amount + ",billingstatus='" + billingstatus + "' where sa_orderitemsid=" + rowsdetail.getLong("sa_orderitemsid"));
|
|
|
}
|
|
|
}
|
|
|
dbConnect.runSqlUpdate(sqllist);
|
|
|
@@ -1775,18 +1775,18 @@ public class Order extends Controller {
|
|
|
}
|
|
|
|
|
|
Rows promotionRows = dbConnect.runSqlQuery("SELECT isauth,orderminamount FROM sa_promotion WHERE siteid='" + siteid + "' AND sa_promotionid='" + sa_promotionid + "'");
|
|
|
- if(promotionRows.isNotEmpty()){
|
|
|
- if(amount.compareTo(promotionRows.get(0).getBigDecimal("orderminamount"))<0){
|
|
|
- return getErrReturnObject().setErrMsg("订单未满足最低起订金额:"+promotionRows.get(0).getBigDecimal("orderminamount")+",请勿提交!").toString();
|
|
|
+ if (promotionRows.isNotEmpty()) {
|
|
|
+ if (amount.compareTo(promotionRows.get(0).getBigDecimal("orderminamount")) < 0) {
|
|
|
+ return getErrReturnObject().setErrMsg("订单未满足最低起订金额:" + promotionRows.get(0).getBigDecimal("orderminamount") + ",请勿提交!").toString();
|
|
|
}
|
|
|
}
|
|
|
- if(!promotionRows.get(0).getBoolean("isauth")){
|
|
|
+ if (!promotionRows.get(0).getBoolean("isauth")) {
|
|
|
SQLFactory sqlFactory = new SQLFactory(this, "促销方案经销商授权区域查询");
|
|
|
- sqlFactory.addParameter("sys_enterpriseid",sys_enterpriseid);
|
|
|
- sqlFactory.addParameter("siteid",siteid);
|
|
|
+ sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
|
|
|
+ sqlFactory.addParameter("siteid", siteid);
|
|
|
Rows spromotionsaleareaRows = dbConnect.runSqlQuery(sqlFactory);
|
|
|
RowsMap spromotionsaleareaRowsMap = spromotionsaleareaRows.toRowsMap("sa_promotionid");
|
|
|
- if ((dbConnect.runSqlQuery("SELECT 1 FROM sa_promotion_auth t1 inner join sa_promotion t2 on t1.sa_promotionid=t2.sa_promotionid and t1.siteid=t2.siteid WHERE if(t2.authmethod=1,not exists(select 1 from sa_promotion_auth where sa_promotionid=t1.sa_promotionid and sys_enterpriseid= "+sys_enterpriseid+"),t1.sys_enterpriseid= "+sys_enterpriseid+") AND t1.siteid='" + siteid + "' AND t1.sa_promotionid='" + sa_promotionid + "'").isEmpty() && !spromotionsaleareaRowsMap.containsKey(String.valueOf(sa_promotionid)))) {
|
|
|
+ if ((dbConnect.runSqlQuery("SELECT 1 FROM sa_promotion_auth t1 inner join sa_promotion t2 on t1.sa_promotionid=t2.sa_promotionid and t1.siteid=t2.siteid WHERE if(t2.authmethod=1,not exists(select 1 from sa_promotion_auth where sa_promotionid=t1.sa_promotionid and sys_enterpriseid= " + sys_enterpriseid + "),t1.sys_enterpriseid= " + sys_enterpriseid + ") AND t1.siteid='" + siteid + "' AND t1.sa_promotionid='" + sa_promotionid + "'").isEmpty() && !spromotionsaleareaRowsMap.containsKey(String.valueOf(sa_promotionid)))) {
|
|
|
return getErrReturnObject().setErrMsg("该促销活动已过期,无法提交").toString();
|
|
|
}
|
|
|
}
|
|
|
@@ -1816,9 +1816,9 @@ public class Order extends Controller {
|
|
|
}
|
|
|
//促销订单:提交时商品必须是上架状态,并且活动方案中的商品必须也是上架状态,否则不允许提交
|
|
|
if (type.equals("促销订单")) {
|
|
|
- Rows promotionitemsRows = dbConnect.runSqlQuery("select t2.itemno from sa_promotion_items t1 inner join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid where t1.sa_promotionid=" + sa_promotionid + " and t1.siteid='" + siteid + "' and t1.isonsale=0 and t1.itemid in(select itemid from sa_orderitems where sa_orderid="+sa_orderid+")");
|
|
|
- if(promotionitemsRows.isNotEmpty()){
|
|
|
- return getErrReturnObject().setErrMsg("商品:"+promotionitemsRows.get(0).getString("itemno")+"已下架,无法提交。").toString();
|
|
|
+ Rows promotionitemsRows = dbConnect.runSqlQuery("select t2.itemno from sa_promotion_items t1 inner join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid where t1.sa_promotionid=" + sa_promotionid + " and t1.siteid='" + siteid + "' and t1.isonsale=0 and t1.itemid in(select itemid from sa_orderitems where sa_orderid=" + sa_orderid + ")");
|
|
|
+ if (promotionitemsRows.isNotEmpty()) {
|
|
|
+ return getErrReturnObject().setErrMsg("商品:" + promotionitemsRows.get(0).getString("itemno") + "已下架,无法提交。").toString();
|
|
|
}
|
|
|
Rows promotionauthRows = dbConnect.runSqlQuery("select * from sa_promotion_auth where sa_promotionid=" + sa_promotionid + " and sys_enterpriseid ='" + sys_enterpriseid + "' and siteid='" + siteid + "'");
|
|
|
if (promotionauthRows.isNotEmpty()) {
|
|
|
@@ -1920,23 +1920,23 @@ public class Order extends Controller {
|
|
|
Rows promotion = dbConnect.runSqlQuery(" select * from sa_promotion where siteid='" + siteid + "'and sa_promotionid=" + sa_promotionid);
|
|
|
Rows promotion_auth = dbConnect.runSqlQuery(" select * from sa_promotion_auth where siteid='" + siteid + "'and sys_enterpriseid=" + sys_enterpriseid + " and sa_promotionid=" + sa_promotionid);
|
|
|
if (promotion.isNotEmpty()) {
|
|
|
- if(promotion.get(0).getString("type").equals("套餐活动")){
|
|
|
+ if (promotion.get(0).getString("type").equals("套餐活动")) {
|
|
|
ArrayList<Long> sa_promotion_itemsids = new ArrayList<Long>();
|
|
|
sa_promotion_itemsids.add((long) 0);
|
|
|
for (Row orderdetail : orderdetails) {
|
|
|
sa_promotion_itemsids.add(orderdetail.getLong("sa_promotion_itemsid"));
|
|
|
}
|
|
|
- int eachlimitqty=promotion.get(0).getInteger("eachlimitqty");
|
|
|
- if(promotion.get(0).getBoolean("eachneedadd") && eachlimitqty>0){
|
|
|
- String sql ="select ifnull(packagetypemx,'') packagetypemx,count(1) count from sa_promotion_items where siteid='"+siteid+"' and sa_promotionid="+sa_promotionid +" and sa_promotion_itemsid in "+sa_promotion_itemsids +" group by ifnull(packagetypemx,'')";
|
|
|
+ int eachlimitqty = promotion.get(0).getInteger("eachlimitqty");
|
|
|
+ if (promotion.get(0).getBoolean("eachneedadd") && eachlimitqty > 0) {
|
|
|
+ String sql = "select ifnull(packagetypemx,'') packagetypemx,count(1) count from sa_promotion_items where siteid='" + siteid + "' and sa_promotionid=" + sa_promotionid + " and sa_promotion_itemsid in " + sa_promotion_itemsids + " group by ifnull(packagetypemx,'')";
|
|
|
sql = sql.replace("[", "(").replace("]", ")");
|
|
|
Rows promotionItemsRows = dbConnect.runSqlQuery(sql);
|
|
|
- for(Row row1 :promotionItemsRows){
|
|
|
- if(StringUtils.isBlank(row1.getString("packagetypemx"))){
|
|
|
+ for (Row row1 : promotionItemsRows) {
|
|
|
+ if (StringUtils.isBlank(row1.getString("packagetypemx"))) {
|
|
|
return getErrReturnObject().setErrMsg("促销方案维护出错").toString();
|
|
|
}
|
|
|
- if(eachlimitqty!=row1.getInteger("count")){
|
|
|
- return getErrReturnObject().setErrMsg(row1.getString("packagetypemx")+"套餐未满足限购品数"+eachlimitqty+"的要求,禁止创建订单,请修改后重试!").toString();
|
|
|
+ if (eachlimitqty != row1.getInteger("count")) {
|
|
|
+ return getErrReturnObject().setErrMsg(row1.getString("packagetypemx") + "套餐未满足限购品数" + eachlimitqty + "的要求,禁止创建订单,请修改后重试!").toString();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -1975,8 +1975,6 @@ public class Order extends Controller {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
//总的金额
|
|
|
BigDecimal amountAll = amount;
|
|
|
BigDecimal costamount_single = BigDecimal.ZERO;
|
|
|
@@ -2299,12 +2297,11 @@ public class Order extends Controller {
|
|
|
String message = "您的订单【" + sonum + "】已审核!";
|
|
|
|
|
|
|
|
|
-
|
|
|
- sqlList.addAll(updateAccountbalance_freez(amount,true, "由销售订单" + sonum + "审核时冻结",sys_enterpriseid, sa_accountclassid, sa_orderid));
|
|
|
+ sqlList.addAll(updateAccountbalance_freez(amount, true, "由销售订单" + sonum + "审核时冻结", sys_enterpriseid, sa_accountclassid, sa_orderid));
|
|
|
|
|
|
sqlList.add(getOrderCheckSql(sa_orderid, reviewtype));
|
|
|
|
|
|
- sqlList.addAll(updateIcinvbal_total(sa_orderid,false,false));
|
|
|
+ sqlList.addAll(updateIcinvbal_sale(sa_orderid, false, false));
|
|
|
|
|
|
dbConnect.runSqlUpdate(sqlList);
|
|
|
|
|
|
@@ -2359,7 +2356,7 @@ public class Order extends Controller {
|
|
|
|
|
|
//验证结算企业
|
|
|
Long sys_enterpriseid = row.getLong("sys_enterpriseid");
|
|
|
- Long sa_accountclassid= row.getLong("sa_accountclassid");
|
|
|
+ Long sa_accountclassid = row.getLong("sa_accountclassid");
|
|
|
String sonum = row.getString("sonum");
|
|
|
|
|
|
BigDecimal amount = beans.order.Order.getAmount(this, sa_orderid);
|
|
|
@@ -2383,11 +2380,11 @@ public class Order extends Controller {
|
|
|
|
|
|
String message = "您的订单【" + sonum + "】已反审核,请注意查看!";
|
|
|
|
|
|
- sqlList.addAll(updateAccountbalance_freez(amount,false, "由销售订单" + sonum + "审核时冻结",sys_enterpriseid, sa_accountclassid, sa_orderid));
|
|
|
+ sqlList.addAll(updateAccountbalance_freez(amount, false, "由销售订单" + sonum + "审核时冻结", sys_enterpriseid, sa_accountclassid, sa_orderid));
|
|
|
|
|
|
sqlList.add(DataContrlLog.createLog(this, "sa_order", sa_orderid, "订单反审核", "订单反审核成功,金额:" + amount).getSQL());
|
|
|
|
|
|
- sqlList.addAll(updateIcinvbal_total(sa_orderid,true,false));
|
|
|
+ sqlList.addAll(updateIcinvbal_sale(sa_orderid, true, false));
|
|
|
|
|
|
dbConnect.runSqlUpdate(sqlList);
|
|
|
sendMsg(message, sa_orderid, sys_enterpriseid);
|
|
|
@@ -3142,7 +3139,7 @@ public class Order extends Controller {
|
|
|
for (Row row : rows) {
|
|
|
Rows rows2 = rowsMap.getOrDefault(row.getString("sa_dispatchid"), new Rows());
|
|
|
if (rows2.isNotEmpty()) {
|
|
|
- row.putIfAbsent("sumamount", rows2.get(0).getBigDecimal("sumamount").setScale(2,BigDecimal.ROUND_HALF_UP));
|
|
|
+ row.putIfAbsent("sumamount", rows2.get(0).getBigDecimal("sumamount").setScale(2, BigDecimal.ROUND_HALF_UP));
|
|
|
row.putIfAbsent("sumqty", rows2.get(0).getBigDecimal("sumqty").setScale(2, BigDecimal.ROUND_HALF_UP));
|
|
|
}
|
|
|
row.putIfAbsent("sumamount", 0);
|
|
|
@@ -3191,7 +3188,7 @@ public class Order extends Controller {
|
|
|
querySQL.addJoinTable(JOINTYPE.left, "sa_dispatch_items", "t6", "t6.sa_dispatch_itemsid = t2.sa_dispatch_itemsid AND t6.siteid = t2.siteid");
|
|
|
querySQL.addJoinTable(JOINTYPE.left, "sa_orderitems", "t7", "t6.sa_orderitemsid = t7.sa_orderitemsid AND t6.siteid = t7.siteid", "sa_orderid");
|
|
|
querySQL.addJoinTable(JOINTYPE.inner, "sa_logistics", "t9", "t9.sa_logisticsid = t1.sa_logisticsid AND t9.siteid = t1.siteid",
|
|
|
- "billno", "billdate", "logisticsstatus","packageqty","logisticsamount","address","remarks");
|
|
|
+ "billno", "billdate", "logisticsstatus", "packageqty", "logisticsamount", "address", "remarks");
|
|
|
querySQL.setSiteid(siteid);
|
|
|
querySQL.setWhere("t9.`status` != '新建'");
|
|
|
querySQL.setWhere(" t7.sa_orderid", sa_orderid);
|
|
|
@@ -3216,14 +3213,14 @@ public class Order extends Controller {
|
|
|
where.append(")");
|
|
|
}
|
|
|
}
|
|
|
- SQLFactory sqlFactory = new SQLFactory(this, "订单_出库单列表" );
|
|
|
+ SQLFactory sqlFactory = new SQLFactory(this, "订单_出库单列表");
|
|
|
sqlFactory.addParameter("siteid", siteid);
|
|
|
sqlFactory.addParameter_SQL("where", where);
|
|
|
sqlFactory.addParameter("sa_orderid", sa_orderid);
|
|
|
// Rows rows = dbConnect.runSqlQuery(sqlFactory);
|
|
|
QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_site_parameter", "sys_site_parameterid");
|
|
|
querySQL.setTableAlias("t1");
|
|
|
- querySQL.addJoinTable(JOINTYPE.right, sqlFactory, "t", "t1.siteid ='111' ","*");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.right, sqlFactory, "t", "t1.siteid ='111' ", "*");
|
|
|
querySQL.setPage(pageSize, pageNumber);
|
|
|
querySQL.setOrderBy(pageSorting);
|
|
|
Rows rows = querySQL.query();
|
|
|
@@ -3253,9 +3250,9 @@ public class Order extends Controller {
|
|
|
sqlFactory.addParameter_SQL("where", where);
|
|
|
String sql = sqlFactory.getSQL();
|
|
|
// Rows rows = dbConnect.runSqlQuery(sql);
|
|
|
- QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_site_parameter", "sys_site_parameterid");
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_site_parameter", "sys_site_parameterid");
|
|
|
querySQL.setTableAlias("t");
|
|
|
- querySQL.addJoinTable(JOINTYPE.right, sqlFactory, "t1", "t.siteid = '111' ","*");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.right, sqlFactory, "t1", "t.siteid = '111' ", "*");
|
|
|
querySQL.setPage(pageSize, pageNumber);
|
|
|
querySQL.setOrderBy(pageSorting);
|
|
|
Rows rows = querySQL.query();
|
|
|
@@ -3292,12 +3289,12 @@ public class Order extends Controller {
|
|
|
|
|
|
QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_invoicebill", "*");
|
|
|
querySQL.setTableAlias("t1");
|
|
|
- querySQL.addQueryFields("sumtaxincludedamount","ifnull((select sum(taxincludedamount) sumtaxincludedamount\n" +
|
|
|
+ querySQL.addQueryFields("sumtaxincludedamount", "ifnull((select sum(taxincludedamount) sumtaxincludedamount\n" +
|
|
|
" from sa_invoicebill_item\n" +
|
|
|
" where sa_invoicebillid = t1.sa_invoicebillid\n" +
|
|
|
" and siteid = t1.siteid), 0)");
|
|
|
querySQL.setSiteid(siteid);
|
|
|
- querySQL.setWhere("t1.sa_invoiceapplyid in (SELECT sa_invoiceapplyid from sa_invoiceapply_order WHERE sa_orderid = '"+sa_orderid+"' and siteid = '"+siteid+"')");
|
|
|
+ querySQL.setWhere("t1.sa_invoiceapplyid in (SELECT sa_invoiceapplyid from sa_invoiceapply_order WHERE sa_orderid = '" + sa_orderid + "' and siteid = '" + siteid + "')");
|
|
|
querySQL.setWhere(where.toString());
|
|
|
querySQL.setPage(pageSize, pageNumber);
|
|
|
querySQL.setOrderBy(pageSorting);
|
|
|
@@ -3533,16 +3530,16 @@ public class Order extends Controller {
|
|
|
// sqlFactory.addParameter_SQL("where", where);
|
|
|
// Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
|
|
|
QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_writeoffbill", "sa_writeoffbillid", "createuserid",
|
|
|
- "createby", "createdate", "checkby","checkdate","billnodate","status","sys_enterpriseid","remarks","unwriteoffamount","writeoffamount","sa_cashbillid");
|
|
|
+ "createby", "createdate", "checkby", "checkdate", "billnodate", "status", "sys_enterpriseid", "remarks", "unwriteoffamount", "writeoffamount", "sa_cashbillid");
|
|
|
querySQL.setTableAlias("t1");
|
|
|
querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t2", "t1.siteid = t2.siteid and t1.sys_enterpriseid = t2.sys_enterpriseid", "enterprisename", "abbreviation");
|
|
|
- querySQL.addJoinTable(JOINTYPE.left, "sa_agents", "t5", "t2.siteid = t5.siteid and t2.sys_enterpriseid = t5.sys_enterpriseid","agentnum");
|
|
|
- querySQL.addJoinTable(JOINTYPE.left, "sa_accountclass", "t3", "t1.siteid = t3.siteid and t1.sa_accountclassid = t3.sa_accountclassid" );
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sa_agents", "t5", "t2.siteid = t5.siteid and t2.sys_enterpriseid = t5.sys_enterpriseid", "agentnum");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sa_accountclass", "t3", "t1.siteid = t3.siteid and t1.sa_accountclassid = t3.sa_accountclassid");
|
|
|
querySQL.addJoinTable(JOINTYPE.left, "sa_cashbill", "t4", "t1.siteid = t4.siteid and t1.sa_cashbillid = t4.sa_cashbillid");
|
|
|
- querySQL.addQueryFields("writeoffbillidbillno","t1.billno");
|
|
|
- querySQL.addQueryFields("cashbillidbillno","t4.billno");
|
|
|
+ querySQL.addQueryFields("writeoffbillidbillno", "t1.billno");
|
|
|
+ querySQL.addQueryFields("cashbillidbillno", "t4.billno");
|
|
|
querySQL.setSiteid(siteid);
|
|
|
- querySQL.setWhere("t1.sa_writeoffbillid in(SELECT sa_writeoffbillid from sa_writeoffbill_order WHERE sa_orderid = '"+sa_orderid+"' and siteid = '"+siteid+"')");
|
|
|
+ querySQL.setWhere("t1.sa_writeoffbillid in(SELECT sa_writeoffbillid from sa_writeoffbill_order WHERE sa_orderid = '" + sa_orderid + "' and siteid = '" + siteid + "')");
|
|
|
querySQL.setWhere(where.toString());
|
|
|
querySQL.setPage(pageSize, pageNumber);
|
|
|
querySQL.setOrderBy(pageSorting);
|
|
|
@@ -3575,9 +3572,9 @@ public class Order extends Controller {
|
|
|
// String sql = sqlFactory.getSQL();
|
|
|
// Rows rows = dbConnect.runSqlQuery(sql);
|
|
|
|
|
|
- QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_site_parameter", "sys_site_parameterid");
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_site_parameter", "sys_site_parameterid");
|
|
|
querySQL.setTableAlias("t2");
|
|
|
- querySQL.addJoinTable(JOINTYPE.right, sqlFactory, "t1", "'111' = t2.siteid ","*");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.right, sqlFactory, "t1", "'111' = t2.siteid ", "*");
|
|
|
querySQL.setPage(pageSize, pageNumber);
|
|
|
querySQL.setOrderBy(pageSorting);
|
|
|
Rows rows = querySQL.query();
|
|
|
@@ -3662,10 +3659,10 @@ public class Order extends Controller {
|
|
|
|
|
|
|
|
|
QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_rebatesettlement_items", "sa_rebatesettlement_itemsid", "qty",
|
|
|
- "marketprice", "discountrate", "price","amount","rebate_discountrate","rebate_price","rebate");
|
|
|
+ "marketprice", "discountrate", "price", "amount", "rebate_discountrate", "rebate_price", "rebate");
|
|
|
querySQL.setTableAlias("t1");
|
|
|
querySQL.addJoinTable(JOINTYPE.left, "plm_item", "t2", "t1.itemid = t2.itemid and t1.siteid = t2.siteid", "itemno", "itemname");
|
|
|
- querySQL.addQueryFields("rebate_unit_price","t1.price-t1.rebate_price");
|
|
|
+ querySQL.addQueryFields("rebate_unit_price", "t1.price-t1.rebate_price");
|
|
|
querySQL.setSiteid(siteid);
|
|
|
querySQL.setWhere("t1.sa_rebatesettlementid", sa_rebatesettlementid);
|
|
|
querySQL.setPage(pageSize, pageNumber);
|
|
|
@@ -3718,8 +3715,8 @@ public class Order extends Controller {
|
|
|
querySQL.addJoinTable(JOINTYPE.inner, "sa_cashbill", "t3", "t1.sa_cashbillid = t3.sa_cashbillid and t1.siteid = t3.siteid");
|
|
|
querySQL.addJoinTable(JOINTYPE.inner, "sa_orderitems", "t4", "t2.siteid = t4.siteid and t2.sa_orderitemsid = t4.sa_orderitemsid",
|
|
|
"rowno", "itemno", "itemname");
|
|
|
- querySQL.addQueryFields("cashbillbillno","t3.billno");
|
|
|
- querySQL.addQueryFields("ordetitemwriteoffamount","t2.writeoffamount");
|
|
|
+ querySQL.addQueryFields("cashbillbillno", "t3.billno");
|
|
|
+ querySQL.addQueryFields("ordetitemwriteoffamount", "t2.writeoffamount");
|
|
|
querySQL.setSiteid(siteid);
|
|
|
querySQL.setWhere("t1.status = '审核'");
|
|
|
querySQL.setWhere("t2.sa_orderid", sa_orderid);
|
|
|
@@ -3738,9 +3735,9 @@ public class Order extends Controller {
|
|
|
sqlFactory.addParameter("sa_orderid", sa_orderid);
|
|
|
// Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
|
|
|
|
|
|
- QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_site_parameter", "sys_site_parameterid");
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_site_parameter", "sys_site_parameterid");
|
|
|
querySQL.setTableAlias("t");
|
|
|
- querySQL.addJoinTable(JOINTYPE.right, sqlFactory, "t1", "t.siteid = '111' ","*");
|
|
|
+ querySQL.addJoinTable(JOINTYPE.right, sqlFactory, "t1", "t.siteid = '111' ", "*");
|
|
|
querySQL.setPage(pageSize, pageNumber);
|
|
|
querySQL.setOrderBy(pageSorting);
|
|
|
Rows rows = querySQL.query();
|
|
|
@@ -4018,7 +4015,7 @@ public class Order extends Controller {
|
|
|
}
|
|
|
BigDecimal amount_orderaccount = orderaccountclassinfo.getBigDecimal("amount");
|
|
|
if (amount_orderaccount == null || amount_orderaccount.equals("")) {
|
|
|
- amount_orderaccount=BigDecimal.ZERO;
|
|
|
+ amount_orderaccount = BigDecimal.ZERO;
|
|
|
}
|
|
|
if (deliedqty.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
totalprice = amount_orderaccount;
|
|
|
@@ -4076,7 +4073,7 @@ public class Order extends Controller {
|
|
|
|
|
|
sqlList.add(DataContrlLog.createLog(this, "sa_order", sa_orderid, "订单手动关闭", "订单手动关闭").getSQL());
|
|
|
|
|
|
- sqlList.addAll(updateIcinvbal_total(sa_orderid,true,true));
|
|
|
+ sqlList.addAll(updateIcinvbal_sale(sa_orderid, true, true));
|
|
|
|
|
|
dbConnect.runSqlUpdate(sqlList);
|
|
|
|
|
|
@@ -4106,7 +4103,7 @@ public class Order extends Controller {
|
|
|
@CACHEING
|
|
|
public String newApiMethod() throws YosException {
|
|
|
Long sa_orderid = content.getLong("sa_orderid");
|
|
|
- Rows rows =dbConnect.runSqlQuery("select t2.itemno,t1.* from sa_orderitems t1 inner join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid where t1.sa_orderid=" + sa_orderid + " and t1.siteid='" + siteid + "' and t1.price<=0");
|
|
|
+ Rows rows = dbConnect.runSqlQuery("select t2.itemno,t1.* from sa_orderitems t1 inner join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid where t1.sa_orderid=" + sa_orderid + " and t1.siteid='" + siteid + "' and t1.price<=0");
|
|
|
return getSucReturnObject().setData(rows).toString();
|
|
|
}
|
|
|
|
|
|
@@ -4244,23 +4241,24 @@ public class Order extends Controller {
|
|
|
|
|
|
/**
|
|
|
* 账户余额冻结
|
|
|
+ *
|
|
|
* @param totalamount
|
|
|
* @param addorsub
|
|
|
* @param remarks
|
|
|
*/
|
|
|
public ArrayList<String> updateAccountbalance_freez(BigDecimal totalamount, boolean addorsub,
|
|
|
- String remarks,long sys_enterpriseid,long sa_accountclassid,long sa_orderid) throws YosException {
|
|
|
- ArrayList<String> sqllist= new ArrayList<>();
|
|
|
+ String remarks, long sys_enterpriseid, long sa_accountclassid, long sa_orderid) throws YosException {
|
|
|
+ ArrayList<String> sqllist = new ArrayList<>();
|
|
|
/******** 冻结数据 ********/
|
|
|
if (addorsub) {
|
|
|
- long sa_accountbalanceid=0;
|
|
|
+ long sa_accountbalanceid = 0;
|
|
|
totalamount = addorsub ? totalamount : totalamount.negate();
|
|
|
- Rows accountbalancerows =dbConnect.runSqlQuery("select * from sa_accountbalance where sa_accountclassid="+sa_accountclassid+" and sys_enterpriseid="+sys_enterpriseid+" and siteid='"+siteid+"'");
|
|
|
- if(accountbalancerows.isNotEmpty()){
|
|
|
- sa_accountbalanceid=accountbalancerows.get(0).getLong("sa_accountbalanceid");
|
|
|
- sqllist.add("update sa_accountbalance set freezamount=ifnull(freezamount,0)+"+totalamount+" where sa_accountbalanceid="+sa_accountbalanceid);
|
|
|
- }else{
|
|
|
- sa_accountbalanceid= createTableID("sa_accountbalance");
|
|
|
+ Rows accountbalancerows = dbConnect.runSqlQuery("select * from sa_accountbalance where sa_accountclassid=" + sa_accountclassid + " and sys_enterpriseid=" + sys_enterpriseid + " and siteid='" + siteid + "'");
|
|
|
+ if (accountbalancerows.isNotEmpty()) {
|
|
|
+ sa_accountbalanceid = accountbalancerows.get(0).getLong("sa_accountbalanceid");
|
|
|
+ sqllist.add("update sa_accountbalance set freezamount=ifnull(freezamount,0)+" + totalamount + " where sa_accountbalanceid=" + sa_accountbalanceid);
|
|
|
+ } else {
|
|
|
+ sa_accountbalanceid = createTableID("sa_accountbalance");
|
|
|
InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sa_accountbalance");
|
|
|
insertSQL.setUniqueid(sa_accountbalanceid);
|
|
|
insertSQL.setSiteid(siteid);
|
|
|
@@ -4281,36 +4279,36 @@ public class Order extends Controller {
|
|
|
frezzInsertSQL.setDateValue("createdate");
|
|
|
sqllist.add(frezzInsertSQL.getSQL());
|
|
|
} else {
|
|
|
- Rows accountbalancerows =dbConnect.runSqlQuery("select * from sa_accountbalance_freez where sourceid="+sa_orderid+" and sourcetable='sa_order' and siteid='"+siteid+"'");
|
|
|
- BigDecimal freezamount =accountbalancerows.sum("amount");
|
|
|
- if(accountbalancerows.isNotEmpty()){
|
|
|
- sqllist.add("update sa_accountbalance set freezamount=ifnull(freezamount,0)-"+freezamount+" where sa_accountbalanceid="+accountbalancerows.get(0).getLong("sa_accountbalanceid"));
|
|
|
+ Rows accountbalancerows = dbConnect.runSqlQuery("select * from sa_accountbalance_freez where sourceid=" + sa_orderid + " and sourcetable='sa_order' and siteid='" + siteid + "'");
|
|
|
+ BigDecimal freezamount = accountbalancerows.sum("amount");
|
|
|
+ if (accountbalancerows.isNotEmpty()) {
|
|
|
+ sqllist.add("update sa_accountbalance set freezamount=ifnull(freezamount,0)-" + freezamount + " where sa_accountbalanceid=" + accountbalancerows.get(0).getLong("sa_accountbalanceid"));
|
|
|
}
|
|
|
- sqllist.add("delete from sa_accountbalance_freez where sourceid="+sa_orderid+" and sourcetable='sa_order' and siteid='"+siteid+"'");
|
|
|
+ sqllist.add("delete from sa_accountbalance_freez where sourceid=" + sa_orderid + " and sourcetable='sa_order' and siteid='" + siteid + "'");
|
|
|
}
|
|
|
return sqllist;
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* @param isinstock 是否增加库存
|
|
|
* @throws YosException
|
|
|
*/
|
|
|
- public ArrayList<String> updateIcinvbal_total(long sa_orderid,boolean isinstock, boolean close) throws YosException {
|
|
|
- HashMap<String, Row> icpaomap = new HashMap<String, Row>();// 用于暂存总仓库存pao的map
|
|
|
- Rows saorderdetail = dbConnect.runSqlQuery("select * from sa_orderitems where sa_orderid="+sa_orderid+" and siteid='"+siteid+"'");
|
|
|
- Rows ICINVBAL_TOTAL =dbConnect.runSqlQuery("select * from st_invbal_total where siteid='"+siteid+"'");
|
|
|
- RowsMap ICINVBAL_TOTALRowsMap=ICINVBAL_TOTAL.toRowsMap("itemid");
|
|
|
+ public ArrayList<String> updateIcinvbal_sale(long sa_orderid, boolean isinstock, boolean close) throws YosException {
|
|
|
+ Rows saorderdetail = dbConnect.runSqlQuery("select * from sa_orderitems where sa_orderid=" + sa_orderid + " and siteid='" + siteid + "'");
|
|
|
+ Rows ICINVBAL_SALE = SQLFactory.createQuerySQL(this, "st_invbal_sale").setSiteid(siteid).setWhere("itemid", saorderdetail.toArrayList("itemid")).query();
|
|
|
+ RowsMap ICINVBAL_SALERowsMap = ICINVBAL_SALE.toRowsMap("itemid");
|
|
|
int i = 0;
|
|
|
ArrayList<String> sqlList = new ArrayList<>();
|
|
|
- for(Row row:saorderdetail){
|
|
|
- long st_invbal_totalid;
|
|
|
- if(ICINVBAL_TOTALRowsMap.containsKey(row.getString("itemid"))){
|
|
|
- st_invbal_totalid=ICINVBAL_TOTALRowsMap.get(row.getString("itemid")).get(0).getLong("st_invbal_totalid");
|
|
|
- }else{
|
|
|
- st_invbal_totalid = createTableID("st_invbal_total");
|
|
|
- InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "st_invbal_total");
|
|
|
- insertSQL.setUniqueid(st_invbal_totalid);
|
|
|
+ for (Row row : saorderdetail) {
|
|
|
+ long st_invbal_saleid;
|
|
|
+ if (ICINVBAL_SALERowsMap.containsKey(row.getString("itemid"))) {
|
|
|
+ st_invbal_saleid = ICINVBAL_SALERowsMap.get(row.getString("itemid")).get(0).getLong("st_invbal_saleid");
|
|
|
+ } else {
|
|
|
+ st_invbal_saleid = createTableID("st_invbal_sale");
|
|
|
+ InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "st_invbal_sale");
|
|
|
+ insertSQL.setUniqueid(st_invbal_saleid);
|
|
|
insertSQL.setSiteid(siteid);
|
|
|
- insertSQL.setValue("itemid",row.getString("itemid"));
|
|
|
+ insertSQL.setValue("itemid", row.getString("itemid"));
|
|
|
insertSQL.setValue("candispatchqty", 0);
|
|
|
insertSQL.setValue("cansaleqty", 0);
|
|
|
insertSQL.setValue("qty", 0);
|
|
|
@@ -4326,7 +4324,7 @@ public class Order extends Controller {
|
|
|
qty = isinstock ? row.getBigDecimal("undeliqty")
|
|
|
: row.getBigDecimal("qty").negate();// 如果是扣减则根据数量进行扣减,反之根据未发货数量进行增加
|
|
|
}
|
|
|
- sqlList.add("update st_invbal_total set cansaleqty=cansaleqty+"+qty+" where st_invbal_totalid="+st_invbal_totalid);
|
|
|
+ sqlList.add("update st_invbal_sale set cansaleqty=cansaleqty+" + qty + " where st_invbal_saleid=" + st_invbal_saleid);
|
|
|
}
|
|
|
return sqlList;
|
|
|
}
|