|
|
@@ -28,6 +28,9 @@ import utility.tools.WebRequest;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.time.Year;
|
|
|
+import java.time.YearMonth;
|
|
|
+import java.time.temporal.IsoFields;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
|
|
|
@@ -148,6 +151,19 @@ public class OrderItems extends Controller {
|
|
|
BigDecimal defaultprice;
|
|
|
BigDecimal price;
|
|
|
BigDecimal saleprice;
|
|
|
+ BigDecimal custamount=new BigDecimal(0);
|
|
|
+ BigDecimal pricerate=new BigDecimal(1);
|
|
|
+ int year= Year.now().getValue();
|
|
|
+ int quarter= YearMonth.now().get(IsoFields.QUARTER_OF_YEAR);
|
|
|
+ Rows custamountrows =dbConnect.runSqlQuery("select * from sa_agents where sys_enterpriseid="+sys_enterpriseid+" and siteid='"+siteid+"'");
|
|
|
+ if(!custamountrows.isEmpty()){
|
|
|
+ custamount=custamountrows.get(0).getBigDecimal("custamount");
|
|
|
+ if(custamountrows.get(0).getInteger("year")==year && custamountrows.get(0).getInteger("quarter")==quarter){
|
|
|
+ if(custamountrows.get(0).getBigDecimal("pricerate").compareTo(BigDecimal.ZERO)>0){
|
|
|
+ pricerate=custamountrows.get(0).getBigDecimal("pricerate");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
//价格
|
|
|
ItemPrice itemPrice = ItemPrice.getItemPrice(this, sys_enterpriseid, itemid);
|
|
|
if (!item.containsKey("defaultprice")) {
|
|
|
@@ -165,9 +181,14 @@ public class OrderItems extends Controller {
|
|
|
if (price.compareTo(BigDecimal.ZERO) < 0) {
|
|
|
return getErrReturnObject().setErrMsg("价格不可小于0").toString();
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
if (isInsert) {
|
|
|
- sqlList.add(orderItemsHelper.getInsertSQL(customproperties, sa_orderitemsid, item, itemRow, type, defaultprice, price, saleprice, itemPrice.getMarketprice(), spec, promotionitems, width, length).getSQL());
|
|
|
+ price=price.multiply(pricerate).add(custamount);
|
|
|
+ sqlList.add(orderItemsHelper.getInsertSQL(customproperties, sa_orderitemsid, item, itemRow, type, defaultprice, price, saleprice, itemPrice.getMarketprice(), spec, promotionitems, width, length,custamount).getSQL());
|
|
|
} else {
|
|
|
+ price=price.multiply(pricerate).add(content.getBigDecimal("custamount"));
|
|
|
sqlList.add(orderItemsHelper.getUpdateSQL(sa_orderitemsid, item, itemRow, type, defaultprice, price, saleprice, width, length).getSQL());
|
|
|
}
|
|
|
|
|
|
@@ -638,6 +659,9 @@ public class OrderItems extends Controller {
|
|
|
// sqlFactory.addParameter("sa_orderid", sa_orderid);
|
|
|
// sqlFactory.addParameter_SQL("where", where);
|
|
|
// Rows rows = dbConnect.runSqlQuery(sqlFactory);
|
|
|
+ int year= Year.now().getValue();
|
|
|
+ int quarter= YearMonth.now().get(IsoFields.QUARTER_OF_YEAR);
|
|
|
+
|
|
|
|
|
|
QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_orderitems","*");
|
|
|
querySQL.setTableAlias("t1");
|
|
|
@@ -649,9 +673,13 @@ public class OrderItems extends Controller {
|
|
|
querySQL.addJoinTable(JOINTYPE.left, "sa_promotion_items", "t4",
|
|
|
"t4.sa_promotion_itemsid = t1.sa_promotion_itemsid and t4.siteid = t1.siteid and t4.sa_promotionid=" + sa_promotionid,"packagetypemx","saledqty","groupqty");
|
|
|
|
|
|
+ querySQL.addJoinTable(JOINTYPE.left, "sa_agents", "t5", "t5.sys_enterpriseid = "+sys_enterpriseid+" and year="+year+" and quarter="+quarter+" AND t5.siteid = t1.siteid");
|
|
|
+
|
|
|
querySQL.addQueryFields("candispatchqty", "ifnull(t2.candispatchqty, 0)");
|
|
|
querySQL.addQueryFields("cansaleqty", "ifnull(t2.cansaleqty, 0)");
|
|
|
querySQL.addQueryFields("totalaty", "ifnull(t2.qty, 0)");
|
|
|
+ querySQL.addQueryFields("rwpricerate", "ifnull(t5.pricerate, 1)");
|
|
|
+
|
|
|
querySQL.addQueryFields("stockstatus", "(SELECT (CASE WHEN t2.cansaleqty>=t3.stockstatus1 THEN '充足' WHEN t2.cansaleqty<=t3.stockstatus2 THEN '缺货' ELSE '紧缺' END))");
|
|
|
if(sa_promotionid>0){
|
|
|
querySQL.addQueryFields("packageqty", "ifnull(t4.packageqty, 0)");
|
|
|
@@ -692,6 +720,14 @@ public class OrderItems extends Controller {
|
|
|
Rows itempriceRows = dbConnect.runSqlQuery(sqlFactory3);
|
|
|
RowsMap itempriceRowsMap = itempriceRows.toRowsMap("itemno");
|
|
|
|
|
|
+
|
|
|
+ SQLFactory sqlFactory4 = new SQLFactory(this, "商品等级价格查询");
|
|
|
+ sqlFactory4.addParameter("siteid", siteid);
|
|
|
+ sqlFactory4.addParameter("itemid", ids);
|
|
|
+ sqlFactory4.addParameter("sys_enterpriseid", sys_enterpriseid);
|
|
|
+ Rows pricegradeRows = dbConnect.runSqlQuery(sqlFactory4);
|
|
|
+ RowsMap pricegradeRowsMap = pricegradeRows.toRowsMap("itemid");
|
|
|
+
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
if(content.getLongValue("onlyquery")==0){
|
|
|
if (siteid.equalsIgnoreCase("lsa")) {
|
|
|
@@ -763,6 +799,12 @@ public class OrderItems extends Controller {
|
|
|
if (!row.containsKey("invbalqty")) {
|
|
|
row.put("invbalqty", BigDecimal.ZERO);
|
|
|
}
|
|
|
+ if (pricegradeRowsMap.containsKey(row.getString("itemid"))) {
|
|
|
+ row.put("pricerate",pricegradeRowsMap.get(row.getString("itemid")).get(0).getBigDecimal("discountrate"));
|
|
|
+ }else{
|
|
|
+ row.put("pricerate",new BigDecimal(1));
|
|
|
+ }
|
|
|
+
|
|
|
row.put("attinfos", attinfoRowsMap.getOrDefault(row.getString("itemid"), new Rows()));
|
|
|
row.put("contractprice", 0);
|
|
|
//处理日期字段空的情况
|