Browse Source

정산현황

marseyes 2 years ago
parent
commit
e56aa241d8

+ 20 - 0
src/main/java/com/oqpo/api/mapper/sttlmng/SttlStateMapper.java

@@ -0,0 +1,20 @@
1
+package com.oqpo.api.mapper.sttlmng;
2
+
3
+
4
+import com.oqpo.api.entity.settmng.StlMgntBaseInfoEntity;
5
+import com.oqpo.api.web.dto.request.GridRequest;
6
+import org.apache.ibatis.annotations.Mapper;
7
+import org.apache.ibatis.annotations.Param;
8
+
9
+import java.util.List;
10
+
11
+@Mapper
12
+public interface SttlStateMapper {
13
+
14
+    List<StlMgntBaseInfoEntity> selectSttlStateGridList(@Param("sBrandId") String sBrandId, @Param("sStoreId") String sStoreId, @Param("sItemNm") String sItemNm,
15
+                                                        @Param("sSttlStCd") String sSttlStCd, @Param("fromDt") String fromDt, @Param("toDt") String toDt, GridRequest gridRequest) throws Exception;
16
+
17
+    int selectSttlStateGridCnt(@Param("sBrandId") String sBrandId, @Param("sStoreId") String sStoreId, @Param("sItemNm") String sItemNm,
18
+                               @Param("sSttlStCd") String sSttlStCd, @Param("fromDt") String fromDt, @Param("toDt") String toDt) throws Exception;
19
+
20
+}

+ 2 - 0
src/main/java/com/oqpo/api/service/sttlmng/SttlReqService.java

