Stringone="select categoryID=sCategoryNO,categoryName=sCategoryDesc,parentID=sUpCategoryNO from tOrgCategory where sOrgNO='"+orgNO+"' and sScopeTypeID='"+scopeTypeID+"' and nCategoryLevel='3'";
Stringtwo="select categoryID=sCategoryNO,categoryName=sCategoryDesc,parentID=sUpCategoryNO from tOrgCategory where sOrgNO='"+orgNO+"' and sScopeTypeID='"+scopeTypeID+"' and nCategoryLevel='2'";
Stringthree="select categoryID=sCategoryNO,categoryName=sCategoryDesc,parentID=sUpCategoryNO from tOrgCategory where sOrgNO='"+orgNO+"' and sScopeTypeID='"+scopeTypeID+"' and nCategoryLevel='1'";
+" AND dTradeDate < dateadd( DAY,1,CONVERT (DATE, getdate())) "
+" AND sOrgNO='"+zone+"' AND sTerminalTypeID='"+terminalTypeID+"' AND sShopNO='"+shopNO+"' AND sViewTypeID='"+viewTypeID+"' AND sValues='"+values+"' ";
intn=jdbcTemplate.queryForInt(checkSql);
if(n>0){
StringupdateSql=" UPDATE tShopViewHistory "
+" SET nCount = nCount + 1 "
+" WHERE "
+" dTradeDate >= CONVERT (DATE, getdate()) "
+" AND dTradeDate < dateadd( DAY,1,CONVERT (DATE, getdate())) "
+" AND sOrgNO='"+zone+"' AND sTerminalTypeID='"+terminalTypeID+"' AND sShopNO='"+shopNO+"' AND sViewTypeID='"+viewTypeID+"' AND sValues='"+values+"' ";
jdbcTemplate.execute(updateSql);
}else{
StringviewType="";
if("1".equals(viewTypeID)){
viewType="Articles";
}elseif("2".equals(viewTypeID)){
viewType="Categories";
}elseif("3".equals(viewTypeID)){
viewType="Brands";
}
StringsaveSql="insert into tShopViewHistory (dTradeDate,sOrgNO,sTerminalTypeID,sTerminalType,sShopNO,sViewTypeID,sViewType,sValues,nCount,dLastUpdateTime) values (GETDATE(),'"+zone+"','"+terminalTypeID+"','"+terminalTypeID+"','"+shopNO+"','"+viewTypeID+"','"+viewType+"','"+values+"',1,GETDATE())";
+" FROM tAgentGoodsPic agp LEFT JOIN tAgentContractGoods g ON g.nGoodsID = agp.nGoodsID AND g.nAgentID = agp.nAgentID and agp.nTag&1=0 and g.nTag&1=0 "
+" WHERE g.sAgentContractNO= '"+agentContractNO+"' AND g.nGoodsID = "+goodsID+" ";
//图片库中商品图片
StringpicSql="SELECT ID=t.nItem,picTypeID=t.sPicTypeID,picType=t.sPicType,picDesc=t.sPicDesc,url=t.sURL FROM tGoodsPic t WHERE t.nGoodsID = "+goodsID+" and t.nTag&1=0 ";
+" LEFT JOIN tAgentContractWarehouse acw ON acw.sWarehouseNO = wd.sWarehouseNO "
+" LEFT JOIN tAgentContractGoods acg ON acg.sAgentContractNO = acw.sAgentContractNO "
+" WHERE "
+" wd.sDistrictID = '"+districtID+"' AND wd.nTag&1=0 AND acw.nTag&1=0 "
+" GROUP BY "
+" wd.sDistrictID, "
+" wd.sWarehouseNO, "
+" acw.sAgentContractNO, "
+" acg.nGoodsID, "
+" wd.nDCPriority, "
+" acg.nRealSalePrice, "
+" acg.nSalePrice,"
+" acg.nTag "
+" ) f1, "
+" ( "
+" SELECT "
+" wd.sDistrictID, "
+" acw.sAgentContractNO, "
+" acg.nGoodsID, "
+" MIN(wd.nDCPriority) nMaxDCPriority "
+" FROM "
+" tWarehouseDistrict wd "
+" LEFT JOIN tAgentContractWarehouse acw ON acw.sWarehouseNO = wd.sWarehouseNO "
+" LEFT JOIN tAgentContractGoods acg ON acg.sAgentContractNO = acw.sAgentContractNO "
+" WHERE "
+" wd.sDistrictID = '"+districtID+"' AND wd.nTag&1=0 AND acw.nTag&1=0 "
+" GROUP BY "
+" wd.sDistrictID, "
+" acw.sAgentContractNO, "
+" acg.nGoodsID "
+" ) f2 "
+"WHERE f1.sDistrictID = f2.sDistrictID and f1.sAgentContractNO = f2.sAgentContractNO and f1.nGoodsID = f2.nGoodsID and f1.nDCPriority = f2.nMaxDCPriority )AS t "
+"LEFT JOIN tAgentStockOnline aso on (t.sWarehouseNO =aso.sWarehouseNO AND aso.nGoodsID=t.nGoodsID AND t.sAgentContractNO = aso.sAgentContractNO ) "
+"LEFT JOIN tFlavorGoods f ON (t.nGoodsID = f.nGoodsID AND sShopNO = '"+shopNO+"' ) "
+" LEFT JOIN tAgentLevelPrice alp ON ( "
+" t.nGoodsID = alp.nGoodsID "
+" AND alp.nTag = 0 "
+" AND alp.nLevelID in (SELECT nLevelID FROM tAgentShopLevel WHERE sShopNO = '"+shopNO+"' and nTag=0 ) ) "
+"WHERE t.nGoodsID in ("+goodsID.substring(0,goodsID.length()-1)+") ";