Browse Source

新功能:关联代理商账号和运营商账号(后端)

原志强 9 years ago
parent
commit
57196d6a95

+ 39 - 0
src/main/java/com/cloudcross/ssp/model/Correlation.java

@@ -0,0 +1,39 @@
+package com.cloudcross.ssp.model;
+
+public class Correlation {
+	private Long agentId;
+	private Long operatorId;
+	private String agentName;
+	private String operatorName;
+	public Long getAgentId() {
+		return agentId;
+	}
+	public void setAgentId(Long agentId) {
+		this.agentId = agentId;
+	}
+	public Long getOperatorId() {
+		return operatorId;
+	}
+	public void setOperatorId(Long operatorId) {
+		this.operatorId = operatorId;
+	}
+	public String getAgentName() {
+		return agentName;
+	}
+	public void setAgentName(String agentName) {
+		this.agentName = agentName;
+	}
+	public String getOperatorName() {
+		return operatorName;
+	}
+	public void setOperatorName(String operatorName) {
+		this.operatorName = operatorName;
+	}
+	@Override
+	public String toString() {
+		return "Correlation [agentId=" + agentId + ", operatorId=" + operatorId
+				+ ", agentName=" + agentName + ", operatorName=" + operatorName
+				+ "]";
+	}
+
+}

+ 134 - 0
src/main/java/com/cloudcross/ssp/model/mapper/correlation.sql.xml

