|
@@ -11,6 +11,7 @@ import beans.hr.Hr;
|
|
|
import beans.itemprice.ItemPrice;
|
|
|
import beans.parameter.Parameter;
|
|
|
import beans.remind.Remind;
|
|
|
+import beans.salearea.SaleArea;
|
|
|
import beans.uploaderpdata.UploadDataToERP;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
@@ -784,65 +785,171 @@ public class Order extends Controller {
|
|
|
|
|
|
}
|
|
|
|
|
|
-// if (isExport) {
|
|
|
-// //去除不需要导出项
|
|
|
-// rows.getFieldList().remove("sa_orderid");
|
|
|
-// rows.getFieldList().remove("submitdate");
|
|
|
-// rows.getFieldList().remove("checkdate");
|
|
|
-// rows.getFieldList().remove("typemx");
|
|
|
-// rows.getFieldList().remove("sys_enterpriseid");
|
|
|
-//
|
|
|
-// rows.getFieldList().remove("erpbillno");
|
|
|
-// rows.getFieldList().remove("agentnum");
|
|
|
-// rows.getFieldList().remove("projectname");
|
|
|
-// rows.getFieldList().remove("siteid");
|
|
|
-// rows.getFieldList().remove("billdate");
|
|
|
-// rows.getFieldList().remove("createuserid");
|
|
|
-// rows.getFieldList().remove("changeuserid");
|
|
|
-// rows.getFieldList().remove("createby");
|
|
|
-// rows.getFieldList().remove("changeby");
|
|
|
-// rows.getFieldList().remove("changedate");
|
|
|
-// rows.getFieldList().remove("checkby");
|
|
|
-// rows.getFieldList().remove("submitby");
|
|
|
-// rows.getFieldList().remove("closeby");
|
|
|
-// rows.getFieldList().remove("closedate");
|
|
|
-//// rows.getFieldList().remove("rec_contactsid");
|
|
|
-//// rows.getFieldList().remove("sa_contractid");
|
|
|
-//// rows.getFieldList().remove("sa_projectid");
|
|
|
-//// rows.getFieldList().remove("sa_accountclassid");
|
|
|
-//// rows.getFieldList().remove("sa_accountclassinfos");
|
|
|
-//// rows.getFieldList().remove("sa_brandid");
|
|
|
-////
|
|
|
-////
|
|
|
-//// rows.getFieldList().remove("sys_enterprise_financeid");
|
|
|
-//// rows.getFieldList().remove("sa_logiscompid");
|
|
|
-//// rows.getFieldList().remove("saler_hrid");
|
|
|
-//// rows.getFieldList().remove("createflag");
|
|
|
-//// rows.getFieldList().remove("pay_enterpriseid");
|
|
|
-//// rows.getFieldList().remove("signbacknum");
|
|
|
-//// rows.getFieldList().remove("rebate_used");
|
|
|
-//// rows.getFieldList().remove("rebate_userate");
|
|
|
-//// rows.getFieldList().remove("sa_promotionid");
|
|
|
-//// rows.getFieldList().remove("tradefieldmx");
|
|
|
-//// rows.getFieldList().remove("reviewtype");
|
|
|
-//// rows.getFieldList().remove("freightstatus");
|
|
|
-//// rows.getFieldList().remove("toolcount");
|
|
|
-//// rows.getFieldList().remove("rebateamount");
|
|
|
-//// rows.getFieldList().remove("signbackstatus");
|
|
|
-//// rows.getFieldList().remove("saletype");
|
|
|
-//
|
|
|
-//// rows.getFieldList().remove("oldid");
|
|
|
-//// rows.getFieldList().remove("projectnote");
|
|
|
-//// rows.getFieldList().remove("deleted");
|
|
|
-//// rows.getFieldList().remove("abstract");
|
|
|
-//// rows.getFieldList().remove("accountclassinfos");
|
|
|
-//// rows.getFieldList().remove("updatek3flag");
|
|
|
-//// rows.getFieldList().remove("salename");
|
|
|
-// rows.getFieldList().remove("ischange");
|
|
|
-//
|
|
|
-// Rows uploadRows = uploadExcelToObs("order", "订单列表", rows, getTitleMap());
|
|
|
-// return getSucReturnObject().setData(uploadRows).toString();
|
|
|
-// }
|
|
|
+
|
|
|
+ return getSucReturnObject().setData(rows).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @API(title = "查询订单列表(区域经理)", apiversion = R.ID20231025160203.v1.class)
|
|
|
+ @CACHEING
|
|
|
+ public String selectListManage_regionalManager() throws YosException, IOException {
|
|
|
+ StringBuffer where = new StringBuffer(" 1=1 ");
|
|
|
+ if (content.containsKey("where")) {
|
|
|
+ JSONObject whereObject = content.getJSONObject("where");
|
|
|
+ if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
|
|
|
+ where.append(" and(");
|
|
|
+ where.append("t1.sonum like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t2.enterprisename like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t2.abbreviation like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+// where.append("or t5.erpbillno like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append("or t1.remarks like'%").append(whereObject.getString("condition")).append("%' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+ //状态
|
|
|
+ if (whereObject.containsKey("status") && !"".equals(whereObject.getString("status"))) {
|
|
|
+ where.append(" and(");
|
|
|
+ where.append("t1.status ='").append(whereObject.getString("status")).append("' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("type") && !"".equals(whereObject.getString("type"))) {
|
|
|
+ where.append(" and(");
|
|
|
+ where.append("t1.type like'%").append(whereObject.getString("type")).append("%' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+ //品牌
|
|
|
+ if (whereObject.containsKey("brandname") && !"".equals(whereObject.getString("brandname"))) {
|
|
|
+ where.append(" and(");
|
|
|
+ where.append("t3.brandname like'%").append(whereObject.getString("brandname")).append("%' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+ //领域
|
|
|
+ if (whereObject.containsKey("tradefield") && !"".equals(whereObject.getString("tradefield"))) {
|
|
|
+ where.append(" and(");
|
|
|
+ where.append("t1.tradefield like'%").append(whereObject.getString("tradefield")).append("%' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("begindate") && !"".equals(whereObject.getString("begindate"))) {
|
|
|
+ where.append(" and DATE_FORMAT(t1.billdate, '%Y-%m-%d') >='").append(whereObject.getString("begindate")).append("' ");
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("enddate") && !"".equals(whereObject.getString("enddate"))) {
|
|
|
+ where.append(" and DATE_FORMAT(t1.billdate, '%Y-%m-%d') <='").append(whereObject.getString("enddate")).append("' ");
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("begindate1") && !"".equals(whereObject.getString("begindate1"))) {
|
|
|
+ where.append(" and DATE_FORMAT(t1.submitdate, '%Y-%m-%d') >='").append(whereObject.getString("begindate1")).append("' ");
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("enddate1") && !"".equals(whereObject.getString("enddate1"))) {
|
|
|
+ where.append(" and DATE_FORMAT(t1.submitdate, '%Y-%m-%d') <='").append(whereObject.getString("enddate1")).append("' ");
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("begindate2") && !"".equals(whereObject.getString("begindate2"))) {
|
|
|
+ where.append(" and DATE_FORMAT(t1.checkdate, '%Y-%m-%d') >='").append(whereObject.getString("begindate2")).append("' ");
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("enddate2") && !"".equals(whereObject.getString("enddate2"))) {
|
|
|
+ where.append(" and DATE_FORMAT(t1.checkdate, '%Y-%m-%d') <='").append(whereObject.getString("enddate2")).append("' ");
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("remarks") && !"".equals(whereObject.getString("remarks"))) {
|
|
|
+ where.append("and t1.remarks like'%").append(whereObject.getString("remarks")).append("%' ");
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("createby") && !"".equals(whereObject.getString("createby"))) {
|
|
|
+ where.append("and t1.createby like'%").append(whereObject.getString("createby")).append("%' ");
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("checkby") && !"".equals(whereObject.getString("checkby"))) {
|
|
|
+ where.append("and t1.checkby like'%").append(whereObject.getString("checkby")).append("%' ");
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("agentinfo") && !"".equals(whereObject.getString("agentinfo"))) {
|
|
|
+ where.append(" and(");
|
|
|
+ where.append(" t2.enterprisename like'%").append(whereObject.getString("agentinfo")).append("%' ");
|
|
|
+ where.append("or t7.agentnum like'%").append(whereObject.getString("agentinfo")).append("%' ");
|
|
|
+ where.append(")");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (whereObject.containsKey("isreturn") && !"".equals(whereObject.getString("isreturn"))) {
|
|
|
+ String isreturn = whereObject.getStringValue("isreturn");
|
|
|
+ if (isreturn.equals("1")) {
|
|
|
+ where.append(" and exists (select 1 from sa_orderitems where sa_orderid=t1.sa_orderid and siteid=t1.siteid and ifnull(returnqty,0)>0) ");
|
|
|
+ } else {
|
|
|
+ where.append(" and not exists (select 1 from sa_orderitems where sa_orderid=t1.sa_orderid and siteid=t1.siteid and ifnull(returnqty,0)=0) ");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (whereObject.containsKey("ischange") && !"".equals(whereObject.getString("ischange"))) {
|
|
|
+ String ischange = whereObject.getStringValue("ischange");
|
|
|
+ if (ischange.equals("0")) {
|
|
|
+ where.append(" and not exists(SELECT * from sa_orderitems_change WHERE sa_orderid = t1.sa_orderid and siteid = t1.siteid)");
|
|
|
+ } else {
|
|
|
+ where.append(" and exists(SELECT * from sa_orderitems_change WHERE sa_orderid = t1.sa_orderid and siteid = t1.siteid)");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ SQLFactory areasqlFactory = new SQLFactory(new promotion(content), "区域经理查询下属营销区域");
|
|
|
+ areasqlFactory.addParameter("siteid", siteid);
|
|
|
+ areasqlFactory.addParameter("hrid", hrid);
|
|
|
+ Rows arearows = dbConnect.runSqlQuery(areasqlFactory);
|
|
|
+ ArrayList<Long> arrayList =arearows.toArrayList("sa_saleareaid", new ArrayList<Long>());
|
|
|
+ arrayList.addAll(SaleArea.getSubSaleAreaIds(this, arrayList));
|
|
|
+
|
|
|
+ String sql = " and t1.sys_enterpriseid in (select sys_enterpriseid from sys_enterprise_tradefield where sa_saleareaid in "+arrayList+")";
|
|
|
+ sql = sql.replace("[", "(").replace("]", ")");
|
|
|
+ where.append(sql);
|
|
|
+
|
|
|
+
|
|
|
+ QuerySQL querySQL = queryListManage(where.toString());
|
|
|
+ querySQL.setOrderBy(pageSorting);
|
|
|
+ Rows rows;
|
|
|
+ querySQL.setPage(pageSize, pageNumber);
|
|
|
+ rows = querySQL.query();
|
|
|
+
|
|
|
+ ArrayList<Long> ids = rows.toArrayList("sa_orderid", new ArrayList<>());
|
|
|
+ //查询数量金额
|
|
|
+ RowsMap OrderAmountRowsMap = beans.order.Order.getSumOrderAmount(this, ids);
|
|
|
+
|
|
|
+ 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(ischangeSQl.getSQL()).toArrayList("sa_orderid", new ArrayList<>());
|
|
|
+
|
|
|
+ for (Row row : rows) {
|
|
|
+ Long id = row.getLong("sa_orderid");
|
|
|
+ if (OrderAmountRowsMap.get(id.toString()).isNotEmpty()) {
|
|
|
+ row.put("amount", OrderAmountRowsMap.get(id.toString()).get(0).getBigDecimal("amount"));
|
|
|
+ row.put("defaultamount", OrderAmountRowsMap.get(id.toString()).get(0).getBigDecimal("defaultamount"));
|
|
|
+ row.put("qty", OrderAmountRowsMap.get(id.toString()).get(0).getBigDecimal("qty"));
|
|
|
+ row.put("writeoffamount", OrderAmountRowsMap.get(id.toString()).get(0).getBigDecimal("writeoffamount"));
|
|
|
+ row.put("invoiceamount", OrderAmountRowsMap.get(id.toString()).get(0).getBigDecimal("invoiceamount"));
|
|
|
+ if (OrderAmountRowsMap.get(id.toString()).get(0).getBigDecimal("returnqty").compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ row.put("isreturn", "1");
|
|
|
+ } else {
|
|
|
+ row.put("isreturn", "0");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ row.put("amount", 0);
|
|
|
+ row.put("defaultamount", 0);
|
|
|
+ row.put("sumamount", 0);
|
|
|
+ row.put("qty", 0);
|
|
|
+ row.put("writeoffamount", 0);
|
|
|
+ row.put("invoiceamount", 0);
|
|
|
+ row.put("isreturn", "0");
|
|
|
+ }
|
|
|
+ BigDecimal writeoffamount = row.getBigDecimal("writeoffamount");
|
|
|
+ BigDecimal invoiceamount = row.getBigDecimal("invoiceamount");
|
|
|
+ BigDecimal amount = row.getBigDecimal("amount");
|
|
|
+ row.put("ischange", ischangesa_orderidList.contains(row.getLong("sa_orderid")) ? "1" : "0");
|
|
|
+
|
|
|
+ if (writeoffamount.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
+ row.put("writeoffstatus", "未核销");
|
|
|
+ } else if (writeoffamount.compareTo(amount) == 0) {
|
|
|
+ row.put("writeoffstatus", "已核销");
|
|
|
+ } else {
|
|
|
+ row.put("writeoffstatus", "部分核销");
|
|
|
+ }
|
|
|
+ if (invoiceamount.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
+ row.put("invoicestatus", "未开票");
|
|
|
+ } else if (invoiceamount.compareTo(amount) == 0) {
|
|
|
+ row.put("invoicestatus", "已开票");
|
|
|
+ } else {
|
|
|
+ row.put("invoicestatus", "部分开票");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
return getSucReturnObject().setData(rows).toString();
|
|
|
}
|