ClientDao.dql 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. -- [queryClientIndustry]
  2. select * from $table$;
  3. -- [addClientIndustry]
  4. insert into $table$ (id, industryCode, industryName, enable,
  5. createBy, createTime,
  6. updateBy, updateTime ) values ( #{id}, #{industrycode}, #{industryname}, #{enable},
  7. #{createby}, #{createtime},
  8. #{updateby}, #{updatetime} );
  9. -- [updateClientIndustry]
  10. update $table$ set industryCode = #{industrycode},industryName = #{industryname},
  11. updateBy = #{updateby},updateTime = #{updatetime} where id = #{id};
  12. -- [enableClientIndustry]
  13. update $table$ set enable = #{enable},updateBy = #{updateby},updateTime = #{updatetime} where id = #{id};
  14. -- [queryClientInfo]
  15. select * from $table$;
  16. -- [addClientInfo]
  17. insert into $table$ (
  18. id, idIndustry, industryName, clientName,
  19. contactMan, contactPhone, clientCode,
  20. province, city, area,
  21. address, clientFrom, overdraftQuota,
  22. idLevel, levelName, idSalesManBelong, salesManNameBelong,
  23. enable, createBy, createTime,
  24. updateBy, updateTime,
  25. invoiceHead,taxRegisterCode,baseBankName,
  26. baseBankNumber,registerAddress,registerPhone,
  27. signKey,dutyMan,againstFlag)
  28. values ( #{id}, #{idindustry}, #{industryname}, #{clientname},
  29. #{contactman}, #{contactphone}, #{clientcode},
  30. #{province}, #{city}, #{area},
  31. #{address}, #{clientfrom}, #{overdraftquota},
  32. #{idlevel}, #{levelname}, #{idsalesmanbelong}, #{salesmannamebelong},
  33. #{enable}, #{createby}, #{createtime},
  34. #{updateby}, #{updatetime},
  35. #{invoicehead},#{taxregistercode},#{basebankname},
  36. #{basebanknumber}, #{registeraddress}, #{registerphone},
  37. #{signkey},#{dutyman},#{againstflag});
  38. -- [updateClientInfo]
  39. update $table$ set
  40. idIndustry = #{idindustry},
  41. industryName = #{industryname},
  42. clientName = #{clientname},
  43. contactMan = #{contactman},
  44. contactPhone = #{contactphone},
  45. province = #{province},
  46. city = #{city},
  47. area = #{area},
  48. address = #{address},
  49. clientFrom = #{clientfrom},
  50. overdraftQuota = #{overdraftquota},
  51. idLevel = #{idlevel},
  52. levelName = #{levelname},
  53. idSalesManBelong = #{idsalesmanbelong},
  54. salesManNameBelong = #{salesmannamebelong},
  55. updateBy = #{updateby},
  56. updateTime = #{updatetime},
  57. invoiceHead = #{invoicehead},
  58. taxRegisterCode=#{taxregistercode},
  59. baseBankName=#{basebankname},
  60. baseBankNumber = #{basebanknumber},
  61. registerAddress= #{registeraddress},
  62. registerPhone=#{registerphone},
  63. signKey = #{signkey},
  64. dutyMan = #{dutyman},
  65. againstFlag = #{againstflag}
  66. where id = #{id};
  67. -- [enableClientInfo]
  68. update $table$ set enable = #{enable},
  69. updateBy = #{updateby},updateTime = #{updatetime}
  70. where id = #{id};
  71. -- [queryClientByBalance]
  72. select round(a.balanceNum / 100.0, 2) as balance_money, b.id, b.clientCode, b.clientName
  73. from $table1$ a
  74. left join $table2$ b on a.idClient = b.id
  75. -- trim prefix=WHERE prefixOverrides=AND|OR
  76. -- if filterZeroBalance > 0
  77. a.balanceNum > 0
  78. -- end
  79. -- isNotEmpty keyWord
  80. and b.clientName LIKE #{Like:keyWord}
  81. -- end
  82. -- end
  83. -- isEmpty orderBy
  84. order by b.createTime desc
  85. -- else
  86. order by #{orderBy}
  87. -- end
  88. ;
  89. -- [sumAllClientBalance]
  90. select 0 as idClient,sum(balanceNum) as balanceNum from $table1$ a left join $table2$ b on a.idClient = b.id where b.enable = 1;
  91. -- [queryClientByBalanceVersion2]
  92. select round(b.balanceNum / 100.0, 2) as balance_money, a.id, a.clientCode, a.clientName,c.totalChargeMoney
  93. from $table2$ a
  94. left join $table1$ b on a.id = b.idClient
  95. left join $table3$ c on a.id = c.idClient
  96. -- trim prefix=WHERE prefixOverrides=AND|OR
  97. -- if filterZeroBalance > 0
  98. b.balanceNum > 0
  99. -- end
  100. -- if filterZeroChargeMoney > 0
  101. c.totalChargeMoney > 0
  102. -- end
  103. -- isNotEmpty keyWord
  104. and a.clientName LIKE #{Like:keyWord}
  105. -- end
  106. -- end
  107. -- isEmpty orderBy
  108. order by a.createTime desc
  109. -- else
  110. order by #{orderBy}
  111. -- end
  112. ;
  113. -- [queryClientLevel]
  114. select * from $table$;
  115. -- [addClientLevel]
  116. insert into $table$ (id, levelName, enable,levelValue,
  117. createBy, createTime, updateBy,updateTime)
  118. values (#{id}, #{levelname}, #{enable}, #{levelvalue},
  119. #{createby},#{createtime}, #{updateby},#{updatetime} );
  120. -- [updateClientLevel]
  121. update $table$ set levelName = #{levelname},levelValue = #{levelvalue},updateBy = #{updateby},updateTime = #{updatetime}
  122. where id = #{id};
  123. -- [enableClientLevel]
  124. update $table$ set enable = #{enable},updateBy = #{updateby},updateTime = #{updatetime}
  125. where id = #{id};
  126. -- [queryClientReceiveAddress]
  127. select * from $table$;
  128. -- [addClientReceiveAddress]
  129. insert into $table$ (id, idClient, receiveMan, receivePhone, idShipMode,
  130. shipModeName,idShipArea, shipArea, province, city,
  131. area, address, coordinate, defaultFlag, shipOrLogistics,
  132. createBy, createTime,
  133. updateBy, updateTime ) values ( #{id}, #{idclient}, #{receiveman}, #{receivephone}, #{idshipmode},
  134. #{shipmodename}, #{idshiparea}, #{shiparea}, #{province}, #{city},
  135. #{area}, #{address}, #{coordinate}, #{defaultflag}, #{shiporlogistics},
  136. #{createby}, #{createtime},
  137. #{updateby}, #{updatetime} );
  138. -- [updateClientReceiveAddress]
  139. update $table$ set receiveMan = #{receiveman},receivePhone = #{receivephone},idShipMode = #{idshipmode},shipModeName = #{shipmodename},
  140. idShipArea = #{idshiparea}, shipArea = #{shiparea}, province = #{province},city = #{city},area = #{area},address = #{address}, coordinate=#{coordinate},
  141. shipOrLogistics = #{shiporlogistics},
  142. updateBy = #{updateby},updateTime = #{updatetime} where id = #{id};
  143. -- [defaultClientReceiveAddress]
  144. update $table$ set defaultFlag = 1,
  145. updateBy = #{updateby},updateTime = #{updatetime}
  146. where id = #{id};
  147. -- [unDefaultClientReceiveAddress]
  148. update $table$ set defaultFlag = 0,
  149. updateBy = #{updateby},updateTime = #{updatetime}
  150. where id != #{id} and idClient=#{idclient};
  151. -- [deleteClientReceiveAddress]
  152. delete from $table$ where id = #{id};
  153. -- [deleteClientReceiveAddressByClient]
  154. delete from $table$ where idClient = #{id};