Преглед изворни кода

1、任务系数只在存货大类为集成灶时取,其他品类取默认1;
2、任务系数按季/年取,若没有取到则默认1
3、价格系数列表查询排除删除状态的数据,接口:2025020710553803

shenjingwei пре 2 недеља
родитељ
комит
c2dd287ed9

+ 25 - 0
src/custom/beans/enterprise/Enterprise.java

@@ -186,4 +186,29 @@ public class Enterprise extends BaseClass {
             this.discountrate = discountrate;
         }
     }
+
+    public static long getAgentsID(Controller controller, long sys_enterpriseid) throws YosException {
+        return getAgentsID(controller.dbConnect, sys_enterpriseid);
+    }
+
+    public static BigDecimal getRWPriceRate(Controller controller, long sa_agentsid) throws YosException {
+        return getRWPriceRate(controller.dbConnect, sa_agentsid);
+    }
+
+    public static long getAgentsID(DBConnect dbConnect, long sys_enterpriseid) throws YosException {
+        Rows rows = dbConnect.runSqlQuery("select sa_agentsid from sa_agents where sys_enterpriseid=" + sys_enterpriseid);
+        return rows.isNotEmpty() ? rows.get(0).getLong("sa_agentsid") : 0;
+    }
+
+    public static BigDecimal getRWPriceRate(DBConnect dbConnect, long sa_agentsid) throws YosException {
+        int year = getYear();
+        int quarter = getQuarterOfYear();
+        Rows rows = dbConnect.runSqlQuery("select pricerate from sa_quarterpricenum where ifnull(pricerate,0)>0 and sa_agentsid=" + sa_agentsid + " and year=" + year + " and quarter<=" + quarter + " order by quarter desc limit 1");
+        if (rows.isNotEmpty()) {
+            return rows.get(0).getBigDecimal("pricerate");
+        } else {
+            return new BigDecimal(1);
+        }
+    }
+
 }

+ 3 - 7
src/custom/common/crm/bean/saorder.java