@@ -261,6 +261,7 @@ public class SttlReqService extends CommonService {
261 261
             StlMgntBaseInfoEntity baseInfo = new StlMgntBaseInfoEntity();
262 262
             baseInfo.setSttlMgntUnqNo(sttlReqProcRequest.getSttlMgntUnqNo());
263 263
             baseInfo.setSttlStCd(SttlStCd.STTL_CONFIRM.getCd());
264
+            baseInfo.setSttlReqDt(sttlReqProcRequest.getSttlReqDt().replace(".", ""));
264 265
             baseInfo.setSttlDt(DateUtil.getCurrentDate());
265 266
             baseInfo.setSttlAmt(sttlAmt);
266 267
             sttlReqMapper.updateStlMgntBaseInfo4SttlReqProc(userId, baseInfo);
@@ -268,6 +269,7 @@ public class SttlReqService extends CommonService {
268 269
             StlMgntBaseInfoEntity baseInfo = new StlMgntBaseInfoEntity();
269 270
             baseInfo.setSttlMgntUnqNo(sttlReqProcRequest.getSttlMgntUnqNo());
270 271
             baseInfo.setSttlStCd(SttlStCd.STTL_REQ.getCd());
272
+            baseInfo.setSttlReqDt(sttlReqProcRequest.getSttlReqDt().replace(".", ""));
271 273
             baseInfo.setSttlDt(null);
272 274
             baseInfo.setSttlAmt(null);
273 275
             sttlReqMapper.updateStlMgntBaseInfo4SttlReqProc(userId, baseInfo);

+ 59 - 0
src/main/java/com/oqpo/api/service/sttlmng/SttlStateService.java

@@ -0,0 +1,59 @@
1
+package com.oqpo.api.service.sttlmng;
2
+
3
+
4
+import com.oqpo.api.entity.settmng.StlMgntBaseInfoEntity;
5
+import com.oqpo.api.mapper.sttlmng.SttlStateMapper;
6
+import com.oqpo.api.service.CommonService;
7
+import com.oqpo.api.web.dto.request.GridRequest;
8
+import com.oqpo.api.web.dto.response.GridResponse;
9
+import com.oqpo.api.web.dto.response.sttlmng.SttlStateGridResponse;
10
+import lombok.extern.slf4j.Slf4j;
11
+import org.springframework.beans.factory.annotation.Autowired;
12
+import org.springframework.stereotype.Service;
13
+
14
+import java.util.List;
15
+import java.util.stream.Collectors;
16
+
17
+@Service
18
+@Slf4j
19
+public class SttlStateService extends CommonService {
20
+
21
+    @Autowired
22
+    private SttlStateMapper sttlStateMapper;
23
+
24
+    /*
25
+      정산요청 그리드 리스트 조회
26
+     */
27
+    public GridResponse selectSttlStateGridList(String sBrandId, String sStoreId, String sItemNm, String sSttlStCd, String fromDt, String toDt, GridRequest gridRequest) throws Exception {
28
+        int gridPage = gridRequest.getGridPage();
29
+        int gridSize = gridRequest.getGridSize();
30
+
31
+        fromDt = fromDt == null ? null : fromDt.replace(".", "");
32
+        toDt = toDt == null ? null : toDt.replace(".", "");
33
+
34
+        int gridRecords = sttlStateMapper.selectSttlStateGridCnt(sBrandId, sStoreId, sItemNm, sSttlStCd, fromDt, toDt);
35
+        int gridTotal = fnCalculateGridTotal(gridSize, gridRecords);
36
+        List<StlMgntBaseInfoEntity> entities = sttlStateMapper.selectSttlStateGridList(sBrandId, sStoreId, sItemNm, sSttlStCd, fromDt, toDt, gridRequest);
37
+        List<Object> gridRows = entities.stream()
38
+                .map(m -> SttlStateGridResponse.builder()
39
+                        .viewCd("R")
40
+                        .sttlMgntUnqNo(m.getSttlMgntUnqNo())        /* 정산관리고유번호 */
41
+                        .brandId(m.getBrandId())
42
+                        .brandNm(m.getBrandNm())
43
+                        .storeId(m.getStoreId())
44
+                        .storeNm(m.getStoreNm())
45
+                        .sttlStCd(m.getSttlStCd())                  /* 정산상태코드 */
46
+                        .sttlStNm(m.getSttlStNm())                  /* 정산상태명 */
47
+                        .sttlReqDt(m.getSttlReqDt())
48
+                        .sttlReqAmt(m.getSttlReqAmt())
49
+                        .sttlDt(m.getSttlDt())
50
+                        .sttlAmt(m.getSttlAmt())
51
+                        .acctBal(m.getAcctBal())
52
+                        .sttlRegMgrId(m.getSttlRegMgrId())
53
+                        .sttlRegMgrNm(m.getSttlRegMgrNm())
54
+                        .build())
55
+                .collect(Collectors.toList());
56
+        return GridResponse.toDTO(gridPage, gridTotal, gridRecords, gridRows);
57
+    }
58
+
59
+}

+ 44 - 0
src/main/java/com/oqpo/api/web/controller/sttlmng/SttlStateController.java

@@ -0,0 +1,44 @@
1
+package com.oqpo.api.web.controller.sttlmng;
2
+
3
+import com.oqpo.api.service.sttlmng.SttlStateService;
4
+import com.oqpo.api.web.dto.request.sttlmng.SttlStateGridRequest;
5
+import com.oqpo.api.web.dto.response.GridResponse;
6
+import io.swagger.annotations.Api;
7
+import io.swagger.annotations.ApiImplicitParam;
8
+import io.swagger.annotations.ApiImplicitParams;
9
+import io.swagger.annotations.ApiOperation;
10
+import lombok.extern.slf4j.Slf4j;
11
+import org.springframework.beans.factory.annotation.Autowired;
12
+import org.springframework.http.ResponseEntity;
13
+import org.springframework.web.bind.annotation.*;
14
+
15
+import javax.validation.Valid;
16
+
17
+@Slf4j
18
+@RestController
19
+@RequestMapping("/api/sttl/state")
20
+@Api(tags = {"정산현황 (SttlStateController)"})
21
+public class SttlStateController {
22
+
23
+    @Autowired
24
+    private SttlStateService sttlStateService;
25
+
26
+    /**
27
+     * 설명 : 정산현황 그리드 리스트
28
+     *
29
+     * @param sttlStateGridRequest
30
+     * @return
31
+     * @throws Exception
32
+     */
33
+    @ApiImplicitParams({
34
+            @ApiImplicitParam(name = "X-AUTH-TOKEN", value = "CONN-KEY", required = true, dataType = "String", paramType = "header")
35
+    })
36
+    @ApiOperation(value = "정산현황 그리드 리스트")
37
+    @PostMapping("/detail-grid-list")
38
+    public ResponseEntity<GridResponse> detailGridList(@RequestBody @Valid SttlStateGridRequest sttlStateGridRequest) throws Exception {
39
+        return ResponseEntity.ok(sttlStateService.selectSttlStateGridList(sttlStateGridRequest.getSBrandId(), sttlStateGridRequest.getSStoreId(),
40
+                sttlStateGridRequest.getSItemNm(), sttlStateGridRequest.getSSttlStCd(),
41
+                sttlStateGridRequest.getFromDt(), sttlStateGridRequest.getToDt(), sttlStateGridRequest.toDTO(sttlStateGridRequest)));
42
+    }
43
+
44
+}

+ 29 - 0
src/main/java/com/oqpo/api/web/dto/request/sttlmng/SttlStateGridRequest.java

@@ -0,0 +1,29 @@
1
+package com.oqpo.api.web.dto.request.sttlmng;
2
+
3
+import com.oqpo.api.web.dto.request.GridRequest;
4
+import io.swagger.annotations.ApiModelProperty;
5
+import lombok.Getter;
6
+import lombok.Setter;
7
+
8
+
9
+@Getter
10
+@Setter
11
+public class SttlStateGridRequest extends GridRequest {
12
+
13
+    @ApiModelProperty(value = "브랜드아이디")
14
+    private String sBrandId;
15
+    @ApiModelProperty(value = "매장아이디")
16
+    private String sStoreId;
17
+    @ApiModelProperty(value = "품목명")
18
+    private String sItemNm;
19
+    @ApiModelProperty(value = "정산상태코드")
20
+    private String sSttlStCd;
21
+    @ApiModelProperty(value = "조회시작일자")
22
+    private String fromDt;
23
+    @ApiModelProperty(value = "조회종료일자")
24
+    private String toDt;
25
+
26
+    protected SttlStateGridRequest(Integer gridSize, Integer gridPage, String sidx, String sord, Boolean pagingYn, Integer gridFirst) {
27
+        super(gridSize, gridPage, sidx, sord, pagingYn, gridFirst);
28
+    }
29
+}

+ 48 - 0
src/main/java/com/oqpo/api/web/dto/response/sttlmng/SttlStateGridResponse.java

@@ -0,0 +1,48 @@
1
+package com.oqpo.api.web.dto.response.sttlmng;
2
+
3
+import com.fasterxml.jackson.annotation.JsonInclude;
4
+import io.swagger.annotations.ApiModelProperty;
5
+import lombok.*;
6
+
7
+
8
+@Getter
9
+@Setter
10
+@Builder
11
+@AllArgsConstructor(access = AccessLevel.PROTECTED)
12
+@JsonInclude(JsonInclude.Include.ALWAYS)
13
+public class SttlStateGridResponse {
14
+
15
+    @ApiModelProperty(value = "CRUD")
16
+    private String viewCd;
17
+
18
+    @ApiModelProperty(value = "정산관리고유번호")
19
+    private String sttlMgntUnqNo;
20
+    @ApiModelProperty(value = "브랜드아이디")
21
+    private String brandId;
22
+    @ApiModelProperty(value = "브랜드명")
23
+    private String brandNm;
24
+    @ApiModelProperty(value = "매장아이디")
25
+    private String storeId;
26
+    @ApiModelProperty(value = "매장명")
27
+    private String storeNm;
28
+    @ApiModelProperty(value = "정산상태코드")
29
+    private String sttlStCd;
30
+    @ApiModelProperty(value = "정산상태명")
31
+    private String sttlStNm;
32
+    @ApiModelProperty(value = "정산요청일자")
33
+    private String sttlReqDt;
34
+    @ApiModelProperty(value = "정산요청금액")
35
+    private Long sttlReqAmt;
36
+    @ApiModelProperty(value = "정산일자")
37
+    private String sttlDt;
38
+    @ApiModelProperty(value = "정산금액")
39
+    private Long sttlAmt;
40
+    @ApiModelProperty(value = "계좌잔액")
41
+    private Long acctBal;
42
+
43
+    @ApiModelProperty(value = "정산등록담당자아이디")
44
+    private String sttlRegMgrId;
45
+    @ApiModelProperty(value = "정산등록담당자명")
46
+    private String sttlRegMgrNm;
47
+
48
+}

+ 1 - 0
src/main/resources/mybatis/sqlmaps/sttlmng/SttlReq.xml

@@ -372,6 +372,7 @@
372 372
     <update id="updateStlMgntBaseInfo4SttlReqProc" >
373 373
         /* SttlReqMapper.updateStlMgntBaseInfo4SttlReqProc */
374 374
         UPDATE stl_mgnt_base_info SET
375
+            sttl_req_dt = #{entity.sttlReqDt},
375 376
             sttl_st_cd = #{entity.sttlStCd},
376 377
             <if test="entity.sttlDt != null and entity.sttlDt != ''">
377 378
             sttl_dt = #{entity.sttlDt},

+ 64 - 0
src/main/resources/mybatis/sqlmaps/sttlmng/SttlState.xml

@@ -0,0 +1,64 @@
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
+
4
+<mapper namespace="com.oqpo.api.mapper.sttlmng.SttlStateMapper">
5
+
6
+    <select id="selectSttlStateGridList" resultType="com.oqpo.api.entity.settmng.StlMgntBaseInfoEntity">
7
+        /* SttlStateMapper.selectSttlStateGridList */
8
+        SELECT A.sttl_mgnt_unq_no,
9
+            DATE_FORMAT(A.sttl_req_dt, '%Y.%m.%d') AS sttl_req_dt,
10
+            A.brand_id, FN_BRAND_NM(A.brand_id) AS brand_nm,
11
+            A.store_id, FN_STORE_NM(A.brand_id, A.store_id) AS store_nm,
12
+            A.sttl_st_cd, FN_CODE_NM('STTL_ST_CD', A.sttl_st_cd) AS sttl_st_nm,
13
+            A.sttl_req_amt,
14
+            DATE_FORMAT(A.sttl_dt, '%Y.%m.%d') AS sttl_dt, A.sttl_amt, A.sttl_reg_mgr_nm, A.sttl_reg_mgr_id
15
+        FROM stl_mgnt_base_info A
16
+        WHERE A.brand_id = #{sBrandId}
17
+        AND A.sttl_req_dt BETWEEN #{fromDt} AND #{toDt}
18
+        <if test="sStoreId != null and sStoreId != ''">
19
+            AND A.store_id = #{sStoreId}
20
+        </if>
21
+        <if test="sSttlStCd != null and sSttlStCd != ''">
22
+            AND A.sttl_st_cd = #{sSttlStCd}
23
+        </if>
24
+        <if test="sItemNm != null and sItemNm != ''">
25
+            AND A.item_nm LIKE CONCAT('%',#{sItemNm},'%')
26
+        </if>
27
+        <choose>
28
+            <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
29
+                <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
30
+                    <if test="gridRequest.sord == 'asc'.toString()">
31
+                        ORDER BY A.sttl_mgnt_unq_no ASC
32
+                    </if>
33
+                    <if test="gridRequest.sord == 'desc'.toString()">
34
+                        ORDER BY A.sttl_mgnt_unq_no DESC
35
+                    </if>
36
+                </if>
37
+            </when>
38
+            <otherwise>
39
+                ORDER BY A.sttl_mgnt_unq_no ASC
40
+            </otherwise>
41
+        </choose>
42
+        <if test="gridRequest.pagingYn == true">
43
+            limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
44
+        </if>
45
+    </select>
46
+
47
+    <select id="selectSttlStateGridCnt" resultType="int">
48
+        /* SttlStateMapper.selectSttlStateGridCnt */
49
+        SELECT COUNT(*)
50
+        FROM stl_mgnt_base_info A
51
+        WHERE A.brand_id = #{sBrandId}
52
+        AND A.sttl_req_dt BETWEEN #{fromDt} AND #{toDt}
53
+        <if test="sStoreId != null and sStoreId != ''">
54
+            AND A.store_id = #{sStoreId}
55
+        </if>
56
+        <if test="sSttlStCd != null and sSttlStCd != ''">
57
+            AND A.sttl_st_cd = #{sSttlStCd}
58
+        </if>
59
+        <if test="sItemNm != null and sItemNm != ''">
60
+            AND A.item_nm LIKE CONCAT('%',#{sItemNm},'%')
61
+        </if>
62
+    </select>
63
+
64
+</mapper>