@@ -0,0 +1,134 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="correlationSqlMapper">
+	<select id="findAllCorrelation"  resultType="com.cloudcross.ssp.model.Correlation">
+		select t_adv_agent.operator_id as operatorId
+		,t_adv_agent.id as agentId
+		,t_adv_agent.name as agentName
+		, t_operator.company_name 
+		from t_adv_agent,t_operator 
+		where operator_id !=0 and t_operator.id = t_adv_agent.operator_id
+	</select>
+	
+	<select id="findCorrelationByOperatorId"  resultType="com.cloudcross.ssp.model.Correlation" parameterType="Long">
+		select t_adv_agent.operator_id as operatorId
+		,t_adv_agent.id as agentId
+		,t_adv_agent.name as agentName
+		, t_operator.company_name 
+		from t_adv_agent,t_operator 
+		where operator_id = #{operatorId} and t_operator.id = t_adv_agent.operator_id
+	</select>
+	
+	<update id="addCorrelation1" parameterType="com.cloudcross.ssp.model.Correlation">
+		update 
+		t_account,
+		t_adv_agent a, 
+		t_advertiser b,
+		t_order c,
+		t_campaign d,
+		t_adgroup e
+		
+		set 
+		t_account.operator_id= #{operatorId},
+		a.operator_id=#{operatorId},
+		b.operator_id=#{operatorId},b.updated = NOW(),
+		c.operator_id=#{operatorId},c.updated = NOW(),
+		d.operator_id=#{operatorId},d.updated = NOW(),
+		e.operator_id=#{operatorId},e.updated = NOW()
+
+		where 
+		t_account.agent_id = #{agentId}
+		and	a.id = #{agentId} 
+		and b.agent_id = #{agentId} 
+		and c.agent_id = #{agentId} 
+		and d.agent_id = #{agentId} 
+		and e.agent_id = #{agentId} 
+	</update>
+	
+	<update id="addCorrelation2" parameterType="com.cloudcross.ssp.model.Correlation">
+		update 
+		t_rpt_adv_banner f,
+		t_rpt_adv_location g,
+		t_rpt_adv_os h,
+		t_rpt_adv_place i,
+		t_rpt_adv_schema j,
+		t_rpt_advertiser k,
+		t_rpt_advertiser_hour l
+		
+		set 
+		f.operator_id=#{operatorId},
+		g.operator_id=#{operatorId},
+		h.operator_id=#{operatorId},
+		i.operator_id=#{operatorId},
+		j.operator_id=#{operatorId},
+		k.operator_id=#{operatorId},
+		l.operator_id=#{operatorId}
+
+		where 
+		and f.advertiser_id in (select id from t_advertiser where agent_id = #{agent_id})
+		and g.advertiser_id in (select id from t_advertiser where agent_id = #{agent_id})
+		and h.advertiser_id in (select id from t_advertiser where agent_id = #{agent_id})
+		and i.advertiser_id in (select id from t_advertiser where agent_id = #{agent_id})
+		and j.advertiser_id in (select id from t_advertiser where agent_id = #{agent_id})
+		and k.advertiser_id in (select id from t_advertiser where agent_id = #{agent_id})
+		and l.advertiser_id in (select id from t_advertiser where agent_id = #{agent_id})
+
+	</update>
+	
+	<update id="deleteCorrelation1" parameterType="com.cloudcross.ssp.model.Correlation">
+		update 
+		t_account,
+		t_adv_agent a, 
+		t_advertiser b,
+		t_order c,
+		t_campaign d,
+		t_adgroup e
+		
+		set 
+		t_account.operator_id= 0,
+		a.operator_id=0,
+		b.operator_id=0,b.updated = NOW(),
+		c.operator_id=0,c.updated = NOW(),
+		d.operator_id=0,d.updated = NOW(),
+		e.operator_id=0,e.updated = NOW()
+
+		where 
+		t_account.agent_id = #{agentId}
+		and	a.id = #{agentId} 
+		and b.agent_id = #{agentId} 
+		and c.agent_id = #{agentId} 
+		and d.agent_id = #{agentId} 
+		and e.agent_id = #{agentId} 
+	</update>
+	
+	<update id="deleteCorrelation2" parameterType="com.cloudcross.ssp.model.Correlation">
+		update 
+		t_rpt_adv_banner f,
+		t_rpt_adv_location g,
+		t_rpt_adv_os h,
+		t_rpt_adv_place i,
+		t_rpt_adv_schema j,
+		t_rpt_advertiser k,
+		t_rpt_advertiser_hour l
+		
+		set 
+		f.operator_id=0,
+		g.operator_id=0,
+		h.operator_id=0,
+		i.operator_id=0,
+		j.operator_id=0,
+		k.operator_id=0,
+		l.operator_id=0
+
+		where 
+		and f.advertiser_id in (select id from t_advertiser where agent_id = #{agent_id})
+		and g.advertiser_id in (select id from t_advertiser where agent_id = #{agent_id})
+		and h.advertiser_id in (select id from t_advertiser where agent_id = #{agent_id})
+		and i.advertiser_id in (select id from t_advertiser where agent_id = #{agent_id})
+		and j.advertiser_id in (select id from t_advertiser where agent_id = #{agent_id})
+		and k.advertiser_id in (select id from t_advertiser where agent_id = #{agent_id})
+		and l.advertiser_id in (select id from t_advertiser where agent_id = #{agent_id})
+
+	</update>
+	
+</mapper>

+ 12 - 0
src/main/java/com/cloudcross/ssp/service/ICorrelationService.java

@@ -0,0 +1,12 @@
+package com.cloudcross.ssp.service;
+
+import java.util.List;
+
+import com.cloudcross.ssp.model.Correlation;
+
+public interface ICorrelationService {
+	public List<Correlation> findAllCorrelation();
+	public Correlation findCorrelationByOperatorId(Long operatorId);
+	public boolean addCorrelation(Correlation c);
+	public boolean deleteCorrelation(Correlation c);
+}

+ 74 - 0
src/main/java/com/cloudcross/ssp/service/impl/CorrelationService.java

@@ -0,0 +1,74 @@
+package com.cloudcross.ssp.service.impl;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.cloudcross.ssp.base.dao.GenericIBatisDao;
+import com.cloudcross.ssp.model.Correlation;
+import com.cloudcross.ssp.service.ICorrelationService;
+
+@Service
+public class CorrelationService implements ICorrelationService{
+
+	@Autowired
+	private GenericIBatisDao myBatisDao;
+	
+	@Override
+	public List<Correlation> findAllCorrelation() {
+		// TODO Auto-generated method stub
+		return myBatisDao.getList("correlationSqlMapper.findAllCorrelation");
+	}
+
+	@Override
+	public Correlation findCorrelationByOperatorId(Long operatorId) {
+		// TODO 通过operatorId查询是否关联代理商
+		return myBatisDao.get("correlationSqlMapper.findCorrelationByOperatorId",operatorId);
+	}
+
+
+	public boolean addCorrelation1(Correlation c) {
+		// TODO 添加所有的账号,代理商,广告主,订单,活动,投放的关联
+		myBatisDao.save("correlationSqlMapper.addCorrelation1", c);
+		return true;
+	}
+
+
+	public boolean deleteCorrelation1(Correlation c) {
+		// TODO 添加所有的账号,代理商,广告主,订单,活动,投放的关联
+		myBatisDao.save("correlationSqlMapper.deleteCorrelation1", c);
+		return true;
+	}
+
+
+	public boolean addCorrelation2(Correlation c) {
+		// TODO 添加所有的报表的operator关联
+		myBatisDao.save("correlationSqlMapper.addCorrelation2", c);
+		return true;
+	}
+
+
+	public boolean deleteCorrelation2(Correlation c) {
+		// TODO Auto-generated method stub
+		myBatisDao.save("correlationSqlMapper.deleteCorrelation2", c);
+		return true;
+	}
+
+	@Override
+	public boolean addCorrelation(Correlation c) {
+		// TODO Auto-generated method stub
+		addCorrelation1(c);
+		addCorrelation2(c);
+		return true;
+	}
+
+	@Override
+	public boolean deleteCorrelation(Correlation c) {
+		// TODO Auto-generated method stub
+		deleteCorrelation1(c);
+		deleteCorrelation2(c);
+		return true;
+	}
+	
+}

+ 43 - 1
src/main/java/com/cloudcross/ssp/web/back/main/ClientAccountController.java

@@ -23,12 +23,14 @@ import org.springframework.web.bind.annotation.ResponseBody;
 import com.cloudcross.ssp.model.Account;
 import com.cloudcross.ssp.model.AdvAgent;
 import com.cloudcross.ssp.model.ClientAccount;
+import com.cloudcross.ssp.model.Correlation;
 import com.cloudcross.ssp.model.Operator;
 import com.cloudcross.ssp.model.RoleAccount;
 import com.cloudcross.ssp.model.UserLogin;
 import com.cloudcross.ssp.service.IAccountService;
 import com.cloudcross.ssp.service.IAdvAgentService;
 import com.cloudcross.ssp.service.IClientAccountService;
+import com.cloudcross.ssp.service.ICorrelationService;
 import com.cloudcross.ssp.service.IOperatorService;
 import com.cloudcross.ssp.service.IRolesService;
 import com.cloudcross.ssp.service.IUserLoginService;
@@ -56,7 +58,8 @@ public class ClientAccountController extends SimpleController{
 	private FreemarkerTemplateProcessor templateProcessor;
 	@Autowired
 	protected IRolesService roleService;
-	
+	@Autowired
+	protected ICorrelationService correlationService;
 	@RequestMapping()
 	public String index(){
 		return redirect(page("list"));
@@ -412,6 +415,45 @@ public class ClientAccountController extends SimpleController{
 		}
 		return success;
 	}
+	/**
+	 * 打开关联列表页
+	 * @param model
+	 * @return
+	 */
+	@RequestMapping("/correlation")
+	public String correlation(Model model){
+		List<Correlation> correlations = correlationService.findAllCorrelation();
+		model.addAttribute("correlations",correlations);
+		System.err.println("ccmd"+correlations);
+		return page("correlation");
+	}
+	/**
+	 * 创建关联
+	 * @return
+	 */
+	@RequestMapping("createcorrelation")
+	public String createCorrelation(){
+		return page("createcorrelation");
+	}
+	/**
+	 * 取消关联
+	 * @return
+	 */
+	@RequestMapping("cancelcorrelation")
+	public String cancelCorrelation(@ModelAttribute("form")Correlation ca){
+		correlationService.deleteCorrelation(ca);
+		return OK;
+	}
+	/**
+	 * 保存关联
+	 * @return
+	 */
+	@RequestMapping("savecorrelation")
+	public String saveCorrelation(@ModelAttribute("form")Correlation ca){
+		correlationService.addCorrelation(ca);
+		return OK;
+	}
+	
 	
 	@RequestMapping("/exportDataReportExcel")
 	public void exportDataReportExcel(HttpServletRequest request,

+ 1 - 1
src/main/webapp/WEB-INF/pages/errors/403.ftl

@@ -22,7 +22,7 @@
   </ul>
   </@block>
  <footer>
-   <div class="copyright"> © Copyright 2012-2015 All Rights Reserved 数传媒</div>
+   <div class="copyright"> © Copyright 2012-2015 All Rights Reserved 数传媒</div>
  </footer>
 	<script type="text/javascript" src='${ctx}/assets/back/back/js/jquery-1.9.1.min.js'></script>
 	<script type="text/javascript">