advertiser.sql.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  3. <mapper namespace="advertiserSqlMapper">
  4. <!--广告主端 广告主list页面数据总条数 -->
  5. <select id="countByParams" parameterType="java.util.Map" resultType="java.lang.Integer">
  6. select count(t.advertiserId) from (
  7. SELECT
  8. tar.id advertiserId
  9. FROM
  10. t_advertiser tar
  11. LEFT JOIN t_order tor ON tar.id = tor.advertiser_id
  12. LEFT JOIN t_industry tiy ON tar.industry_id = tiy.id
  13. WHERE tar. STATUS != - 1
  14. <if test="value!=null">
  15. and tar.name like #{value}
  16. </if>
  17. <if test="status!=null">
  18. and tar.status = #{status}
  19. </if>
  20. <if test="industryId!=null">
  21. and tar.industry_id = #{industryId}
  22. </if>
  23. <if test="agentId!=null">
  24. and tar.agent_id = #{agentId}
  25. </if>
  26. GROUP BY tar.id
  27. )t
  28. </select>
  29. <!--广告主端 广告主list页面数据加载 -->
  30. <select id="selectByParams" parameterType="java.util.Map" resultType="com.cloudcross.ssp.model.Advertiser">
  31. select
  32. tar.id id,
  33. tar.name name,
  34. tiy.name industryName,
  35. count(tor.id) as orderNum,
  36. tar.updated updated,
  37. tar.status status
  38. from t_advertiser tar
  39. LEFT JOIN t_order tor on tar.id = tor.advertiser_id
  40. LEFT JOIN t_industry tiy ON tar.industry_id = tiy.id
  41. where tar.status != -1
  42. <if test="value!=null">
  43. and tar.name like #{value}
  44. </if>
  45. <if test="status!=null">
  46. and tar.status = #{status}
  47. </if>
  48. <if test="industryId!=null">
  49. and tar.industry_id = #{industryId}
  50. </if>
  51. <if test="agentId!=null">
  52. and tar.agent_id = #{agentId}
  53. </if>
  54. group by tar.id order by tar.id desc
  55. limit #{pager.offset}, #{pager.limit}
  56. </select>
  57. <!-- 根据广告主ID来查询一条信息 -->
  58. <select id="selectById" parameterType="java.lang.Integer" resultType="com.cloudcross.ssp.model.Advertiser">
  59. SELECT
  60. tar.id id,
  61. tar.industry_id industryId,
  62. tar.agent_id agentId,
  63. tar.operator_id operatorId,
  64. tar.name name,
  65. tar.reg_name regName,
  66. tar.homepage homePage,
  67. tar.contacts contacts,
  68. tar.tel tel,
  69. tar.email email,
  70. tar.memo memo,
  71. tar.balance balance,
  72. tar.cpi_path cpiPath,
  73. tar.licence_path licencePath,
  74. tar.id_path idPath,
  75. tar.org_path orgPath,
  76. tar.check_account checkAccount,
  77. tar.check_status checkStatus,
  78. tar.check_memo checkMemo,
  79. tar.admin_id adminId,
  80. tar.status status,
  81. tar.updated updated
  82. FROM
  83. t_advertiser tar where id = #{id}
  84. </select>
  85. <!-- 添加 -->
  86. <insert id="addAdvertiser" parameterType="com.cloudcross.ssp.model.Advertiser">
  87. insert into t_advertiser
  88. <trim prefix="(" suffix=")" suffixOverrides=",">
  89. <if test="industryId != null">
  90. industry_id,
  91. </if>
  92. <if test="agentId != null">
  93. agent_id,
  94. </if>
  95. <if test="operatorId != null">
  96. operator_id,
  97. </if>
  98. <if test="name != null">
  99. name,
  100. </if>
  101. <if test="regName != null">
  102. reg_name,
  103. </if>
  104. <if test="homePage != null">
  105. homePage,
  106. </if>
  107. <if test="contacts != null">
  108. contacts,
  109. </if>
  110. <if test="tel != null">
  111. tel,
  112. </if>
  113. <if test="email != null">
  114. email,
  115. </if>
  116. <if test="memo != null">
  117. memo,
  118. </if>
  119. <if test="balance != null">
  120. balance,
  121. </if>
  122. <if test="cpiPath != null">
  123. cpi_path,
  124. </if>
  125. <if test="licencePath != null">
  126. licence_path,
  127. </if>
  128. <if test="idPath != null">
  129. id_path,
  130. </if>
  131. <if test="orgPath != null">
  132. org_path,
  133. </if>
  134. <if test="checkAccount != null">
  135. check_account,
  136. </if>
  137. <if test="checkStatus != null">
  138. check_status,
  139. </if>
  140. <if test="checkMemo != null">
  141. check_memo,
  142. </if>
  143. <if test="adminId != null">
  144. admin_id,
  145. </if>
  146. <if test="status != null">
  147. status,
  148. </if>
  149. <if test="updated != null">
  150. updated
  151. </if>
  152. </trim>
  153. <trim prefix="values (" suffix=")" suffixOverrides=",">
  154. <if test="industryId != null">
  155. #{industryId},
  156. </if>
  157. <if test="agentId != null">
  158. #{agentId},
  159. </if>
  160. <if test="operatorId != null">
  161. #{operatorId},
  162. </if>
  163. <if test="name != null">
  164. #{name},
  165. </if>
  166. <if test="regName != null">
  167. #{regName},
  168. </if>
  169. <if test="homePage != null">
  170. #{homePage},
  171. </if>
  172. <if test="contacts != null">
  173. #{contacts},
  174. </if>
  175. <if test="tel != null">
  176. #{tel},
  177. </if>
  178. <if test="email != null">
  179. #{email},
  180. </if>
  181. <if test="memo != null">
  182. #{memo},
  183. </if>
  184. <if test="balance != null">
  185. #{balance},
  186. </if>
  187. <if test="cpiPath != null">
  188. #{cpiPath},
  189. </if>
  190. <if test="licencePath != null">
  191. #{licencePath},
  192. </if>
  193. <if test="idPath != null">
  194. #{idPath},
  195. </if>
  196. <if test="orgPath != null">
  197. #{orgPath,jdbcType=VARCHAR},
  198. </if>
  199. <if test="checkAccount != null">
  200. #{checkAccount},
  201. </if>
  202. <if test="checkStatus != null">
  203. #{checkStatus},
  204. </if>
  205. <if test="checkMemo != null">
  206. #{checkMemo},
  207. </if>
  208. <if test="adminId != null">
  209. #{adminId},
  210. </if>
  211. <if test="status != null">
  212. #{status},
  213. </if>
  214. <if test="updated != null">
  215. #{updated},
  216. </if>
  217. </trim>
  218. </insert>
  219. <!-- 修改 -->
  220. <update id="editAdvertiser" parameterType="com.cloudcross.ssp.model.Advertiser">
  221. update t_advertiser set
  222. <trim suffix="" suffixOverrides=",">
  223. <if test="industryId != null">
  224. industry_id = #{industryId},
  225. </if>
  226. <if test="agentId != null">
  227. agent_id = #{agentId},
  228. </if>
  229. <if test="operatorId != null">
  230. operator_id = #{operatorId},
  231. </if>
  232. <if test="name != null">
  233. name = #{name},
  234. </if>
  235. <if test="regName != null">
  236. reg_name = #{regName},
  237. </if>
  238. <if test="homePage != null">
  239. homePage = #{homePage},
  240. </if>
  241. <if test="contacts != null">
  242. contacts = #{contacts},
  243. </if>
  244. <if test="tel != null">
  245. tel = #{tel},
  246. </if>
  247. <if test="email != null">
  248. email = #{email},
  249. </if>
  250. <if test="memo != null">
  251. memo = #{memo},
  252. </if>
  253. <if test="balance != null">
  254. balance = #{balance},
  255. </if>
  256. <if test="cpiPath != null">
  257. cpi_path = #{cpiPath},
  258. </if>
  259. <if test="licencePath != null">
  260. licence_path = #{licencePath},
  261. </if>
  262. <if test="idPath != null">
  263. id_path = #{idPath},
  264. </if>
  265. <if test="orgPath != null">
  266. org_path = #{orgPath},
  267. </if>
  268. <if test="checkAccount != null">
  269. check_account = #{checkAccount},
  270. </if>
  271. <if test="checkStatus != null">
  272. check_status = #{checkStatus},
  273. </if>
  274. <if test="checkMemo != null">
  275. check_memo = #{checkMemo},
  276. </if>
  277. <if test="adminId != null">
  278. admin_id = #{adminId},
  279. </if>
  280. <if test="status != null">
  281. status = #{status},
  282. </if>
  283. <if test="updated != null">
  284. updated = #{updated,jdbcType=TIMESTAMP}
  285. </if>
  286. where id = #{id}
  287. </trim>
  288. </update>
  289. <sql id="base_column">
  290. t_advertiser.id as id,
  291. t_advertiser.agent_id as agentId,
  292. industry_id as industryId,
  293. t_advertiser.name as name,
  294. reg_name as regName,
  295. homepage as homePage,
  296. t_advertiser.contacts,
  297. t_advertiser.tel as tel,
  298. t_advertiser.email as email,
  299. t_advertiser.balance as balance,
  300. t_advertiser.status as status,
  301. t_advertiser.memo as memo,
  302. t_advertiser.cpi_path as cpiPath,
  303. t_advertiser.licence_path as licencePath,
  304. t_advertiser.id_path as idPath,
  305. t_advertiser.org_path as orgPath,
  306. t_advertiser.check_account as checkAccount,
  307. t_advertiser.check_status as checkStatus,
  308. t_advertiser.check_memo as checkMemo,
  309. t_advertiser.admin_id as adminId,
  310. t_advertiser.updated as updated
  311. </sql>
  312. <select id="selectByAgentId" parameterType="int" resultType="com.cloudcross.ssp.model.Advertiser">
  313. select
  314. <include refid="base_column" />
  315. from t_advertiser
  316. <where>
  317. agent_id = #{id} and
  318. status != -1
  319. </where>
  320. </select>
  321. <select id="selectByName" parameterType="String" resultType="long">
  322. select
  323. max(id)
  324. from t_advertiser
  325. <where>
  326. name = #{name} and
  327. status != -1
  328. </where>
  329. </select>
  330. <select id="selectByOperatoradvertiser" parameterType="int" resultType="com.cloudcross.ssp.model.Advertiser">
  331. select
  332. <include refid="base_column" />
  333. from t_advertiser
  334. <where>
  335. agent_id = #{operatorId} and
  336. status != -1.
  337. </where>
  338. </select>
  339. <select id="selectByOperatoroperator" parameterType="int" resultType="com.cloudcross.ssp.model.Advertiser">
  340. select
  341. <include refid="base_column" />
  342. from t_advertiser
  343. <where>
  344. operator_id = #{operatorId} and
  345. status != -1.
  346. </where>
  347. </select>
  348. <select id="selectByParamsback" parameterType="map" resultType="com.cloudcross.ssp.model.Advertiser">
  349. select
  350. <include refid="base_column" />
  351. ,b.name as industryName, count(c.advertiser_id) as orderNum from t_industry b,t_advertiser left join t_order c
  352. on t_advertiser.id = c.advertiser_id
  353. where 1 = 1
  354. <if test="value!=null">
  355. and t_advertiser.name like #{value}
  356. </if>
  357. <if test="status!=null">
  358. and t_advertiser.status = #{status}
  359. </if>
  360. <if test="industryId!=null">
  361. and t_advertiser.industry_id = #{industryId}
  362. </if>
  363. <if test="agentId!=null">
  364. and t_advertiser.agent_id = #{agentId}
  365. </if>
  366. and t_advertiser.status != -1
  367. and t_advertiser.industry_id = b.id
  368. group by t_advertiser.id
  369. order by t_advertiser.id desc
  370. limit #{pager.offset}, #{pager.limit}
  371. </select>
  372. <select id="selectByParamsoperator" parameterType="map" resultType="com.cloudcross.ssp.model.Advertiser">
  373. select
  374. <include refid="base_column" />
  375. ,b.name as industryName, count(c.advertiser_id) as orderNum from t_industry b,t_advertiser left join t_order c
  376. on t_advertiser.id = c.advertiser_id
  377. where 1 = 1
  378. <if test="key!=null and value!=null">
  379. <choose>
  380. <when test="key=='name'">
  381. and t_advertiser.name like #{value}
  382. </when>
  383. </choose>
  384. </if>
  385. <if test="status!=null">
  386. and t_advertiser.status = #{status}
  387. </if>
  388. <if test="industryId!=null">
  389. and t_advertiser.industry_id = #{industryId}
  390. </if>
  391. and t_advertiser.status != -1
  392. and t_advertiser.industry_id = b.id
  393. group by t_advertiser.id
  394. order by t_advertiser.id desc
  395. limit #{pager.offset}, #{pager.limit}
  396. </select>
  397. <select id="selectByStatus" parameterType="map" resultType="com.cloudcross.ssp.model.Advertiser">
  398. select
  399. <include refid="base_column" />
  400. ,b.name as industryName, count(c.advertiser_id) as orderNum from t_industry b,t_advertiser left join t_order c
  401. on t_advertiser.id = c.advertiser_id
  402. where 1 = 1
  403. and t_advertiser.status = #{status}
  404. and t_advertiser.industry_id = b.id
  405. group by t_advertiser.id
  406. order by t_advertiser.id desc
  407. limit #{pager.offset}, #{pager.limit}
  408. </select>
  409. <select id="countByStatus" parameterType="map" resultType="int">
  410. select count(a.id)
  411. from t_advertiser a where status = #{status}
  412. </select>
  413. <select id="countByParamsoperator" parameterType="map" resultType="int">
  414. select count(a.id)
  415. from t_advertiser a where status != -1
  416. <if test="key!=null and value!=null">
  417. <choose>
  418. <when test="key=='name'">
  419. and a.name like #{value}
  420. </when>
  421. </choose>
  422. </if>
  423. <if test="status!=null">
  424. and a.status = #{status}
  425. </if>
  426. <if test="industryId!=null">
  427. and a.industry_id = #{industryId}
  428. </if>
  429. </select>
  430. <insert id="addAdvertiserback" parameterType="com.cloudcross.ssp.model.Advertiser">
  431. insert into t_advertiser(industry_id,name,reg_name,homepage,contacts,tel,email,memo
  432. ,cpi_path,licence_path,id_path,org_path,check_memo,updated)
  433. values(#{industryId},#{name},#{regName},#{homePage},#{contacts},#{tel}, #{email},#{memo}
  434. ,#{cpiPath},#{licencePath},#{idPath}, #{orgPath},#{checkMemo},NOW())
  435. </insert>
  436. <insert id="addAdvertiseroperator" parameterType="com.cloudcross.ssp.model.Advertiser">
  437. insert into t_advertiser(industry_id,name,reg_name,homepage,contacts,tel,email,updated,memo)
  438. values(#{industryId},#{name},#{regName},#{homePage},#{contacts},#{tel}, #{email},#{updated},#{memo})
  439. </insert>
  440. <update id="editAdvertiserback" parameterType="com.cloudcross.ssp.model.Advertiser">
  441. update t_advertiser
  442. set industry_id = #{industryId},name = #{name},reg_name = #{regName},homepage = #{homePage},contacts = #{contacts},tel=#{tel}
  443. ,email = #{email},memo = #{memo},updated = NOW()
  444. ,cpi_path = #{cpiPath},licence_path = #{licencePath},id_path = #{idPath},org_path = #{orgPath},check_memo = #{checkMemo}
  445. where t_advertiser.id=#{id}
  446. </update>
  447. <update id="editAdvertiseroperator" parameterType="com.cloudcross.ssp.model.Advertiser">
  448. update t_advertiser
  449. set industry_id = #{industryId},name = #{name},reg_name = #{regName},homepage = #{homePage},contacts = #{contacts},tel=#{tel}
  450. ,email = #{email},updated = #{updated},memo = #{memo}
  451. where t_advertiser.id=#{id}
  452. </update>
  453. <update id="updateAdvertiserStatus" parameterType="HashMap">
  454. update t_advertiser
  455. set status = #{status},updated = #{modifyDate}
  456. where t_advertiser.id in
  457. <foreach item="advertiserId" collection="advertiserIdList"
  458. open="(" separator="," close=")">
  459. #{advertiserId}
  460. </foreach>
  461. </update>
  462. <update id="updateSupdated" parameterType="HashMap">
  463. update t_adgroup
  464. set t_adgroup.supdated= NOW()
  465. where t_adgroup.advertiser_id in
  466. <foreach item="advertiserId" collection="advertiserIdList"
  467. open="(" separator="," close=")">
  468. #{advertiserId}
  469. </foreach>
  470. </update>
  471. <!-- 导出Excel用 -->
  472. <select id="findDeliverEffectAnalysis" parameterType="map" resultType="com.cloudcross.ssp.model.Advertiser">
  473. select
  474. <include refid="base_column" />
  475. ,b.name as industryName, count(c.advertiser_id) as orderNum from t_industry b,t_advertiser left join t_order c
  476. on t_advertiser.id = c.advertiser_id
  477. where 1 = 1
  478. <if test="key!=null and value!=null">
  479. <choose>
  480. <when test="key=='name'">
  481. and t_advertiser.name like #{value}
  482. </when>
  483. </choose>
  484. </if>
  485. <if test="status!=null">
  486. and t_advertiser.status = #{status}
  487. </if>
  488. <if test="industryId!=null">
  489. and t_advertiser.industry_id = #{industryId}
  490. </if>
  491. and t_advertiser.status != -1
  492. and t_advertiser.industry_id = b.id
  493. group by t_advertiser.id
  494. order by t_advertiser.id desc
  495. </select>
  496. <select id="selectAdvertiserNameById" parameterType="int" resultType="String">
  497. select name from t_advertiser where id = #{id}
  498. </select>
  499. </mapper>