INSERT INTO rtn_req_base_info /* RtnReqMapper.insertRtnReqBaseInfo */ (rtn_req_unq_no, store_id, brand_id, rtn_req_dt, rtn_req_tm , rtn_req_st_cd, rtn_req_mgr_id, rtn_req_mgr_nm, rtn_req_mgr_tel_no , whs_dvsn, col_req_dt, note, rtn_rjct_dt, rtn_rjct_nm , rtn_rjct_id, rtn_rjct_rsn, rtn_req_amt, rtn_req_item_qty, rtn_whs_id, rtn_location , sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id) VALUES (#{entity.rtnReqUnqNo}, #{entity.storeId}, #{entity.brandId}, case when #{entity.rtnReqStCd} = 'RR20' then date_format(now(),'%Y%m%d') else null end , #{entity.rtnReqTm} , #{entity.rtnReqStCd}, #{userId}, #{entity.rtnReqMgrNm}, #{entity.rtnReqMgrTelNo} , #{entity.whsDvsn}, #{entity.colReqDt}, #{entity.note}, #{entity.rtnRjctDt}, #{entity.rtnRjctNm} , #{entity.rtnRjctId}, #{entity.rtnRjctRsn}, #{entity.rtnReqAmt}, #{entity.rtnReqItemQty}, #{entity.rtnWhsId}, #{entity.rtnLocation} , NOW(), #{userId}, NOW(), #{userId}) UPDATE rtn_req_base_info SET /* RtnReqMapper.updateRtnReqBaseInfo */ rtn_req_dt = case when #{entity.rtnReqStCd} = 'RR20' then date_format(now(),'%Y%m%d') else null end, rtn_req_tm = #{entity.rtnReqTm}, rtn_req_st_cd = #{entity.rtnReqStCd}, whs_dvsn = #{entity.whsDvsn}, col_req_dt = #{entity.colReqDt}, note = #{entity.note}, rtn_req_amt = #{entity.rtnReqAmt}, rtn_req_item_qty = #{entity.rtnReqItemQty}, rtn_whs_id = #{entity.rtnWhsId}, rtn_location = #{entity.rtnLocation}, sys_chg_dttm = NOW(), sys_chg_id = #{userId} WHERE rtn_req_unq_no = #{entity.rtnReqUnqNo} AND brand_id = #{entity.brandId} INSERT INTO rtn_req_dtl_ptcl /* RtnReqMapper.insertRtnReqDtlPtcl */ (rtn_req_unq_no, rtn_req_dtl_no, item_id, item_nm, unit , rtn_qty, rtn_amt, rtn_dvsn, rtn_rsn , spply_id, unit_amt, store_unit_unq_no, brand_unit_unq_no, rtn_rsn_dvsn, unit_gubun , sys_reg_dttm, sys_reg_id, sys_chg_dttm, sys_chg_id) VALUES (#{item.rtnReqUnqNo}, #{item.rtnReqDtlNo}, #{item.itemId}, #{item.itemNm}, #{item.unit} , #{item.rtnQty}, #{item.rtnAmt}, #{item.rtnDvsn}, #{item.rtnRsn} , #{item.spplyId}, #{item.unitAmt}, #{item.storeUnitUnqNo}, #{item.brandUnitUnqNo}, #{item.rtnRsnDvsn}, #{unitGubun} , NOW(), #{userId}, NOW(), #{userId}) UPDATE rtn_req_dtl_ptcl SET /* RtnReqMapper.updateRtnReqDtlPtcl */ rtn_qty = #{item.rtnQty}, rtn_amt = #{item.rtnAmt}, rtn_dvsn = #{item.rtnDvsn}, rtn_rsn = #{item.rtnRsn}, rtn_rsn_dvsn = #{item.rtnRsnDvsn}, sys_chg_dttm = NOW(), sys_chg_id = #{userId} WHERE rtn_req_unq_no = #{item.rtnReqUnqNo} AND rtn_req_dtl_no = #{item.rtnReqDtlNo} DELETE FROM rtn_req_dtl_ptcl /* RtnReqMapper.deleteRtnReqDtlPtcl */ WHERE rtn_req_unq_no = #{rtnReqUnqNo} AND rtn_req_dtl_no in #{item.rtnReqDtlNo}