jmh 4 лет назад
Родитель
Сommit
662e2e81ec

+ 31 - 0
src/main/java/com/style24/admin/biz/dao/TsaOcmDao.java

@@ -2,11 +2,13 @@ package com.style24.admin.biz.dao;
 
 import java.util.Collection;
 
+import com.gagaframework.web.parameter.GagaMap;
 import com.style24.core.support.annotation.ShopDs;
 import com.style24.persistence.domain.Extmall;
 import com.style24.persistence.domain.ExtmallNoti;
 import com.style24.persistence.domain.ExtmallOrigin;
 import com.style24.persistence.domain.ExtmallPriceSync;
+import com.style24.persistence.domain.ExtmallSettle;
 
 /**
  * 영업망관리 Dao
@@ -69,4 +71,33 @@ public interface TsaOcmDao {
 	 */
 	void saveExtmallPriceSync(ExtmallPriceSync extmallPriceSync);
 
+	/**
+	 * 제휴몰정산가격업로드- 목록 건수
+	 *
+	 * @param extmallOrder
+	 * @return
+	 * @author jmh
+	 * @since 2021. 8. 3
+	 */
+	int getExtmallSettleListCount(ExtmallSettle extmallSettle);
+
+	/**
+	 * 제휴몰정산가격업로드- 목록
+	 *
+	 * @param extmallOrder
+	 * @return
+	 * @author jmh
+	 * @since 2021. 8. 3
+	 */
+	Collection<ExtmallSettle> getExtmallSettleList(ExtmallSettle extmallSettle);
+
+	/**
+	 * 제휴몰정산가격업로드- 목록 엑셀
+	 *
+	 * @param extmallOrder
+	 * @return
+	 * @author jmh
+	 * @since 2021. 8. 3
+	 */
+	Collection<GagaMap> getExtmallSettleExcelList(ExtmallSettle extmallSettle);
 }

+ 63 - 0
src/main/java/com/style24/admin/biz/service/TsaOcmService.java

@@ -6,13 +6,18 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import com.gagaframework.excel.GagaExcelUtil;
+import com.gagaframework.excel.env.GagaExcelConstants;
+import com.gagaframework.web.parameter.GagaMap;
 import com.style24.admin.biz.dao.TsaOcmDao;
+import com.style24.admin.support.env.TsaConstants;
 import com.style24.admin.support.security.session.TsaSession;
 import com.style24.core.support.message.TscMessageByLocale;
 import com.style24.persistence.domain.Extmall;
 import com.style24.persistence.domain.ExtmallNoti;
 import com.style24.persistence.domain.ExtmallOrigin;
 import com.style24.persistence.domain.ExtmallPriceSync;
+import com.style24.persistence.domain.ExtmallSettle;
 
 import lombok.extern.slf4j.Slf4j;
 
@@ -104,4 +109,62 @@ public class TsaOcmService {
         }
     }
 
