Store.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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.oqpo.api.mapper.stinfo.StoreBaseInfoMapper">
  4. <select id="selectPopStoreGridList" resultType="com.oqpo.api.entity.stinfo.StoreBaseInfoEntity">
  5. select /* selectPopStoreGridList */
  6. A.brand_id, fn_brand_nm(A.brand_id) as brand_nm,
  7. A.store_id, A.store_nm, A.store_st_cd, fn_code_nm('STORE_ST_CD', A.store_st_cd) as store_st_nm,
  8. A.loan_dvsn
  9. from store_base_info A
  10. where 1=1
  11. and A.brand_id = #{sBrandId}
  12. <if test="sStoreNm != null and sStoreNm != ''">
  13. and A.store_nm like concat('%',#{sStoreNm},'%')
  14. </if>
  15. <choose>
  16. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  17. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  18. <if test="gridRequest.sord == 'asc'.toString()">
  19. order by A.store_nm asc
  20. </if>
  21. <if test="gridRequest.sord == 'desc'.toString()">
  22. order by A.store_nm desc
  23. </if>
  24. </if>
  25. </when>
  26. <otherwise>
  27. order by A.store_nm asc
  28. </otherwise>
  29. </choose>
  30. <if test="gridRequest.pagingYn == true">
  31. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  32. </if>
  33. </select>
  34. <select id="selectPopStoreGridCnt" resultType="int">
  35. select /*selectPopStoreGridCnt*/
  36. count(*)
  37. from store_base_info
  38. where 1=1
  39. and brand_id = #{sBrandId}
  40. <if test="sStoreNm != null and sStoreNm != ''">
  41. and store_nm like concat('%',#{sStoreNm},'%')
  42. </if>
  43. </select>
  44. <select id="selectStoreGridList" resultType="com.oqpo.api.entity.stinfo.StoreBaseInfoEntity">
  45. select /* selectStoreGridList */
  46. brand_id, fn_brand_nm(brand_id) as brand_nm, store_id, store_nm, fn_get_regno(1,bsns_reg_no) as bsns_reg_no,
  47. store_dvsn, fn_code_nm('STORE_DVSN', store_dvsn) as store_dvsn_nm, store_st_cd, fn_code_nm('STORE_ST_CD',store_st_cd) as store_st_nm ,
  48. date_format(sys_reg_dttm,'%Y.%m.%d %H:%s:%i') as sys_reg_dttm
  49. from store_base_info
  50. where 1=1
  51. and brand_id = #{sBrandId}
  52. <if test="searchDateType == '10'">
  53. and open_dt between #{fromDt} and #{toDt}
  54. </if>
  55. <if test="searchDateType == '20'">
  56. and sys_reg_dttm between date_format(concat(#{fromDt},'000000'),'%Y%m%d%H%s%i') and date_format(concat(#{toDt},'000000'),'%Y%m%d%H%s%i')
  57. </if>
  58. <if test="sStoreDvsn != null and sStoreDvsn != ''">
  59. and store_dvsn = #{sStoreDvsn}
  60. </if>
  61. <if test="sStoreStCd != null and sStoreStCd != ''">
  62. and store_st_cd = #{sStoreStCd}
  63. </if>
  64. <if test="sLoanDvsn != null and sLoanDvsn != ''">
  65. and loan_dvsn = #{sLoanDvsn}
  66. </if>
  67. <if test="sStoreNm != null and sStoreNm != ''">
  68. and store_nm like concat('%',#{sStoreNm},'%')
  69. </if>
  70. <choose>
  71. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  72. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  73. <if test="gridRequest.sord == 'asc'.toString()">
  74. order by brand_nm asc
  75. </if>
  76. <if test="gridRequest.sord == 'desc'.toString()">
  77. order by brand_nm desc
  78. </if>
  79. </if>
  80. </when>
  81. <otherwise>
  82. order by brand_nm asc
  83. </otherwise>
  84. </choose>
  85. <if test="gridRequest.pagingYn == true">
  86. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  87. </if>
  88. </select>
  89. <select id="selectStoreGridCnt" resultType="int">
  90. select /*selectStoreGridCnt*/
  91. count(*)
  92. from store_base_info
  93. where 1=1
  94. and brand_id = #{sBrandId}
  95. <if test="searchDateType == '10'">
  96. and open_dt between #{fromDt} and #{toDt}
  97. </if>
  98. <if test="searchDateType == '20'">
  99. and sys_reg_dttm between date_format(concat(#{fromDt},'000000'),'%Y%m%d%H%s%i') and date_format(concat(#{toDt},'000000'),'%Y%m%d%H%s%i')
  100. </if>
  101. <if test="sStoreDvsn != null and sStoreDvsn != ''">
  102. and store_dvsn = #{sStoreDvsn}
  103. </if>
  104. <if test="sStoreStCd != null and sStoreStCd != ''">
  105. and store_st_cd = #{sStoreStCd}
  106. </if>
  107. <if test="sLoanDvsn != null and sLoanDvsn != ''">
  108. and loan_dvsn = #{sLoanDvsn}
  109. </if>
  110. <if test="sStoreNm != null and sStoreNm != ''">
  111. and store_nm like concat('%',#{sStoreNm},'%')
  112. </if>
  113. </select>
  114. <select id="selectStoreInfo" resultType="com.oqpo.api.entity.stinfo.StoreBaseInfoEntity">
  115. select store.brand_id, brand.brand_nm as 'brandInfo.brand_nm', store.store_id,store.store_nm,store.store_dvsn,fn_code_nm('STORE_DVSN',store.store_dvsn) as store_dvsn_nm
  116. ,store.mbl_no,date_format(store.open_dt,'%Y.%m.%d') as open_dt,date_format(store.close_dt,'%Y.%m.%d') as close_dt,store.loan_mgnt_unq_no,store.loan_dvsn
  117. ,fn_code_nm('LOAN_DVSN',store.loan_dvsn) as loan_dvsn_nm, store.limit_amt, store.rtn_proc_dvsn,fn_code_nm('RTN_PROC_DVSN',store.rtn_proc_dvsn) as rtn_proc_dvsn_nm,store.zip_no,store.addr1
  118. ,store.addr2,fn_get_telno(store.tel_no) as tel_no,fn_get_telno(store.fax_no) as fax_no,store.emal_addr,store.store_st_cd
  119. ,fn_code_nm('STORE_ST_CD',store.store_st_cd) as store_st_nm,fn_get_regno(1, store.bsns_reg_no) as bsns_reg_no,fn_get_regno(2, store.corp_reg_no) as corp_reg_no
  120. ,store.ctgr_bsns,store.bsns_cndt,store.owner_nm,store.del_yn,store.area_cd,fn_code_nm('AREA_CD',store.area_cd) as area_nm
  121. ,store.lat_x,store.long_y,store.oq_brand_id,store.oq_store_id,date_format(store.sys_reg_dttm,'%Y.%m.%d %H:%s:%i') as sys_reg_dttm
  122. ,store.sys_reg_id,date_format(store.sys_chg_dttm,'%Y.%m.%d %H:%s:%i') as sys_chg_dttm,store.sys_chg_id
  123. ,loan.acct_bal - loan.use_amt_total as 'loanInfo.loanInfo.acct_bal'
  124. ,store.bnk_cd , store.acct_no, store.owac_nm
  125. ,brand.bnk_cd as 'brandInfo.bnk_cd', fn_code_nm('BNK_CD',brand.bnk_cd) as 'brandInfo.bnk_nm', brand.acct_no as 'brandInfo.acct_no', brand.owac_nm as 'brandInfo.owac_nm'
  126. ,store.whs_use_yn
  127. from store_base_info store
  128. join brand_base_info brand on store.brand_id = brand.brand_id
  129. left outer join loan_mgnt_base_info loan on store.loan_mgnt_unq_no = loan.loan_mgnt_unq_no and store.brand_id = loan.brand_id and store.store_id = loan.store_id and loan.use_yn = 'Y'
  130. where 1=1
  131. and store.brand_id = #{brandId}
  132. and store.store_id = #{storeId}
  133. </select>
  134. <insert id="insertStoreInfo" >
  135. insert into store_base_info
  136. (
  137. brand_id,store_id,store_nm,store_dvsn,mbl_no
  138. ,open_dt,close_dt,loan_mgnt_unq_no,loan_dvsn,limit_amt, rtn_proc_dvsn
  139. ,zip_no,addr1,addr2,tel_no,fax_no
  140. ,emal_addr,store_st_cd,bsns_reg_no,corp_reg_no,ctgr_bsns
  141. ,bsns_cndt, bnk_cd, acct_no, owac_nm, owner_nm,del_yn,area_cd,lat_x, whs_use_yn
  142. ,long_y,oq_brand_id,oq_store_id,sys_reg_dttm,sys_reg_id,sys_chg_dttm,sys_chg_id
  143. )
  144. values
  145. (
  146. #{entity.brandId},#{entity.storeId},#{entity.storeNm},#{entity.storeDvsn},#{entity.mblNo},
  147. #{entity.openDt},#{entity.closeDt},#{entity.loanMgntUnqNo},#{entity.loanDvsn},#{entity.limitAmt},#{entity.rtnProcDvsn},
  148. #{entity.zipNo},#{entity.addr1},#{entity.addr2},#{entity.telNo},#{entity.faxNo},
  149. #{entity.emalAddr},#{entity.storeStCd},#{entity.bsnsRegNo},#{entity.corpRegNo},#{entity.ctgrBsns},
  150. #{entity.bsnsCndt},#{entity.bnkCd}, #{entity.acctNo}, #{entity.owacNm}, #{entity.ownerNm},'N',#{entity.areaCd},#{entity.latX},#{entity.whsUseYn},
  151. #{entity.longY},null,null,now(),#{userId},now(),#{userId}
  152. )
  153. </insert>
  154. <update id="updateStoreInfo">
  155. update store_base_info
  156. set store_nm = #{entity.storeNm}
  157. ,store_dvsn = #{entity.storeDvsn}
  158. ,mbl_no = #{entity.mblNo}
  159. ,open_dt = #{entity.openDt}
  160. ,close_dt = case when #{entity.storeStCd} = 'ST03' then date_format(now(),'%Y%m%d') else null end
  161. ,loan_mgnt_unq_no = #{entity.loanMgntUnqNo}
  162. ,loan_dvsn = #{entity.loanDvsn}
  163. ,rtn_proc_dvsn = #{entity.rtnProcDvsn}
  164. ,limit_amt = #{entity.limitAmt}
  165. ,zip_no = #{entity.zipNo}
  166. ,addr1 = #{entity.addr1}
  167. ,addr2 = #{entity.addr2}
  168. ,tel_no = #{entity.telNo}
  169. ,fax_no = #{entity.faxNo}
  170. ,emal_addr = #{entity.emalAddr}
  171. ,store_st_cd = #{entity.storeStCd}
  172. ,ctgr_bsns = #{entity.ctgrBsns}
  173. ,bsns_cndt = #{entity.bsnsCndt}
  174. ,bnk_cd = #{entity.bnkCd}
  175. ,acct_no = #{entity.acctNo}
  176. ,owner_nm = #{entity.ownerNm}
  177. ,owac_nm = #{entity.owacNm}
  178. ,area_cd = #{entity.areaCd}
  179. ,lat_x = #{entity.latX}
  180. ,long_y = #{entity.longY}
  181. ,whs_use_yn = #{entity.whsUseYn}
  182. ,sys_chg_dttm = now()
  183. ,sys_chg_id = #{userId}
  184. where brand_id = #{entity.brandId}
  185. and store_id = #{entity.storeId}
  186. </update>
  187. <select id="selectStoreInitPw" resultType="String">
  188. select bsns_reg_no
  189. from store_base_info
  190. where brand_id = #{brandId}
  191. and store_id = #{storeId}
  192. </select>
  193. <select id="selectStoreLoanInfo" resultType="com.oqpo.api.entity.stinfo.StoreBaseInfoEntity">
  194. select loan_mgnt_unq_no,loan_dvsn,nvl(limit_amt,0) as limit_amt, nvl(whs_use_yn,'N') as whs_use_yn
  195. from store_base_info
  196. where 1=1
  197. and brand_id = #{brandId}
  198. and store_id = #{storeId}
  199. </select>
  200. <update id="updateCloseStore" >
  201. update store_base_info
  202. set sys_chg_dttm = now()
  203. ,sys_chg_id = #{userId}
  204. ,store_st_cd = 'ST03'
  205. where 1=1
  206. <if test="brandId != null and brandId != ''">
  207. and brand_id = #{brandId}
  208. </if>
  209. <if test="afflShopId != null and afflShopId != ''">
  210. and brand_id in (select brand_id from affl_shop_base_info where affl_shop_id = #{afflShopId})
  211. </if>
  212. </update>
  213. <select id="selectStoreLoanMgntUnqNo" resultType="String">
  214. select loan_mgnt_unq_no
  215. from store_base_info
  216. where store_id = #{storeId}
  217. </select>
  218. </mapper>