Browse Source

数据报表

jun.zhou 9 years ago
parent
commit
853215ba56

+ 9 - 0
src/main/java/com/cloudcross/ssp/model/mapper/report.sql.xml

@@ -68,6 +68,9 @@
 		<if test="advertiserId != null and advertiserId ">
 		<if test="advertiserId != null and advertiserId ">
 			and a.advertiser_id = #{advertiserId}
 			and a.advertiser_id = #{advertiserId}
 		</if>
 		</if>
+		<if test="ids != null and ids != ''">
+			and a.advertiser_id in (#{ids})
+		</if>
 		<if test="orderId != null and orderId != ''">
 		<if test="orderId != null and orderId != ''">
 			and a.order_id = #{orderId}
 			and a.order_id = #{orderId}
 		</if>
 		</if>
@@ -458,6 +461,9 @@
 		<if test="advertiserId != null and advertiserId ">
 		<if test="advertiserId != null and advertiserId ">
 			and a.advertiser_id = #{advertiserId}
 			and a.advertiser_id = #{advertiserId}
 		</if>
 		</if>
+		<if test="ids != null and ids != ''">
+			and a.advertiser_id in (#{ids})
+		</if>
 		<if test="orderId != null and orderId != ''">
 		<if test="orderId != null and orderId != ''">
 			and a.order_id = #{orderId}
 			and a.order_id = #{orderId}
 		</if>
 		</if>
@@ -1391,6 +1397,9 @@ sum(click) as totalClick, if(sum(a.impression) > 0,sum(a.click)/sum(a.impression
 		<if test="advertiserId != null and advertiserId ">
 		<if test="advertiserId != null and advertiserId ">
 			and a.advertiser_id = #{advertiserId}
 			and a.advertiser_id = #{advertiserId}
 		</if>
 		</if>
+		<if test="ids != null and ids != ''">
+			and a.advertiser_id in (#{ids})
+		</if>
 		<if test="orderId != null and orderId != ''">
 		<if test="orderId != null and orderId != ''">
 			and a.order_id = #{orderId}
 			and a.order_id = #{orderId}
 		</if>
 		</if>

+ 10 - 2
src/main/java/com/cloudcross/ssp/web/advertiser/main/ad/report/AdvertiserReportController.java

@@ -26,6 +26,7 @@ import com.cloudcross.ssp.base.dao.GenericIBatisDao;
 import com.cloudcross.ssp.base.utils.freemarker.FreemarkerTemplateProcessor;
 import com.cloudcross.ssp.base.utils.freemarker.FreemarkerTemplateProcessor;
 import com.cloudcross.ssp.base.web.SimpleController;
 import com.cloudcross.ssp.base.web.SimpleController;
 import com.cloudcross.ssp.common.utils.Pager;
 import com.cloudcross.ssp.common.utils.Pager;
+import com.cloudcross.ssp.loader.AdvertiserLoader;
 import com.cloudcross.ssp.model.Account;
 import com.cloudcross.ssp.model.Account;
 import com.cloudcross.ssp.model.DeliverAnalysis;
 import com.cloudcross.ssp.model.DeliverAnalysis;
 import com.cloudcross.ssp.model.Dimension;
 import com.cloudcross.ssp.model.Dimension;
@@ -65,7 +66,9 @@ public class AdvertiserReportController extends SimpleController {
 		//前端需要传广告主idadvertiser和时间过来dateRangePicker
 		//前端需要传广告主idadvertiser和时间过来dateRangePicker
 		//判断前端传过来的登录账户id确定权限
 		//判断前端传过来的登录账户id确定权限
 		Account account = getLoginUser();
 		Account account = getLoginUser();
-		paramMap.put("agentId", account.getAgentId());
+		Long agentId = account.getAgentId();
+		String ids = AdvertiserLoader.getAdvertiserIdByAgentId(agentId);
+		paramMap.put("agentId",agentId);
 		
 		
 		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
 		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
 		String startDate = null;
 		String startDate = null;
@@ -94,19 +97,21 @@ public class AdvertiserReportController extends SimpleController {
 				|| "".equals(paramMap.get("selectedadvertiserId"))) {
 				|| "".equals(paramMap.get("selectedadvertiserId"))) {
 			advertiserId = null;
 			advertiserId = null;
 			advertiserName = "全部广告主";
 			advertiserName = "全部广告主";
+			paramMap.put("ids", ids);
 		} else {
 		} else {
 			// 如果要查询的是所有广告主则让广告主id为空
 			// 如果要查询的是所有广告主则让广告主id为空
 			if (-1 == Long.parseLong((String) paramMap
 			if (-1 == Long.parseLong((String) paramMap
 					.get("selectedadvertiserId"))) {
 					.get("selectedadvertiserId"))) {
 				advertiserId = null;
 				advertiserId = null;
 				advertiserName = "全部广告主";
 				advertiserName = "全部广告主";
+				paramMap.put("ids", ids);
 			} else {
 			} else {
 				advertiserId = Long.parseLong((String) paramMap
 				advertiserId = Long.parseLong((String) paramMap
 						.get("selectedadvertiserId"));
 						.get("selectedadvertiserId"));
 				advertiserName = advertiserService.findById(advertiserId).getName();
 				advertiserName = advertiserService.findById(advertiserId).getName();
 			}
 			}
 		}
 		}
-	
+		
 		//订单选择与否
 		//订单选择与否
 		if (null == paramMap.get("selectedorderId")
 		if (null == paramMap.get("selectedorderId")
 				|| "".equals(paramMap.get("selectedorderId"))) {
 				|| "".equals(paramMap.get("selectedorderId"))) {
@@ -962,6 +967,7 @@ public class AdvertiserReportController extends SimpleController {
 			@RequestParam(defaultValue="1") int page){
 			@RequestParam(defaultValue="1") int page){
 		
 		
 		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
 		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+		String ids = AdvertiserLoader.getAdvertiserIdByAgentId(getLoginUser().getAgentId());
 		String startDate = null;
 		String startDate = null;
 		String endDate = null;
 		String endDate = null;
 		Long advertiserId = null; 
 		Long advertiserId = null; 
@@ -978,11 +984,13 @@ public class AdvertiserReportController extends SimpleController {
 		if (null == paramMap.get("selectedadvertiserId")
 		if (null == paramMap.get("selectedadvertiserId")
 					|| "".equals(paramMap.get("selectedadvertiserId"))) {
 					|| "".equals(paramMap.get("selectedadvertiserId"))) {
 				advertiserId = null;
 				advertiserId = null;
+				paramMap.put("ids", ids);
 			} else {
 			} else {
 				// 如果要查询的是所有广告主则让广告主id为空
 				// 如果要查询的是所有广告主则让广告主id为空
 				if (-1 == Long.parseLong((String) paramMap
 				if (-1 == Long.parseLong((String) paramMap
 						.get("selectedadvertiserId"))) {
 						.get("selectedadvertiserId"))) {
 					advertiserId = null;
 					advertiserId = null;
+					paramMap.put("ids", ids);
 				} else {
 				} else {
 					advertiserId = Long.parseLong((String) paramMap
 					advertiserId = Long.parseLong((String) paramMap
 							.get("selectedadvertiserId"));
 							.get("selectedadvertiserId"));