From 05683f2b2bdbdbe21cf17ad523c21ab338bd1c54 Mon Sep 17 00:00:00 2001
From: wuxw <928255095@qq.com>
Date: 星期二, 19 七月 2022 21:49:55 +0800
Subject: [PATCH] 优化添加设备 功能

---
 service-acct/src/main/java/com/java110/acct/api/AccountApi.java |  168 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 160 insertions(+), 8 deletions(-)

diff --git a/service-acct/src/main/java/com/java110/acct/api/AccountApi.java b/service-acct/src/main/java/com/java110/acct/api/AccountApi.java
index abae1f3..2df6b46 100644
--- a/service-acct/src/main/java/com/java110/acct/api/AccountApi.java
+++ b/service-acct/src/main/java/com/java110/acct/api/AccountApi.java
@@ -1,15 +1,25 @@
 package com.java110.acct.api;
 
+import com.alibaba.fastjson.JSONObject;
 import com.java110.acct.bmo.account.IGetAccountBMO;
+import com.java110.acct.bmo.account.IOwnerPrestoreAccountBMO;
 import com.java110.dto.account.AccountDto;
-import com.java110.dto.shopVipAccountDetail.ShopVipAccountDetailDto;
+import com.java110.dto.accountDetail.AccountDetailDto;
+import com.java110.dto.fee.FeeDto;
+import com.java110.dto.owner.OwnerCarDto;
+import com.java110.dto.owner.OwnerDto;
+import com.java110.dto.owner.OwnerRoomRelDto;
+import com.java110.intf.fee.IFeeInnerServiceSMO;
+import com.java110.intf.user.IOwnerCarInnerServiceSMO;
+import com.java110.intf.user.IOwnerRoomRelInnerServiceSMO;
+import com.java110.po.accountDetail.AccountDetailPo;
+import com.java110.utils.util.Assert;
+import com.java110.utils.util.StringUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.RequestHeader;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
 
 /**
  * @ClassName AccountApi
@@ -26,6 +36,19 @@
 
     @Autowired
     private IGetAccountBMO getAccountBMOImpl;
+
+    @Autowired
+    private IOwnerPrestoreAccountBMO ownerPrestoreAccountBMOImpl;
+
+    @Autowired
+    private IFeeInnerServiceSMO feeInnerServiceSMOImpl;
+
+    @Autowired
+    private IOwnerRoomRelInnerServiceSMO ownerRoomRelInnerServiceSMOImpl;
+
+    @Autowired
+    private IOwnerCarInnerServiceSMO ownerCarInnerServiceSMOImpl;
+
     /**
      * 寰俊鍒犻櫎娑堟伅妯℃澘
      *
@@ -36,12 +59,141 @@
      */
     @RequestMapping(value = "/queryAccount", method = RequestMethod.GET)
     public ResponseEntity<String> queryAccount(@RequestHeader(value = "store-id", required = false) String storeId,
-                                                            @RequestParam(value = "page") int page,
-                                                            @RequestParam(value = "row") int row) {
+                                               @RequestParam(value = "page") int page,
+                                               @RequestParam(value = "row") int row) {
         AccountDto accountDto = new AccountDto();
         accountDto.setPage(page);
         accountDto.setRow(row);
         accountDto.setObjId(storeId);
         return getAccountBMOImpl.get(accountDto);
     }
