瀏覽代碼

사은품관리 화면에 "재고수량" 칼럼 추가. 재고수량 가져오는 데이터 분석 쿼리문 정리 및 수정

gagamel 4 年之前
父節點
當前提交
a283a2425f

+ 3 - 0
src/main/java/com/style24/persistence/domain/FreeGoods.java

@@ -30,4 +30,7 @@ public class FreeGoods extends TscBaseDomain {
 	private String skucode;  
 	private String skumodelno; 
 	
+	private int limitQty;			// 한정수량(=재고)
+	private int leftQty;			// 남은수량
+	
 }

+ 108 - 89
src/main/java/com/style24/persistence/mybatis/shop/TsaGoods.xml

@@ -4000,95 +4000,114 @@
 	<!-- 사은품 목록 -->
 	<select id="getFreeGoodsList" parameterType="GoodsSearch" resultType="FreeGoods">
 		/* TsaGoods.getFreeGoodsList */
-		SELECT G.* FROM (
-			SELECT G.PRODUCT_NO
-			     , G.PRODUCT_CODE
-			     , G.GOODS_NM
-			     , G.USE_YN
-			     , G.SYS_IMG_NM
-			     , G.BRAND_CD
-			     , B.BRAND_ENM
-			     , FN_GET_USER_NM(G.REG_NO) AS REG_NM
-			     , DATE_FORMAT(G.REG_DT,'%Y%m%d%H%i%S') AS REG_DT
-			     , FN_GET_USER_NM(G.UPD_NO) AS UPD_NM
-			     , DATE_FORMAT(G.UPD_DT,'%Y%m%d%H%i%S') AS UPD_DT
-			     , (SELECT MAX(SKUCODE) FROM TB_IF_INCOMELOTITEM INC WHERE INC.PRODUCTNO = G.PRODUCT_NO ) AS SKUCODE
-			     , (SELECT MAX(SKUMODELNO) FROM TB_IF_INCOMELOTITEM INC WHERE INC.PRODUCTNO = G.PRODUCT_NO ) AS SKUMODELNO
-			FROM TB_FREE_GOODS G
-			INNER JOIN TB_BRAND B ON G.BRAND_CD = B.BRAND_CD
-			INNER JOIN TB_BRAND_SUPPLY BS ON G.BRAND_CD = BS.BRAND_CD
-			WHERE 1 = 1
-			<if test='conditionList != null and conditionList.length>0'>
-			    <choose>
-			      <when test='search != null and search == "searchProductNo"'>
-			AND (
-			      <foreach collection="conditionList" item="item" index="index" separator="or">
-			       G.PRODUCT_NO = #{item}
-			      </foreach>
-			     )
-			      </when>
-			      <when test='search != null and search == "searchGoodsNm"'>
-			AND (
-			      <foreach collection="conditionList" item="item" index="index" separator="or">
-			       UPPER(G.GOODS_NM) LIKE CONCAT(UPPER(#{item}),'%')
-			      </foreach>
-			     )
-			      </when>
-			      <when test='search != null and search == "searchProductCode"'>
-			AND (
-			      <foreach collection="conditionList" item="item" index="index" separator="or">
-			       UPPER(G.PRODUCT_CODE) LIKE CONCAT(UPPER(#{item}),'%')
-			      </foreach>
-			     )
-			      </when>
-			      <otherwise>
-			AND 1 = 1
-			      </otherwise>
-			    </choose>
-			</if>
-			<if test="supplyCompCd != null and supplyCompCd != ''">
-			AND BS.SUPPLY_COMP_CD = #{supplyCompCd}
-			</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>
-			<if test='dateGbn != null and dateGbn == "R"'>
-			    <if test="stDate != null and stDate != ''">
-			AND G.REG_DT >= DATE_FORMAT(#{stDate}, '%Y-%m-%d %H:%i:%S')
-			    </if>
-			    <if test="edDate != null and edDate != ''">
-			    <![CDATA[
-			AND G.REG_DT < DATE_FORMAT(DATE_ADD(#{edDate}, INTERVAL 1 DAY), '%Y-%m-%d %H:%i:%S')
-			    ]]>
-			    </if>
-			</if>
-		) G
-		WHERE 1=1
-			<if test='conditionList != null and conditionList.length>0'>
-			    <choose>
-			      <when test='search != null and search == "searchSkucode"'>
-			AND (
-			      <foreach collection="conditionList" item="item" index="index" separator="or">
-			       G.SKUCODE = #{item}
-			      </foreach>
-			     )
-			      </when>
-			      <when test='search != null and search == "searchSkumodelno"'>
-			AND (
-			      <foreach collection="conditionList" item="item" index="index" separator="or">
-			       UPPER(G.SKUMODELNO) LIKE CONCAT(UPPER(#{item}),'%')
-			      </foreach>
-			     )
-			      </when>
-			      <otherwise>
-			AND 1 = 1
-			      </otherwise>
-			    </choose>
-			</if>
-		ORDER BY G.PRODUCT_NO DESC
+		SELECT G.SYS_IMG_NM
+		     , G.BRAND_CD
+		     , G.BRAND_ENM
+		     , G.PRODUCT_NO
+		     , G.PRODUCT_CODE
+		     , MAX(G.SKUCODE)              AS SKUCODE
+		     , G.GOODS_NM
+		     , MAX(G.SKUMODELNO)           AS SKUMODELNO
+		     , IFNULL(SUM(FV.LIMIT_QTY),0) AS LIMIT_QTY  /*한정수량(=재고)*/
+		     , IFNULL(SUM(FV.LEFT_QTY),0)  AS LEFT_QTY   /*남은수량*/
+		     , G.USE_YN
+		     , G.REG_NM
+		     , G.REG_DT
+		     , G.UPD_NM
+		     , G.UPD_DT
+		FROM   (
+		        SELECT G.SYS_IMG_NM                                    /*시스템이미지명*/
+		             , G.BRAND_CD                                      /*브랜드코드*/
+		             , B.BRAND_ENM                                     /*브랜드영문명*/
+		             , G.PRODUCT_NO                                    /*WMS상품번호*/
+		             , G.PRODUCT_CODE                                  /*WMS상품코드*/
+		             , INC.SKUCODE                                     /*옵션번호*/
+		             , G.GOODS_NM                                      /*상품명(=사은품명)*/
+		             , INC.SKUMODELNO                                  /*옵션모델번호*/
+		             , G.USE_YN                                        /*사용여부*/
+		             , FN_GET_USER_NM(G.REG_NO)              AS REG_NM /*등록자명*/
+		             , DATE_FORMAT(G.REG_DT,'%Y%m%d%H%i%S')  AS REG_DT /*등록일시*/
+		             , FN_GET_USER_NM(G.UPD_NO)              AS UPD_NM /*수정자명*/
+		             , DATE_FORMAT(G.UPD_DT,'%Y%m%d%H%i%S')  AS UPD_DT /*수정일시*/
+		        FROM   TB_FREE_GOODS G
+		        INNER JOIN TB_BRAND B ON G.BRAND_CD = B.BRAND_CD
+		        INNER JOIN TB_BRAND_SUPPLY BS ON G.BRAND_CD = BS.BRAND_CD
+		        LEFT OUTER JOIN TB_IF_INCOMELOTITEM INC ON G.PRODUCT_NO = INC.PRODUCTNO
+		        WHERE 1 = 1
+		        <if test='conditionList != null and conditionList.length > 0'>
+		            <choose>
+		                <when test='search != null and search == "searchProductNo"'> <!-- WMS상품번호 -->
+		        AND    (
+		                    <foreach collection="conditionList" item="item" index="index" separator="or">
+		                    G.PRODUCT_NO = #{item}
+		                    </foreach>
+		               )
+		                </when>
+		                <when test='search != null and search == "searchGoodsNm"'> <!-- 사은품명 -->
+		        AND    (
+		                    <foreach collection="conditionList" item="item" index="index" separator="or">
+		                    UPPER(G.GOODS_NM) LIKE CONCAT(UPPER(#{item}),'%')
+		                    </foreach>
+		               )
+		                </when>
+		                <when test='search != null and search == "searchProductCode"'> <!-- WMS상품코드 -->
+		        AND    (
+		                    <foreach collection="conditionList" item="item" index="index" separator="or">
+		                    UPPER(G.PRODUCT_CODE) LIKE CONCAT(UPPER(#{item}),'%')
+		                    </foreach>
+		               )
+		                </when>
+		                <when test='search != null and search == "searchSkucode"'> <!-- SKUCODE -->
+		        AND    (
+		                    <foreach collection="conditionList" item="item" index="index" separator="or">
+		                    INC.SKUCODE = #{item}
+		                    </foreach>
+		               )
+		                </when>
+		                <when test='search != null and search == "searchSkumodelno"'> <!-- SKUMODELNO -->
+		        AND    (
+		                    <foreach collection="conditionList" item="item" index="index" separator="or">
+		                    UPPER(INC.SKUMODELNO) LIKE CONCAT(UPPER(#{item}),'%')
+		                    </foreach>
+		               )
+		                </when>
+		                <otherwise>
+		        AND    1 = 1
+		                </otherwise>
+		            </choose>
+		        </if>
+		        <if test="supplyCompCd != null and supplyCompCd != ''">
+		        AND    BS.SUPPLY_COMP_CD = #{supplyCompCd}
+		        </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>
+		        <if test='dateGbn != null and dateGbn == "R"'>
+		            <if test="stDate != null and stDate != ''">
+		        AND    G.REG_DT >= STR_TO_DATE(#{stDate},'%Y-%m-%d %H:%i:%S')
+		            </if>
+		            <if test="edDate != null and edDate != ''">
+		        AND    G.REG_DT <![CDATA[<]]> STR_TO_DATE(DATE_ADD(#{edDate},INTERVAL 1 DAY),'%Y-%m-%d %H:%i:%S')
+		            </if>
+		        </if>
+		       ) G
+		LEFT OUTER JOIN TB_FREEGIFT_VAL FV ON G.PRODUCT_NO = FV.PRODUCT_NO
+		WHERE  1 = 1
+		GROUP  BY G.SYS_IMG_NM
+		        , G.BRAND_CD
+		        , G.BRAND_ENM
+		        , G.PRODUCT_NO
+		        , G.PRODUCT_CODE
+		        , G.GOODS_NM
+		        , G.USE_YN
+		        , G.REG_NM
+		        , G.REG_DT
+		        , G.UPD_NM
+		        , G.UPD_DT
+		ORDER  BY G.PRODUCT_NO DESC
 	</select>
 
 	<!-- 상품이미지 변경 -->

+ 10 - 3
src/main/webapp/WEB-INF/views/goods/GoodsFreeGoodsForm.html

@@ -164,9 +164,16 @@
 		},
 		{headerName: "WMS상품코드", field: "productCode", width: 100, cellClass: 'text-center'},
 		{headerName: "SKUCODE", field: "skucode", width: 90, cellClass: 'text-center'},		
- 		{headerName: "사은품명", field: "goodsNm", width: 300, cellClass: 'text-left'},
- 		{headerName: "SKUMODELNO", field: "skumodelno", width: 100, cellClass: 'text-left'},
-
+		{headerName: "사은품명", field: "goodsNm", width: 300, cellClass: 'text-left'},
+		{headerName: "SKUMODELNO", field: "skumodelno", width: 100, cellClass: 'text-left'},
+		{
+			headerName: "재고수량", field: "limitQty", width: 100, cellClass: 'text-center',
+			cellRenderer: function(params) { return gagaAgGrid.toAddComma(params.value) }
+		},
+// 		{
+// 			headerName: "남은수량", field: "leftQty", width: 100, cellClass: 'text-center',
+// 			cellRenderer: function(params) { return gagaAgGrid.toAddComma(params.value) }
+// 		},
 		{headerName: "사용여부", field: "useYn", width: 100, cellClass: 'text-center'},
 		{headerName: "등록일자", field: "regDt", width: 150, cellClass: 'text-center',
 			cellRenderer: function(params) {