NewCmShopMapper.xml 13 KB

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