@@ -53,13 +53,9 @@ public class saorder extends CrmBase {
 
                 SQLDump sqlDump = new SQLDump();
                 long sys_enterpriseid = agentRows.get(0).getLong("sys_enterpriseid");
+                long sa_agentsid = agentRows.get(0).getLong("sa_agentsid");
 
-                BigDecimal rwpricerate = new BigDecimal(1);
-                int year = agentRows.get(0).getInteger("year");
-                int quarter = agentRows.get(0).getInteger("quarter");
-                if (year == getYear() && getQuarterOfYear() >= quarter && agentRows.get(0).getDouble("pricerate") > 0) {
-                    rwpricerate = agentRows.get(0).getBigDecimal("pricerate");
-                }
+                BigDecimal rwpricerate = Enterprise.getRWPriceRate(dbConnect, sa_agentsid);
                 Row enterprise = Enterprise.getEnterprise(controller, sys_enterpriseid);
 
                 Rows financeRows = dbConnect.runSqlQuery("select * from sys_enterprise_finance where siteid='MD' and sys_enterpriseid='" + sys_enterpriseid + "' and isdefault=1");
@@ -126,7 +122,7 @@ public class saorder extends CrmBase {
                     orderitemInsert.setValue("custamount", custamount.doubleValue());//客户档案资料费
 
                     BigDecimal defaultprice = itemPrice.getGraderateprice();
-                    if (topclassnum.equals("集成灶")) {
+                    if ("集成灶".equals(topclassnum)) {
                         defaultprice = defaultprice.multiply(rwpricerate);
                         orderitemInsert.setValue("rwpricerate", rwpricerate.doubleValue());
                     } else {

+ 3 - 10
src/custom/restcontroller/sale/shoppingcart/ShoppingCart.java

@@ -3,6 +3,7 @@ package restcontroller.sale.shoppingcart;
 import beans.Item.Item;
 import beans.customscheme.CustomScheme;
 import beans.datacontrllog.DataContrlLog;
+import beans.enterprise.Enterprise;
 import beans.itemprice.ItemPrice;
 import com.alibaba.fastjson2.JSONArray;
 import com.alibaba.fastjson2.JSONObject;
@@ -269,7 +270,7 @@ public class ShoppingCart extends Controller {
 //        String sql = sqlFactory.getSQL();
 //        Rows rows = dbConnect.runSqlQuery(sql);
 
-        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_shoppingcart", "sa_shoppingcartid", "sa_brandid", "itemid", "itemno", "sa_promotionid", "sa_promotion_itemsid", "qty", "length", "width", "cheek", "colors", "material", "", "", "");
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_shoppingcart", "sa_shoppingcartid", "sa_brandid", "itemid", "itemno", "sa_promotionid", "sa_promotion_itemsid", "qty", "length", "width", "cheek", "colors", "material");
         querySQL.setTableAlias("t1");
         querySQL.addJoinTable(JOINTYPE.left, "sa_brand", "t2", "t2.sa_brandid = t1.sa_brandid AND t2.siteid = t1.siteid", "brandname");
         querySQL.addJoinTable(JOINTYPE.left, "plm_item", "t3", "t3.itemid = t1.itemid AND t3.siteid = t1.siteid", "topclassnum", "itemname", "model", "spec", "orderminqty", "orderaddqty", "orderminqty_auxunit", "orderaddqty_auxunit", "iscustomsize", "pricingmetod", "widthschemeid", "lengthschemeid", "materialschemeid", "colorschemeid", "cheekschemeid", "sa_customschemeid", "custamount");
@@ -303,15 +304,7 @@ public class ShoppingCart extends Controller {
         //定制信息
         CustomScheme customScheme = new CustomScheme(this);
 
-        BigDecimal rwpricerate = new BigDecimal(1);
-        Rows agentrows = dbConnect.runSqlQuery("select * from sa_agents where sys_enterpriseid=" + sys_enterpriseid + " and siteid='" + siteid + "'");
-        if (!agentrows.isEmpty()) {
-            int year = agentrows.get(0).getInteger("year");
-            int quarter = agentrows.get(0).getInteger("quarter");
-            if (getYear() == year && getQuarterOfYear() >= quarter && agentrows.get(0).getBigDecimal("pricerate").compareTo(BigDecimal.ZERO) > 0) {
-                rwpricerate = agentrows.get(0).getBigDecimal("pricerate");
-            }
-        }
+        BigDecimal rwpricerate = Enterprise.getRWPriceRate(this, Enterprise.getAgentsID(this, sys_enterpriseid));
         for (Row row : rows) {
             if ((attRowsMap.getOrDefault(row.getString("itemid"), new Rows())).isEmpty()) {
                 row.put("attinfos", defaultImageRows);

+ 2 - 10
src/custom/restcontroller/webmanage/sale/order/OrderItems.java

@@ -357,18 +357,10 @@ public class OrderItems extends Controller {
             }
 
             custamount = item.getBigDecimal("custamount");
-//            int year = Year.now().getValue();
-//            int quarter = YearMonth.now().get(IsoFields.QUARTER_OF_YEAR);
-            Rows agentrows = dbConnect.runSqlQuery("select * from sa_agents where sys_enterpriseid=" + sys_enterpriseid + " and siteid='" + siteid + "'");
             Rows itemrows = dbConnect.runSqlQuery("select topclassnum from plm_item where itemid=" + itemid + " and siteid='" + siteid + "'");
-            if (agentrows.isNotEmpty() && !type.equals("配件订单")) {
-                int year = agentrows.get(0).getInteger("year");
-                int quarter = agentrows.get(0).getInteger("quarter");
-                if (getYear() == year && getQuarterOfYear() >= quarter && "集成灶".equals(itemrows.get(0).getString("topclassnum")) && agentrows.get(0).getDouble("pricerate") > 0) {
-                    rwpricerate = agentrows.get(0).getBigDecimal("pricerate");
-                }
+            if (!type.equals("配件订单") && "集成灶".equals(itemrows.get(0).getString("topclassnum"))) {
+                rwpricerate = Enterprise.getRWPriceRate(this, Enterprise.getAgentsID(this, sys_enterpriseid));
             }
-
             //价格
             ItemPrice itemPrice = ItemPrice.getItemPrice(this, sys_enterpriseid, itemid);
             price = orderItemsHelper.getPrice(orderRows.get(0), itemPrice, item);