NewCmShopMapper.xml 11 KB

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