+    /**
+	 * 제휴몰정산가격업로드-목록 건수
+	 *
+	 * @param extmallOrder
+	 * @return
+	 * @author jmh
+	 * @since 2020. 8. 3
+	 */
+	public int getExtmallSettleListCount(ExtmallSettle extmallSettle) {
+		return ocmDao.getExtmallSettleListCount(extmallSettle);
+	}
+
+	/**
+	 * 제휴몰정산가격업로드-목록
+	 *
+	 * @param extmallOrder
+	 * @return
+	 * @author jmh
+	 * @since 2020. 8. 3
+	 */
+	public Collection<ExtmallSettle> getExtmallSettleList(ExtmallSettle extmallSettle) {
+		return ocmDao.getExtmallSettleList(extmallSettle);
+	}
+
+	/**
+	 * 제휴몰정산가격업로드-목록 엑셀다운로드
+	 *
+	 * @param extmallOrder
+	 * @param excelFilenameWithPath - 경로를 포함한 엑셀파일명
+	 * @return
+	 * @author jmh
+	 * @since 2021. 8. 3
+	 */
+	public void getExtmallSettleExcelList(ExtmallSettle extmallSettle, String excelFilenameWithPath) {
+
+		// 헤더 title 설정
+		String[] listTitles = {"IF결과", "IF결과메세지", "샵링커 주문번호", "쇼핑몰 주문번호", "스타일24 주문번호", "주문상세번호", "주문상세상태", "배송업체", "송장번호", "전송일시"};
+
+		// DB 처리 시 사용되는 파라미터명(셀명) 설정
+		String[] cellNames = {"API_RESULT", "API_MESSAGE", "AGENT_ORDER_ID", "EXTMALL_ORDER_ID", "ORD_NO", "ORD_DTL_NO", "ORD_DTL_STAT_NM", "SHIP_COMP_NM", "DELIVERY_INVOICE", "REG_DT"};
+
+		String[] cellTypes = {
+			GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_LEFT.name(),
+			GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_CENTER.name(),
+			GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_CENTER.name(),
+			GagaExcelConstants.CellType.CHAR_CENTER.name(), GagaExcelConstants.CellType.CHAR_CENTER.name(),
+			GagaExcelConstants.CellType.CHAR_LEFT.name(), GagaExcelConstants.CellType.CHAR_CENTER.name()};
+
+		Collection<GagaMap> dataList = ocmDao.getExtmallSettleExcelList(extmallSettle);
+
+		try {
+
+			GagaExcelUtil.createExcel(excelFilenameWithPath, dataList, "제휴몰정산가격", listTitles, cellNames, cellTypes, TsaConstants.EXCEL_FOOTER_TITLE);
+
+		} catch (Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
 }

+ 32 - 12
src/main/java/com/style24/admin/biz/web/TsaOcmController.java

@@ -3,6 +3,7 @@ package com.style24.admin.biz.web;
 import java.util.ArrayList;
 import java.util.Collection;
 
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.env.Environment;
 import org.springframework.stereotype.Controller;
@@ -13,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.servlet.ModelAndView;
 
+import com.fasterxml.jackson.databind.ObjectMapper;
 import com.gagaframework.excel.GagaExcelUtil;
 import com.gagaframework.web.parameter.GagaMap;
 import com.gagaframework.web.rest.server.GagaResponse;
@@ -24,12 +26,13 @@ import com.style24.admin.support.security.session.TsaSession;
 import com.style24.core.biz.service.TscOrderOcmService;
 import com.style24.core.support.env.TscConstants;
 import com.style24.core.support.message.TscMessageByLocale;
+import com.style24.persistence.TscPageRequest;
 import com.style24.persistence.domain.Extmall;
 import com.style24.persistence.domain.ExtmallNoti;
 import com.style24.persistence.domain.ExtmallOrder;
 import com.style24.persistence.domain.ExtmallOrigin;
 import com.style24.persistence.domain.ExtmallPriceSync;
-import com.style24.persistence.domain.ShoplinkerInvoice;
+import com.style24.persistence.domain.ExtmallSettle;
 
 import lombok.extern.slf4j.Slf4j;
 
@@ -58,6 +61,9 @@ public class TsaOcmController extends TsaBaseController {
 
 	@Autowired
 	private TsaRendererService rendererService;
+	
+	@Autowired
+	private ObjectMapper mapper;
 
 	private static final int EXCEL_ROW_COUNT = 500;
 
@@ -388,29 +394,43 @@ public class TsaOcmController extends TsaBaseController {
 	/**
 	 * 제휴몰정산가격업로드 - 목록조회
 	 *
-	 * @param 
+	 * @param  extmallOrder
 	 * @return GagaMap
 	 * @author jmh
 	 * @since 2021. 08. 02
 	 */
 	@PostMapping("/extmall/settle/list")
 	@ResponseBody
-	public GagaMap getExtmallSettleList(@RequestBody ShoplinkerInvoice shoplinkerInvoice) {
+	public GagaMap getExtmallSettleList(@RequestBody ExtmallSettle extmallSettle) {
 
 		GagaMap result = new GagaMap();
 
-		// multi row 검색관련 처리
-		/*		if (!StringUtils.isBlank(shoplinkerInvoice.getCondition())) {
-			shoplinkerInvoice.setConditionList(shoplinkerInvoice.getCondition().replaceAll("\r", "").trim().split("\n"));
+		//multi row 검색관련 처리
+		if (!StringUtils.isBlank(extmallSettle.getSupplyCompList())) {
+			try {
+				String[] arrSupplyComp = mapper.readValue(extmallSettle.getSupplyCompList(), String[].class);
+				extmallSettle.setMultiSupplyComp(arrSupplyComp);
+			} catch (Exception e) {
+				throw new IllegalStateException("업체코드 검색중 오류로 인해 조회되지 않았습니다.");
+			}
+		}
+		
+		if (!StringUtils.isBlank(extmallSettle.getBrandList())) {
+			try {
+				String[] arrBrandCd = mapper.readValue(extmallSettle.getBrandList(), String[].class);
+				extmallSettle.setMultiBrand(arrBrandCd);
+			} catch (Exception e) {
+				throw new IllegalStateException("브랜드코드 검색중 오류로 인해 조회되지 않았습니다.");
+			}
 		}
 
-		shoplinkerInvoice.setRegNo(TsaSession.getInfo().getUserNo()); // 엑셀조회시 로그인 사용자의 엑셀 상품조회시 사용
-		shoplinkerInvoice.setPageable(new TscPageRequest(shoplinkerInvoice.getPageNo() - 1, shoplinkerInvoice.getPageSize()));
-		shoplinkerInvoice.getPageable().setTotalCount(admShoplinkerService.getSendInvoiceListCount(shoplinkerInvoice));
+		extmallSettle.setRegNo(TsaSession.getInfo().getUserNo()); // 엑셀조회시 로그인 사용자의 엑셀 상품조회시 사용
+		extmallSettle.setPageable(new TscPageRequest(extmallSettle.getPageNo() - 1, extmallSettle.getPageSize()));
+		extmallSettle.getPageable().setTotalCount(ocmService.getExtmallSettleListCount(extmallSettle));
+
+		result.set("pageing", extmallSettle);
+		result.set("list", ocmService.getExtmallSettleList(extmallSettle));
 
-		result.set("pageing", shoplinkerInvoice);
-		result.set("invoiceList", admShoplinkerService.getSendInvoiceList(shoplinkerInvoice));
-*/
 		return result;
 	}
 }

+ 86 - 0
src/main/java/com/style24/persistence/domain/ExtmallSettle.java

@@ -0,0 +1,86 @@
+package com.style24.persistence.domain;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.style24.persistence.TscBaseDomain;
+import com.style24.persistence.TscPageRequest;
+
+import lombok.Data;
+
+/**
+ * 제휴몰가격정산 Domain
+ *
+ * @author jmh
+ * @since 2021. 8. 3
+ */
+@SuppressWarnings("serial")
+@Data
+public class ExtmallSettle extends TscBaseDomain {
+
+	private Integer ordDtlItemHstSq;	// 주문상세단품이력일련번호
+	private Integer ordNo;				// 주문번호
+	private Integer ordDtlNo;			// 주문상세번호
+	private String itemCd;				// 상품코드
+	private String optCd;				// 옵션코드
+	private String optCd1;				// 옵션코드1
+	private String optCd2;				// 옵션코드2
+	private int itemQty;				// 단품수량
+	private int itemPrice;				// 단품단가	
+	private int usacPrice;
+	private String regNm;
+	private String updNm;
+	
+	private String mallGb;				// 몰구분
+	private String mallGbNm;			// 몰구분명
+	private String extmallOrderId;		// 제휴몰주문번호
+	private String extmallId;			// 제휴몰ID
+	private String extmallNm;			// 제휴몰명
+	private String supplyCompCd;		// 공급업체코드
+	private String supplyCompNm;		// 공급업체명
+	private String distributionGb;		// 유통구분
+	private String distributionGbNm;	// 유통구분명
+	private String settleDayNm;			// 정산주기명
+	private String ordDt;				// 주문일시
+	private String settleGb;			// 정산구분
+	private String settleGbNm;			// 정산구분명
+	private String occurDt;				// 발생(출고/회수)일시
+	private String goodsCd;				// 상품코드
+	private String goodsNm;				// 상품명
+	private String brandCd;				// 브랜드코드
+	private String brandEnm;			// 브랜드영문명
+	private String mdId;				// 담당MD아이디
+	private String mdNm;				// 담당MD명	
+	private int mallPrice;				// 몰판매가
+	private int sellPrice;				// 판매가(정산용)
+	private int sellQty;				// 판매수량
+	private double sellAmt;				// 판매금액(CPN1_DC_AMT가 빠진 금액이 들어가 있음)
+	private double cpn1DcAmt;			// 즉시사용쿠폰금액
+	private double goodsCpnDcAmt;		// 상품쿠폰사용금액
+	private double cartCpnDcAmt;		// 주문서쿠폰사용금액
+	private double pntDcAmt;			// 포인트사용금액
+	private double tmtbDcAmt;			// 다다익선할인금액
+	private double gfcdUseAmt;			// 상품권사용금액
+	private double selfCpnDcAmt;		// 자사쿠폰분담액
+	private double supplyCompCpnDcAmt;	// 입점쿠폰분담액
+	private double realSellPrice;		// 실판매가
+	private double realSellAmt;			// 실판매금액(=상품총액. 쿠폰과 다다익선만 차감. 상품권과 포인트는 포함)
+	private double sellFeeRate;			// 판매수수료율
+	private double sellFeeAmt;			// 수수료(실판매금액 * 판매수수료율)
+	private double settleAmt;			// 정산대상액(실판매금액 - 수수료)
+
+	// 검색조건
+	private String stDate;				// 매출시작일자
+	private String edDate;				// 매출종료일자
+	private String supplyCompList;		// 공급업체코드목록
+	private String brandList;			// 브랜드코드목록
+	@JsonFormat(with = JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
+	private String[] multiBrand;
+	@JsonFormat(with = JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
+	private String[] multiSupplyComp;
+	
+	// Pagination
+	private TscPageRequest pageable;
+	private int pageNo = 1;
+	private int pageSize = 50;
+	private int pageUnit = 10;
+	
+}

+ 151 - 0
src/main/java/com/style24/persistence/mybatis/shop/TsaOcm.xml

@@ -176,5 +176,156 @@
 		     , UPD_DT = NOW()
 	</insert>
 
+	<!-- 제휴몰정산가격업로드- 목록 건수 cnt -->
+	<select id="getExtmallSettleListCount" parameterType="ExtmallSettle" resultType="int">
+		/* TsaOcm.getExtmallSettleListCount */
+		SELECT 
+			count(ODIH.ORD_DTL_ITEM_HST_SQ)
+					          
+		FROM   TB_ORDER_DETAIL_ITEM_HST ODIH
+		        INNER JOIN TB_ORDER_DETAIL OD ON ODIH.ORD_DTL_NO = OD.ORD_DTL_NO
+		        INNER JOIN TB_ORDER O ON ODIH.ORD_NO = O.ORD_NO
+		        INNER JOIN TB_SUPPLY_COMPANY SC ON OD.SUPPLY_COMP_CD = SC.SUPPLY_COMP_CD
+		        INNER JOIN TB_GOODS G ON OD.GOODS_CD = G.GOODS_CD
+		        INNER JOIN TB_BRAND B ON G.BRAND_CD = B.BRAND_CD
+		        LEFT OUTER JOIN shoplinker_order SO on OD.AGENT_ORDER_ID = SO.SHOPLINKER_ORDER_ID 
+		        LEFT OUTER JOIN TB_EXTMALL E ON OD.EXTMALL_ID = E.EXTMALL_ID
+		        left outer join TB_EXTMALL_USAC_PRICE F on ODIH.ORD_DTL_ITEM_HST_SQ = F.ORD_DTL_ITEM_HST_SQ
+		      
+        WHERE  1 = 1
+        AND    O.MALL_GB = 'G011_20'
+        AND    ODIH.ITEM_PRICE != IFNULL(F.USAC_PRICE, ODIH.ITEM_PRICE)
+				        
+		ORDER  BY ODIH.ORD_DTL_ITEM_HST_SQ 
+		
+		<include refid="getExtmallSettleCondition_sql"/>
 
+	</select>
+
+	<!-- 제휴몰정산가격업로드- 목록 -->
+	<select id="getExtmallSettleList" parameterType="ExtmallSettle" resultType="ExtmallSettle">
+		/* TsaOcm.getExtmallSettleList */
+		/* TsaSettle.getGoodsSettleList */
+		SELECT 
+			ODIH.ORD_DTL_ITEM_HST_SQ                                                           /*주문상세단품이력일련번호*/
+		     , ODIH.ORD_NO                                                                        /*주문번호*/
+		     , ODIH.ORD_DTL_NO                                                                    /*주문상세번호*/
+		     
+		     , ODIH.ITEM_CD                                                                       /*단품코드*/
+		     , ODIH.OPT_CD
+		     , ODIH.OPT_CD1                                                                       /*옵션코드1*/
+		     , ODIH.OPT_CD2                                                                       /*옵션코드2*/
+		     , ODIH.ITEM_QTY
+		     , ODIH.ITEM_PRICE                                          AS SELL_PRICE             /*판매가*/
+		     , IFNULL(F.USAC_PRICE, ODIH.ITEM_PRICE) as USAC_PRICE
+		     , F.REG_DT 
+		     , F.UPD_DT 
+		     , fn_get_user_nm(F.REG_NO) AS REG_NM
+		     , fn_get_user_nm(F.UPD_NO) AS UPD_NM          
+		               
+		     , O.MALL_GB                                                                          /*몰구분*/
+		     , FN_GET_CODE_NM('G011',O.MALL_GB)                         AS MALL_GB_NM             /*몰구분명*/
+		     , OD.EXTMALL_ORDER_ID                                                                /*제휴몰주문번호*/
+		     , OD.EXTMALL_ID                                                                      /*제휴몰ID*/
+		     , E.EXTMALL_NM                                                                       /*제휴몰명*/
+			 , OD.GOODS_CD                                                                        /*상품코드*/
+		     , G.GOODS_NM                                                                         /*상품명*/
+		     , G.BRAND_CD                                                                         /*브랜드코드*/
+		     , B.BRAND_ENM                                                                        /*브랜드명*/
+		          
+		FROM   TB_ORDER_DETAIL_ITEM_HST ODIH
+		        INNER JOIN TB_ORDER_DETAIL OD ON ODIH.ORD_DTL_NO = OD.ORD_DTL_NO
+		        INNER JOIN TB_ORDER O ON ODIH.ORD_NO = O.ORD_NO
+		        INNER JOIN TB_SUPPLY_COMPANY SC ON OD.SUPPLY_COMP_CD = SC.SUPPLY_COMP_CD
+		        INNER JOIN TB_GOODS G ON OD.GOODS_CD = G.GOODS_CD
+		        INNER JOIN TB_BRAND B ON G.BRAND_CD = B.BRAND_CD
+		        LEFT OUTER JOIN shoplinker_order SO on OD.AGENT_ORDER_ID = SO.SHOPLINKER_ORDER_ID 
+		        LEFT OUTER JOIN TB_EXTMALL E ON OD.EXTMALL_ID = E.EXTMALL_ID
+		        left outer join TB_EXTMALL_USAC_PRICE F on ODIH.ORD_DTL_ITEM_HST_SQ = F.ORD_DTL_ITEM_HST_SQ
+		      
+        WHERE  1 = 1
+        AND    O.MALL_GB = 'G011_20'
+        -- AND    ODIH.ITEM_PRICE != IFNULL(SO.USAC_PRICE, ODIH.ITEM_PRICE)
+        AND    ODIH.ORD_AMT != IFNULL(SO.ORDER_PRICE, ODIH.ORD_AMT)
+        AND    ODIH.ORD_DTL_STAT IN ('G720_20','G720_50','G720_60') /*판매-배송중,환입-반품완료,환입-교환완료*/
+
+		<include refid="getExtmallSettleCondition_sql"/>
+
+		ORDER  BY ODIH.ORD_DTL_ITEM_HST_SQ 
+		LIMIT #{pageable.limitStartRow} ,  #{pageable.pageSize}
+	</select>
+
+	<!-- 제휴몰정산가격업로드- 목록 엑셀 -->
+	<select id="getExtmallSettleExcelList" parameterType="ExtmallSettle" resultType="paramMap">
+		/* TsaOcm.getExtmallSettleExcelList */
+		SELECT
+			OD.ORD_NO
+			, OD.ORD_DTL_NO
+			, (SELECT SHIP_COMP_NM FROM TB_SHIP_COMPANY S WHERE S.SHIP_COMP_CD = OD.SHIP_COMP_CD ) AS SHIP_COMP_NM
+			, OD.SHIP_COMP_CD AS DELIVERY_CODE-- 배송업체(택배사코드)
+			, OD.INVOICE_NO AS DELIVERY_INVOICE-- 송장번호
+
+			, OD.VENDOR_ID -- 외부몰벤더ID
+			, OD.EXTMALL_ID -- 외부몰ID(외부몰)
+			, OD.AGENT_ORDER_ID -- 에이전트주문번호
+			, OD.EXTMALL_ORDER_ID -- 외부몰주문번호
+			, OD.DELV_ASSIGN_STAT -- 출고지정상태(P:대기,Y:수락,N:거부)
+			, OD.ORD_EXCH_GB -- 주문교환구분(O:주문,E:교환)
+			, OD.ORD_DTL_STAT -- 주문상세상태(공통코드G013)
+			, FN_GET_CODE_NM('G013', OD.ORD_DTL_STAT) AS ORD_DTL_STAT_NM
+			, OD.DELV_STDT
+
+			, CASE WHEN 'true' = SL.API_RESULT THEN '전송완료'
+  		    	   WHEN 'false' = SL.API_RESULT THEN '전송실패'
+  		    	   WHEN 'error' = SL.API_RESULT THEN '오류'
+  		    	   ELSE IFNULL(SL.API_RESULT, '')
+			  END API_RESULT
+			, SL.API_MESSAGE
+			, SL.XML_TXT
+			, SL.REG_DT
+		FROM
+			TB_ORDER_DETAIL OD
+			LEFT OUTER JOIN SHOPLINKER_SYNC_HST SL ON OD.ORD_DTL_NO = SL.ORD_DTL_NO AND SL.API_TYPE = 'INVOICE'
+		WHERE OD.VENDOR_ID = 'G003_V001'
+		AND (OD.ORD_DTL_STAT = 'G013_50' OR SL.ORD_DTL_NO IS NOT NULL)
+		AND OD.INVOICE_NO IS NOT NULL
+		AND OD.DELV_STDT IS NOT NULL
+
+		<include refid="getExtmallSettleCondition_sql"/>
+
+		ORDER BY OD.ORD_NO, OD.ORD_DTL_NO
+
+	</select>
+
+	<!-- 상품 목록 조건 정보 -->
+	<sql id="getExtmallSettleCondition_sql">
+        
+			<if test="stDate != null and stDate != ''">
+	        AND    ODIH.REG_DT  >=  DATE_FORMAT(#{stDate}, '%Y-%m-%d %H:%i:%S')
+            </if>
+            <if test="edDate != null and edDate != ''">
+            <![CDATA[
+	        AND ODIH.REG_DT < DATE_FORMAT(DATE_ADD(#{edDate}, INTERVAL 1 DAY), '%Y-%m-%d %H:%i:%S')
+            ]]>
+            </if>
+
+	        <if test='distributionGb != null and distributionGb != ""'>
+	        AND    SC.DISTRIBUTION_GB = #{distributionGb}
+	        </if>
+	        <if test='extmallId != null and extmallId != ""'>
+	        AND    OD.EXTMALL_ID = #{extmallId}
+	        </if>
+	        <if test="multiSupplyComp != null and multiSupplyComp != ''">
+	        AND    SC.SUPPLY_COMP_CD IN
+	            <foreach collection="multiSupplyComp" item="item" index="index"  open="(" close=")" separator=",">
+	            #{item}
+	            </foreach>
+	        </if>
+	        <if test="multiBrand != null and multiBrand != ''">
+	        AND    B.BRAND_CD IN
+	            <foreach collection="multiBrand" item="item" index="index"  open="(" close=")" separator=",">
+	            #{item}
+	            </foreach>
+	        </if>
+	</sql>
 </mapper>

+ 140 - 135
src/main/webapp/WEB-INF/views/ocm/ExtmallSettleRegisterForm.html

@@ -25,9 +25,9 @@
 		</div>
 		<!-- //메뉴 설명 -->
 		
-		<!-- 검색조건 영역 -->
-		<div class="panelStyle">
-			<form id="searchForm" name="searchForm" action="#" th:action="@{'/settle/goods/list'}" onsubmit="$('#btnSearch').trigger('click'); return false;">
+		<form id="searchForm" name="searchForm" action="#" th:action="@{'/ocm/extmall/settle/list'}" onsubmit="$('#btnSearch').trigger('click'); return false;">
+			<!-- 검색조건 영역 -->
+			<div class="panelStyle">
 				<table class="frmStyle" aria-describedby="검색조건">
 					<colgroup>
 						<col style="width:10%;"/>
@@ -91,40 +91,43 @@
 						<button type="button" class="btn btn-gray btn-lg" id="btnInit">초기화</button>
 					</li>
 				</ul>
-			</form>
-		</div>
-		<!-- 검색조건 영역 -->
-
-		<!-- 리스트 영역 -->
-		<div class="panelStyle">
-			<ul class="panelBar">
-				<li>
-					<button type="button" class="btn btn-default btn-lg" onclick="fnExcelDownLoad();">엑셀다운로드</button>
-				</li>
-				<li class="right">
-					검색결과 : <strong><span id="gridRowTotalCount">0</span> 건</strong>&nbsp;
-					쪽번호 <span id="pgNo">0</span>/ <strong id="endPgNo">0</strong>&nbsp;&nbsp;
-					<select id="pageSize" name="pageSize">
-						<option value="50" selected="selected">50개씩 보기</option>
-						<option value="100">100개씩 보기</option>
-						<option value="500">500개씩 보기</option>
-						<option value="1000">1000개씩 보기</option>
-					</select>
-					<input type="hidden" name="pageNo" id="pageNo" value ="1"/>
-				</li>
-			</ul>
-
-			<div id="gridList" style="width: 100%; height: 470px" class="ag-theme-balham"></div>
-
-			<ul class="panelBar">
-				<li class="center">
-					<div class="tablePaging" id="invoiceListPagination"></div>
-				</li>
-			</ul>
-		</div>
-		<!-- //리스트 영역 -->
+			
+			</div>
+			<!-- 검색조건 영역 -->
+	
+			<!-- 리스트 영역 -->
+			<div class="panelStyle">
+				<ul class="panelBar">
+					<li>
+						<button type="button" class="btn btn-default btn-lg" onclick="fnExcelDownLoad();">엑셀다운로드</button>
+					</li>
+					<li class="right">
+						검색결과 : <strong><span id="gridRowTotalCount">0</span> 건</strong>&nbsp;
+						쪽번호 <span id="pgNo">0</span>/ <strong id="endPgNo">0</strong>&nbsp;&nbsp;
+						<select id="pageSize" name="pageSize">
+							<option value="50" selected="selected">50개씩 보기</option>
+							<option value="100">100개씩 보기</option>
+							<option value="500">500개씩 보기</option>
+							<option value="1000">1000개씩 보기</option>
+						</select>
+						<input type="hidden" name="pageNo" id="pageNo" value ="1"/>
+					</li>
+				</ul>
+	
+				<div id="gridList" style="width: 100%; height: 470px" class="ag-theme-balham"></div>
+	
+				<ul class="panelBar">
+					<li class="center">
+						<div class="tablePaging" id="listPagination"></div>
+					</li>
+				</ul>
+			</div>
+			<!-- //리스트 영역 -->
+		
+		</form>
 	</div>
 
+<script type="text/javascript" src="/ux/plugins/gaga/gaga.paging.js?v=20210114"></script>
 <script th:inline="javascript">
 /*<![CDATA[*/
 	let vendorList = gagajf.convertToArray([[${vendorList}]]);
@@ -133,108 +136,26 @@
 	let distributionGbList = gagajf.convertToArray([[${distributionGbList}]]);
 
 	let columnDefs = [
+		{ headerName: "단품이력일련번호", field: "ordDtlItemHstSq", width: 150, cellClass: 'text-center' },
 		{ headerName: "주문번호", field: "ordNo", width: 100, cellClass: 'text-center' },
-		{ headerName: "주문상세번호", field: "ordDtlNo", width: 150, cellClass: 'text-center' },
-		{ headerName: "몰구분", field: "mallGbNm", width: 100, cellClass: 'text-center' },
-		{ headerName: "제휴몰주문번호", field: "extmallOrderId", width: 150, cellClass: 'text-center' },
-		{ headerName: "제휴몰명", field: "extmallNm", width: 150, cellClass: 'text-center' },
-// 		{
-// 			headerName: "공급업체", field: "supplyCompCd", width: 100, cellClass: 'text-center',
-// 			valueGetter: function (params) {
-// 				return gagaAgGrid.lookupValue(supplyCompList, params.data.supplyCompCd);
-// 			}
-// 		},
-		{ headerName: "공급업체", field: "supplyCompNm", width: 150, cellClass: 'text-center' },
-// 		{
-// 			headerName: "유통구분", field: "distributionGb", width: 100, cellClass: 'text-center',
-// 			valueGetter: function (params) {
-// 				return gagaAgGrid.lookupValue(distributionGbList, params.data.distributionGb);
-// 			}
-// 		},
-		{ headerName: "유통구분", field: "distributionGbNm", width: 100, cellClass: 'text-center'},
-		{ headerName: "정산주기", field: "settleDayNm", width: 100, cellClass: 'text-center' },
-		{ headerName: "주문일시", field: "ordDt", width: 150, cellClass: 'text-center' },
-		{ headerName: "정산구분", field: "settleGbNm", width: 100, cellClass: 'text-center' },
-		{ headerName: "발생(출고/회수)일시", field: "occurDt", width: 150, cellClass: 'text-center' },
+		{ headerName: "주문상세번호", field: "ordDtlNo", width: 100, cellClass: 'text-center' },
+		{ headerName: "단품코드", field: "itemCd", width: 100, cellClass: 'text-center' },
 		{ headerName: "상품코드", field: "goodsCd", width: 120, cellClass: 'text-center' },
-		{ headerName: "상품명", field: "goodsNm", width: 300 },
-		{ headerName: "브랜드", field: "brandEnm", width: 100, cellClass: 'text-center' },
-		{ headerName: "담당MD", field: "mdNm", width: 100, cellClass: 'text-center' },
-		{ headerName: "단품코드", field: "itemCd", width: 120, cellClass: 'text-center' },
-		{ headerName: "옵션", field: "optCd1", width: 100, cellClass: 'text-center' },
-		{
-			headerName: "판매가", field: "sellPrice", width: 100, cellClass: 'text-right',
-			cellRenderer: function (params) { return gagaAgGrid.toAddComma(params.value); }
-		},
-		{
-			headerName: "판매수량", field: "sellQty", width: 100, cellClass: 'text-center',
-			cellRenderer: function (params) { return gagaAgGrid.toAddComma(params.value); },
-			cellStyle : function(params) { if (Number(params.value) < 0) return { 'color' : 'red' } }
-		},
-		{
-			headerName: "판매총액", field: "sellAmt", width: 100, cellClass: 'text-right',
-			cellRenderer: function (params) { return gagaAgGrid.toAddComma(params.value); },
-			cellStyle : function(params) { if (Number(params.value) < 0) return { 'color' : 'red' } }
-		},
-		{
-			headerName: "즉시사용쿠폰금액", field: "cpn1DcAmt", width: 120, cellClass: 'text-right',
-			cellRenderer: function (params) { return gagaAgGrid.toAddComma(params.value); }
-		},
-		{
-			headerName: "상품쿠폰사용금액", field: "goodsCpnDcAmt", width: 120, cellClass: 'text-right',
-			cellRenderer: function (params) { return gagaAgGrid.toAddComma(params.value); }
-		},
-		{
-			headerName: "주문서쿠폰사용금액", field: "cartCpnDcAmt", width: 130, cellClass: 'text-right',
-			cellRenderer: function (params) { return gagaAgGrid.toAddComma(params.value); }
-		},
-		{
-			headerName: "포인트사용금액", field: "pntDcAmt", width: 120, cellClass: 'text-right',
-			cellRenderer: function (params) { return gagaAgGrid.toAddComma(params.value); }
-		},
-		{
-			headerName: "다다익선할인금액", field: "tmtbDcAmt", width: 120, cellClass: 'text-right',
-			cellRenderer: function (params) { return gagaAgGrid.toAddComma(params.value); }
-		},
-		{
-			headerName: "상품권사용금액", field: "gfcdUseAmt", width: 120, cellClass: 'text-right',
-			cellRenderer: function (params) { return gagaAgGrid.toAddComma(params.value); }
-		},	
-		{
-			headerName: "자사쿠폰분담액", field: "selfCpnDcAmt", width: 120, cellClass: 'text-right',
-			cellRenderer: function (params) { return gagaAgGrid.toAddComma(params.value); }
-		},
-		{
-			headerName: "입점쿠폰분담액", field: "supplyCompCpnDcAmt", width: 120, cellClass: 'text-right',
-			cellRenderer: function (params) { return gagaAgGrid.toAddComma(params.value); }
-		},
-		{
-			headerName: "실판매가", field: "realSellPrice", width: 100, cellClass: 'text-right',
-			cellRenderer: function (params) { return gagaAgGrid.toAddComma(params.value); }
-		},
-		{
-			headerName: "상품총액", field: "realSellAmt", width: 100, cellClass: 'text-right',
-			cellRenderer: function (params) { return gagaAgGrid.toAddComma(params.value); },
-			cellStyle : function(params) { if (Number(params.value) < 0) return { 'color' : 'red' } }
-		},
-		{
-			headerName: "판매수수료율(%)", field: "sellFeeRate", width: 120, cellClass: 'text-center',
-			cellRenderer: function (params) { return params.value + '%'; }
-		},
-		{
-			headerName: "수수료", field: "sellFeeAmt", width: 100, cellClass: 'text-right',
-			cellRenderer: function (params) { return gagaAgGrid.toAddComma(params.value); },
-			cellStyle : function(params) { if (Number(params.value) < 0) return { 'color' : 'red' } }
-		},
-		{
-			headerName: "정산대상액", field: "settleAmt", width: 100, cellClass: 'text-right',
-			cellRenderer: function (params) { return gagaAgGrid.toAddComma(params.value); },
-			cellStyle : function(params) { if (Number(params.value) < 0) return { 'color' : 'red' } }
-		}
+		{ headerName: "상품명", field: "goodsNm", width: 250 },
+		{ headerName: "옵션코드", field: "optCd", width: 100, cellClass: 'text-center' },
+		{ headerName: "옵션1", field: "optCd1", width: 100, cellClass: 'text-center' },
+		{ headerName: "옵션2", field: "optCd2", width: 100, cellClass: 'text-center' },
+		{ headerName: "단품수량", field: "itemQty", width: 100, cellClass: 'text-center' },
+		{ headerName: "단품단가", field: "itemPrice", width: 100, cellClass: 'text-center' },
+		{ headerName: "정산가", field: "usacPrice", width: 100, cellClass: 'text-center' },
+		
+		{headerName: "등록자", field: "regNm", width: 100, cellClass: 'text-center'},
+		{headerName: "등록일", field: "regDt", width: 100, cellClass: 'text-center'},
+		{headerName: "수정자", field: "updNm", width: 100, cellClass: 'text-center'},
+		{headerName: "수정자", field: "updDt", width: 100, cellClass: 'text-center'},
 	];
 
 	let gridOptions = gagaAgGrid.getGridOptions(columnDefs);
-
 	
 	
 	// 벤더 콤보박스 변경 시
@@ -302,13 +223,97 @@
 	}
 	
 	// 검색
-	$('#btnSearch').on('click', function() {
+	/*$('#btnSearch').on('click', function() {
 		// 입력 값 체크
 		if (!gagajf.validation($('#searchForm')))
 			return false;
 		
 		gagaAgGrid.fetch($('#searchForm').prop('action'), gridOptions, '#searchForm');
+	}); */
+	
+	//페이징
+	$('#searchForm select[name=pageSize]').on('change', function() {
+		$("#searchForm input[name=pageNo]").val('1');
+		fnGoodsListSearch();
+	});
+
+
+	/**************** 검색 ********************************************************/
+	$('#btnSearch').on('click', function() {
+		//gagaAgGrid.fetch($('#searchForm').prop('action'), gridOptions, '#searchForm');
+		$("#searchForm input[name=pageNo]").val('1');
+		fnGoodsListSearch();
 	});
+
+	// 조회
+	var fnGoodsListSearch = function() {
+		if(!fnConditionCheck()) return;
+		gagaPaging.init('searchForm', fnSearchCallBack, 'listPagination', $('#searchForm').find('#pageSize').val());
+		gagaPaging.load($("#searchForm input[name=pageNo]").val());
+	}
+
+	//검색 조건 확인
+	var fnConditionCheck = function(){
+		var formId = '#searchForm';
+		var form = document.searchForm;
+
+		if (event.keyCode === 13) return false;
+
+		var searchFlag = false;
+		var cnt = 0;
+
+		if( !gagajf.isNull($("#searchForm textarea[name=condition]").val())
+				|| (!gagajf.isNull($("#searchForm input[name=stDate]").val()) && !gagajf.isNull($("#searchForm input[name=edDate]").val()))
+			){
+			searchFlag = true;
+		}else{
+			
+		}
+
+		if(searchFlag == false){
+			mcxDialog.alert("검색조건을 입력하세요.");
+			return false;
+		}
+
+		var fromDate = $('#searchForm input[name=stDate]').val();
+		var toDate = $('#searchForm input[name=edDate]').val();
+
+		if (!gagajf.isNull(fromDate) || !gagajf.isNull(toDate)) {
+
+			if (gagajf.isNull(fromDate) || gagajf.isNull(toDate)) {
+				mcxDialog.alertC("등록일 조회시 시작일자와 종료일자를 입력하세요.", {
+					sureBtnText: "확인",
+					sureBtnClick: function() {
+						$('#searchForm input[name=stDate]').focus();
+					}
+				});
+				return false;
+			}
+
+			if (fromDate > toDate) {
+				mcxDialog.alertC("등록 시작일자는 종료일자 보다 클 수 없습니다.", {
+					sureBtnText: "확인",
+					sureBtnClick: function() {
+						$('#searchForm input[name=stDate]').focus();
+					}
+				});
+				return false;
+			}
+		}
+		return true;
+	}
+
+	var fnSearchCallBack = function(result){
+
+		$('#searchForm').find('#gridRowTotalCount').html(result.pageing.pageable.totalCount.addComma());
+		$('#searchForm').find('#pageNo').val(result.pageing.pageable.pageNo.addComma());
+		$('#searchForm').find('#pgNo').html(result.pageing.pageable.pageNo.addComma());
+		$('#searchForm').find('#endPgNo').html(result.pageing.pageable.totalPage.addComma());
+		gridOptions.api.setRowData(result.list);
+		gagaPaging.createPagination(result.pageing.pageable);
+
+	}
+	/**************** 검색 // *****************************************************/
 	
 	// 초기화 클릭시
 	$('#btnInit').on('click', function() {
@@ -325,10 +330,10 @@
 	});
 	
 	$(document).ready(function() {
-		cfnCreateCalendar('#terms', 'salesStdt', 'salesEddt', true, '매출');
+		cfnCreateCalendar('#terms', 'stDate', 'edDate', true, '매출');
 		$('.btnToday').trigger('click');
 		
-		$('#extmallVendor').hide();
+		//$('#extmallVendor').hide();
 		
 		// Create a agGrid
 		gagaAgGrid.createGrid('gridList', gridOptions);