+
+    /**
+     * 鏌ヨ涓氫富璐︽埛
+     *
+     * @param communityId 灏忓尯ID
+     * @return
+     * @serviceCode /account/queryOwnerAccount
+     * @path /app/account/queryOwnerAccount
+     */
+    @RequestMapping(value = "/queryOwnerAccount", method = RequestMethod.GET)
+    public ResponseEntity<String> queryOwnerAccount(
+            @RequestParam(value = "communityId") String communityId,
+            @RequestParam(value = "ownerId", required = false) String ownerId,
+            @RequestParam(value = "ownerName", required = false) String ownerName,
+            @RequestParam(value = "feeId", required = false) String feeId,
+            @RequestParam(value = "link", required = false) String link,
+            @RequestParam(value = "idCard", required = false) String idCard,
+            @RequestParam(value = "acctType", required = false) String acctType,
+            @RequestParam(value = "page") int page,
+            @RequestParam(value = "row") int row) {
+        AccountDto accountDto = new AccountDto();
+        accountDto.setPage(page);
+        accountDto.setRow(row);
+        if (!StringUtil.isEmpty(feeId)) {
+            FeeDto feeDto = new FeeDto();
+            feeDto.setFeeId(feeId);
+            List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto);
+            Assert.listOnlyOne(feeDtos, "鏌ヨ璐圭敤淇℃伅閿欒锛�");
+            //鑾峰彇浠樿垂瀵硅薄绫诲瀷(3333 鎴垮眿 6666 鏄溅浣�)
+            String payerObjType = feeDtos.get(0).getPayerObjType();
+            //鑾峰彇浠樿垂瀵硅薄id
+            String payerObjId = feeDtos.get(0).getPayerObjId();
+            if (FeeDto.PAYER_OBJ_TYPE_ROOM.equals(payerObjType)) { //鎴垮眿
+                OwnerRoomRelDto ownerRoomRelDto = new OwnerRoomRelDto();
+                ownerRoomRelDto.setRoomId(payerObjId);
+                List<OwnerRoomRelDto> ownerRoomRelDtos = ownerRoomRelInnerServiceSMOImpl.queryOwnerRoomRels(ownerRoomRelDto);
+                Assert.listOnlyOne(ownerRoomRelDtos, "鏌ヨ涓氫富鎴垮眿鍏崇郴琛ㄩ敊璇紒");
+                ownerId = ownerRoomRelDtos.get(0).getOwnerId();
+            } else if (FeeDto.PAYER_OBJ_TYPE_CAR.equals(payerObjType)) {
+                OwnerCarDto ownerCarDto = new OwnerCarDto();
+                ownerCarDto.setCarId(payerObjId);
+                List<OwnerCarDto> ownerCarDtos = ownerCarInnerServiceSMOImpl.queryOwnerCars(ownerCarDto);
+//                Assert.listOnlyOne(ownerCarDtos, "鏌ヨ涓氫富杞﹁締鍏崇郴琛ㄩ敊璇紒");
+                ownerId = ownerCarDtos.get(0).getOwnerId();
+            } else {
+                ownerId = "-1";
+            }
+            accountDto.setObjId(ownerId);
+        } else {
+            accountDto.setObjId(ownerId);
+        }
+        accountDto.setObjType(AccountDto.OBJ_TYPE_PERSON);
+        accountDto.setAcctName(ownerName);
+        accountDto.setPartId(communityId);
+        accountDto.setAcctType(acctType);
+        OwnerDto ownerDto = new OwnerDto();
+        ownerDto.setOwnerId(ownerId);
+        ownerDto.setCommunityId(communityId);
+        ownerDto.setLink(link);
+        ownerDto.setIdCard(idCard);
+        return getAccountBMOImpl.queryOwnerAccount(accountDto, ownerDto);
+    }
+
+    /**
+     * 鏌ヨ涓氫富璐︽埛鏄庣粏
+     *
+     * @param objId 灏忓尯ID
+     * @return
+     * @serviceCode /account/queryOwnerAccountDetail
+     * @path /app/account/queryOwnerAccountDetail
+     */
+    @RequestMapping(value = "/queryOwnerAccountDetail", method = RequestMethod.GET)
+    public ResponseEntity<String> queryOwnerAccountDetail(@RequestParam(value = "objId", required = false) String objId,
+                                                          @RequestParam(value = "acctId", required = false) String acctId,
+                                                          @RequestParam(value = "page") int page,
+                                                          @RequestParam(value = "row") int row) {
+        AccountDetailDto accountDto = new AccountDetailDto();
+        accountDto.setPage(page);
+        accountDto.setRow(row);
+        accountDto.setObjId(objId);
+        accountDto.setAcctId(acctId);
+        return getAccountBMOImpl.getDetail(accountDto);
+    }
+
+    /**
+     * 鏌ヨ璐︽埛鏄庣粏
+     *
+     * @param storeId 灏忓尯ID
+     * @return
+     * @serviceCode /account/queryAccountDetail
+     * @path /app/account/queryAccountDetail
+     */
+    @RequestMapping(value = "/queryAccountDetail", method = RequestMethod.GET)
+    public ResponseEntity<String> queryAccountDetail(@RequestHeader(value = "store-id", required = false) String storeId,
+                                                     @RequestParam(value = "acctId", required = false) String acctId,
+                                                     @RequestParam(value = "detailType", required = false) String detailType,
+                                                     @RequestParam(value = "orderId", required = false) String orderId,
+                                                     @RequestParam(value = "page") int page,
+                                                     @RequestParam(value = "row") int row) {
+        AccountDetailDto accountDto = new AccountDetailDto();
+        accountDto.setPage(page);
+        accountDto.setRow(row);
+        accountDto.setObjId(storeId);
+        accountDto.setAcctId(acctId);
+        accountDto.setDetailType(detailType);
+        accountDto.setOrderId(orderId);
+        return getAccountBMOImpl.getDetail(accountDto);
+    }
+
+    /**
+     * 涓氫富璐︽埛棰勫瓨
+     *
+     * @param reqJson 灏忓尯ID
+     * @return
+     * @serviceCode /account/ownerPrestoreAccount
+     * @path /app/account/ownerPrestoreAccount
+     */
+    @RequestMapping(value = "/ownerPrestoreAccount", method = RequestMethod.POST)
+    public ResponseEntity<String> queryAccountDetail(@RequestBody JSONObject reqJson) {
+        Assert.hasKeyAndValue(reqJson, "communityId", "灏忓尯ID涓嶈兘涓虹┖");
+        Assert.hasKeyAndValue(reqJson, "ownerId", "涓氫富涓嶈兘涓虹┖");
+        Assert.hasKeyAndValue(reqJson, "amount", "閲戦涓嶈兘涓虹┖");
+        Assert.hasKeyAndValue(reqJson, "acctType", "璐︽埛绫诲瀷涓嶈兘涓虹┖");
+        AccountDetailPo accountDetailPo = new AccountDetailPo();
+        accountDetailPo.setRemark(reqJson.getString("remark"));
+        accountDetailPo.setObjId(reqJson.getString("ownerId"));
+        accountDetailPo.setAmount(reqJson.getString("amount"));
+        return ownerPrestoreAccountBMOImpl.prestore(accountDetailPo, reqJson);
+    }
 }

--
Gitblit v1.8.0