NewCmShopMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  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.caimei.modules.user.dao.NewCmShopDao">
  4. <sql id="newCmShopColumns">
  5. a.shopID AS "shopID",
  6. a.checkMan as "checkMan",
  7. a.userID AS "userID",
  8. u.name AS "name",
  9. u.userName AS "sname",
  10. a.logo AS "logo",
  11. a.legalPerson AS "legalPerson",
  12. a.businessLicense AS "businessLicense",
  13. a.businessLicenseImage AS "businessLicenseImage",
  14. a.taxCertificate AS "taxCertificate",
  15. a.taxCertificateImage AS "taxCertificateImage",
  16. a.townID AS "townID",
  17. d.provinceID AS "provinceID",
  18. c.cityID AS "cityID",
  19. a.address AS "address",
  20. a.registeredCapital AS "registeredCapital",
  21. a.nature AS "nature",
  22. a.turnover AS "turnover",
  23. a.linkMan AS "linkMan",
  24. a.contractPhone AS "contractPhone",
  25. u.bindMobile AS "contractMobile",
  26. a.contractEmail AS "contractEmail",
  27. a.fax AS "fax",
  28. a.zipCode AS "zipCode",
  29. a.info AS "info",
  30. a.productDesc AS "productDesc",
  31. a.website,
  32. a.wxOfficialAccount,
  33. a.wxApplets,
  34. a.addTime AS "addTime",
  35. a.auditStatus AS "auditStatus",
  36. a.auditTime AS "auditTime",
  37. a.auditNote AS "auditNote",
  38. a.validFlag AS "validFlag",
  39. a.status AS "status",
  40. a.maintenanceFee AS "maintenanceFee",
  41. a.maintenanceDate AS "maintenanceDate",
  42. a.businessScope AS "businessScope",
  43. u.account AS "account",
  44. u.registerTime AS "registerTime",
  45. a.firstShopType AS "firstShopType",
  46. a.secondShopType AS "secondShopType",
  47. a.medicalPracticeLicenseImg1 AS "medicalPracticeLicenseImg1",
  48. a.medicalPracticeLicenseImg2 AS "medicalPracticeLicenseImg2",
  49. a.medicalPracticeLicenseImg3 AS "medicalPracticeLicenseImg3",
  50. a.mainpro AS "mainpro",
  51. a.bankAccount AS "bankAccount",
  52. a.ableRebateAmount AS "ableRebateAmount",
  53. a.rebateAmount AS "rebateAmount",
  54. a.bankAccountName AS "bankAccountName",
  55. a.bankName AS "bankName",
  56. a.socialCreditCode AS "socialCreditCode",
  57. u.email,
  58. u.source AS "source",
  59. d.name AS "province",c.name AS "city",b.name AS "town"
  60. </sql>
  61. <sql id="newCmShopJoins">
  62. LEFT JOIN user u ON u.userID = a.userID
  63. LEFT JOIN town b ON b.townID=a.townID
  64. LEFT JOIN city c ON c.cityID=b.cityID
  65. LEFT JOIN province d ON d.provinceID=c.provinceID
  66. </sql>
  67. <select id="get" resultType="NewCmShop">
  68. SELECT
  69. <include refid="newCmShopColumns"/>
  70. FROM shop a
  71. <include refid="newCmShopJoins"/>
  72. WHERE a.shopID = #{id}
  73. </select>
  74. <select id="getShopcert" resultType="com.caimei.modules.cibe.entity.ShopCert">
  75. SELECT
  76. *
  77. FROM shopcert s
  78. WHERE s.shopID = #{shopId}
  79. and s.shopCertTypeID = #{type}
  80. </select>
  81. <select id="findList" resultType="NewCmShop">
  82. SELECT
  83. <include refid="newCmShopColumns"/>
  84. FROM shop a
  85. <include refid="newCmShopJoins"/>
  86. <where>
  87. <if test="name != null and name != ''">
  88. AND a.name LIKE
  89. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  90. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  91. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  92. </if>
  93. <if test="status != null and status != ''">
  94. AND a.status = #{status}
  95. </if>
  96. <if test="contractMobile != null and contractMobile != ''">
  97. AND a.contractMobile = #{contractMobile}
  98. </if>
  99. <if test="linkMan != null and linkMan != ''">
  100. AND a.linkMan LIKE
  101. <if test="dbName == 'oracle'">'%'||#{linkMan}||'%'</if>
  102. <if test="dbName == 'mssql'">'%'+#{linkMan}+'%'</if>
  103. <if test="dbName == 'mysql'">concat('%',#{linkMan},'%')</if>
  104. </if>
  105. <if test="startTime != null and startTime != ''">
  106. AND (u.registerTime &gt; #{startTime} OR u.registerTime = #{startTime})
  107. </if>
  108. <if test="endTime != null and endTime != ''">
  109. AND (u.registerTime &lt; #{endTime} OR u.registerTime = #{endTime})
  110. </if>
  111. <if test="email != null and email != ''">
  112. AND u.email = #{email}
  113. </if>
  114. <if test="source != null and source != ''">
  115. AND u.source = #{source}
  116. </if>
  117. </where>
  118. <choose>
  119. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  120. ORDER BY ${page.orderBy}
  121. </when>
  122. <otherwise>
  123. ORDER BY case when a.status = 91 then 0 else 1 end desc, a.shopID DESC
  124. </otherwise>
  125. </choose>
  126. </select>
  127. <select id="findAllList" resultType="NewCmShop">
  128. SELECT
  129. <include refid="newCmShopColumns"/>
  130. FROM shop a
  131. <include refid="newCmShopJoins"/>
  132. <where>
  133. </where>
  134. <choose>
  135. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  136. ORDER BY ${page.orderBy}
  137. </when>
  138. <otherwise>
  139. </otherwise>
  140. </choose>
  141. </select>
  142. <select id="findSplitCode" resultType="com.caimei.modules.user.entity.SplitCode">
  143. select shopId,commercialCode as splitCode,codeDetail as codeRemark
  144. from cm_shop_splitcode
  145. where shopId = #{shopID}
  146. </select>
  147. <insert id="saveShopcert" parameterType="com.caimei.modules.cibe.entity.ShopCert" keyProperty="shopCertID" useGeneratedKeys="true">
  148. INSERT INTO `shopcert` (
  149. `shopID`,
  150. `shopCertTypeID`,
  151. `name`,
  152. `image`,
  153. `organization`,
  154. `effectDate`,
  155. `loseEfficacyDate`
  156. )
  157. VALUES(
  158. #{shopID},
  159. #{shopCertTypeID},
  160. #{name},
  161. #{image},
  162. #{organization},
  163. #{effectDate},
  164. #{loseEfficacyDate}
  165. )
  166. </insert>
  167. <insert id="insert" parameterType="NewCmShop" keyProperty="id" useGeneratedKeys="true">
  168. INSERT INTO shop(
  169. userID,
  170. name,
  171. sname,
  172. logo,
  173. legalPerson,
  174. businessLicense,
  175. businessLicenseImage,
  176. taxCertificate,
  177. taxCertificateImage,
  178. provinceID,
  179. cityID,
  180. townID,
  181. address,
  182. registeredCapital,
  183. nature,
  184. turnover,
  185. linkMan,
  186. contractPhone,
  187. contractMobile,
  188. contractEmail,
  189. fax,
  190. zipCode,
  191. info,
  192. productDesc,
  193. addTime,
  194. auditStatus,
  195. auditTime,
  196. auditNote,
  197. validFlag,
  198. status,
  199. maintenanceFee,
  200. maintenanceDate,
  201. businessScope,
  202. firstShopType,
  203. secondShopType,
  204. medicalPracticeLicenseImg1,
  205. medicalPracticeLicenseImg2,
  206. medicalPracticeLicenseImg3,
  207. mainpro,
  208. socialCreditCode
  209. ) VALUES (
  210. #{userID},
  211. #{name},
  212. #{sname},
  213. #{logo},
  214. #{legalPerson},
  215. #{businessLicense},
  216. #{businessLicenseImage},
  217. #{taxCertificate},
  218. #{taxCertificateImage},
  219. #{provinceID},
  220. #{cityID},
  221. #{townID},
  222. #{address},
  223. #{registeredCapital},
  224. #{nature},
  225. #{turnover},
  226. #{linkMan},
  227. #{contractPhone},
  228. #{contractMobile},
  229. #{contractEmail},
  230. #{fax},
  231. #{zipCode},
  232. #{info},
  233. #{productDesc},
  234. #{addTime},
  235. #{auditStatus},
  236. #{auditTime},
  237. #{auditNote},
  238. #{validFlag},
  239. #{status},
  240. #{maintenanceFee},
  241. #{maintenanceDate},
  242. #{businessScope},
  243. #{firstShopType},
  244. #{secondShopType},
  245. #{medicalPracticeLicenseImg1},
  246. #{medicalPracticeLicenseImg2},
  247. #{medicalPracticeLicenseImg3},
  248. #{mainpro},
  249. #{socialCreditCode}
  250. )
  251. </insert>
  252. <insert id="insertSplitCode">
  253. insert into cm_shop_splitcode
  254. (shopId, commercialCode, codeDetail)
  255. values (#{shopId},#{splitCode},#{codeRemark})
  256. </insert>
  257. <update id="update">
  258. UPDATE shop
  259. <set>
  260. name = #{name},
  261. website = #{website},
  262. wxOfficialAccount = #{wxOfficialAccount},
  263. wxApplets = #{wxApplets},
  264. <if test="sname != null and sname != ''" >
  265. sname = #{sname},
  266. </if>
  267. <if test="logo != null and logo != ''" >
  268. logo = #{logo},
  269. </if>
  270. <if test="legalPerson != null and legalPerson != ''" >
  271. legalPerson = #{legalPerson},
  272. </if>
  273. <if test="businessLicense != null and businessLicense != ''" >
  274. businessLicense = #{businessLicense},
  275. </if>
  276. <if test="businessLicenseImage != null and businessLicenseImage != ''" >
  277. businessLicenseImage = #{businessLicenseImage},
  278. </if>
  279. <if test="taxCertificate != null and taxCertificate != ''" >
  280. taxCertificate = #{taxCertificate},
  281. </if>
  282. <if test="taxCertificateImage != null and taxCertificateImage != ''" >
  283. taxCertificateImage = #{taxCertificateImage},
  284. </if>
  285. <if test="address != null and address != ''" >
  286. address = #{address},
  287. </if>
  288. <if test="registeredCapital != null and registeredCapital != ''" >
  289. registeredCapital = #{registeredCapital},
  290. </if>
  291. <if test="nature != null and nature != ''" >
  292. nature = #{nature},
  293. </if>
  294. <if test="turnover != null and turnover != ''" >
  295. turnover = #{turnover},
  296. </if>
  297. <if test="linkMan != null and linkMan != ''" >
  298. linkMan = #{linkMan},
  299. </if>
  300. <if test="contractPhone != null and contractPhone != ''" >
  301. contractPhone = #{contractPhone},
  302. </if>
  303. <if test="contractMobile != null and contractMobile != ''" >
  304. contractMobile = #{contractMobile},
  305. </if>
  306. <if test="contractEmail != null and contractEmail != ''" >
  307. contractEmail = #{contractEmail},
  308. </if>
  309. <if test="fax != null and fax != ''" >
  310. fax = #{fax},
  311. </if>
  312. <if test="zipCode != null and zipCode != ''" >
  313. zipCode = #{zipCode},
  314. </if>
  315. <if test="info != null and info != ''" >
  316. info = #{info},
  317. </if>
  318. <if test="productDesc != null and productDesc != ''" >
  319. productDesc = #{productDesc},
  320. </if>
  321. <if test="status != null and status != ''" >
  322. status = #{status},
  323. </if>
  324. <if test="provinceID != null and provinceID != ''" >
  325. provinceID = #{provinceID},
  326. </if>
  327. <if test="cityID != null and cityID != ''" >
  328. cityID = #{cityID},
  329. </if>
  330. <if test="townID != null and townID != ''" >
  331. townID = #{townID},
  332. </if>
  333. <if test="maintenanceFee != null and maintenanceFee != ''" >
  334. maintenanceFee = #{maintenanceFee},
  335. </if>
  336. <if test="maintenanceDate != null and maintenanceDate != ''" >
  337. maintenanceDate = #{maintenanceDate},
  338. </if>
  339. <if test="businessScope != null and businessScope != ''" >
  340. businessScope = #{businessScope},
  341. </if>
  342. <if test="firstShopType != null and firstShopType != ''" >
  343. firstShopType=#{firstShopType},
  344. </if>
  345. <if test="secondShopType != null and secondShopType != ''" >
  346. secondShopType=#{secondShopType},
  347. </if>
  348. <if test="medicalPracticeLicenseImg1 != null and medicalPracticeLicenseImg1 != ''" >
  349. medicalPracticeLicenseImg1=#{medicalPracticeLicenseImg1},
  350. </if>
  351. <if test="medicalPracticeLicenseImg2 != null and medicalPracticeLicenseImg2 != ''" >
  352. medicalPracticeLicenseImg2=#{medicalPracticeLicenseImg2},
  353. </if>
  354. <if test="medicalPracticeLicenseImg3 != null and medicalPracticeLicenseImg3 != ''" >
  355. medicalPracticeLicenseImg3=#{medicalPracticeLicenseImg3},
  356. </if>
  357. <if test="mainpro != null and mainpro != ''">
  358. mainpro=#{mainpro},
  359. </if>
  360. <if test="ableRebateAmount != null">
  361. ableRebateAmount=#{ableRebateAmount},
  362. </if>
  363. <if test="rebateAmount != null">
  364. rebateAmount=#{rebateAmount},
  365. </if>
  366. <if test="bankAccount != null">
  367. bankAccount=#{bankAccount},
  368. </if>
  369. <if test="bankAccountName != null">
  370. bankAccountName=#{bankAccountName},
  371. </if>
  372. <if test="bankName != null">
  373. bankName=#{bankName},
  374. </if>
  375. <if test="socialCreditCode != null">
  376. socialCreditCode = #{socialCreditCode}
  377. </if>
  378. </set>
  379. WHERE shopID = #{shopID}
  380. </update>
  381. <delete id="delete">
  382. DELETE FROM shop
  383. WHERE shopID = #{id}
  384. </delete>
  385. <delete id="deleteCert">
  386. DELETE FROM shopcert
  387. WHERE shopID = #{shopID}
  388. </delete>
  389. <delete id="deleteSplitCode">
  390. delete from cm_shop_splitcode
  391. where shopId = #{shopID}
  392. </delete>
  393. <update id="updateAbleRebateAmount" parameterType="NewCmShop">
  394. update shop set ableRebateAmount = #{ableRebateAmount} where shopID = #{shopID}
  395. </update>
  396. <update id="backAbleRebateAmount" parameterType="NewCmShop">
  397. update shop set ableRebateAmount = (ableRebateAmount + #{balancePayFee}) where shopID = #{shopID}
  398. </update>
  399. <update id="updateRebateAmount">
  400. update shop set rebateAmount = (rebateAmount - #{balancePayFee})
  401. where shopID = #{shopID}
  402. </update>
  403. </mapper>