UserMapperExt.xml 73 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073
  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="com.goafanti.common.dao.UserMapper">
  4. <select id="selectPersonalCustomerList" resultType="com.goafanti.customer.bo.CustomerListOut">
  5. select
  6. a.id as uid,
  7. a.identify_name as name,
  8. date_format(a.create_time,'%Y-%m-%d %H:%i:%S') as createTime,
  9. dg1.name as province,
  10. dg2.name as city,
  11. dg3.name as area,
  12. d.name as adminName
  13. from user a
  14. left join user_identity b on a.id = b.uid
  15. left join district_glossory dg1 on b.province = dg1.id
  16. left join district_glossory dg2 on b.city = dg2.id
  17. left join district_glossory dg3 on b.area = dg3.id
  18. left join admin d on a.aid = d.id
  19. where a.type = 0 and a.status != 1
  20. <if test="aid != null and aid !=''">
  21. and a.aid = #{aid,jdbcType=VARCHAR}
  22. </if>
  23. <if test="name != null and name != ''">
  24. and a.identify_name like concat('%',#{name},'%')
  25. </if>
  26. <if test="startDate != null and startDate != ''">
  27. and a.transfer_time &gt; #{startDate}
  28. </if>
  29. <if test="endDate != null and endDate != ''">
  30. and a.transfer_time &lt; #{endDate}
  31. </if>
  32. <if test="province != null">
  33. and b.province = #{province,jdbcType=INTEGER}
  34. </if>
  35. <if test="city != null">
  36. and b.city = #{city,jdbcType=INTEGER}
  37. </if>
  38. <if test="area != null">
  39. and b.area = #{area,jdbcType=INTEGER}
  40. </if>
  41. <if test="page_sql != null">
  42. ${page_sql}
  43. </if>
  44. </select>
  45. <select id="selectPersonalCustomerCount" resultType="java.lang.Integer">
  46. select
  47. count(0)
  48. from user a
  49. left join user_identity b on a.id = b.uid
  50. left join district_glossory dg1 on b.province = dg1.id
  51. left join district_glossory dg2 on b.city = dg2.id
  52. left join district_glossory dg3 on b.area = dg3.id
  53. left join admin d on a.aid = d.id
  54. where a.type = 0 and a.status != 1
  55. <if test="aid != null and aid !=''">
  56. and a.aid = #{aid,jdbcType=VARCHAR}
  57. </if>
  58. <if test="name != null and name != ''">
  59. and a.identify_name like concat('%',#{name},'%')
  60. </if>
  61. <if test="startDate != null and startDate != ''">
  62. and a.transfer_time &gt; #{startDate}
  63. </if>
  64. <if test="endDate != null and endDate != ''">
  65. and a.transfer_time &lt; #{endDate}
  66. </if>
  67. <if test="province != null">
  68. and b.province = #{province,jdbcType=INTEGER}
  69. </if>
  70. <if test="city != null">
  71. and b.city = #{city,jdbcType=INTEGER}
  72. </if>
  73. <if test="area != null">
  74. and b.area = #{area,jdbcType=INTEGER}
  75. </if>
  76. </select>
  77. <select id="selectPrivatePersonalCustomerList" resultType="com.goafanti.customer.bo.CustomerListOut">
  78. select t0.id as uid,
  79. t0.aid,
  80. date_format(t0.transfer_time,'%Y-%m-%d %H:%i:%S') as transferTime,
  81. date_format(t0.create_time,'%Y-%m-%d %H:%i:%S') as createTime,
  82. t0.identify_name as name,
  83. t0.society_tag as societyTag,
  84. date_format(t1.last_follow_time,'%Y-%m-%d %H:%i:%S') as lastFollowTime,
  85. date_format(t2.last_sign_time,'%Y-%m-%d %H:%i:%S') as lastSignTime,
  86. b.contacts,
  87. b.contact_mobile as contactMobile,
  88. dg1.name as province,
  89. dg2.name as city,
  90. dg3.name as area,
  91. ifnull(t1.last_follow_time,t0.transfer_time) as orderTime,
  92. c.name as industry,
  93. d.name as adminName
  94. from
  95. (select id,aid,type,share_type,create_time,transfer_time,identify_name,society_tag from user where aid = #{aid} and type = 0 and share_type = 0 and status != 1)t0
  96. left join
  97. (select uid,aid,max(create_time) as last_follow_time from user_follow where aid = #{aid} group by uid)t1
  98. on t0.id = t1.uid left join
  99. (select aid,uid,max(lock_time) as last_sign_time from user_lock_release where aid = #{aid} group by uid)t2
  100. on t0.id = t2.uid
  101. left join user_identity b on t0.id = b.uid
  102. left join district_glossory dg1 on b.province = dg1.id
  103. left join district_glossory dg2 on b.city = dg2.id
  104. left join district_glossory dg3 on b.area = dg3.id
  105. left join industry_category c on b.industry = c.id
  106. left join admin d on t0.aid = d.id where 1=1
  107. <if test="name != null and name != ''">
  108. and t0.identify_name like concat('%',#{name},'%')
  109. </if>
  110. <if test="startDate != null and startDate != ''">
  111. and t0.transfer_time &gt; #{startDate}
  112. </if>
  113. <if test="endDate != null and endDate != ''">
  114. and t0.transfer_time &lt; #{endDate}
  115. </if>
  116. <if test="province != null">
  117. and b.province = #{province,jdbcType=INTEGER}
  118. </if>
  119. <if test="city != null">
  120. and b.city = #{city,jdbcType=INTEGER}
  121. </if>
  122. <if test="area != null">
  123. and b.area = #{area,jdbcType=INTEGER}
  124. </if>
  125. order by orderTime
  126. <if test="page_sql != null">
  127. ${page_sql}
  128. </if>
  129. </select>
  130. <select id="selectPrivatePersonalCustomerCount" resultType="java.lang.Integer">
  131. select count(0)
  132. from
  133. (select id,aid,type,share_type,transfer_time,identify_name,society_tag from user where aid = #{aid} and type = 0 and share_type = 0 and status != 1)t0
  134. left join user_identity b on t0.id = b.uid where 1=1
  135. <if test="name != null and name != ''">
  136. and t0.identify_name like concat('%',#{name},'%')
  137. </if>
  138. <if test="startDate != null and startDate != ''">
  139. and t0.transfer_time &gt; #{startDate}
  140. </if>
  141. <if test="endDate != null and endDate != ''">
  142. and t0.transfer_time &lt; #{endDate}
  143. </if>
  144. <if test="province != null">
  145. and b.province = #{province,jdbcType=INTEGER}
  146. </if>
  147. <if test="city != null">
  148. and b.city = #{city,jdbcType=INTEGER}
  149. </if>
  150. <if test="area != null">
  151. and b.area = #{area,jdbcType=INTEGER}
  152. </if>
  153. </select>
  154. <select id="selectPublicPersonalCustomerList" resultType="com.goafanti.customer.bo.CustomerListOut">
  155. select
  156. a.id as uid,
  157. a.aid,
  158. a.identify_name as name,
  159. a.create_time as createTime,
  160. a.transfer_time as transferTime,
  161. b.contacts,
  162. b.contact_mobile as contactMobile,
  163. dg1.name as province,
  164. dg2.name as city,
  165. dg3.name as area
  166. from
  167. user a inner join user_identity b on a.id = b.uid
  168. left join district_glossory dg1 on b.province = dg1.id
  169. left join district_glossory dg2 on b.city = dg2.id
  170. left join district_glossory dg3 on b.area = dg3.id
  171. where
  172. a.type = 0 and a.share_type = 1 and a.status != 1
  173. <if test="aid != null and aid !=''">
  174. and a.aid = #{aid,jdbcType=VARCHAR}
  175. </if>
  176. <if test="name != null and name != ''">
  177. and a.identify_name like concat('%',#{name},'%')
  178. </if>
  179. <if test="startDate != null and startDate != ''">
  180. and a.transfer_time &gt; #{startDate}
  181. </if>
  182. <if test="endDate != null and endDate != ''">
  183. and a.transfer_time &lt; #{endDate}
  184. </if>
  185. <if test="province != null">
  186. and b.province = #{province,jdbcType=INTEGER}
  187. </if>
  188. <if test="city != null">
  189. and b.city = #{city,jdbcType=INTEGER}
  190. </if>
  191. <if test="area != null">
  192. and b.area = #{area,jdbcType=INTEGER}
  193. </if>
  194. order by a.create_time
  195. <if test="page_sql != null">
  196. ${page_sql}
  197. </if>
  198. </select>
  199. <select id="selectPublicPersonalCustomerCount" resultType="java.lang.Integer">
  200. select
  201. count(0)
  202. from
  203. user a inner join user_identity b on a.id = b.uid
  204. left join district_glossory dg1 on b.province = dg1.id
  205. left join district_glossory dg2 on b.city = dg2.id
  206. left join district_glossory dg3 on b.area = dg3.id
  207. where
  208. a.type = 0 and a.share_type = 1 and a.status != 1
  209. <if test="aid != null and aid !=''">
  210. and a.aid = #{aid,jdbcType=VARCHAR}
  211. </if>
  212. <if test="name != null and name != ''">
  213. and a.identify_name like concat('%',#{name},'%')
  214. </if>
  215. <if test="startDate != null and startDate != ''">
  216. and a.transfer_time &gt; #{startDate}
  217. </if>
  218. <if test="endDate != null and endDate != ''">
  219. and a.transfer_time &lt; #{endDate}
  220. </if>
  221. <if test="province != null">
  222. and b.province = #{province,jdbcType=INTEGER}
  223. </if>
  224. <if test="city != null">
  225. and b.city = #{city,jdbcType=INTEGER}
  226. </if>
  227. <if test="area != null">
  228. and b.area = #{area,jdbcType=INTEGER}
  229. </if>
  230. </select>
  231. <select id="selectSignPersonalCustomerList" resultType="com.goafanti.customer.bo.CustomerListOut">
  232. select
  233. t0.uid as uid,
  234. date_format(t0.update_time,'%Y-%m-%d %H:%i:%S') as lastSignTime,
  235. date_format(t1.last_follow_time,'%Y-%m-%d %H:%i:%S') as lastFollowTime,
  236. t2.society_tag as societyTag,
  237. t2.identify_name as name,
  238. t2.share_type as shareType,
  239. date_format(t2.transfer_time,'%Y-%m-%d %H:%i:%S') as transferTime,
  240. dg1.name as province,
  241. dg2.name as city,
  242. dg3.name as area,
  243. b.contacts,
  244. b.contact_mobile as contactMobile,
  245. c.name as industry,
  246. d.name as adminName
  247. from
  248. (select uid,aid,max(lock_time) as update_time
  249. from user_lock_release
  250. where type=1 and aid= #{aid,jdbcType=VARCHAR}
  251. group by uid)t0
  252. left join
  253. (select uid,aid,max(create_time) as last_follow_time from user_follow where aid =#{aid,jdbcType=VARCHAR} group by uid)t1
  254. on t0.uid = t1.uid
  255. inner join
  256. (select id,aid,share_type,society_tag,identify_name,transfer_time from user where type = 0 and status != 1)t2
  257. on t0.uid = t2.id
  258. left join user_identity b on t0.uid = b.uid
  259. left join district_glossory dg1 on b.province = dg1.id
  260. left join district_glossory dg2 on b.city = dg2.id
  261. left join district_glossory dg3 on b.area = dg3.id
  262. left join industry_category c on b.industry = c.id
  263. left join admin d on t2.aid = d.id where 1 = 1
  264. <if test="name != null and name != ''">
  265. and t2.identify_name like concat('%',#{name},'%')
  266. </if>
  267. <if test="shareType != null">
  268. and t2.share_type = #{shareType,jdbcType=VARCHAR}
  269. </if>
  270. <if test="startDate != null and startDate != ''">
  271. and t2.transfer_time &gt; #{startDate}
  272. </if>
  273. <if test="endDate != null and endDate != ''">
  274. and t2.transfer_time &lt; #{endDate}
  275. </if>
  276. <if test="province != null">
  277. and b.province = #{province,jdbcType=INTEGER}
  278. </if>
  279. <if test="city != null">
  280. and b.city = #{city,jdbcType=INTEGER}
  281. </if>
  282. <if test="area != null">
  283. and b.area = #{area,jdbcType=INTEGER}
  284. </if>
  285. <if test="page_sql != null">
  286. ${page_sql}
  287. </if>
  288. </select>
  289. <select id="selectSignPersonalCustomerCount" resultType="java.lang.Integer">
  290. select
  291. count(0)
  292. from
  293. (select uid,aid,max(lock_time) as update_time
  294. from user_lock_release
  295. where type=1 and aid= #{aid,jdbcType=VARCHAR}
  296. group by uid)t0
  297. <!-- (select uid,max(lock_time) from user_lock_release where aid = #{aid} and type = 1 and status = 0 group by uid)t0 -->
  298. inner join
  299. (select id,aid,share_type,society_tag,identify_name,transfer_time from user where type = 0 and status != 1)t2
  300. on t0.uid = t2.id
  301. left join user_identity b on t0.uid = b.uid
  302. where 1 = 1
  303. <if test="name != null and name != ''">
  304. and t2.identify_name like concat('%',#{name},'%')
  305. </if>
  306. <if test="shareType != null">
  307. and t2.share_type = #{shareType,jdbcType=VARCHAR}
  308. </if>
  309. <if test="startDate != null and startDate != ''">
  310. and t2.transfer_time &gt; #{startDate}
  311. </if>
  312. <if test="endDate != null and endDate != ''">
  313. and t2.transfer_time &lt; #{endDate}
  314. </if>
  315. <if test="province != null">
  316. and b.province = #{province,jdbcType=INTEGER}
  317. </if>
  318. <if test="city != null">
  319. and b.city = #{city,jdbcType=INTEGER}
  320. </if>
  321. <if test="area != null">
  322. and b.area = #{area,jdbcType=INTEGER}
  323. </if>
  324. </select>
  325. <select id="selectOrganizationCustomerList" resultType="com.goafanti.customer.bo.CustomerListOut">
  326. select
  327. a.id as uid,
  328. a.identify_name as name,
  329. date_format(a.create_time,'%Y-%m-%d %H:%i:%S') as createTime,
  330. dg1.name as province,
  331. dg2.name as city,
  332. dg3.name as area,
  333. a.aid,
  334. a.sign_bills signBills,
  335. a.share_type as shareType,
  336. a.information_maintainer as mid
  337. from user a
  338. left join organization_identity b on a.id = b.uid
  339. left join district_glossory dg1 on b.location_province = dg1.id
  340. left join district_glossory dg2 on b.location_city = dg2.id
  341. left join district_glossory dg3 on b.location_area = dg3.id
  342. left join admin d on a.aid = d.id
  343. where a.type = 1 and a.status != 1
  344. <if test="role == 0">
  345. and a.identify_name = #{name}
  346. </if>
  347. <if test="role == 1">
  348. and a.identify_name like concat('%', #{name},'%')
  349. </if>
  350. <if test="aid != null and aid !=''">
  351. and a.aid = #{aid,jdbcType=VARCHAR}
  352. </if>
  353. <if test="departmentId != null and departmentId !=''">
  354. and d.department_id=#{departmentId,jdbcType=VARCHAR}
  355. </if>
  356. <if test="startDate != null and startDate != ''">
  357. and a.transfer_time &gt; #{startDate}
  358. </if>
  359. <if test="endDate != null and endDate != ''">
  360. and a.transfer_time &lt; #{endDate}
  361. </if>
  362. <if test="province != null">
  363. and b.location_province = #{province,jdbcType=INTEGER}
  364. </if>
  365. <if test="city != null">
  366. and b.location_city = #{city,jdbcType=INTEGER}
  367. </if>
  368. <if test="area != null">
  369. and b.location_area = #{area,jdbcType=INTEGER}
  370. </if>
  371. <if test="page_sql != null">
  372. ${page_sql}
  373. </if>
  374. </select>
  375. <select id="selectOrganizationCustomerCount" resultType="java.lang.Integer">
  376. select
  377. count(0)
  378. from user a
  379. left join organization_identity b on a.id = b.uid
  380. <if test="departmentId != null and departmentId !=''">
  381. INNER join (select id
  382. from admin
  383. where department_id=#{departmentId,jdbcType=VARCHAR}) d on a.aid = d.id
  384. </if>
  385. where a.type = 1 and a.status != 1
  386. <if test="role == 0">
  387. and a.identify_name = #{name}
  388. </if>
  389. <if test="role == 1">
  390. and a.identify_name like concat('%', #{name},'%')
  391. </if>
  392. <if test="aid != null and aid !=''">
  393. and a.aid = #{aid,jdbcType=VARCHAR}
  394. </if>
  395. <if test="startDate != null and startDate != ''">
  396. and a.transfer_time &gt; #{startDate}
  397. </if>
  398. <if test="endDate != null and endDate != ''">
  399. and a.transfer_time &lt; #{endDate}
  400. </if>
  401. <if test="province != null">
  402. and b.location_province = #{province,jdbcType=INTEGER}
  403. </if>
  404. <if test="city != null">
  405. and b.location_city = #{city,jdbcType=INTEGER}
  406. </if>
  407. <if test="area != null">
  408. and b.location_area = #{area,jdbcType=INTEGER}
  409. </if>
  410. </select>
  411. <select id="selectPrivateOrganizationCustomerList" resultType="com.goafanti.customer.bo.CustomerListOut">
  412. select a.id uid,a.aid,a.identify_name name,a.society_tag societyTag,a.`level`,b.name aName,dg1.name as province,dg2.name as city,
  413. a.guidance, dg3.name as area,
  414. date_format(um.last_sign_time,'%Y-%m-%d %H:%i:%S') lastSignTime,
  415. date_format(a.transfer_time,'%Y-%m-%d %H:%i:%S') as transferTime,
  416. date_format(a.create_time,'%Y-%m-%d %H:%i:%S') as createTime,
  417. date_format(um.last_follow_time,'%Y-%m-%d %H:%i:%S') lastFollowTime,
  418. if(a.transfer_time &lt; um.last_follow_time,um.last_follow_time,a.transfer_time) as orderTime
  419. from user a left join admin b on a.aid=b.id left join organization_identity d on a.id = d.uid
  420. left join district_glossory dg1 on d.location_province = dg1.id
  421. left join district_glossory dg2 on d.location_city = dg2.id
  422. left join district_glossory dg3 on d.location_area = dg3.id
  423. left join user_mid um on um.aid=a.aid and um.uid=a.id
  424. where a.type= 1 and a.share_type=0 and a.source in(1,2,3)
  425. <if test="power ==0">
  426. and a.aid = #{aid,jdbcType=VARCHAR}
  427. </if>
  428. <if test="power ==1 or power ==2">
  429. and a.aid in
  430. <foreach item="item" collection="alist" separator="," open="(" close=")" index="">
  431. #{item}
  432. </foreach>
  433. </if>
  434. <if test="name != null and name != ''">
  435. and a.identify_name like concat('%',#{name},'%')
  436. </if>
  437. <if test="startDate != null and startDate != ''">
  438. and a.transfer_time &gt; #{startDate}
  439. </if>
  440. <if test="endDate != null and endDate != ''">
  441. and a.transfer_time &lt; #{endDate}
  442. </if>
  443. <if test="province != null">
  444. and d.location_province = #{province,jdbcType=INTEGER}
  445. </if>
  446. <if test="city != null">
  447. and d.location_city = #{city,jdbcType=INTEGER}
  448. </if>
  449. <if test="area != null">
  450. and d.location_area = #{area,jdbcType=INTEGER}
  451. </if>
  452. <if test="level != null">
  453. and a.level = #{level,jdbcType=INTEGER}
  454. </if>
  455. <if test="sort != 1">
  456. order by orderTime
  457. </if>
  458. <if test="sort == 1">
  459. order by a.create_time
  460. </if>
  461. <if test="sortType == 1">
  462. desc
  463. </if>
  464. <if test="page_sql != null">
  465. ${page_sql}
  466. </if>
  467. </select>
  468. <select id="selectPrivateOrganizationCustomerCount" resultType="java.lang.Integer">
  469. select count(*)
  470. from user a left join admin b on a.aid=b.id
  471. left join organization_identity d on a.id = d.uid left join district_glossory dg1 on d.location_province = dg1.id
  472. left join district_glossory dg2 on d.location_city = dg2.id left join district_glossory dg3 on d.location_area = dg3.id
  473. where a.type= 1 and a.share_type=0 and a.source in(1,2,3)
  474. <if test="power ==0">
  475. and a.aid = #{aid,jdbcType=VARCHAR}
  476. </if>
  477. <if test="power ==1 or power ==2">
  478. and a.aid in
  479. <foreach item="item" collection="alist" separator="," open="(" close=")" index="">
  480. #{item}
  481. </foreach>
  482. </if>
  483. <if test="name != null and name != ''">
  484. and a.identify_name like concat('%',#{name},'%')
  485. </if>
  486. <if test="startDate != null and startDate != ''">
  487. and a.transfer_time &gt; #{startDate}
  488. </if>
  489. <if test="endDate != null and endDate != ''">
  490. and a.transfer_time &lt; #{endDate}
  491. </if>
  492. <if test="province != null">
  493. and d.location_province = #{province,jdbcType=INTEGER}
  494. </if>
  495. <if test="city != null">
  496. and d.location_city = #{city,jdbcType=INTEGER}
  497. </if>
  498. <if test="area != null">
  499. and d.location_area = #{area,jdbcType=INTEGER}
  500. </if>
  501. <if test="level != null">
  502. and a.level = #{level,jdbcType=INTEGER}
  503. </if>
  504. </select>
  505. <select id="selectPublicOrganizationCustomerList" resultType="com.goafanti.customer.bo.CustomerListOut">
  506. select
  507. a.id as uid,
  508. a.identify_name as name,
  509. a.create_time as createTime,
  510. a.transfer_time as transferTime,
  511. dg1.name as province,
  512. dg2.name as city,
  513. dg3.name as area
  514. from
  515. user a
  516. inner join organization_identity b on a.id = b.uid
  517. left join district_glossory dg1 on b.location_province = dg1.id
  518. left join district_glossory dg2 on b.location_city = dg2.id
  519. left join district_glossory dg3 on b.location_area = dg3.id
  520. where
  521. a.type = 1
  522. and a.share_type = 1
  523. and a.status != 1
  524. and a.source != 0
  525. <if test="aid != null and aid !=''">
  526. and a.aid = #{aid,jdbcType=VARCHAR}
  527. </if>
  528. <if test="name != null and name != ''">
  529. and a.identify_name like concat('%',#{name},'%')
  530. </if>
  531. <if test="startDate != null and startDate != ''">
  532. and a.transfer_time &gt; #{startDate}
  533. </if>
  534. <if test="endDate != null and endDate != ''">
  535. and a.transfer_time &lt; #{endDate}
  536. </if>
  537. <if test="province != null">
  538. and b.location_province = #{province,jdbcType=INTEGER}
  539. </if>
  540. <if test="city != null">
  541. and b.location_city = #{city,jdbcType=INTEGER}
  542. </if>
  543. <if test="area != null">
  544. and b.location_area = #{area,jdbcType=INTEGER}
  545. </if>
  546. <if test="sort == 1">
  547. order by a.transfer_time desc
  548. </if>
  549. <if test="sort == 2">
  550. order by a.transfer_time
  551. </if>
  552. <if test="page_sql != null">
  553. ${page_sql}
  554. </if>
  555. </select>
  556. <select id="selectPublicOrganizationCustomerCount" resultType="java.lang.Integer">
  557. select
  558. count(0)
  559. from
  560. user a
  561. inner join organization_identity b on a.id = b.uid
  562. left join district_glossory dg1 on b.location_province = dg1.id
  563. left join district_glossory dg2 on b.location_city = dg2.id
  564. left join district_glossory dg3 on b.location_area = dg3.id
  565. where
  566. a.type = 1
  567. and a.share_type = 1
  568. and a.status != 1
  569. and a.source != 0
  570. <if test="aid != null and aid !=''">
  571. and a.aid = #{aid,jdbcType=VARCHAR}
  572. </if>
  573. <if test="name != null and name != ''">
  574. and a.identify_name like concat('%',#{name},'%')
  575. </if>
  576. <if test="startDate != null and startDate != ''">
  577. and a.transfer_time &gt; #{startDate}
  578. </if>
  579. <if test="endDate != null and endDate != ''">
  580. and a.transfer_time &lt; #{endDate}
  581. </if>
  582. <if test="province != null">
  583. and b.location_province = #{province,jdbcType=INTEGER}
  584. </if>
  585. <if test="city != null">
  586. and b.location_city = #{city,jdbcType=INTEGER}
  587. </if>
  588. <if test="area != null">
  589. and b.location_area = #{area,jdbcType=INTEGER}
  590. </if>
  591. </select>
  592. <select id="selectSignOrganizationCustomerList" resultType="com.goafanti.customer.bo.CustomerListOut">
  593. select
  594. t0.uid as uid,
  595. date_format(t3.last_sign_time,'%Y-%m-%d %H:%I:%S') as lastSignTime,
  596. t1.last_follow_time as lastFollowTime,
  597. t2.society_tag as societyTag,
  598. t2.identify_name as name,
  599. t2.share_type as shareType,
  600. t2.transfer_time as transferTime,
  601. dg1.name as province,
  602. dg2.name as city,
  603. dg3.name as area,
  604. c.name as industry,
  605. d.name as adminName
  606. from
  607. (select uid,aid,max(lock_time) as update_time
  608. from user_lock_release
  609. where type=1 and status=0 and aid= #{aid,jdbcType=VARCHAR}
  610. group by uid)t0
  611. left join
  612. (select uid,aid,max(create_time) as last_follow_time from user_follow where aid = #{aid,jdbcType=VARCHAR} group by uid)t1
  613. on t0.uid = t1.uid
  614. inner join
  615. (select id,aid,share_type,society_tag,identify_name,transfer_time from user where type = 1)t2
  616. on t0.uid = t2.id
  617. left join (select aid,uid,max(lock_time) as last_sign_time from user_lock_release where aid = #{aid,jdbcType=VARCHAR} group by uid)t3
  618. on t0.uid = t3.uid
  619. left join organization_identity b on t0.uid = b.uid
  620. left join district_glossory dg1 on b.location_province = dg1.id
  621. left join district_glossory dg2 on b.location_city = dg2.id
  622. left join district_glossory dg3 on b.location_area = dg3.id
  623. left join industry_category c on b.industry = c.id
  624. left join admin d on t2.aid = d.id where 1 = 1
  625. <if test="name != null and name != ''">
  626. and t2.identify_name like concat('%',#{name},'%')
  627. </if>
  628. <if test="shareType != null">
  629. and t2.share_type = #{shareType,jdbcType=VARCHAR}
  630. </if>
  631. <if test="startDate != null and startDate != ''">
  632. and t2.transfer_time &gt; #{startDate}
  633. </if>
  634. <if test="endDate != null and endDate != ''">
  635. and t2.transfer_time &lt; #{endDate}
  636. </if>
  637. <if test="province != null">
  638. and b.location_province = #{province,jdbcType=INTEGER}
  639. </if>
  640. <if test="city != null">
  641. and b.location_city = #{city,jdbcType=INTEGER}
  642. </if>
  643. <if test="area != null">
  644. and b.location_area = #{area,jdbcType=INTEGER}
  645. </if>
  646. order by t1.last_follow_time desc
  647. <if test="page_sql != null">
  648. ${page_sql}
  649. </if>
  650. </select>
  651. <select id="selectSignOrganizationCustomerCount" resultType="java.lang.Integer">
  652. select
  653. count(0)
  654. from
  655. (select uid,aid,max(lock_time) as update_time
  656. from user_lock_release
  657. where type=1 and status=0 and aid= #{aid,jdbcType=VARCHAR}
  658. group by uid)t0
  659. inner join
  660. (select id,aid,share_type,society_tag,identify_name,transfer_time from user where type = 1)t2
  661. on t0.uid = t2.id
  662. left join organization_identity b on t0.uid = b.uid where 1 = 1
  663. <if test="name != null and name != ''">
  664. and t2.identify_name like concat('%',#{name},'%')
  665. </if>
  666. <if test="shareType != null">
  667. and t2.share_type = #{shareType,jdbcType=VARCHAR}
  668. </if>
  669. <if test="startDate != null and startDate != ''">
  670. and t2.transfer_time &gt; #{startDate}
  671. </if>
  672. <if test="endDate != null and endDate != ''">
  673. and t2.transfer_time &lt; #{endDate}
  674. </if>
  675. <if test="province != null">
  676. and b.location_province = #{province,jdbcType=INTEGER}
  677. </if>
  678. <if test="city != null">
  679. and b.location_city = #{city,jdbcType=INTEGER}
  680. </if>
  681. <if test="area != null">
  682. and b.location_area = #{area,jdbcType=INTEGER}
  683. </if>
  684. </select>
  685. <select id="findCustomerByName" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.CustomerSimpleBo">
  686. select id,identify_name as name from user where identify_name like
  687. concat('%',#{identifyName},'%') and status <![CDATA[!= ]]> 1 and audit_status = 1
  688. </select>
  689. <select id="judgeCustomerByName" resultType="java.lang.Integer">
  690. select count(0) from user where identify_name = #{identifyName,jdbcType=VARCHAR}
  691. and status <![CDATA[!= ]]> 1
  692. </select>
  693. <select id="findOrganizationCustomerDetail" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.CustomerOrganizationDetailBo">
  694. select
  695. a.id as uid,
  696. a.society_tag as societyTag,
  697. a.company_logo_url as companyLogoUrl,
  698. a.introduction,
  699. a.identify_name as identifyName,
  700. b.industry,
  701. b.location_province as locationProvince,
  702. b.location_city as locationCity,
  703. b.location_area as locationArea,
  704. b.postal_address as postalAddress,
  705. b.contacts_fixed_tel as contactsFixedTel,
  706. b.contacts_fax as contactsFax,
  707. b.registered_capital registeredCapital,
  708. b.enterprise_scale as enterpriseScale,
  709. b.legal_person as legalPerson,
  710. b.legal_person_id_card as legalPersonIdCard,
  711. b.legal_person_tel as legalPersonTel,
  712. b.legal_person_email as legalPersonEmail,
  713. b.org_code as orgCode,
  714. b.org_code_url as orgCodeUrl,
  715. b.business_scope as businessScope,
  716. b.id,
  717. b.contacts,
  718. b.contact_mobile as contactMobile,
  719. b.licence_number as licenceNumber,
  720. a.aid as aid,
  721. d.name as adminName,
  722. a.information_maintainer as informationMaintainer,
  723. c.name as informationMaintainerName,
  724. a.core_technology as coreTechnology,
  725. a. accomplish_situation as accomplishSituation,
  726. a.intellectual_property as intellectualProperty,
  727. b.year_sales_amount as yearSalesAmount,
  728. b.last_year_research_amount as lastYearResearchAmount,
  729. b.assets,
  730. b.qualification,
  731. b.cooperation_situation as cooperationSituation,
  732. a.credit_rating as creditRating,
  733. e.poject_application_url as pojectApplicationUrl
  734. from
  735. user a inner join organization_identity b on a.id = b.uid
  736. left join admin d on d.id = a.aid
  737. left join admin c on c.id = a.information_maintainer
  738. left join organization_application_info e on a.id=e.uid
  739. where
  740. a.id = #{uid,jdbcType=VARCHAR}
  741. </select>
  742. <select id="findPersonalCustomerDetail" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.CustomerPersonalDetailBo">
  743. select
  744. a.id as uid,
  745. a.identify_name as identifyName,
  746. a.society_tag as societyTag,
  747. a.head_portrait_url as headPortraitUrl,
  748. a.introduction,
  749. b.id,
  750. b.industry,
  751. b.sex,
  752. b.date_of_birth_year as dateOfBirthYear,
  753. b.date_of_birth_month as dateOfBirthMonth,
  754. b.id_number as idNumber,
  755. b.province,
  756. b.city,
  757. b.area,
  758. b.positive_id_url as positiveIdUrl,
  759. b.opposite_id_url as oppositeIdUrl,
  760. b.postal_address as postalAddress,
  761. b.contact_mobile as contactMobile,
  762. b.fixed_tel as fixedTel,
  763. b.email,
  764. b.expert,
  765. b.international,
  766. b.contacts,
  767. b.contact_mobile as contactMobile,
  768. b.qq,
  769. b.professional_title as professionalTitle,
  770. b.work_unit as workUnit,
  771. b.education,
  772. b.major_category as majorCategory,
  773. b.qualification,
  774. b.audit_status as auditStatus,
  775. b.graduate_school as graduateSchool,
  776. b.consultation_price as consultationPrice,
  777. b.release_status as releaseStatus,
  778. a.aid as aid,d.name as adminName
  779. from
  780. user a inner join user_identity b on
  781. a.id = b.uid
  782. left join admin d on d.id = a.aid
  783. where
  784. a.id = #{uid,jdbcType=VARCHAR}
  785. </select>
  786. <select id="selectFollowHistoryList" resultType="com.goafanti.customer.bo.FollowListBo">
  787. select a.id as followId, a.aid, a.create_time as followTime, a.contact_type as contactType,
  788. a.result,a.guidance, b.identify_name as identifyName, c.name as contacts, c.mobile as contactMobile,
  789. d.name as adminName,date_format(a.guidance_time,'%Y-%m-%d %H:%i:%S') as guidanceTime
  790. <if test="businessProjectId != null and businessProjectId != ''"><!-- 客户甲项目A所有的跟进记录 -->
  791. ,e.id as ufbId,e.follow_situation as followSituation,e.customer_status as customerStatus
  792. </if>
  793. from user_follow a
  794. left join user b on a.uid = b.id
  795. left join organization_contact_book c on a.ocb_id = c.id
  796. left join admin d on a.aid = d.id
  797. <if test="businessProjectId != null and businessProjectId != ''"><!-- 客户甲项目A所有的跟进记录 -->
  798. inner join user_follow_business e on a.id = e.follow_id
  799. </if>
  800. where a.effective = 0
  801. <if test="uid != null and uid != ''">
  802. and a.uid = #{uid,jdbcType=VARCHAR}
  803. </if>
  804. <if test="aid != null and aid != ''">
  805. and a.aid = #{aid,jdbcType=VARCHAR}
  806. </if>
  807. <if test="businessProjectId != null and businessProjectId != ''"><!-- 客户甲项目A所有的跟进记录 -->
  808. and e.business_project_id = #{businessProjectId,jdbcType=VARCHAR}
  809. </if>
  810. order by a.create_time desc
  811. <if test="page_sql != null">
  812. ${page_sql}
  813. </if>
  814. </select>
  815. <select id="selectFollowHistoryCount" resultType="java.lang.Integer">
  816. select
  817. count(0)
  818. from user_follow a
  819. left join user b on a.uid = b.id
  820. left join organization_contact_book c on a.ocb_id = c.id
  821. left join admin d on a.aid = d.id
  822. <if test="businessProjectId != null and businessProjectId != ''"><!-- 客户甲项目A所有的跟进记录 -->
  823. inner join user_follow_business e on a.id = e.follow_id
  824. </if>
  825. where a.effective = 0
  826. <if test="uid != null and uid != ''">
  827. and a.uid = #{uid,jdbcType=VARCHAR}
  828. </if>
  829. <if test="aid != null and aid != ''">
  830. and a.aid = #{aid,jdbcType=VARCHAR}
  831. </if>
  832. <if test="businessProjectId != null and businessProjectId != ''"><!-- 客户甲项目A所有的跟进记录 -->
  833. and e.business_project_id = #{businessProjectId,jdbcType=VARCHAR}
  834. </if>
  835. </select>
  836. <select id="findUserAccountDetail" parameterType="java.lang.String" resultType="com.goafanti.common.model.User">
  837. select
  838. id,
  839. mobile,
  840. nickname,
  841. create_time as createTime,
  842. type,
  843. source,
  844. email,
  845. identify_name as identifyName,
  846. status,
  847. guidance
  848. from
  849. user
  850. where id = #{uid,jdbcType=VARCHAR}
  851. </select>
  852. <select id="findCustomerContacts" parameterType="java.lang.String" resultType="com.goafanti.common.model.OrganizationContactBook">
  853. select a.id,a.name,a.mobile,a.email,a.qq,a.wechat,a.department,a.position,a.major,a.fixed_tel fixedTel,a.aname,b.location_province,
  854. d1.name provinceName,d2.name cityName,d3.name areaName,date_format(a.create_time,'%Y-%m-%d')createTimes from organization_contact_book a
  855. left join organization_identity b on a.uid=b.uid left join district_glossory d1 on b.location_province=d1.id
  856. left join district_glossory d2 on b.location_city=d2.id left join district_glossory d3 on b.location_area=d3.id
  857. where a.uid = #{uid,jdbcType=VARCHAR} order by a.create_time desc
  858. </select>
  859. <select id="findAllContacts" parameterType="java.lang.String" resultType="com.goafanti.common.model.OrganizationContactBook">
  860. select id,name,mobile,major,sex,department,position,wechat,qq from organization_contact_book
  861. where uid = #{uid,jdbcType=VARCHAR}
  862. </select>
  863. <select id="findFollowById" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.FollowBusinessBo">
  864. select
  865. a.id as followId,
  866. a.uid,
  867. a.ocb_id as ocbId,
  868. a.contact_type as contactType,
  869. a.result,
  870. a.create_time as followTime,
  871. b.identify_name as identifyName,
  872. c.name as contacts,
  873. c.mobile as contactMobile,
  874. d.name as adminName
  875. from
  876. user_follow a
  877. left join user b on a.uid = b.id
  878. left join organization_contact_book c on a.ocb_id = c.id
  879. left join admin d on a.aid = d.id
  880. where a.id = #{followId,jdbcType=VARCHAR}
  881. </select>
  882. <select id="customerStatisticsList" resultType="com.goafanti.customer.bo.StatisticBo">
  883. select a.*,b.name as adminName,c.name as departmentName from (
  884. select
  885. aid,
  886. sum(case when customer_status = 0 then 1 else 0 end) as newNo, <!-- 新客户 -->
  887. sum(case when customer_status = 1 then 1 else 0 end) as intentionNo, <!-- 意向客户 -->
  888. sum(case when customer_status = 2 then 1 else 0 end) as pointNo, <!-- 重点客户 -->
  889. sum(case when customer_status = 3 then 1 else 0 end) as interviewNo, <!-- 面谈客户 -->
  890. sum(case when customer_status = 4 then 1 else 0 end) as signNo, <!-- 签单客户 -->
  891. sum(case when customer_status = 5 then 1 else 0 end) as refuseNo, <!-- 拒绝客户 -->
  892. sum(case when customer_status = 6 then 1 else 0 end) as stopNo <!-- 停止跟进 -->
  893. from user_business where 1=1
  894. <if test="sDate != null">
  895. and create_time &gt; #{sDate,jdbcType=DATE}
  896. </if>
  897. <if test="eDate != null">
  898. and create_time &lt; #{eDate,jdbcType=DATE}
  899. </if>
  900. <if test="businessGlossoryId != null">
  901. and business_glossory_id = #{businessGlossoryId,jdbcType=VARCHAR}
  902. </if>
  903. group by aid
  904. )a
  905. left join admin b on a.aid = b.id
  906. left join department c on b.department_id = c.id
  907. <if test="depNo != null">
  908. where c.dep_no like concat(#{depNo,jdbcType=VARCHAR},'%')
  909. </if>
  910. <if test="page_sql != null">
  911. ${page_sql}
  912. </if>
  913. </select>
  914. <select id="customerStatisticsCount" resultType="java.lang.Integer">
  915. select count(0) from (
  916. select
  917. aid
  918. from user_business where 1=1
  919. <if test="sDate != null">
  920. and create_time &gt; #{sDate,jdbcType=DATE}
  921. </if>
  922. <if test="eDate != null">
  923. and create_time &lt; #{eDate,jdbcType=DATE}
  924. </if>
  925. <if test="businessGlossoryId != null">
  926. and business_glossory_id = #{businessGlossoryId,jdbcType=VARCHAR}
  927. </if>
  928. group by aid
  929. )a
  930. left join admin b on a.aid = b.id
  931. left join department c on b.department_id = c.id
  932. <if test="depNo !=null">
  933. where c.dep_no like concat(#{depNo,jdbcType=VARCHAR},'%')
  934. </if>
  935. </select>
  936. <select id="businessStatisticList" resultType="com.goafanti.customer.bo.StatisticBo">
  937. select a.*,b.name as adminName,c.name as departmentName from (
  938. select
  939. aid,
  940. sum(case when follow_situation = 0 then 1 else 0 end) as sendMaterialNo, <!-- 已发项目介绍资料 -->
  941. sum(case when follow_situation = 1 then 1 else 0 end) as interviewNo, <!-- 已约面谈 -->
  942. sum(case when follow_situation = 2 then 1 else 0 end) as sendProspectusNo, <!-- 已发合同计划书 -->
  943. sum(case when follow_situation = 3 then 1 else 0 end) as quoteNo, <!-- 已报价 -->
  944. sum(case when follow_situation = 4 then 1 else 0 end) as sendContractNo, <!-- 已发合同 -->
  945. sum(case when follow_situation = 5 then 1 else 0 end) as signContractNo, <!-- 已签合同 -->
  946. sum(case when follow_situation = 6 then 1 else 0 end) as onVisaNo, <!-- 面谈中 -->
  947. sum(case when follow_situation = 7 then 1 else 0 end) as visaNo <!-- 已面签 -->
  948. from user_business where 1=1
  949. <if test="sDate != null">
  950. and create_time &gt; #{sDate,jdbcType=DATE}
  951. </if>
  952. <if test="eDate != null">
  953. and create_time &lt; #{eDate,jdbcType=DATE}
  954. </if>
  955. <if test="businessGlossoryId != null">
  956. and business_glossory_id = #{businessGlossoryId,jdbcType=VARCHAR}
  957. </if>
  958. group by aid
  959. )a
  960. left join admin b on a.aid = b.id
  961. left join department c on b.department_id = c.id
  962. <if test="depNo !=null">
  963. where c.dep_no like concat(#{depNo,jdbcType=VARCHAR},'%')
  964. </if>
  965. <if test="page_sql != null">
  966. ${page_sql}
  967. </if>
  968. </select>
  969. <select id="businessStatisticCount" resultType="java.lang.Integer">
  970. select count(0) from (
  971. select
  972. aid
  973. from user_business where 1=1
  974. <if test="sDate != null">
  975. and create_time &gt; #{sDate,jdbcType=DATE}
  976. </if>
  977. <if test="eDate != null">
  978. and create_time &lt; #{eDate,jdbcType=DATE}
  979. </if>
  980. <if test="businessGlossoryId != null">
  981. and business_glossory_id = #{businessGlossoryId,jdbcType=VARCHAR}
  982. </if>
  983. group by aid
  984. )a
  985. left join admin b on a.aid = b.id
  986. left join department c on b.department_id = c.id
  987. <if test="depNo !=null">
  988. where c.dep_no like concat(#{depNo,jdbcType=VARCHAR},'%')
  989. </if>
  990. </select>
  991. <select id="followStatisticList" resultType="com.goafanti.customer.bo.StatisticBo">
  992. select x.*,b.name as adminName,c.name as departmentName,y.* from (
  993. select
  994. count(0) as followNo,
  995. aid,
  996. sum(case when contact_type = 0 then 1 else 0 end) as visitNo, <!-- 外出 -->
  997. sum(case when contact_type = 1 then 1 else 0 end) as telNo, <!-- 电话 -->
  998. sum(case when contact_type = 2 then 1 else 0 end) as qqNo, <!-- QQ -->
  999. sum(case when contact_type = 3 then 1 else 0 end) as wxNo, <!-- 微信 -->
  1000. sum(case when contact_type = 4 then 1 else 0 end) as emailNo, <!-- 邮件 -->
  1001. sum(case when contact_type = 5 then 1 else 0 end) as letterNo <!-- 书信 -->
  1002. from user_follow where 1=1
  1003. <if test="sDate != null">
  1004. and create_time &gt; #{sDate,jdbcType=DATE}
  1005. </if>
  1006. <if test="eDate != null">
  1007. and create_time &lt; #{eDate,jdbcType=DATE}
  1008. </if>
  1009. group by aid
  1010. )x
  1011. left join admin b on x.aid = b.id
  1012. left join department c on b.department_id = c.id
  1013. left join
  1014. (
  1015. select
  1016. count( 0 ) as customerNo,
  1017. aid
  1018. from
  1019. (
  1020. select
  1021. aid,
  1022. uid
  1023. from
  1024. user_follow
  1025. group by
  1026. aid,
  1027. uid
  1028. ) a
  1029. group by
  1030. aid
  1031. )y on x.aid = y.aid
  1032. <if test="depNo !=null">
  1033. where c.dep_no like concat(#{depNo,jdbcType=VARCHAR},'%')
  1034. </if>
  1035. </select>
  1036. <select id="followStatisticCount" resultType="java.lang.Integer">
  1037. select count(0) from (
  1038. select
  1039. aid
  1040. from user_follow where 1=1
  1041. <if test="sDate != null">
  1042. and create_time &gt; #{sDate,jdbcType=DATE}
  1043. </if>
  1044. <if test="sDate != null">
  1045. and create_time &lt; #{eDate,jdbcType=DATE}
  1046. </if>
  1047. group by aid
  1048. )x
  1049. left join admin b on x.aid = b.id
  1050. left join department c on b.department_id = c.id
  1051. <if test="depNo !=null">
  1052. where c.dep_no like concat(#{depNo,jdbcType=VARCHAR},'%')
  1053. </if>
  1054. </select>
  1055. <select id="findBusinessByFollowId" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.BusinessListBo">
  1056. select
  1057. a.id as ufbId,
  1058. a.follow_situation as followSituation,
  1059. a.customer_status as customerStatus,
  1060. a.remarks,
  1061. a.business_project_id as businessProjectId,
  1062. b.bname as businessProjectName,
  1063. c.cname as businessVarietiesName
  1064. from
  1065. user_follow_business a
  1066. left join business_project b on a.business_project_id = b.id
  1067. left join business_category c on b.cid = c.id
  1068. where
  1069. a.follow_id = #{followId,jdbcType=VARCHAR}
  1070. </select>
  1071. <select id="selectBusinessList" resultType="com.goafanti.customer.bo.BusinessListBo">
  1072. select
  1073. c.bname as businessName,
  1074. b.identify_name as identifyName,
  1075. a.id as businessId,
  1076. a.business_project_id as businessProjectId,
  1077. a.create_time as createTime,
  1078. a.update_time as updateTime,
  1079. a.follow_situation as followSituation,
  1080. a.customer_status as customerStatus,
  1081. d.name as adminName
  1082. from
  1083. user_business a inner join user b on
  1084. a.uid = b.id left join business_project c on
  1085. a.business_project_id = c.id left join admin d on
  1086. a.aid = d.id
  1087. where 1 = 1
  1088. <if test="aid != null and aid != ''">
  1089. and a.aid = #{aid,jdbcType=VARCHAR}
  1090. </if>
  1091. <if test="uid != null and uid !=''">
  1092. and a.uid = #{uid,jdbcType=VARCHAR}
  1093. </if>
  1094. <if test="businessProjectId !=null and businessProjectId != ''">
  1095. and a.business_project_id = #{businessProjectId,jdbcType=VARCHAR}
  1096. </if>
  1097. <if test="identifyName != null and identifyName != ''">
  1098. and b.identify_name like concat('%', #{identifyName},'%')
  1099. </if>
  1100. <if test="followSituation != null">
  1101. and a.follow_situation = #{followSituation,jdbcType=INTEGER}
  1102. </if>
  1103. <if test="customerStatus != null">
  1104. and a.customer_status = #{customerStatus,jdbcType=INTEGER}
  1105. </if>
  1106. <if test="adminName != null and adminName != ''">
  1107. and d.name = #{adminName,jdbcType=VARCHAR}
  1108. </if>
  1109. <if test="startDate != null and startDate != ''">
  1110. and a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  1111. </if>
  1112. <if test="endDate != null and endDate != ''">
  1113. and a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  1114. </if>
  1115. order by a.create_time desc
  1116. <if test="page_sql != null">
  1117. ${page_sql}
  1118. </if>
  1119. </select>
  1120. <select id="selectBusinessCount" parameterType="com.goafanti.customer.bo.BusinessListBo" resultType="java.lang.Integer">
  1121. select
  1122. count(*)
  1123. from
  1124. user_business a inner join user b on
  1125. a.uid = b.id left join business_project c on
  1126. a.business_project_id = c.id left join admin d on
  1127. a.aid = d.id
  1128. where 1 = 1
  1129. <if test="aid != null and aid != ''">
  1130. and a.aid = #{aid,jdbcType=VARCHAR}
  1131. </if>
  1132. <if test="uid != null and uid !=''">
  1133. and a.uid = #{uid,jdbcType=VARCHAR}
  1134. </if>
  1135. <if test="businessProjectId !=null and businessProjectId != ''">
  1136. and a.business_project_id = #{businessProjectId,jdbcType=VARCHAR}
  1137. </if>
  1138. <if test="identifyName != null and identifyName != ''">
  1139. and b.identify_name like concat('%', #{identifyName},'%')
  1140. </if>
  1141. <if test="followSituation != null">
  1142. and a.follow_situation = #{followSituation,jdbcType=INTEGER}
  1143. </if>
  1144. <if test="customerStatus != null">
  1145. and a.customer_status = #{customerStatus,jdbcType=INTEGER}
  1146. </if>
  1147. <if test="adminName != null and adminName != ''">
  1148. and d.name = #{adminName,jdbcType=VARCHAR}
  1149. </if>
  1150. <if test="startDate != null and startDate != ''">
  1151. and a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  1152. </if>
  1153. <if test="endDate != null and endDate != ''">
  1154. and a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  1155. </if>
  1156. </select>
  1157. <select id="selectBusinessManageList" resultType="com.goafanti.customer.bo.BusinessListBo">
  1158. select
  1159. c.name as businessName,
  1160. b.identify_name as identifyName,
  1161. a.id as businessId,
  1162. a.create_time as createTime,
  1163. a.update_time as updateTime,
  1164. a.follow_situation as followSituation,
  1165. a.customer_status as customerStatus,
  1166. d.name as adminName
  1167. from
  1168. user_business a inner join user b on
  1169. a.uid = b.id left join business_glossory c on
  1170. a.business_project_id = c.id left join admin d on
  1171. a.aid = d.id
  1172. left join department dm on dm.id = d.department_id
  1173. where 1 = 1
  1174. <if test="aid != null and aid != ''">
  1175. and (b.aid = #{aid,jdbcType=VARCHAR} or d.department_id=(select department_id from admin where id=#{aid,jdbcType=VARCHAR}))
  1176. </if>
  1177. <if test="uid != null and uid !=''">
  1178. and a.uid = #{uid,jdbcType=VARCHAR}
  1179. </if>
  1180. <if test="businessProjectId !=null and businessProjectId != ''">
  1181. and a.business_project_id = #{businessProjectId,jdbcType=VARCHAR}
  1182. </if>
  1183. <if test="identifyName != null and identifyName != ''">
  1184. and b.identify_name like concat('%', #{identifyName},'%')
  1185. </if>
  1186. <if test="followSituation != null">
  1187. and a.follow_situation = #{followSituation,jdbcType=INTEGER}
  1188. </if>
  1189. <if test="customerStatus != null">
  1190. and a.customer_status = #{customerStatus,jdbcType=INTEGER}
  1191. </if>
  1192. <if test="adminName != null and adminName != ''">
  1193. and d.name = #{adminName,jdbcType=VARCHAR}
  1194. </if>
  1195. <if test="startDate != null and startDate != ''">
  1196. and a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  1197. </if>
  1198. <if test="endDate != null and endDate != ''">
  1199. and a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  1200. </if>
  1201. order by a.create_time desc
  1202. <if test="page_sql != null">
  1203. ${page_sql}
  1204. </if>
  1205. </select>
  1206. <select id="selectBusinessManageCount" parameterType="com.goafanti.customer.bo.BusinessListBo" resultType="java.lang.Integer">
  1207. select
  1208. count(0)
  1209. from
  1210. user_business a inner join user b on
  1211. a.uid = b.id left join business_glossory c on
  1212. a.business_project_id = c.id left join admin d on
  1213. a.aid = d.id
  1214. left join department dm on dm.id = d.department_id
  1215. where 1 = 1
  1216. <if test="aid != null and aid != ''">
  1217. and (b.aid = #{aid,jdbcType=VARCHAR} or d.department_id=(select department_id from admin where id=#{aid,jdbcType=VARCHAR}))
  1218. </if>
  1219. <if test="uid != null and uid !=''">
  1220. and a.uid = #{uid,jdbcType=VARCHAR}
  1221. </if>
  1222. <if test="businessProjectId !=null and businessProjectId != ''">
  1223. and a.business_project_id = #{businessProjectId,jdbcType=VARCHAR}
  1224. </if>
  1225. <if test="identifyName != null and identifyName != ''">
  1226. and b.identify_name like concat('%', #{identifyName},'%')
  1227. </if>
  1228. <if test="followSituation != null">
  1229. and a.follow_situation = #{followSituation,jdbcType=INTEGER}
  1230. </if>
  1231. <if test="customerStatus != null">
  1232. and a.customer_status = #{customerStatus,jdbcType=INTEGER}
  1233. </if>
  1234. <if test="adminName != null and adminName != ''">
  1235. and d.name = #{adminName,jdbcType=VARCHAR}
  1236. </if>
  1237. <if test="startDate != null and startDate != ''">
  1238. and a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  1239. </if>
  1240. <if test="endDate != null and endDate != ''">
  1241. and a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  1242. </if>
  1243. </select>
  1244. <select id="selectManagePersonalCustomerList" resultType="com.goafanti.customer.bo.CustomerListOut">
  1245. select
  1246. a.id as uid,
  1247. a.type,
  1248. a.status,
  1249. date_format(a.create_time,'%Y-%m-%d %H:%i:%s') as createTime,
  1250. a.business_audit as businessAudit,
  1251. a.current_member_status as currentMemberStatus,
  1252. a.identify_name as name,
  1253. a.lvl,a.is_member as isMember,
  1254. a.society_tag as societyTag,
  1255. a.share_type as shareType,
  1256. b.contacts,
  1257. b.contact_mobile as contactMobile,
  1258. b.international,
  1259. b.expert,
  1260. b.audit_status as auditStatus,
  1261. dg1.name as province,
  1262. dg2.name as city,
  1263. dg3.name as area,
  1264. c.name as industry,
  1265. d.name as adminName,
  1266. b.release_status as releaseStatus
  1267. from user a inner join user_identity b on a.id = b.uid
  1268. left join district_glossory dg1 on b.province = dg1.id
  1269. left join district_glossory dg2 on b.city = dg2.id
  1270. left join district_glossory dg3 on b.area = dg3.id
  1271. left join industry_category c on b.industry = c.id
  1272. left join admin d on a.aid = d.id
  1273. LEFT JOIN department dm on dm.id = d.department_id
  1274. where a.type = 0 and a.status != 1 and a.audit_status = 1
  1275. and a.share_type =0
  1276. <if test="aid != null and aid !=''">
  1277. and (a.aid = #{aid,jdbcType=VARCHAR} or d.department_id=(select department_id from admin where id=#{aid,jdbcType=VARCHAR}))
  1278. </if>
  1279. <if test="name != null and name != ''">
  1280. and a.identify_name like concat('%',#{name},'%')
  1281. </if>
  1282. <if test="shareType != null">
  1283. and a.share_type = #{shareType,jdbcType=INTEGER}
  1284. </if>
  1285. <if test="status != null">
  1286. and a.status = #{status,jdbcType=INTEGER}
  1287. </if>
  1288. <if test="businessAudit != null">
  1289. and a.business_audit = #{businessAudit,jdbcType=INTEGER}
  1290. </if>
  1291. <if test="isMember != null">
  1292. and a.is_member = #{isMember,jdbcType=INTEGER}
  1293. </if>
  1294. <if test="lvl != null">
  1295. and a.lvl = #{lvl,jdbcType=INTEGER}
  1296. </if>
  1297. <if test="currentMemberStatus != null">
  1298. and a.current_member_status = #{currentMemberStatus,jdbcType=INTEGER}
  1299. </if>
  1300. <if test="societyTag != null and societyTag != ''">
  1301. and a.society_tag = #{societyTag,jdbcType=VARCHAR}
  1302. </if>
  1303. <if test="startDate != null and startDate != ''">
  1304. and a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  1305. </if>
  1306. <if test="endDate != null and endDate != ''">
  1307. and a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  1308. </if>
  1309. <if test="province != null">
  1310. and b.province = #{province,jdbcType=INTEGER}
  1311. </if>
  1312. <if test="city != null">
  1313. and b.city = #{city,jdbcType=INTEGER}
  1314. </if>
  1315. <if test="area != null">
  1316. and b.area = #{area,jdbcType=INTEGER}
  1317. </if>
  1318. <if test="industry != null">
  1319. and b.industry = #{industry,jdbcType=INTEGER}
  1320. </if>
  1321. <if test="expert != null">
  1322. and b.expert = #{expert,jdbcType=INTEGER}
  1323. </if>
  1324. <if test="international != null">
  1325. and b.international = #{international,jdbcType=INTEGER}
  1326. </if>
  1327. <if test="auditStatus != null">
  1328. and b.audit_status = #{auditStatus,jdbcType=INTEGER}
  1329. </if>
  1330. <if test="page_sql != null">
  1331. ${page_sql}
  1332. </if>
  1333. </select>
  1334. <select id="selectManagePersonalCustomerCount" resultType="java.lang.Integer">
  1335. select count(0)
  1336. from user a inner join user_identity b on a.id = b.uid
  1337. left join admin d on a.aid = d.id
  1338. LEFT JOIN department dm on dm.id = d.department_id
  1339. where a.type = 0 and a.status != 1 and a.audit_status = 1
  1340. <if test="aid != null and aid !=''">
  1341. and (a.aid = #{aid,jdbcType=VARCHAR} or d.department_id=(select department_id from admin where id=#{aid,jdbcType=VARCHAR}))
  1342. </if>
  1343. <if test="name != null and name != ''">
  1344. and a.identify_name like concat('%',#{name},'%')
  1345. </if>
  1346. <if test="shareType != null">
  1347. and a.share_type = #{shareType,jdbcType=VARCHAR}
  1348. </if>
  1349. <if test="status != null">
  1350. and a.status = #{status,jdbcType=INTEGER}
  1351. </if>
  1352. <if test="businessAudit != null">
  1353. and a.business_audit = #{businessAudit,jdbcType=INTEGER}
  1354. </if>
  1355. <if test="isMember != null">
  1356. and a.is_member = #{isMember,jdbcType=INTEGER}
  1357. </if>
  1358. <if test="lvl != null">
  1359. and a.lvl = #{lvl,jdbcType=INTEGER}
  1360. </if>
  1361. <if test="currentMemberStatus != null">
  1362. and a.current_member_status = #{currentMemberStatus,jdbcType=INTEGER}
  1363. </if>
  1364. <if test="societyTag != null and societyTag != ''">
  1365. and a.society_tag = #{societyTag,jdbcType=VARCHAR}
  1366. </if>
  1367. <if test="startDate != null and startDate != ''">
  1368. and a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  1369. </if>
  1370. <if test="endDate != null and endDate != ''">
  1371. and a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  1372. </if>
  1373. <if test="province != null">
  1374. and b.province = #{province,jdbcType=INTEGER}
  1375. </if>
  1376. <if test="city != null">
  1377. and b.city = #{city,jdbcType=INTEGER}
  1378. </if>
  1379. <if test="area != null">
  1380. and b.area = #{area,jdbcType=INTEGER}
  1381. </if>
  1382. <if test="industry != null">
  1383. and b.industry = #{industry,jdbcType=INTEGER}
  1384. </if>
  1385. <if test="expert != null">
  1386. and b.expert = #{expert,jdbcType=INTEGER}
  1387. </if>
  1388. <if test="international != null">
  1389. and b.international = #{international,jdbcType=INTEGER}
  1390. </if>
  1391. <if test="auditStatus != null">
  1392. and b.audit_status = #{auditStatus,jdbcType=INTEGER}
  1393. </if>
  1394. </select>
  1395. <select id="selectManageOrganizationCustomerList" resultType="com.goafanti.customer.bo.CustomerListOut">
  1396. select
  1397. a.id as uid,
  1398. a.type,
  1399. a.status,
  1400. date_format(a.create_time,'%Y-%m-%d %H:%i:%s') as createTime,
  1401. a.identify_name as name,
  1402. a.society_tag as societyTag,
  1403. share_type as shareType,
  1404. b.contacts,
  1405. b.contact_mobile as contactMobile,
  1406. dg1.name as province,
  1407. dg2.name as city,
  1408. dg3.name as area,
  1409. c.name as industry,
  1410. d.name as adminName
  1411. from user a inner join organization_identity b on a.id = b.uid
  1412. left join district_glossory dg1 on b.location_province = dg1.id
  1413. left join district_glossory dg2 on b.location_city = dg2.id
  1414. left join district_glossory dg3 on b.location_area = dg3.id
  1415. left join industry_category c on b.industry = c.id
  1416. left join admin d on a.aid = d.id
  1417. LEFT JOIN department dm on dm.id = d.department_id
  1418. where a.type = 1 and a.status != 1 and a.audit_status = 1
  1419. <if test="aid != null and aid !=''">
  1420. and (a.aid = #{aid,jdbcType=VARCHAR} or d.department_id=(select department_id from admin where id=#{aid,jdbcType=VARCHAR}))
  1421. </if>
  1422. <if test="name != null and name != ''">
  1423. and a.identify_name like concat('%',#{name},'%')
  1424. </if>
  1425. <if test="shareType != null">
  1426. and a.share_type = #{shareType,jdbcType=VARCHAR}
  1427. </if>
  1428. <if test="status != null">
  1429. and a.status = #{status,jdbcType=INTEGER}
  1430. </if>
  1431. <if test="societyTag != null and societyTag != ''">
  1432. and a.society_tag = #{societyTag,jdbcType=VARCHAR}
  1433. </if>
  1434. <if test="startDate != null and startDate != ''">
  1435. and a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  1436. </if>
  1437. <if test="endDate != null and endDate != ''">
  1438. and a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  1439. </if>
  1440. <if test="province != null">
  1441. and b.location_province = #{province,jdbcType=INTEGER}
  1442. </if>
  1443. <if test="city != null">
  1444. and b.location_city = #{city,jdbcType=INTEGER}
  1445. </if>
  1446. <if test="area != null">
  1447. and b.location_area = #{area,jdbcType=INTEGER}
  1448. </if>
  1449. <if test="page_sql != null">
  1450. ${page_sql}
  1451. </if>
  1452. </select>
  1453. <select id="selectManageOrganizationCustomerCount" resultType="java.lang.Integer">
  1454. select
  1455. count(0)
  1456. from user a inner join organization_identity b on a.id = b.uid
  1457. left join admin d on a.aid = d.id
  1458. LEFT JOIN department dm on dm.id = d.department_id
  1459. where a.type = 1 and a.status != 1 and a.audit_status = 1
  1460. <if test="aid != null and aid !=''">
  1461. and (a.aid = #{aid,jdbcType=VARCHAR} or d.department_id=(select department_id from admin where id=#{aid,jdbcType=VARCHAR}))
  1462. </if>
  1463. <if test="name != null and name != ''">
  1464. and a.identify_name like concat('%',#{name},'%')
  1465. </if>
  1466. <if test="shareType != null">
  1467. and a.share_type = #{shareType,jdbcType=VARCHAR}
  1468. </if>
  1469. <if test="status != null">
  1470. and a.status = #{status,jdbcType=INTEGER}
  1471. </if>
  1472. <if test="societyTag != null and societyTag != ''">
  1473. and a.society_tag = #{societyTag,jdbcType=VARCHAR}
  1474. </if>
  1475. <if test="startDate != null and startDate != ''">
  1476. and a.create_time &gt; STR_TO_DATE(#{startDate},'%Y-%m-%d %H:%i:%s')
  1477. </if>
  1478. <if test="endDate != null and endDate != ''">
  1479. and a.create_time &lt; STR_TO_DATE(#{endDate},'%Y-%m-%d %H:%i:%s')
  1480. </if>
  1481. <if test="province != null">
  1482. and b.location_province = #{province,jdbcType=INTEGER}
  1483. </if>
  1484. <if test="city != null">
  1485. and b.location_city = #{city,jdbcType=INTEGER}
  1486. </if>
  1487. <if test="area != null">
  1488. and b.location_area = #{area,jdbcType=INTEGER}
  1489. </if>
  1490. </select>
  1491. <select id="findAdminName" resultType="com.goafanti.customer.bo.CustomerListOut">
  1492. select d.name as adminName,d.id as aid
  1493. from admin d left join department dm on dm.id = d.department_id
  1494. where d.department_id=(select department_id from admin where id=#{aid,jdbcType=INTEGER})
  1495. </select>
  1496. <select id="findEnteringAuditList" resultType="com.goafanti.customer.bo.CustomerListOut">
  1497. select u.id as uid,u.nickname as name,u.mobile as contactMobile,a.name as adminName,u.create_time as createTime,u.audit_status as auditStatus
  1498. from user u left join admin a on u.aid=a.id
  1499. where u.audit_status=0 and u.status != 1 and u.share_type=0
  1500. <if test="aid != null and aid !=''">
  1501. and u.aid = #{aid,jdbcType=VARCHAR}
  1502. </if>
  1503. <if test="name != null and name != ''">
  1504. and u.nickname = #{name,jdbcType=VARCHAR}
  1505. </if>
  1506. <if test="adminName != null and adminName != ''">
  1507. and a.name = #{adminName,jdbcType=VARCHAR}
  1508. </if>
  1509. <if test="page_sql != null">
  1510. ${page_sql}
  1511. </if>
  1512. </select>
  1513. <select id="findEnteringAuditCount" resultType="java.lang.Integer">
  1514. select
  1515. count(0)
  1516. from user u left join admin a on u.aid=a.id
  1517. where u.audit_status=0 and u.status != 1 and u.share_type=0
  1518. <if test="aid != null and aid !=''">
  1519. and u.aid = #{aid,jdbcType=VARCHAR}
  1520. </if>
  1521. <if test="name != null and name != ''">
  1522. and u.nickname = #{name,jdbcType=VARCHAR}
  1523. </if>
  1524. <if test="adminName != null and adminName != ''">
  1525. and a.name = #{adminName,jdbcType=VARCHAR}
  1526. </if>
  1527. </select>
  1528. <select id="findEnteringAuditIsNoList" resultType="com.goafanti.customer.bo.CustomerListOut">
  1529. select u.id as uid,u.nickname as name,u.mobile as contactMobile,a.name as adminName,u.create_time as createTime,
  1530. u.audit_status as auditStatus,u.audit_opinion as auditOpinion,u.society_tag as societyTag
  1531. from user u left join admin a on u.aid=a.id
  1532. where u.audit_status=2 and u.status != 1
  1533. <if test="aid != null and aid !=''">
  1534. and u.aid = #{aid,jdbcType=VARCHAR}
  1535. </if>
  1536. <if test="name != null and name != ''">
  1537. and u.nickname = #{name,jdbcType=VARCHAR}
  1538. </if>
  1539. <if test="adminName != null and adminName != ''">
  1540. and a.name = #{adminName,jdbcType=VARCHAR}
  1541. </if>
  1542. <if test="page_sql != null">
  1543. ${page_sql}
  1544. </if>
  1545. </select>
  1546. <select id="findEnteringAuditIsNoCount" resultType="java.lang.Integer">
  1547. select
  1548. count(0)
  1549. from user u left join admin a on u.aid=a.id
  1550. where u.audit_status=2 and u.status != 1
  1551. <if test="aid != null and aid !=''">
  1552. and u.aid = #{aid,jdbcType=VARCHAR}
  1553. </if>
  1554. <if test="name != null and name != ''">
  1555. and u.nickname = #{name,jdbcType=VARCHAR}
  1556. </if>
  1557. <if test="adminName != null and adminName != ''">
  1558. and a.name = #{adminName,jdbcType=VARCHAR}
  1559. </if>
  1560. </select>
  1561. <update id="updateRefusedCustomer" parameterType="map">
  1562. update user
  1563. set
  1564. nickname = #{nickname,jdbcType=VARCHAR},
  1565. mobile = #{mobile,jdbcType=VARCHAR},
  1566. society_tag = #{societyTag,jdbcType=VARCHAR},
  1567. audit_status=1
  1568. where id = #{id,jdbcType=VARCHAR}
  1569. </update>
  1570. <select id="selectLockedProject" resultType="com.goafanti.customer.bo.LockingReleaseBo">
  1571. select
  1572. a.id,
  1573. a.uid,
  1574. a.aid,
  1575. date_format( a.lock_time, '%Y-%m-%d %H:%i:%S' ) as lockTime,
  1576. a.business_project_id as businessProjectId,
  1577. b.bname as businessProjectName,
  1578. d.name as salesmanName
  1579. from
  1580. user_lock_release a left join business_project b on
  1581. a.business_project_id = b.id left join business_category c on
  1582. b.cid = c.id left join admin d on
  1583. a.aid = d.id
  1584. where 1 = 1
  1585. <if test="uid != null and uid != ''">
  1586. and a.uid = #{uid}
  1587. </if>
  1588. <if test="aid != null and aid != ''">
  1589. and a.aid = #{aid}
  1590. </if>
  1591. <if test="businessProjectId != null and businessProjectId != ''">
  1592. and a.business_project_id = #{businessProjectId}
  1593. </if>
  1594. <if test="type != null">
  1595. and a.type = #{type}
  1596. </if>
  1597. <if test="status != null">
  1598. and a.status = #{status}
  1599. </if>
  1600. </select>
  1601. <select id="selectPrivateCustomerByName" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.CustomerSimpleBo">
  1602. select b.id,b.identify_name as name from
  1603. (select uid from user_lock_release where type = 0 and status = 0 and aid = #{aid} group by uid) a
  1604. inner join user b on a.uid = b.id
  1605. where b.status != 1 and b.identify_name like concat('%',#{name},'%')
  1606. </select>
  1607. <select id="selectSignedCustomerByName" parameterType="java.lang.String" resultType="com.goafanti.customer.bo.CustomerSimpleBo">
  1608. select b.id,b.identify_name as name from user b
  1609. where b.status != 1 and b.share_type =2
  1610. and b.aid = #{aid} and b.identify_name like concat('%',#{name},'%')
  1611. </select>
  1612. <update id="updateReleaseLock" parameterType="java.lang.String">
  1613. update user a,user_lock_release b set a.share_type = 1,a.transfer_time = #{time} where b.status=1 and b.`type`=0 and a.id=b.uid
  1614. </update>
  1615. <select id="marketingStatistics" parameterType="java.lang.String" resultType="com.goafanti.report.bo.marketingESBo">
  1616. select
  1617. aid,
  1618. count(0) as yearFollowNo,
  1619. ifnull(sum(case when contact_type = 0 then 1 else 0 end) ,0)as yearVisitNo,
  1620. ifnull(sum(case when contact_type = 1 then 1 else 0 end) ,0)as yearTelNo
  1621. from user_follow where 1=1
  1622. and aid = #{id,jdbcType=VARCHAR}
  1623. and create_time &gt; #{dailyStart,jdbcType=VARCHAR}
  1624. and create_time &lt; #{dailyEnd,jdbcType=VARCHAR}
  1625. GROUP BY aid
  1626. </select>
  1627. <select id="marketingDepStatistics" parameterType="java.lang.String" resultType="com.goafanti.report.bo.marketingESBo">
  1628. select
  1629. b.department_id,
  1630. count( 0 ) as yearFollowNo,
  1631. ifnull(
  1632. sum( case when a.contact_type = 0 then 1 else 0 end ),
  1633. 0
  1634. ) as yearVisitNo,
  1635. ifnull(
  1636. sum( case when a.contact_type = 1 then 1 else 0 end ),
  1637. 0
  1638. ) as yearTelNo
  1639. from user_follow a left join admin b on a.aid =b.id
  1640. where
  1641. 1 = 1
  1642. <if test="depId !=null">
  1643. and b.department_id = #{depId,jdbcType=VARCHAR}
  1644. </if>
  1645. and a.create_time &gt; #{dailyStart,jdbcType=VARCHAR}
  1646. and a.create_time &lt; #{dailyEnd,jdbcType=VARCHAR}
  1647. GROUP BY b.department_id
  1648. </select>
  1649. <select id="countmarketingDepStatistics" parameterType="java.lang.String" resultType="com.goafanti.report.bo.CountMarketingStatisticsBo">
  1650. select
  1651. count( 0 ) as yearFollowNo,
  1652. ifnull(
  1653. sum( case when a.contact_type = 0 then 1 else 0 end ),
  1654. 0
  1655. ) as yearVisitNo,
  1656. ifnull(
  1657. sum( case when a.contact_type = 1 then 1 else 0 end ),
  1658. 0
  1659. ) as yearTelNo
  1660. from user_follow a left join admin b on a.aid =b.id
  1661. where
  1662. 1 = 1
  1663. <if test="depId !=null">
  1664. and b.department_id = #{depId,jdbcType=VARCHAR}
  1665. </if>
  1666. and a.create_time &gt; #{dailyStart,jdbcType=VARCHAR}
  1667. and a.create_time &lt; #{dailyEnd,jdbcType=VARCHAR}
  1668. </select>
  1669. <select id="selectCustomerInformationList" resultType="com.goafanti.customer.bo.CustomerListIn">
  1670. select a.id,a.nickname as name,c.name as province,c1.name as city,c2.name as area,b.contacts,b.contact_mobile as contactMobile,
  1671. date_format(a.create_time,'%Y-%m-%d %H:%i:%S') as createTime,d.name as industry,a.credit_rating as creditRating,a.integrity as dataGrade
  1672. from user a left join organization_identity b
  1673. on a.id=b.uid left join district_glossory c
  1674. on b.location_province=c.id left join district_glossory c1
  1675. on b.location_city=c1.id left join district_glossory c2
  1676. on b.location_area=c2.id left join industry_category d on b.industry = d.id
  1677. <if test="follow !=null and follow!=''">
  1678. left join (select aid,uid,contact_type from user_follow where aid= #{aid,jdbcType=VARCHAR} and contact_type=0 GROUP by uid) e on a.id=e.uid and a.aid=e.aid
  1679. </if>
  1680. where a.status=0
  1681. and a.information_maintainer = #{aid,jdbcType=VARCHAR}
  1682. <if test="type !=null and type!=''">
  1683. and a.`type`=#{type,jdbcType=VARCHAR}
  1684. </if>
  1685. <if test="follow ==0">
  1686. and (e.contact_type !=0 or e.contact_type is null)
  1687. </if>
  1688. <if test="follow ==1">
  1689. and e.contact_type=0
  1690. </if>
  1691. <if test="name!=null and name!=''">
  1692. and a.nickname like concat('%',#{name,jdbcType=VARCHAR},'%')
  1693. </if>
  1694. <if test="province!=null and province!=''">
  1695. and b.location_province= #{province,jdbcType=VARCHAR}
  1696. </if>
  1697. <if test="city!=null and city!=''">
  1698. and b.location_city=#{city,jdbcType=VARCHAR}
  1699. </if>
  1700. <if test="area !=null and area !=''">
  1701. and b.location_area= #{area,jdbcType=VARCHAR}
  1702. </if>
  1703. <if test="startDate != null and startDate != ''">
  1704. and a.create_time &gt; #{startDate}
  1705. </if>
  1706. <if test="endDate != null and endDate != ''">
  1707. and a.create_time &lt; #{endDate}
  1708. </if>
  1709. <if test="dataGrade ==0">
  1710. and a.integrity !=1
  1711. </if>
  1712. <if test="dataGrade ==1">
  1713. and a.integrity =1
  1714. </if>
  1715. order by a.create_time desc,a.nickname desc
  1716. <if test="page_sql != null">
  1717. ${page_sql}
  1718. </if>
  1719. </select>
  1720. <select id="selectCustomerInformationCount" resultType="java.lang.Integer">
  1721. select count(0)
  1722. from user a left join organization_identity b
  1723. on a.id=b.uid
  1724. <if test="follow !=null and follow!=''">
  1725. left join (select aid,uid,contact_type from user_follow where aid= #{aid,jdbcType=VARCHAR} and contact_type=0 GROUP by uid) e on a.id=e.uid and a.aid=e.aid
  1726. </if>
  1727. where a.status=0 and a.information_maintainer = #{aid,jdbcType=VARCHAR}
  1728. <if test="type !=null and type!=''">
  1729. and a.`type`=#{type,jdbcType=VARCHAR}
  1730. </if>
  1731. <if test="follow ==0">
  1732. and (e.contact_type !=0 or e.contact_type is null)
  1733. </if>
  1734. <if test="follow ==1">
  1735. and e.contact_type=0
  1736. </if>
  1737. <if test="name!=null and name!=''">
  1738. and a.nickname like concat('%',#{name,jdbcType=VARCHAR},'%')
  1739. </if>
  1740. <if test="province!=null and province!=''">
  1741. and b.location_province= #{province,jdbcType=VARCHAR}
  1742. </if>
  1743. <if test="city!=null and city!=''">
  1744. and b.location_city=#{city,jdbcType=VARCHAR}
  1745. </if>
  1746. <if test="area !=null and area !=''">
  1747. and b.location_area= #{area,jdbcType=VARCHAR}
  1748. </if>
  1749. <if test="startDate != null and startDate != ''">
  1750. and a.create_time &gt; #{startDate}
  1751. </if>
  1752. <if test="endDate != null and endDate != ''">
  1753. and a.create_time &lt; #{endDate}
  1754. </if>
  1755. <if test="dataGrade ==0">
  1756. and a.integrity !=1
  1757. </if>
  1758. <if test="dataGrade ==1">
  1759. and a.integrity =1
  1760. </if>
  1761. </select>
  1762. <select id="selectDepCustomerInformationList" resultType="com.goafanti.customer.bo.CustomerListIn">
  1763. select x.id,
  1764. x.name,
  1765. x.province,
  1766. x.city,
  1767. x.area ,
  1768. x.contacts,
  1769. x.contact_mobile as contactMobile,
  1770. date_format( x.create_time, '%Y-%m-%d %H:%i:%S' ) as createTime,
  1771. x.industry as industry,
  1772. y.name as iname,
  1773. x.integrity as dataGrade,
  1774. x.credit_rating as creditRating
  1775. from(
  1776. select
  1777. a.id,
  1778. a.nickname as name,
  1779. c.name as province,
  1780. c1.name as city,
  1781. c2.name as area,
  1782. b.contacts,
  1783. b.contact_mobile,
  1784. a.create_time,
  1785. d.name as industry,
  1786. a.credit_rating ,
  1787. a.information_maintainer,
  1788. a.integrity
  1789. from
  1790. user a left join organization_identity b on
  1791. a.id = b.uid left join district_glossory c
  1792. on b.location_province=c.id left join district_glossory c1
  1793. on b.location_city=c1.id left join district_glossory c2
  1794. on b.location_area=c2.id left join industry_category d
  1795. on b.industry = d.id
  1796. where a.status=0
  1797. <if test="type !=null and type!=''">
  1798. and a.`type`=#{type,jdbcType=VARCHAR}
  1799. </if>
  1800. <if test="name!=null and name!=''">
  1801. and a.nickname like concat('%',#{name,jdbcType=VARCHAR},'%')
  1802. </if>
  1803. <if test="province!=null and province!=''">
  1804. and b.location_province= #{province,jdbcType=VARCHAR}
  1805. </if>
  1806. <if test="city!=null and city!=''">
  1807. and b.location_city=#{city,jdbcType=VARCHAR}
  1808. </if>
  1809. <if test="area !=null and area !=''">
  1810. and b.location_area= #{area,jdbcType=VARCHAR}
  1811. </if>
  1812. <if test="startDate != null and startDate != ''">
  1813. and a.create_time &gt; #{startDate}
  1814. </if>
  1815. <if test="endDate != null and endDate != ''">
  1816. and a.create_time &lt; #{endDate}
  1817. </if>
  1818. <if test="dataGrade ==0">
  1819. and a.integrity !=1
  1820. </if>
  1821. <if test="dataGrade ==1">
  1822. and a.integrity =1
  1823. </if>
  1824. order by a.create_time,a.nickname desc
  1825. )x
  1826. inner join(
  1827. select id ,name from admin a
  1828. inner join (select department_id as depId from admin where id= #{aid,jdbcType=VARCHAR})b on a.department_id=b.depId
  1829. ) y on y.id = x.information_maintainer
  1830. <if test="page_sql != null">
  1831. ${page_sql}
  1832. </if>
  1833. </select>
  1834. <select id="selectDepCustomerInformationCount" resultType="java.lang.Integer">
  1835. select count(0)
  1836. from user a left join organization_identity b
  1837. on a.id=b.uid inner join (select id from admin a
  1838. inner join (select department_id as depId from admin where id= #{aid,jdbcType=VARCHAR} )b on a.department_id=b.depId) y
  1839. on y.id=a.information_maintainer
  1840. where 1=1 and a.status=0
  1841. <if test="type !=null and type!=''">
  1842. and a.`type`=#{type,jdbcType=VARCHAR}
  1843. </if>
  1844. <if test="name!=null and name!=''">
  1845. and a.nickname like concat('%',#{name,jdbcType=VARCHAR},'%')
  1846. </if>
  1847. <if test="province!=null and province!=''">
  1848. and b.location_province= #{province,jdbcType=VARCHAR}
  1849. </if>
  1850. <if test="city!=null and city!=''">
  1851. and b.location_city=#{city,jdbcType=VARCHAR}
  1852. </if>
  1853. <if test="area !=null and area !=''">
  1854. and b.location_area= #{area,jdbcType=VARCHAR}
  1855. </if>
  1856. <if test="startDate != null and startDate != ''">
  1857. and a.create_time &gt; #{startDate}
  1858. </if>
  1859. <if test="endDate != null and endDate != ''">
  1860. and a.create_time &lt; #{endDate}
  1861. </if>
  1862. <if test="dataGrade ==0">
  1863. and a.integrity !=1
  1864. </if>
  1865. <if test="dataGrade ==1">
  1866. and a.integrity =1
  1867. </if>
  1868. </select>
  1869. <select id="checkCustomerInformation" resultType="java.lang.Integer">
  1870. select count(a.id)
  1871. from user a left join organization_identity b
  1872. on a.id=b.uid
  1873. where b.industry is not null
  1874. and b.business_scope is not null
  1875. and b.registered_capital is not null and b.registered_capital !=0
  1876. and b.location_province is not null and b.location_province !=0
  1877. and b.cooperation_situation is not null and b.cooperation_situation !=''
  1878. and b.qualification is not null and b.qualification !=''
  1879. and b.assets is not null and b.assets !=''
  1880. and b.last_year_research_amount is not null and b.last_year_research_amount !=''
  1881. and b.year_sales_amount is not null and b.year_sales_amount !=''
  1882. and a.core_technology is not null and a.core_technology !=''
  1883. and a.accomplish_situation is not null and a.accomplish_situation !=''
  1884. and a.credit_rating is not null and a.credit_rating !=''
  1885. and a.id=#{uid,jdbcType=VARCHAR}
  1886. </select>
  1887. <select id="userDataStatistics" resultType="com.goafanti.report.bo.userDataListBo">
  1888. select a.name ,c.name as depName,ifnull(d.count,0) as signUser,ifnull(e.count,0) as fullUser,
  1889. ifnull(f.count,0) as dayFullUser,ifnull(g.count,0) as dayNewUser,ifnull(h.count,0) as countUser,
  1890. ifnull(i.count,0) as signFullUser
  1891. from admin a inner join (select uid from user_role x
  1892. inner join(select id from `role` where role_name in ('营销员','营销经理','营销管理员')) y
  1893. on x.rid=y.id)b on a.id =b.uid left join department c on a.department_id=c.id
  1894. left join (select x.aid,count(1)as count from (select aid,uid from user_lock_release
  1895. where type=1 and status=0 group by aid,uid)x group by aid)d on a.id=d.aid
  1896. left join (select aid,count(1) as count from user where integrity=1 and type=1 and status=0 and share_type=0 group by aid) e on a.id=e.aid
  1897. left join (select aid,count(1) as count
  1898. from user where integrity=1 and type=1 and status=0 and share_type=0 and to_days(update_time)=to_days(now()) group by aid) f on a.id=f.aid
  1899. left join (select aid,count(1) as count
  1900. from user where type=1 and status=0 and share_type=0 and to_days(create_time)=to_days(now()) group by aid) g on a.id=g.aid
  1901. left join (select aid,count(1) as count
  1902. from user where type=1 and status=0 and share_type=0 group by aid) h on a.id=h.aid
  1903. left join (select x.aid,count(1)as count from (select x1.aid,x1.uid from user_lock_release x1
  1904. left join user y on x1.uid=y.id where x1.type=1
  1905. and x1.status=0 and y.integrity=1 group by aid,uid)x group by aid) i on a.id=i.aid
  1906. where a.status='正常'
  1907. <if test="depId!=null and depId!=''">
  1908. and a.department_id= #{depId,jdbcType=VARCHAR}
  1909. </if>
  1910. </select>
  1911. <select id="userDataStatisticsCount" resultType="com.goafanti.report.bo.userDataListBo">
  1912. select sum(z.signUser) as signUser,sum(z.fullUser) as fullUser,sum(z.dayFullUser) as dayFullUser,
  1913. sum(z.dayNewUser) as dayNewUser,sum(z.countUser) as countUser,sum(z.signFullUser) as signFullUser from (select a.name ,c.name as depName,ifnull(d.count,0) as signUser,ifnull(e.count,0) as fullUser,
  1914. ifnull(f.count,0) as dayFullUser,ifnull(g.count,0) as dayNewUser,ifnull(h.count,0) as countUser,
  1915. ifnull(i.count,0) as signFullUser
  1916. from admin a inner join (select uid from user_role x
  1917. inner join(select id from `role` where role_name in ('营销员','营销经理','营销管理员')) y
  1918. on x.rid=y.id)b on a.id =b.uid left join department c on a.department_id=c.id
  1919. left join (select x.aid,count(1)as count from (select aid,uid from user_lock_release
  1920. where type=1 and status=0 group by aid,uid)x group by aid)d on a.id=d.aid
  1921. left join (select aid,count(1) as count from user where integrity=1 and type=1 and status=0 and share_type=0 group by aid) e on a.id=e.aid
  1922. left join (select aid,count(1) as count
  1923. from user where integrity=1 and type=1 and status=0 and share_type=0 and to_days(update_time)=to_days(now()) group by aid) f on a.id=f.aid
  1924. left join (select aid,count(1) as count
  1925. from user where type=1 and status=0 and share_type=0 and to_days(create_time)=to_days(now()) group by aid) g on a.id=g.aid
  1926. left join (select aid,count(1) as count
  1927. from user where type=1 and status=0 and share_type=0 group by aid) h on a.id=h.aid
  1928. left join (select x.aid,count(1)as count from (select x1.aid,x1.uid from user_lock_release x1
  1929. left join user y on x1.uid=y.id where x1.type=1
  1930. and x1.status=0 and y.integrity=1 group by aid,uid)x group by aid) i on a.id=i.aid
  1931. where a.status='正常'
  1932. <if test="depId!=null and depId!=''">
  1933. and a.department_id= #{depId,jdbcType=VARCHAR}
  1934. </if>
  1935. )z
  1936. </select>
  1937. <select id="UserReceiveCount" parameterType="string" resultType="integer">
  1938. select count(*) from `user`
  1939. where aid= #{aid,jdbcType=VARCHAR}
  1940. and source=2
  1941. and share_type=0
  1942. and to_days(transfer_time)=to_days(now())
  1943. </select>
  1944. <select id="privateUnitCustomerList" parameterType="Map" resultType="com.goafanti.customer.bo.CustomerListOut">
  1945. select t0.id as uid,
  1946. t0.aid,
  1947. date_format(t0.transfer_time,'%Y-%m-%d %H:%i:%S') as transferTime,
  1948. date_format(t0.create_time,'%Y-%m-%d %H:%i:%S') as createTime,
  1949. t0.identify_name as name,
  1950. t0.society_tag as societyTag,
  1951. t0.level,
  1952. date_format(t1.last_follow_time,'%Y-%m-%d %H:%i:%S') as lastFollowTime,
  1953. date_format(t2.last_sign_time,'%Y-%m-%d %H:%i:%S') as lastSignTime,
  1954. b.contacts,
  1955. b.contact_mobile as contactMobile,
  1956. dg1.name as province,
  1957. dg2.name as city,
  1958. dg3.name as area,
  1959. c.name as industry,
  1960. if(t0.transfer_time &lt; t1.last_follow_time,t1.last_follow_time,t0.transfer_time) as orderTime,
  1961. d.name as adminName
  1962. from
  1963. (select id,aid,type,share_type,transfer_time,create_time,identify_name,society_tag,level from user where aid = #{params.aid} and type = 1 and share_type = 0 and status != 1)t0
  1964. left join
  1965. (select uid,aid,max(create_time) as last_follow_time from user_follow where aid = #{params.aid} group by uid)t1
  1966. on t0.id = t1.uid left join
  1967. (select aid,uid,max(lock_time) as last_sign_time from user_lock_release where aid = #{params.aid} group by uid)t2
  1968. on t0.id = t2.uid
  1969. left join organization_identity b on t0.id = b.uid
  1970. left join district_glossory dg1 on b.location_province = dg1.id
  1971. left join district_glossory dg2 on b.location_city = dg2.id
  1972. left join district_glossory dg3 on b.location_area = dg3.id
  1973. left join industry_category c on b.industry = c.id
  1974. left join admin d on t0.aid = d.id where 1=1
  1975. <if test="params != null">
  1976. <if test="params.aid != null and params.aid !=''">
  1977. and t0.aid = #{params.aid,jdbcType=VARCHAR}
  1978. </if>
  1979. <if test="params.name != null and params.name != ''">
  1980. and t0.identify_name like concat('%',#{params.name},'%')
  1981. </if>
  1982. <if test="params.startDate != null and params.startDate != ''">
  1983. and t0.transfer_time &gt; #{params.startDate}
  1984. </if>
  1985. <if test="params.endDate != null and params.endDate != ''">
  1986. and t0.transfer_time &lt; #{params.endDate}
  1987. </if>
  1988. <if test="params.province != null">
  1989. and b.location_province = #{params.province,jdbcType=INTEGER}
  1990. </if>
  1991. <if test="params.city != null">
  1992. and b.location_city = #{params.city,jdbcType=INTEGER}
  1993. </if>
  1994. <if test="params.area != null">
  1995. and b.location_area = #{params.area,jdbcType=INTEGER}
  1996. </if>
  1997. <if test="params.level != null">
  1998. and t0.level = #{params.level,jdbcType=INTEGER}
  1999. </if>
  2000. </if>
  2001. order by orderTime
  2002. <if test="params!=null and params.sort == 1">
  2003. order by t0.create_time
  2004. </if>
  2005. <if test="params != null and params.sortType == 1">
  2006. desc
  2007. </if>
  2008. </select>
  2009. <select id="checkUserMax" parameterType="string" resultType="integer">
  2010. select count(*) from `user`
  2011. where aid= #{aid,jdbcType=VARCHAR}
  2012. and source in(1,2,3) and share_type=0
  2013. </select>
  2014. <select id="checkLock" parameterType="string" resultType="integer">
  2015. select count(*) from `user`
  2016. where id= #{uid,jdbcType=VARCHAR}
  2017. and share_type=2
  2018. </select>
  2019. <update id="updateShareType">
  2020. update user set share_type =2,aid = #{aid}
  2021. where id= #{uid}
  2022. </update>
  2023. </mapper>