NewCmShopMapper.xml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  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. a.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. ifnull(u.bindMobile,a.contractMobile) 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. a.shopType AS "shopType",
  60. a.cardNumber AS "cardNumber",
  61. a.chargeSupport AS "chargeSupport",
  62. d.name AS "province",c.name AS "city",b.name AS "town"
  63. </sql>
  64. <sql id="newCmShopJoins">
  65. LEFT JOIN user u ON u.userID = a.userID
  66. LEFT JOIN town b ON b.townID=a.townID
  67. LEFT JOIN city c ON c.cityID=b.cityID
  68. LEFT JOIN province d ON d.provinceID=c.provinceID
  69. </sql>
  70. <select id="get" resultType="NewCmShop">
  71. SELECT
  72. <include refid="newCmShopColumns"/>
  73. FROM shop a
  74. <include refid="newCmShopJoins"/>
  75. WHERE a.shopID = #{id}
  76. </select>
  77. <select id="getShopcert" resultType="com.caimei.modules.cibe.entity.ShopCert">
  78. SELECT *
  79. FROM shopcert s
  80. WHERE s.shopID = #{shopId}
  81. and s.shopCertTypeID = #{type}
  82. </select>
  83. <select id="findList" resultType="NewCmShop">
  84. SELECT
  85. <include refid="newCmShopColumns"/>
  86. FROM shop a
  87. <include refid="newCmShopJoins"/>
  88. <where>
  89. <if test="name != null and name != ''">
  90. AND a.name LIKE concat('%',#{name},'%')
  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 concat('%',#{linkMan},'%')
  100. </if>
  101. <if test="shopType !=null">
  102. AND a.shopType = #{shopType}
  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. <if test="shopID != null and shopID>0">
  117. AND a.shopID = #{shopID}
  118. </if>
  119. </where>
  120. <choose>
  121. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  122. ORDER BY ${page.orderBy}
  123. </when>
  124. <otherwise>
  125. ORDER BY case when a.status = 91 then 0 else 1 end desc, a.shopID DESC
  126. </otherwise>
  127. </choose>
  128. </select>
  129. <select id="findAllList" resultType="NewCmShop">
  130. SELECT
  131. <include refid="newCmShopColumns"/>
  132. FROM shop a
  133. <include refid="newCmShopJoins"/>
  134. <where>
  135. </where>
  136. <choose>
  137. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  138. ORDER BY ${page.orderBy}
  139. </when>
  140. <otherwise>
  141. </otherwise>
  142. </choose>
  143. </select>
  144. <select id="findSplitCode" resultType="com.caimei.modules.user.entity.SplitCode">
  145. select shopId, commercialCode as splitCode, codeDetail as codeRemark, email as email, weChatFlag
  146. from cm_shop_splitcode
  147. where shopId = #{shopID}
  148. </select>
  149. <insert id="saveShopcert" parameterType="com.caimei.modules.cibe.entity.ShopCert" keyProperty="shopCertID"
  150. useGeneratedKeys="true">
  151. INSERT INTO `shopcert` (`shopID`,
  152. `shopCertTypeID`,
  153. `name`,
  154. `image`,
  155. `organization`,
  156. `effectDate`,
  157. `loseEfficacyDate`)
  158. VALUES (#{shopID},
  159. #{shopCertTypeID},
  160. #{name},
  161. #{image},
  162. #{organization},
  163. #{effectDate},
  164. #{loseEfficacyDate})
  165. </insert>
  166. <insert id="insert" parameterType="NewCmShop" keyProperty="shopID" useGeneratedKeys="true">
  167. INSERT INTO shop(userID,
  168. name,
  169. sname,
  170. logo,
  171. legalPerson,
  172. businessLicense,
  173. businessLicenseImage,
  174. taxCertificate,
  175. taxCertificateImage,
  176. provinceID,
  177. cityID,
  178. townID,
  179. address,
  180. registeredCapital,
  181. nature,
  182. turnover,
  183. linkMan,
  184. contractPhone,
  185. contractMobile,
  186. contractEmail,
  187. fax,
  188. zipCode,
  189. info,
  190. productDesc,
  191. addTime,
  192. auditStatus,
  193. auditTime,
  194. auditNote,
  195. validFlag,
  196. status,
  197. maintenanceFee,
  198. maintenanceDate,
  199. businessScope,
  200. firstShopType,
  201. secondShopType,
  202. medicalPracticeLicenseImg1,
  203. medicalPracticeLicenseImg2,
  204. medicalPracticeLicenseImg3,
  205. mainpro,
  206. socialCreditCode,
  207. shopType)
  208. VALUES (#{userID},
  209. #{name},
  210. #{sname},
  211. #{logo},
  212. #{legalPerson},
  213. #{businessLicense},
  214. #{businessLicenseImage},
  215. #{taxCertificate},
  216. #{taxCertificateImage},
  217. #{provinceID},
  218. #{cityID},
  219. #{townID},
  220. #{address},
  221. #{registeredCapital},
  222. #{nature},
  223. #{turnover},
  224. #{linkMan},
  225. #{contractPhone},
  226. #{contractMobile},
  227. #{contractEmail},
  228. #{fax},
  229. #{zipCode},
  230. #{info},
  231. #{productDesc},
  232. #{addTime},
  233. #{auditStatus},
  234. #{auditTime},
  235. #{auditNote},
  236. #{validFlag},
  237. #{status},
  238. #{maintenanceFee},
  239. #{maintenanceDate},
  240. #{businessScope},
  241. #{firstShopType},
  242. #{secondShopType},
  243. #{medicalPracticeLicenseImg1},
  244. #{medicalPracticeLicenseImg2},
  245. #{medicalPracticeLicenseImg3},
  246. #{mainpro},
  247. #{socialCreditCode},
  248. #{shopType})
  249. </insert>
  250. <insert id="insertSplitCode">
  251. insert into cm_shop_splitcode
  252. (shopId, commercialCode, codeDetail, email, weChatFlag)
  253. values (#{shopId}, #{splitCode}, #{codeRemark}, #{email}, #{weChatFlag})
  254. </insert>
  255. <insert id="insertSepcial" parameterType="NewCmShop" keyProperty="shopID" useGeneratedKeys="true">
  256. insert into shop(name, linkMan, contractMobile, status, addTime, shopType)
  257. VALUES (#{name}, #{linkMan}, #{contractMobile}, #{status}, now(), 2)
  258. </insert>
  259. <update id="update">
  260. UPDATE shop
  261. <set>
  262. <if test="name != null and name != ''">
  263. name = #{name},
  264. </if>
  265. website = #{website},
  266. wxOfficialAccount = #{wxOfficialAccount},
  267. wxApplets = #{wxApplets},
  268. <if test="chargeSupport != null">
  269. chargeSupport=#{chargeSupport},
  270. </if>
  271. <if test="sname != null and sname != ''">
  272. sname = #{sname},
  273. </if>
  274. <if test="logo != null and logo != ''">
  275. logo = #{logo},
  276. </if>
  277. <if test="legalPerson != null and legalPerson != ''">
  278. legalPerson = #{legalPerson},
  279. </if>
  280. <if test="businessLicense != null and businessLicense != ''">
  281. businessLicense = #{businessLicense},
  282. </if>
  283. <if test="businessLicenseImage != null and businessLicenseImage != ''">
  284. businessLicenseImage = #{businessLicenseImage},
  285. </if>
  286. <if test="taxCertificate != null and taxCertificate != ''">
  287. taxCertificate = #{taxCertificate},
  288. </if>
  289. <if test="taxCertificateImage != null and taxCertificateImage != ''">
  290. taxCertificateImage = #{taxCertificateImage},
  291. </if>
  292. <if test="address != null and address != ''">
  293. address = #{address},
  294. </if>
  295. <if test="registeredCapital != null and registeredCapital != ''">
  296. registeredCapital = #{registeredCapital},
  297. </if>
  298. <if test="nature != null and nature != ''">
  299. nature = #{nature},
  300. </if>
  301. <if test="turnover != null and turnover != ''">
  302. turnover = #{turnover},
  303. </if>
  304. <if test="linkMan != null and linkMan != ''">
  305. linkMan = #{linkMan},
  306. </if>
  307. <if test="contractPhone != null and contractPhone != ''">
  308. contractPhone = #{contractPhone},
  309. </if>
  310. <if test="contractMobile != null and contractMobile != ''">
  311. contractMobile = #{contractMobile},
  312. </if>
  313. <if test="contractEmail != null and contractEmail != ''">
  314. contractEmail = #{contractEmail},
  315. </if>
  316. <if test="fax != null and fax != ''">
  317. fax = #{fax},
  318. </if>
  319. <if test="zipCode != null and zipCode != ''">
  320. zipCode = #{zipCode},
  321. </if>
  322. <if test="info != null and info != ''">
  323. info = #{info},
  324. </if>
  325. <if test="productDesc != null and productDesc != ''">
  326. productDesc = #{productDesc},
  327. </if>
  328. <if test="status != null and status != ''">
  329. status = #{status},
  330. </if>
  331. <if test="provinceID != null and provinceID != ''">
  332. provinceID = #{provinceID},
  333. </if>
  334. <if test="cityID != null and cityID != ''">
  335. cityID = #{cityID},
  336. </if>
  337. <if test="townID != null and townID != ''">
  338. townID = #{townID},
  339. </if>
  340. <if test="maintenanceFee != null and maintenanceFee != ''">
  341. maintenanceFee = #{maintenanceFee},
  342. </if>
  343. <if test="maintenanceDate != null and maintenanceDate != ''">
  344. maintenanceDate = #{maintenanceDate},
  345. </if>
  346. <if test="businessScope != null and businessScope != ''">
  347. businessScope = #{businessScope},
  348. </if>
  349. <if test="firstShopType != null and firstShopType != ''">
  350. firstShopType=#{firstShopType},
  351. </if>
  352. <if test="secondShopType != null and secondShopType != ''">
  353. secondShopType=#{secondShopType},
  354. </if>
  355. <if test="medicalPracticeLicenseImg1 != null and medicalPracticeLicenseImg1 != ''">
  356. medicalPracticeLicenseImg1=#{medicalPracticeLicenseImg1},
  357. </if>
  358. <if test="medicalPracticeLicenseImg2 != null and medicalPracticeLicenseImg2 != ''">
  359. medicalPracticeLicenseImg2=#{medicalPracticeLicenseImg2},
  360. </if>
  361. <if test="medicalPracticeLicenseImg3 != null and medicalPracticeLicenseImg3 != ''">
  362. medicalPracticeLicenseImg3=#{medicalPracticeLicenseImg3},
  363. </if>
  364. <if test="mainpro != null and mainpro != ''">
  365. mainpro=#{mainpro},
  366. </if>
  367. <if test="ableRebateAmount != null">
  368. ableRebateAmount=#{ableRebateAmount},
  369. </if>
  370. <if test="rebateAmount != null">
  371. rebateAmount=#{rebateAmount},
  372. </if>
  373. <if test="bankAccount != null">
  374. bankAccount=#{bankAccount},
  375. </if>
  376. <if test="bankAccountName != null">
  377. bankAccountName=#{bankAccountName},
  378. </if>
  379. <if test="bankName != null">
  380. bankName=#{bankName},
  381. </if>
  382. <if test="socialCreditCode != null">
  383. socialCreditCode = #{socialCreditCode}
  384. </if>
  385. </set>
  386. WHERE shopID = #{shopID}
  387. </update>
  388. <delete id="delete">
  389. DELETE
  390. FROM shop
  391. WHERE shopID = #{id}
  392. </delete>
  393. <delete id="deleteCert">
  394. DELETE
  395. FROM shopcert
  396. WHERE shopID = #{shopID}
  397. </delete>
  398. <delete id="deleteSplitCode">
  399. delete
  400. from cm_shop_splitcode
  401. where shopId = #{shopID}
  402. </delete>
  403. <update id="updateAbleRebateAmount" parameterType="NewCmShop">
  404. update shop
  405. set ableRebateAmount = #{ableRebateAmount}
  406. where shopID = #{shopID}
  407. </update>
  408. <update id="backAbleRebateAmount" parameterType="NewCmShop">
  409. update shop
  410. set ableRebateAmount = (ableRebateAmount + #{balancePayFee})
  411. where shopID = #{shopID}
  412. </update>
  413. <update id="updateRebateAmount">
  414. update shop
  415. set rebateAmount = (rebateAmount - #{balancePayFee})
  416. where shopID = #{shopID}
  417. </update>
  418. <update id="offline">
  419. update shop
  420. set status = 91
  421. where shopID = #{shopID}
  422. </update>
  423. <update id="online">
  424. update shop
  425. set status = 90
  426. where shopID = #{shopID}
  427. </update>
  428. <select id="maintenanceList" resultType="CmDiscernReceipt">
  429. SELECT
  430. c.validityDate as validityDate, c.dateStrings as expirationDate,a.id as
  431. receiptID,a.shopID,a.receiptAmount,a.receiptDate,a.receStatct,s.linkMan
  432. FROM cm_discern_receipt a
  433. LEFT JOIN shop s ON s.shopID = a.shopID
  434. LEFT JOIN cm_receipt c ON c.receiptID = a.id
  435. <where>
  436. AND a.shopID=#{shopID}
  437. AND a.newReceiptType=1
  438. <if test="startTime != null and startTime != ''">
  439. AND (a.receiptDate &gt; #{startTime} OR a.receiptDate = #{startTime})
  440. </if>
  441. <if test="endTime != null and endTime != ''">
  442. AND (a.receiptDate &lt; #{endTime} OR a.receiptDate = #{endTime})
  443. </if>
  444. and a.receiptDate is not null
  445. ORDER BY a.receiptDate DESC
  446. </where>
  447. <choose>
  448. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  449. ORDER BY ${page.orderBy}
  450. </when>
  451. </choose>
  452. </select>
  453. <insert id="Removethelastfee">
  454. insert into cm_discern_receipt
  455. (shopID, receStatct, receiptDate, delFlag, newReceiptType)
  456. values (#{shopID}, #{receStatct}, #{receiptDate}, 1, 1)
  457. </insert>
  458. <select id="therectip" resultType="Integer">
  459. SELECT id
  460. FROM cm_discern_receipt
  461. WHERE receStatct = 2
  462. ORDER BY id DESC
  463. LIMIT 1
  464. </select>
  465. <update id="Removethelast">
  466. update cm_discern_receipt
  467. set newReceiptType=1,
  468. receStatct = 1
  469. where id = #{receiptID}
  470. </update>
  471. <insert id="addthelast" keyColumn="id" keyProperty="receiptID" useGeneratedKeys="true">
  472. insert cm_discern_receipt
  473. (receiptDate, confirmDate, reviewDate, updateDate, newReceiptType,
  474. receStatct, delFlag, shopID)
  475. value (now(), now(), now(), now(), 1, 2, 1, #{shopID})
  476. </insert>
  477. <insert id="cmreceipt">
  478. insert into cm_receipt
  479. (validityDate, dateStrings, receiptID)
  480. values (#{validityDate}, #{expirationDate}, #{receiptID})
  481. </insert>
  482. <select id="cmrectiptlist" resultType="com.caimei.modules.order.entity.CmDiscernReceipt">
  483. SELECT r.receiptID as receiptID,
  484. r.dateStrings as expirationDate,
  485. r.validityDate as validityDate,
  486. c.receStatct AS receStatct
  487. FROM cm_receipt r
  488. LEFT JOIN cm_discern_receipt c ON c.id = r.receiptID
  489. LEFT JOIN shop s ON s.shopID = c.shopID
  490. WHERE c.shopID = #{shopID}
  491. AND c.newReceiptType = 1
  492. ORDER BY r.id DESC
  493. LIMIT 1
  494. </select>
  495. <select id="cmrectCount" resultType="java.lang.Integer">
  496. SELECT count(*)
  497. FROM cm_receipt r
  498. LEFT JOIN cm_discern_receipt c ON c.id = r.receiptID
  499. LEFT JOIN shop s ON s.shopID = c.shopID
  500. WHERE c.shopID = #{shopID}
  501. AND c.newReceiptType = 1
  502. ORDER BY r.id DESC
  503. LIMIT 1
  504. </select>
  505. </mapper>