|
|
@@ -113,14 +113,14 @@ public class Order extends Controller {
|
|
|
sqlFactory.addParameter("sa_accountclassid", "69");
|
|
|
sqlList.addAll(updateAccountclassinfos(sa_orderid, 69, sys_enterpriseid));
|
|
|
} else {
|
|
|
- if(type.equals("促销订单")){
|
|
|
- Rows accountclassRows = dbConnect.runSqlQuery("select sa_accountclassid from sa_promotion where siteid='"+siteid+"' and sa_promotionid="+content.getLongValue("sa_promotionid"));
|
|
|
- if(!accountclassRows.isEmpty()){
|
|
|
+ if (type.equals("促销订单")) {
|
|
|
+ Rows accountclassRows = dbConnect.runSqlQuery("select sa_accountclassid from sa_promotion where siteid='" + siteid + "' and sa_promotionid=" + content.getLongValue("sa_promotionid"));
|
|
|
+ if (!accountclassRows.isEmpty()) {
|
|
|
sqlFactory.addParameter("sa_accountclassid", accountclassRows.get(0).getLong("sa_accountclassid"));
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
sqlFactory.addParameter("sa_accountclassid", beans.order.Order.getDefaultAccount(siteid, type));
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
sqlFactory.addParameter("sa_accountclassid", beans.order.Order.getDefaultAccount(siteid, type));
|
|
|
}
|
|
|
sqlList.addAll(updateAccountclassinfos(sa_orderid, beans.order.Order.getDefaultAccount(siteid, type), sys_enterpriseid));
|
|
|
@@ -180,8 +180,12 @@ public class Order extends Controller {
|
|
|
sqlFactory.addParameter("billdate", billdate);
|
|
|
}
|
|
|
if (content.containsKey("sa_accountclassid")) {
|
|
|
- sqlFactory.addParameter("sa_accountclassid", content.getLongValue("sa_accountclassid"));
|
|
|
- sqlList.addAll(updateAccountclassinfos(sa_orderid, content.getLongValue("sa_accountclassid"), sys_enterpriseid));
|
|
|
+ Long sa_accountclassid = content.getLongValue("sa_accountclassid");
|
|
|
+ if(sa_accountclassid<=0){
|
|
|
+ return getErrReturnObject().setErrMsg("账户不存在").toString();
|
|
|
+ }
|
|
|
+ sqlFactory.addParameter("sa_accountclassid", sa_accountclassid);
|
|
|
+ sqlList.addAll(updateAccountclassinfos(sa_orderid,sa_accountclassid, sys_enterpriseid));
|
|
|
}
|
|
|
} else {
|
|
|
//订单更新时
|
|
|
@@ -197,6 +201,8 @@ public class Order extends Controller {
|
|
|
return getErrReturnObject().setErrMsg("物料账户只能添加物料商品,请检查").toString();
|
|
|
}
|
|
|
}
|
|
|
+ }else {
|
|
|
+ return getErrReturnObject().setErrMsg("账户不存在").toString();
|
|
|
}
|
|
|
sqlFactory.addParameter("sa_accountclassid", content.getLongValue("sa_accountclassid"));
|
|
|
sqlList.addAll(updateAccountclassinfos(sa_orderid, content.getLongValue("sa_accountclassid"), sys_enterpriseid));
|
|
|
@@ -286,23 +292,34 @@ public class Order extends Controller {
|
|
|
sqlFactory.addParameter("typemx", "");
|
|
|
//订货企业id
|
|
|
sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
|
|
|
+ Long sa_accountclassid = 0L;
|
|
|
//营销账户类型ID
|
|
|
if ((type.equals("标准订单") || type.equals("特殊订单")) && content.getString("tradefield").equals("整装工程")) {
|
|
|
- sqlFactory.addParameter("sa_accountclassid", "69");
|
|
|
+ sa_accountclassid = 69l;
|
|
|
+
|
|
|
|
|
|
} else {
|
|
|
- if(type.equals("促销订单")){
|
|
|
- Rows accountclassRows = dbConnect.runSqlQuery("select sa_accountclassid from sa_promotion where siteid='"+siteid+"' and sa_promotionid="+content.getLongValue("sa_promotionid"));
|
|
|
- if(!accountclassRows.isEmpty()){
|
|
|
- sqlFactory.addParameter("sa_accountclassid", accountclassRows.get(0).getLong("sa_accountclassid"));
|
|
|
- }else{
|
|
|
- sqlFactory.addParameter("sa_accountclassid", beans.order.Order.getDefaultAccount(siteid, type));
|
|
|
+ if (type.equals("促销订单")) {
|
|
|
+ Rows accountclassRows = dbConnect.runSqlQuery("select sa_accountclassid from sa_promotion where siteid='" + siteid + "' and sa_promotionid=" + content.getLongValue("sa_promotionid"));
|
|
|
+ if (!accountclassRows.isEmpty()) {
|
|
|
+ sa_accountclassid = accountclassRows.get(0).getLong("sa_accountclassid");
|
|
|
+
|
|
|
+ } else {
|
|
|
+ sa_accountclassid = beans.order.Order.getDefaultAccount(siteid, type);
|
|
|
+
|
|
|
}
|
|
|
- }else{
|
|
|
- sqlFactory.addParameter("sa_accountclassid", beans.order.Order.getDefaultAccount(siteid, type));
|
|
|
+ } else {
|
|
|
+ sa_accountclassid = beans.order.Order.getDefaultAccount(siteid, type);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+ if(sa_accountclassid<=0){
|
|
|
+ return getErrReturnObject().setErrMsg("账户不存在").toString();
|
|
|
+ }
|
|
|
+ sqlFactory.addParameter("sa_accountclassid", sa_accountclassid);
|
|
|
+
|
|
|
+
|
|
|
|
|
|
//品牌ID
|
|
|
sqlFactory.addParameter("sa_brandid", sa_brandid);
|
|
|
@@ -385,14 +402,14 @@ public class Order extends Controller {
|
|
|
if ((type.equals("标准订单") || type.equals("特殊订单")) && content.getString("tradefield").equals("整装工程")) {
|
|
|
sqlList1.addAll(updateAccountclassinfos(sa_orderid, 69, sys_enterpriseid));
|
|
|
} else {
|
|
|
- if(type.equals("促销订单")){
|
|
|
- Rows accountclassRows = dbConnect.runSqlQuery("select sa_accountclassid from sa_promotion where siteid='"+siteid+"' and sa_promotionid="+content.getLongValue("sa_promotionid"));
|
|
|
- if(!accountclassRows.isEmpty()){
|
|
|
+ if (type.equals("促销订单")) {
|
|
|
+ Rows accountclassRows = dbConnect.runSqlQuery("select sa_accountclassid from sa_promotion where siteid='" + siteid + "' and sa_promotionid=" + content.getLongValue("sa_promotionid"));
|
|
|
+ if (!accountclassRows.isEmpty()) {
|
|
|
sqlList1.addAll(updateAccountclassinfos(sa_orderid, accountclassRows.get(0).getLong("sa_accountclassid"), sys_enterpriseid));
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
sqlList1.addAll(updateAccountclassinfos(sa_orderid, beans.order.Order.getDefaultAccount(siteid, type), sys_enterpriseid));
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
sqlList1.addAll(updateAccountclassinfos(sa_orderid, beans.order.Order.getDefaultAccount(siteid, type), sys_enterpriseid));
|
|
|
}
|
|
|
|
|
|
@@ -824,7 +841,7 @@ public class Order extends Controller {
|
|
|
querySQL.addJoinTable(JOINTYPE.left, "sa_agents", "t6", "t6.sys_enterpriseid=t1.sys_enterpriseid and t6.siteid = t1.siteid",
|
|
|
"agentnum");
|
|
|
querySQL.addJoinTable(JOINTYPE.left, "sa_promotion", "t7", "t7.sa_promotionid=t1.sa_promotionid and t7.siteid = t1.siteid",
|
|
|
- "promnum","promname");
|
|
|
+ "promnum", "promname");
|
|
|
querySQL.addQueryFields("amount", "CAST(0 AS CHAR(20))");
|
|
|
querySQL.addQueryFields("qty", "CAST(0 AS CHAR(20))");
|
|
|
querySQL.setWhere("t1.siteid", siteid);
|
|
|
@@ -1237,7 +1254,7 @@ public class Order extends Controller {
|
|
|
if (type.equals("标准订单")) {
|
|
|
Rows iteminfos = dbConnect.runSqlQuery("select t2.itemno from sa_orderitems t1 inner join plm_item t2 on t1.siteid=t2.siteid and t1.itemid=t2.itemid where t1.sa_orderid=" + sa_orderid + " and t1.siteid='" + siteid + "' and t2.isonsale!=1");
|
|
|
if (iteminfos.isNotEmpty()) {
|
|
|
- return getErrReturnObject().setErrMsg("检测到品号"+iteminfos.get(0).getLong("itemno") + "未上架,请删除后重试").toString();
|
|
|
+ return getErrReturnObject().setErrMsg("检测到品号" + iteminfos.get(0).getLong("itemno") + "未上架,请删除后重试").toString();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1285,7 +1302,7 @@ public class Order extends Controller {
|
|
|
boolean islimit = promotionitemsRowsMap.get(itemid).get(0).getBoolean("islimit");
|
|
|
if (islimit) {
|
|
|
if (groupqty.compareTo(saledqty.add(qty)) < 0) {
|
|
|
- return getErrReturnObject().setErrMsg("品号:"+orderdetail.getString("itemno") +"已超过限购数量:"+groupqty.subtract(saledqty)).toString();
|
|
|
+ return getErrReturnObject().setErrMsg("品号:" + orderdetail.getString("itemno") + "已超过限购数量:" + groupqty.subtract(saledqty)).toString();
|
|
|
}
|
|
|
}
|
|
|
sqlList.add("update sa_promotion_items set saledqty=ifnull(saledqty,0)+" + qty + " where sa_promotion_itemsid=" + promotionitemsRowsMap.get(itemid).get(0).getLong("sa_promotion_itemsid"));
|
|
|
@@ -1294,34 +1311,34 @@ public class Order extends Controller {
|
|
|
}
|
|
|
|
|
|
//促销订单经销商限购金额判断
|
|
|
- String promotiontype="";
|
|
|
- BigDecimal associationamount=BigDecimal.ZERO;
|
|
|
- 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()){
|
|
|
- promotiontype=promotion.get(0).getString("type");
|
|
|
- associationamount=promotion.get(0).getBigDecimal("associationamount");
|
|
|
- }
|
|
|
- if(promotion_auth.isNotEmpty()){
|
|
|
+ String promotiontype = "";
|
|
|
+ BigDecimal associationamount = BigDecimal.ZERO;
|
|
|
+ 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()) {
|
|
|
+ promotiontype = promotion.get(0).getString("type");
|
|
|
+ associationamount = promotion.get(0).getBigDecimal("associationamount");
|
|
|
+ }
|
|
|
+ if (promotion_auth.isNotEmpty()) {
|
|
|
boolean islimit = promotion_auth.get(0).getBoolean("islimit");
|
|
|
BigDecimal limitamount = promotion_auth.get(0).getBigDecimal("limitamount");
|
|
|
BigDecimal saledamount = promotion_auth.get(0).getBigDecimal("saledamount");
|
|
|
- System.out.println("limitamount:"+limitamount);
|
|
|
- System.out.println("saledamount:"+saledamount);
|
|
|
- System.out.println("associationamount:"+associationamount);
|
|
|
- if(islimit){
|
|
|
- if(!promotiontype.equals("返利促销")){
|
|
|
- if(amount.compareTo(limitamount.subtract(saledamount))>0){
|
|
|
+ System.out.println("limitamount:" + limitamount);
|
|
|
+ System.out.println("saledamount:" + saledamount);
|
|
|
+ System.out.println("associationamount:" + associationamount);
|
|
|
+ if (islimit) {
|
|
|
+ if (!promotiontype.equals("返利促销")) {
|
|
|
+ if (amount.compareTo(limitamount.subtract(saledamount)) > 0) {
|
|
|
return getErrReturnObject().setErrMsg("已超过促销方案限定金额,无法提交").toString();
|
|
|
}
|
|
|
sqlList.add("update sa_promotion_auth set saledamount=saledamount+" + amount + " where sa_promotion_authid=" + promotion_auth.get(0).getLong("sa_promotion_authid"));
|
|
|
- }else{
|
|
|
- if(amount.subtract((limitamount.subtract(saledamount))).compareTo(associationamount)>0){
|
|
|
+ } else {
|
|
|
+ if (amount.subtract((limitamount.subtract(saledamount))).compareTo(associationamount) > 0) {
|
|
|
return getErrReturnObject().setErrMsg("已超过促销方案限定金额,无法提交").toString();
|
|
|
}
|
|
|
- if(amount.compareTo((limitamount.subtract(saledamount)))>0){
|
|
|
+ if (amount.compareTo((limitamount.subtract(saledamount))) > 0) {
|
|
|
sqlList.add("update sa_promotion_auth set saledamount=saledamount+" + (limitamount.subtract(saledamount)) + " where sa_promotion_authid=" + promotion_auth.get(0).getLong("sa_promotion_authid"));
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
sqlList.add("update sa_promotion_auth set saledamount=saledamount+" + amount + " where sa_promotion_authid=" + promotion_auth.get(0).getLong("sa_promotion_authid"));
|
|
|
}
|
|
|
|
|
|
@@ -1368,7 +1385,7 @@ public class Order extends Controller {
|
|
|
for (Object object : accountclassinfos) {
|
|
|
JSONObject jsonObject = (JSONObject) object;
|
|
|
if (Accountbalance.judgeBalance(this, pay_enterpriseid, jsonObject.getLong("sa_accountclassid"), jsonObject.getBigDecimal("amount"))) {
|
|
|
- CashbillEntity entity = getCashbillEntity(jsonObject.getBigDecimal("amount"), sa_orderid, "订单提交", sonum,"由" + sonum + "订单提交时," + jsonObject.getString("accountname") + "账户自动支出产生");
|
|
|
+ CashbillEntity entity = getCashbillEntity(jsonObject.getBigDecimal("amount"), sa_orderid, "订单提交", sonum, "由" + sonum + "订单提交时," + jsonObject.getString("accountname") + "账户自动支出产生");
|
|
|
//
|
|
|
if (accountclassrowsMap.containsKey(jsonObject.getString("sa_accountclassid")) && accountclassrowsMap.get(jsonObject.getString("sa_accountclassid")).isNotEmpty()) {
|
|
|
jsonObject.put("balance", accountclassrowsMap.get(jsonObject.getString("sa_accountclassid")).get(0).getBigDecimal("balance").subtract(jsonObject.getBigDecimal("amount")));
|
|
|
@@ -1383,7 +1400,7 @@ public class Order extends Controller {
|
|
|
}
|
|
|
} else {
|
|
|
if (Accountbalance.judgeBalance(this, pay_enterpriseid, sa_accountclassid, amount)) {
|
|
|
- CashbillEntity entity = getCashbillEntity(amount, sa_orderid, "订单提交",sonum, "由" + sonum + "订单提交时自动产生");
|
|
|
+ CashbillEntity entity = getCashbillEntity(amount, sa_orderid, "订单提交", sonum, "由" + sonum + "订单提交时自动产生");
|
|
|
sqlList.addAll(Accountbalance.createCashbillPay(this, pay_enterpriseid, sa_accountclassid, entity, true));
|
|
|
} else {
|
|
|
return getErrReturnObject().setErrMsg("账户余额不足,还差" + Accountbalance.InsufficientBalance(this, pay_enterpriseid, sa_accountclassid, amount) + "元!").toString();
|
|
|
@@ -1437,7 +1454,7 @@ public class Order extends Controller {
|
|
|
//金额=金额-返利金金额
|
|
|
BigDecimal amount = beans.order.Order.getAmount(this, sa_orderid);
|
|
|
//创建支出凭证
|
|
|
- CashbillEntity entity = getCashbillEntity(amount, sa_orderid, source,sonum, "由" + sonum + source + "时自动产生");
|
|
|
+ CashbillEntity entity = getCashbillEntity(amount, sa_orderid, source, sonum, "由" + sonum + source + "时自动产生");
|
|
|
sqlList.addAll(Accountbalance.createCashbillPay(this, pay_enterpriseid, sa_accountclassid, entity, true));
|
|
|
//创建返利金支出凭证
|
|
|
Rows cashbillRows = dbConnect.runSqlQuery("SELECT * from sa_cashbill WHERE class='返利金' and STATUS ='审核' and rebate_enddate>=CURRENT_TIME and rebate_balance>0 and sys_enterpriseid= " + pay_enterpriseid + " and siteid = '" + siteid + "' ORDER BY rebate_enddate ");
|
|
|
@@ -1453,7 +1470,7 @@ public class Order extends Controller {
|
|
|
|
|
|
//返利代金券小于返利金金额,例如:rebate_balance:10,rebateamount:50
|
|
|
if (rebate_balance.compareTo(rebateamount) == -1) {
|
|
|
- entity2 = getCashbillEntity(rebate_balance, sa_orderid, source,sonum,"【返利金】由" + sonum + source + "时自动产生");
|
|
|
+ entity2 = getCashbillEntity(rebate_balance, sa_orderid, source, sonum, "【返利金】由" + sonum + source + "时自动产生");
|
|
|
rebateamount = rebateamount.subtract(rebate_balance);
|
|
|
rebate_balance = BigDecimal.ZERO;
|
|
|
|
|
|
@@ -1461,14 +1478,14 @@ public class Order extends Controller {
|
|
|
}
|
|
|
//返利代金券等于返利金金额
|
|
|
if (rebate_balance.compareTo(rebateamount) == 0) {
|
|
|
- entity2 = getCashbillEntity(rebate_balance, sa_orderid, source,sonum, "【返利金】由" + sonum + source + "时自动产生");
|
|
|
+ entity2 = getCashbillEntity(rebate_balance, sa_orderid, source, sonum, "【返利金】由" + sonum + source + "时自动产生");
|
|
|
rebateamount = BigDecimal.ZERO;
|
|
|
rebate_balance = BigDecimal.ZERO;
|
|
|
|
|
|
}
|
|
|
//返利代金券大于返利金金额
|
|
|
if (rebate_balance.compareTo(rebateamount) == 1) {
|
|
|
- entity2 = getCashbillEntity(rebateamount, sa_orderid, source, sonum,"【返利金】由" + sonum + source + "时自动产生");
|
|
|
+ entity2 = getCashbillEntity(rebateamount, sa_orderid, source, sonum, "【返利金】由" + sonum + source + "时自动产生");
|
|
|
rebate_balance = rebate_balance.subtract(rebateamount);
|
|
|
rebateamount = BigDecimal.ZERO;
|
|
|
|
|
|
@@ -1558,7 +1575,7 @@ public class Order extends Controller {
|
|
|
for (Object object : accountclassinfos) {
|
|
|
JSONObject jsonObject = (JSONObject) object;
|
|
|
if (Accountbalance.judgeBalance(this, pay_enterpriseid, jsonObject.getLong("sa_accountclassid"), jsonObject.getBigDecimal("amount"))) {
|
|
|
- CashbillEntity entity = getCashbillEntity(jsonObject.getBigDecimal("amount"), sa_orderid, "订单审核",sonum, "由" + sonum + "订单审核时," + jsonObject.getString("accountname") + "账户自动支出产生");
|
|
|
+ CashbillEntity entity = getCashbillEntity(jsonObject.getBigDecimal("amount"), sa_orderid, "订单审核", sonum, "由" + sonum + "订单审核时," + jsonObject.getString("accountname") + "账户自动支出产生");
|
|
|
jsonObject.put("balance", jsonObject.getBigDecimalValue("balance").subtract(jsonObject.getBigDecimal("amount")));
|
|
|
sqlList.addAll(Accountbalance.createCashbillPay(this, pay_enterpriseid, jsonObject.getLong("sa_accountclassid"), entity, true));
|
|
|
} else {
|
|
|
@@ -1567,7 +1584,7 @@ public class Order extends Controller {
|
|
|
}
|
|
|
} else {
|
|
|
if (Accountbalance.judgeBalance(this, pay_enterpriseid, sa_accountclassid, amount)) {
|
|
|
- CashbillEntity entity = getCashbillEntity(amount, sa_orderid, "订单审核", sonum,"由" + sonum + "订单审核时自动产生");
|
|
|
+ CashbillEntity entity = getCashbillEntity(amount, sa_orderid, "订单审核", sonum, "由" + sonum + "订单审核时自动产生");
|
|
|
sqlList.addAll(Accountbalance.createCashbillPay(this, pay_enterpriseid, sa_accountclassid, entity, true));
|
|
|
} else {
|
|
|
return getErrReturnObject().setErrMsg("账户余额不足,还差" + Accountbalance.InsufficientBalance(this, pay_enterpriseid, sa_accountclassid, amount) + "元!").toString();
|
|
|
@@ -1618,7 +1635,6 @@ public class Order extends Controller {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
//通过版本更新订单表头数据
|
|
|
beans.order.Order.updateOrderWithVersion(this);
|
|
|
|
|
|
@@ -1639,7 +1655,7 @@ public class Order extends Controller {
|
|
|
//订单扣款节点(1:订单提交、2:订单审核)
|
|
|
String order_paymentnode = Parameter.get(siteid, "order_paymentnode");
|
|
|
if (order_paymentnode.equals("2")) {
|
|
|
- sqlList.addAll(returnPayBill(row, "订单反审核",sonum, "由" + sonum + "订单反审核时自动产生"));
|
|
|
+ sqlList.addAll(returnPayBill(row, "订单反审核", sonum, "由" + sonum + "订单反审核时自动产生"));
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -1793,7 +1809,7 @@ public class Order extends Controller {
|
|
|
if (!rows.get(0).getString("status").equals("提交")) {
|
|
|
return getErrReturnObject().setErrMsg("订单非提交状态无法退回").toString();
|
|
|
}
|
|
|
- if(rows.get(0).getLong("sa_promotionid")!=0){
|
|
|
+ if (rows.get(0).getLong("sa_promotionid") != 0) {
|
|
|
if (dbConnect.runSqlQuery("SELECT 1 FROM sa_promotion WHERE CURRENT_TIME> enddate AND siteid='" + siteid + "' AND sa_promotionid='" + rows.get(0).getLong("sa_promotionid") + "'").isNotEmpty()) {
|
|
|
//return getErrReturnObject().setErrMsg("活动已结束,是否确认退回,退回后无法再次提交").toString();
|
|
|
}
|
|
|
@@ -1826,12 +1842,12 @@ public class Order extends Controller {
|
|
|
}
|
|
|
|
|
|
//促销订单经销商限购金额判断
|
|
|
- Rows promotion_auth = dbConnect.runSqlQuery("select * from sa_promotion_auth where sys_enterpriseid="+sys_enterpriseid+" and sa_promotionid="+row.getLong("sa_promotionid"));
|
|
|
- if(promotion_auth.isNotEmpty()){
|
|
|
+ Rows promotion_auth = dbConnect.runSqlQuery("select * from sa_promotion_auth where sys_enterpriseid=" + sys_enterpriseid + " and sa_promotionid=" + row.getLong("sa_promotionid"));
|
|
|
+ if (promotion_auth.isNotEmpty()) {
|
|
|
boolean islimit = promotion_auth.get(0).getBoolean("islimit");
|
|
|
BigDecimal limitamount = promotion_auth.get(0).getBigDecimal("limitamount");
|
|
|
BigDecimal saledamount = promotion_auth.get(0).getBigDecimal("saledamount");
|
|
|
- if(islimit){
|
|
|
+ if (islimit) {
|
|
|
sqlList.add("update sa_promotion_auth set saledamount=saledamount-" + amount + " where sa_promotion_authid=" + promotion_auth.get(0).getLong("sa_promotion_authid"));
|
|
|
}
|
|
|
}
|
|
|
@@ -1855,7 +1871,7 @@ public class Order extends Controller {
|
|
|
// sqlList.addAll(Accountbalance.createCashbillPay(this, pay_enterpriseid, sa_accountclassid, entity, true));
|
|
|
// }
|
|
|
|
|
|
- sqlList.addAll(returnPayBill(row, "订单退回",sonum, "由" + sonum + "订单退回时自动产生"));
|
|
|
+ sqlList.addAll(returnPayBill(row, "订单退回", sonum, "由" + sonum + "订单退回时自动产生"));
|
|
|
|
|
|
String message = "您的订单【" + sonum + "】已退回,退款金额为【" + amount + "】 已转入到您的资金账户";
|
|
|
|
|
|
@@ -1922,7 +1938,7 @@ public class Order extends Controller {
|
|
|
}
|
|
|
|
|
|
|
|
|
- sqlList.addAll(returnPayBill(row, "订单撤回", sonum,"由" + sonum + "订单撤回时自动产生"));
|
|
|
+ sqlList.addAll(returnPayBill(row, "订单撤回", sonum, "由" + sonum + "订单撤回时自动产生"));
|
|
|
|
|
|
String message = "您的订单【" + sonum + "】 金额为【" + amount + "】 已撤回!";
|
|
|
|
|
|
@@ -2062,7 +2078,7 @@ public class Order extends Controller {
|
|
|
//订单扣款节点(1:订单提交、2:订单审核)
|
|
|
String order_paymentnode = Parameter.get(siteid, "order_paymentnode");
|
|
|
if (order_paymentnode.equals("2")) {
|
|
|
- sqlList.addAll(returnPayBill(row, "订单_交期撤回",sonum, "由" + sonum + "订单交期撤回时自动产生"));
|
|
|
+ sqlList.addAll(returnPayBill(row, "订单_交期撤回", sonum, "由" + sonum + "订单交期撤回时自动产生"));
|
|
|
}
|
|
|
|
|
|
sqlList.add(DataContrlLog.createLog(this, "sa_order", sa_orderid, "订单交期撤回", "订单交期撤回:" + amount).getSQL());
|
|
|
@@ -2087,7 +2103,7 @@ public class Order extends Controller {
|
|
|
amount = rebateRow.getBigDecimal("amount");
|
|
|
if (amount.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
Long sa_cashbillid_rebate = rebateRow.getLong("sa_cashbillid_rebate");
|
|
|
- CashbillEntity entity = getCashbillEntity(amount.negate(), sa_orderid, source,sourcenotes, "【返利金】" + remarks);
|
|
|
+ CashbillEntity entity = getCashbillEntity(amount.negate(), sa_orderid, source, sourcenotes, "【返利金】" + remarks);
|
|
|
sqlList.addAll(beans.order.Order.createRebateBillPay(this, entity, pay_enterpriseid, sa_cashbillid_rebate));
|
|
|
}
|
|
|
}
|
|
|
@@ -2112,7 +2128,7 @@ public class Order extends Controller {
|
|
|
}
|
|
|
}
|
|
|
if (amount.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- CashbillEntity entity = getCashbillEntity(amount.negate(), sa_orderid, source,sourcenotes, remarks);
|
|
|
+ CashbillEntity entity = getCashbillEntity(amount.negate(), sa_orderid, source, sourcenotes, remarks);
|
|
|
sqlList.addAll(Accountbalance.createCashbillPay(this, pay_enterpriseid, row.getLong("sa_accountclassid"), entity, true));
|
|
|
}
|
|
|
}
|
|
|
@@ -2557,7 +2573,7 @@ public class Order extends Controller {
|
|
|
} else {
|
|
|
sqlFactory.addParameter("rebate_used", 0);
|
|
|
}
|
|
|
- sqlList.add(DataContrlLog.createLog(this, "sa_order", sa_orderid_copy, "订单复制", "由订单" +row.getString("sonum")+"复制而来").getSQL());
|
|
|
+ sqlList.add(DataContrlLog.createLog(this, "sa_order", sa_orderid_copy, "订单复制", "由订单" + row.getString("sonum") + "复制而来").getSQL());
|
|
|
sqlList.add(sqlFactory.getSQL());
|
|
|
|
|
|
//复制商品
|
|
|
@@ -2850,7 +2866,8 @@ public class Order extends Controller {
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * 创建凭证实体
|
|
|
+ * 创建凭证实体
|
|
|
+ *
|
|
|
* @param amount
|
|
|
* @param ownerid
|
|
|
* @param source
|
|
|
@@ -2859,7 +2876,7 @@ public class Order extends Controller {
|
|
|
* @return
|
|
|
* @throws YosException
|
|
|
*/
|
|
|
- public CashbillEntity getCashbillEntity(BigDecimal amount, Long ownerid, String source, String sourcenotes,String remarks) throws YosException {
|
|
|
+ public CashbillEntity getCashbillEntity(BigDecimal amount, Long ownerid, String source, String sourcenotes, String remarks) throws YosException {
|
|
|
CashbillEntity entity = new CashbillEntity();
|
|
|
entity.setAmount(amount);
|
|
|
entity.setOwnerid(ownerid);
|
|
|
@@ -2987,7 +3004,7 @@ public class Order extends Controller {
|
|
|
|
|
|
String type = orderRow.get(0).getString("type");
|
|
|
if (type.equals("促销订单")) {
|
|
|
- Rows orderdetails = dbConnect.runSqlQuery("select sa_promotion_itemsid,itemno,sum(undeliqty) qty from sa_orderitems where siteid='" + siteid + "' and sa_orderid=" + sa_orderid +" group by sa_promotion_itemsid,itemno");
|
|
|
+ Rows orderdetails = dbConnect.runSqlQuery("select sa_promotion_itemsid,itemno,sum(undeliqty) qty from sa_orderitems where siteid='" + siteid + "' and sa_orderid=" + sa_orderid + " group by sa_promotion_itemsid,itemno");
|
|
|
Rows promotionitems = dbConnect.runSqlQuery("select * from sa_promotion_items where siteid='" + siteid + "' and sa_promotionid=" + orderRow.get(0).getLong("sa_promotionid"));
|
|
|
RowsMap promotionitemsRowsMap = promotionitems.toRowsMap("sa_promotion_itemsid");
|
|
|
for (Row orderdetail : orderdetails) {
|
|
|
@@ -3007,21 +3024,21 @@ public class Order extends Controller {
|
|
|
JSONArray sa_accountclassinfos = orderRow.get(0).getJSONArray("sa_accountclassinfos");
|
|
|
JSONObject orderaccountclassinfo = new JSONObject();
|
|
|
JSONObject promotionaccountclassinfo = new JSONObject();
|
|
|
- for (Object object:sa_accountclassinfos) {
|
|
|
- JSONObject jsonObject=(JSONObject)object;
|
|
|
- if(jsonObject.getLong("sa_accountclassid")==sa_accountclassid){
|
|
|
- orderaccountclassinfo=jsonObject;
|
|
|
- }else{
|
|
|
- promotionaccountclassinfo=jsonObject;
|
|
|
+ for (Object object : sa_accountclassinfos) {
|
|
|
+ JSONObject jsonObject = (JSONObject) object;
|
|
|
+ if (jsonObject.getLong("sa_accountclassid") == sa_accountclassid) {
|
|
|
+ orderaccountclassinfo = jsonObject;
|
|
|
+ } else {
|
|
|
+ promotionaccountclassinfo = jsonObject;
|
|
|
}
|
|
|
}
|
|
|
- Rows promotion_auth = dbConnect.runSqlQuery(" select * from sa_promotion_auth where siteid='"+siteid+"'and sys_enterpriseid="+sys_enterpriseid+" and sa_promotionid="+ orderRow.get(0).getLong("sa_promotionid"));
|
|
|
- long sa_promotion_authid=0;
|
|
|
- if(promotion_auth.isNotEmpty()){
|
|
|
- sa_promotion_authid=promotion_auth.get(0).getLong("sa_promotion_authid");
|
|
|
+ Rows promotion_auth = dbConnect.runSqlQuery(" select * from sa_promotion_auth where siteid='" + siteid + "'and sys_enterpriseid=" + sys_enterpriseid + " and sa_promotionid=" + orderRow.get(0).getLong("sa_promotionid"));
|
|
|
+ long sa_promotion_authid = 0;
|
|
|
+ if (promotion_auth.isNotEmpty()) {
|
|
|
+ sa_promotion_authid = promotion_auth.get(0).getLong("sa_promotion_authid");
|
|
|
}
|
|
|
- if(orderaccountclassinfo.getBigDecimal("amount").compareTo(totalprice)>=0){
|
|
|
- System.out.println("1111");
|
|
|
+ if (orderaccountclassinfo.getBigDecimal("amount").compareTo(totalprice) >= 0) {
|
|
|
+ System.out.println("1111");
|
|
|
CashbillEntity entity = new CashbillEntity();
|
|
|
entity.setAmount(totalprice.negate());
|
|
|
entity.setSource("订单手工关闭");
|
|
|
@@ -3033,7 +3050,7 @@ public class Order extends Controller {
|
|
|
entity.setTypemx("订单关闭退款");
|
|
|
sqlList.addAll(Accountbalance.createCashbillPay(this, sys_enterpriseid, orderaccountclassinfo.getLongValue("sa_accountclassid"), entity, true));
|
|
|
sqlList.add("update sa_promotion_auth set saledamount=saledamount-" + totalprice + " where sa_promotion_authid=" + sa_promotion_authid);
|
|
|
- }else if(orderaccountclassinfo.getBigDecimal("amount").compareTo(totalprice)<0){
|
|
|
+ } else if (orderaccountclassinfo.getBigDecimal("amount").compareTo(totalprice) < 0) {
|
|
|
System.out.println("222");
|
|
|
CashbillEntity entity = new CashbillEntity();
|
|
|
entity.setAmount(orderaccountclassinfo.getBigDecimal("amount").negate());
|
|
|
@@ -3048,7 +3065,7 @@ public class Order extends Controller {
|
|
|
|
|
|
sqlList.add("update sa_promotion_auth set saledamount=saledamount-" + orderaccountclassinfo.getBigDecimal("amount") + " where sa_promotion_authid=" + sa_promotion_authid);
|
|
|
|
|
|
- CashbillEntity promotionentity = new CashbillEntity();
|
|
|
+ CashbillEntity promotionentity = new CashbillEntity();
|
|
|
promotionentity.setAmount((totalprice.subtract(orderaccountclassinfo.getBigDecimal("amount"))).negate());
|
|
|
promotionentity.setSource("订单手工关闭");
|
|
|
promotionentity.setSourcenote(orderRow.get(0).getString("sonum"));
|
|
|
@@ -3057,7 +3074,7 @@ public class Order extends Controller {
|
|
|
promotionentity.setRemarks("由" + orderRow.get(0).getString("sonum") + "订单手工关闭时自动产生");
|
|
|
promotionentity.setType("普通费用");
|
|
|
promotionentity.setTypemx("订单关闭退款");
|
|
|
- sqlList.addAll(Accountbalance.createCashbillPay(this, sys_enterpriseid, promotionaccountclassinfo.getLongValue("sa_accountclassid"), promotionentity, true));
|
|
|
+ sqlList.addAll(Accountbalance.createCashbillPay(this, sys_enterpriseid, promotionaccountclassinfo.getLongValue("sa_accountclassid"), promotionentity, true));
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -3092,8 +3109,11 @@ public class Order extends Controller {
|
|
|
ArrayList<String> sqlList = new ArrayList<>();
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
- BigDecimal orderamount = getAmount(this, sa_orderid);
|
|
|
- Rows accountclassrows = dbConnect.runSqlQuery("select t1.*,ifnull(t2.balance,0) balance,ifnull(t2.creditquota,0) creditquota from sa_accountclass t1 left join sa_accountbalance t2 on t1.sa_accountclassid=t2.sa_accountclassid and t1.siteid=t2.siteid and t2.sys_enterpriseid=" + (sys_enterpriseid == 0 ? orderRows.get(0).getLong("pay_enterpriseid") : sys_enterpriseid) + " where isused=1 and t1.siteid='" + siteid + "' and t1.sa_accountclassid="+(sa_accountclassid == 0 ? orderRows.get(0).getLong("sa_accountclassid") : sa_accountclassid));
|
|
|
+ BigDecimal orderamount = getAmount(this, sa_orderid);
|
|
|
+ Rows accountclassrows = dbConnect.runSqlQuery("select t1.*,ifnull(t2.balance,0) balance,ifnull(t2.creditquota,0) creditquota from sa_accountclass t1 left join sa_accountbalance t2 on t1.sa_accountclassid=t2.sa_accountclassid and t1.siteid=t2.siteid and t2.sys_enterpriseid=" + (sys_enterpriseid == 0 ? orderRows.get(0).getLong("pay_enterpriseid") : sys_enterpriseid) + " where isused=1 and t1.siteid='" + siteid + "' and t1.sa_accountclassid=" + (sa_accountclassid == 0 ? orderRows.get(0).getLong("sa_accountclassid") : sa_accountclassid));
|
|
|
+ if (accountclassrows.isEmpty()) {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
if (orderRows.isEmpty()) {
|
|
|
//全部优先账户扣款
|
|
|
jsonObject.put("amount", orderamount);
|
|
|
@@ -3105,21 +3125,21 @@ public class Order extends Controller {
|
|
|
sqlList.add("update sa_order set sa_accountclassinfos='" + jsonArray + "' where sa_orderid=" + sa_orderid + " and siteid='" + siteid + "'");
|
|
|
return sqlList;
|
|
|
}
|
|
|
- String type="";
|
|
|
- Rows promotionrows =dbConnect.runSqlQuery("select * from sa_promotion where siteid='"+siteid+"' and sa_promotionid="+ orderRows.get(0).getLong("sa_promotionid"));
|
|
|
- Rows promotionenterpriserows =dbConnect.runSqlQuery("select * from sa_promotion_auth where siteid='"+siteid+"'and sys_enterpriseid="+(sys_enterpriseid == 0 ? orderRows.get(0).getLong("pay_enterpriseid") : sys_enterpriseid)+" and sa_promotionid="+ orderRows.get(0).getLong("sa_promotionid"));
|
|
|
- if(promotionrows.isNotEmpty()){
|
|
|
- type=promotionrows.get(0).getString("type");
|
|
|
+ String type = "";
|
|
|
+ Rows promotionrows = dbConnect.runSqlQuery("select * from sa_promotion where siteid='" + siteid + "' and sa_promotionid=" + orderRows.get(0).getLong("sa_promotionid"));
|
|
|
+ Rows promotionenterpriserows = dbConnect.runSqlQuery("select * from sa_promotion_auth where siteid='" + siteid + "'and sys_enterpriseid=" + (sys_enterpriseid == 0 ? orderRows.get(0).getLong("pay_enterpriseid") : sys_enterpriseid) + " and sa_promotionid=" + orderRows.get(0).getLong("sa_promotionid"));
|
|
|
+ if (promotionrows.isNotEmpty()) {
|
|
|
+ type = promotionrows.get(0).getString("type");
|
|
|
}
|
|
|
- if(type.equals("返利促销")){
|
|
|
+ if (type.equals("返利促销")) {
|
|
|
BigDecimal associationamount = promotionrows.get(0).getBigDecimal("associationamount");
|
|
|
long associationaccountclassid = promotionrows.get(0).getLong("associationaccountclassid");
|
|
|
- Rows associationaccountclassrows = dbConnect.runSqlQuery("select t1.*,ifnull(t2.balance,0) balance,ifnull(t2.creditquota,0) creditquota from sa_accountclass t1 left join sa_accountbalance t2 on t1.sa_accountclassid=t2.sa_accountclassid and t1.siteid=t2.siteid and t2.sys_enterpriseid=" + (sys_enterpriseid == 0 ? orderRows.get(0).getLong("pay_enterpriseid") : sys_enterpriseid) + " where isused=1 and t1.siteid='" + siteid + "' and t1.sa_accountclassid="+associationaccountclassid);
|
|
|
- if(promotionenterpriserows.isNotEmpty()){
|
|
|
- if(promotionenterpriserows.get(0).getBoolean("islimit")){
|
|
|
+ Rows associationaccountclassrows = dbConnect.runSqlQuery("select t1.*,ifnull(t2.balance,0) balance,ifnull(t2.creditquota,0) creditquota from sa_accountclass t1 left join sa_accountbalance t2 on t1.sa_accountclassid=t2.sa_accountclassid and t1.siteid=t2.siteid and t2.sys_enterpriseid=" + (sys_enterpriseid == 0 ? orderRows.get(0).getLong("pay_enterpriseid") : sys_enterpriseid) + " where isused=1 and t1.siteid='" + siteid + "' and t1.sa_accountclassid=" + associationaccountclassid);
|
|
|
+ if (promotionenterpriserows.isNotEmpty()) {
|
|
|
+ if (promotionenterpriserows.get(0).getBoolean("islimit")) {
|
|
|
BigDecimal limitamount = promotionenterpriserows.get(0).getBigDecimal("limitamount");
|
|
|
BigDecimal saledamount = promotionenterpriserows.get(0).getBigDecimal("saledamount");
|
|
|
- if(orderamount.compareTo(limitamount.subtract(saledamount))<=0){
|
|
|
+ if (orderamount.compareTo(limitamount.subtract(saledamount)) <= 0) {
|
|
|
//全部优先账户扣款
|
|
|
jsonObject.put("amount", orderamount);
|
|
|
jsonObject.put("sa_accountclassid", accountclassrows.get(0).getLong("sa_accountclassid"));
|
|
|
@@ -3127,7 +3147,7 @@ public class Order extends Controller {
|
|
|
jsonObject.put("balance", accountclassrows.get(0).getBigDecimal("balance"));
|
|
|
jsonObject.put("creditquota", accountclassrows.get(0).getBigDecimal("creditquota"));
|
|
|
jsonArray.add(jsonObject);
|
|
|
- }else if(orderamount.compareTo(limitamount.subtract(saledamount))>0){
|
|
|
+ } else if (orderamount.compareTo(limitamount.subtract(saledamount)) > 0) {
|
|
|
//全部优先账户扣款
|
|
|
jsonObject.put("amount", limitamount.subtract(saledamount));
|
|
|
jsonObject.put("sa_accountclassid", accountclassrows.get(0).getLong("sa_accountclassid"));
|
|
|
@@ -3143,11 +3163,11 @@ public class Order extends Controller {
|
|
|
associationjsonObject.put("balance", associationaccountclassrows.get(0).getBigDecimal("balance"));
|
|
|
associationjsonObject.put("creditquota", associationaccountclassrows.get(0).getBigDecimal("creditquota"));
|
|
|
jsonArray.add(associationjsonObject);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
return sqlList;
|
|
|
}
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
//全部优先账户扣款
|
|
|
jsonObject.put("amount", orderamount);
|
|
|
jsonObject.put("sa_accountclassid", accountclassrows.get(0).getLong("sa_accountclassid"));
|
|
|
@@ -3156,7 +3176,7 @@ public class Order extends Controller {
|
|
|
jsonObject.put("creditquota", accountclassrows.get(0).getBigDecimal("creditquota"));
|
|
|
jsonArray.add(jsonObject);
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
//全部优先账户扣款
|
|
|
jsonObject.put("amount", orderamount);
|
|
|
jsonObject.put("sa_accountclassid", accountclassrows.get(0).getLong("sa_accountclassid"));
|