Commit 2b48dc3d authored by Quxl's avatar Quxl

x

parent 772a8443
......@@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.aliyuncs.utils.StringUtils;
import com.egolm.common.Util;
import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.jdbc.Page;
import com.egolm.common.jdbc.dialect.SqlServerDialect;
......@@ -65,26 +66,20 @@ public class ActivityServiceImpl implements ActivityService {
String projectSql = projectSql(orgNo, projectId);
Map<String,Object> projectMap = jdbcTemplate.queryForMap(projectSql);
// String orderSql = orderSql(projectId);
// Map<String,Object> orderMap = jdbcTemplate.queryForMap(orderSql);
// projectMap.putAll(orderMap);
String sql = "SELECT PlanID = a.nPlanID,ProjectID = a.nProjectID,PlanName = a.sPlanName, PlanSummary = a.sPlanSummary,PlanUrl = a.sUrl,AgentContractNO = a.sAgentContractNO, "
+ " GoodsID = a.nGoodsID, GoodsNO = acg.sGoodsNO,GoodsDesc = acg.sGoodsDesc,PlanStock = a.nPlanStock, PlanPrice = a.nPrice,LimitQty = a.nLimitQty, "
+ " PlanReturnDays = (select datediff(dd, dEndDate, dReturnDate) from tZHCProject p where p.nProjectID = a.nProjectID), LastUpdateTime = a.dLastUpdateTime ,SaleCount = 0 "
+ " FROM tZHCPlan a join tAgentContractGoods acg on a.sAgentContractNO = acg.sAgentContractNO and a.nGoodsID = acg.nGoodsID "
+ " WHERE a.nProjectID = ? ";
List<Map<String,Object>> goodsList = jdbcTemplate.queryForList(sql,projectId);
if(goodsList != null && goodsList.size() >0) {
for(Map<String,Object> goodsMap:goodsList) {
String GoodsID = goodsMap.get("GoodsID")+"";
String AgentContractNO = goodsMap.get("AgentContractNO")+"";
String goodsSql = goodsSql(GoodsID, AgentContractNO);
Map<String,Object> goodsCountMap = jdbcTemplate.queryForMap(goodsSql);
goodsMap.putAll(goodsCountMap);
}
String sql0 = "select so.nPlanID, sum(so.nSaleQty) nSaleQty from tSalesOrder so, tZHCPlan p where so.sB2BOrderTypeID = '3' and so.nPlanID = p.nPlanID and p.nProjectID = " + projectId + " group by nPlanID";
List<Map<String, Object>> list = jdbcTemplate.queryForList(sql0);
Map<String, Map<String, Object>> mm = Util.listToMM(list, "nPlanID");
List<Map<String,Object>> goodsList = jdbcTemplate.queryForList(sql,projectId);
for(Map<String, Object> map : goodsList) {
Object PlanID = map.get("PlanID");
Object saleQty = mm.get("" + PlanID).get("nSaleQty");
map.put("SaleCount", saleQty);
}
projectMap.put("goodsList", goodsList);
......@@ -108,31 +103,4 @@ public class ActivityServiceImpl implements ActivityService {
}
return sql;
}
private String orderSql (String projectId) {
String sql = "SELECT SaleQty = count(distinct ts.sSubOrderID), SaleAmount = isnull(sum(td.nSaleAmount),0) "
+ " FROM tZHCProject a join tOrg o on a.sOrgNO = o.sOrgNO "
+ " join tZHCPlan b on a.nProjectID = b.nProjectID "
+ " left join tSalesOrderSub ts WITH(NOLOCK) on ts.dOrderDate >= a.dStartDate "
+ " and ts.dOrderDate <= a.dEndDate "
+ " and ts.sSalesOrderTypeID = '4' "//--众筹订单
+ " and ts.nOrderStatus&1 = 0 "
+ " and ts.nOrderStatus&32 = 32 " //--已付款
+ " left join tSalesOrderSubDtl td WITH(NOLOCK) on ts.sSubOrderID = td.sSubOrderID and td.sAgentContractNO = b.sAgentContractNO and td.nGoodsID = b.nGoodsID "
+ " WHERE a.nProjectID = "+projectId+" ";
return sql;
}
private String goodsSql(String GoodsID,String AgentContractNO ) { //子订单
String sql = "select SaleCount = count(DISTINCT ts.sSubOrderID) "
+ " from tSalesOrder r, tSalesOrderSub ts, tSalesOrderSubDtl td "
+ " where r.sSalesOrderID = ts.sSalesOrderID "
+ " AND ts.sSubOrderID = td.sSubOrderID "
+ " AND ts.sSalesOrderTypeID = '0' " //--销售
+ " AND r.sB2BOrderTypeID = '3' "
+ " AND td.nGoodsID = "+GoodsID+" AND td.sAgentContractNO = '"+AgentContractNO+"' ";
return sql;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment