Explorar o código

优化欠费缴费 账户扣款

wuxw %!s(int64=2) %!d(string=hai) anos
pai
achega
240deec0ac

+ 54 - 0
service-acct/src/main/java/com/java110/acct/payment/business/oweFee/OweFeePaymentBusiness.java

@@ -9,16 +9,21 @@ import com.java110.core.factory.CommunitySettingFactory;
 import com.java110.core.factory.GenerateCodeFactory;
 import com.java110.core.log.LoggerFactory;
 import com.java110.core.smo.IComputeFeeSMO;
+import com.java110.dto.account.AccountDto;
 import com.java110.dto.community.CommunityDto;
 import com.java110.dto.fee.FeeAttrDto;
 import com.java110.dto.fee.FeeDto;
+import com.java110.dto.owner.OwnerDto;
 import com.java110.dto.payment.PaymentOrderDto;
+import com.java110.intf.acct.IAccountInnerServiceSMO;
 import com.java110.intf.community.ICommunityV1InnerServiceSMO;
 import com.java110.intf.fee.IFeeInnerServiceSMO;
+import com.java110.intf.user.IOwnerV1InnerServiceSMO;
 import com.java110.utils.cache.CommonCache;
 import com.java110.utils.cache.MappingCache;
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.DateUtil;
+import com.java110.utils.util.ListUtil;
 import com.java110.utils.util.StringUtil;
 import org.slf4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -61,6 +66,12 @@ public class OweFeePaymentBusiness implements IPaymentBusiness {
     @Autowired
     private ICommunityV1InnerServiceSMO communityV1InnerServiceSMOImpl;
 
+    @Autowired
+    private IAccountInnerServiceSMO accountInnerServiceSMOImpl;
+
+    @Autowired
+    private IOwnerV1InnerServiceSMO ownerV1InnerServiceSMOImpl;
+
 
     @Override
     public PaymentOrderDto unified(ICmdDataFlowContext context, JSONObject reqJson) {
@@ -128,6 +139,9 @@ public class OweFeePaymentBusiness implements IPaymentBusiness {
 
         money = tmpMoney.setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
 
+        //todo 支持账户扣款
+        money = ifHasAccount(reqJson, money);
+
         PaymentOrderDto paymentOrderDto = new PaymentOrderDto();
         paymentOrderDto.setOrderId(orderId);
         paymentOrderDto.setMoney(money);
@@ -140,10 +154,15 @@ public class OweFeePaymentBusiness implements IPaymentBusiness {
         saveFees.put("roomId", roomId);
         saveFees.put("communityId", reqJson.getString("communityId"));
         saveFees.put("fees", tmpFeeDtos);
+        if (reqJson.containsKey("acctId")) {
+            saveFees.put("accountAmount", reqJson.getDoubleValue("accountAmount"));
+            saveFees.put("acctId", reqJson.getString("acctId"));
+        }
         CommonCache.setValue(FeeDto.REDIS_PAY_OWE_FEE + orderId, saveFees.toJSONString(), CommonCache.PAY_DEFAULT_EXPIRE_TIME);
         return paymentOrderDto;
     }
 
+
     /**
      * 判断是否是 选择的费用交费
      *
@@ -223,4 +242,39 @@ public class OweFeePaymentBusiness implements IPaymentBusiness {
 
         return communityDtos.get(0).getName() + "-" + feeDto.getFeeName();
     }
+
+    private double ifHasAccount(JSONObject reqJson, double money) {
+
+        if (!reqJson.containsKey("acctId")) {
+            return money;
+        }
+
+        String acctId = reqJson.getString("acctId");
+
+        if (StringUtil.isEmpty(acctId)) {
+            return money;
+        }
+
+        AccountDto accountDto = new AccountDto();
+        accountDto.setAcctId(acctId);
+        accountDto.setAcctType(AccountDto.ACCT_TYPE_CASH);
+        List<AccountDto> accountDtos = accountInnerServiceSMOImpl.queryAccounts(accountDto);
+
+        if (ListUtil.isNull(accountDtos)) {
+            return money;
+        }
+
+        Double acctAmount = Double.parseDouble(accountDtos.get(0).getAmount());
+        if (acctAmount >= money) {
+            reqJson.put("accountAmount", money);
+            return 0.00;
+        }
+
+        reqJson.put("accountAmount", acctAmount.doubleValue());
+
+        BigDecimal accountAmountDec = new BigDecimal(acctAmount);
+        accountAmountDec = new BigDecimal(money).subtract(accountAmountDec).setScale(2, BigDecimal.ROUND_HALF_UP);
+        return accountAmountDec.doubleValue();
+    }
+
 }

+ 1 - 1
service-acct/src/main/java/com/java110/acct/smo/impl/AccountInnerServiceSMOImpl.java

@@ -210,7 +210,7 @@ public class AccountInnerServiceSMOImpl extends BaseServiceSMO implements IAccou
                 throw new IllegalArgumentException("余额不足");
             }
             AccountPo accountPo = new AccountPo();
-            accountPo.setObjId(accountDetailPo.getObjId());
+            accountPo.setObjId(accounts.get(0).getObjId());
             accountPo.setAcctId(accountDetailPo.getAcctId());
             accountPo.setAmount(amount + "");
             flag = accountServiceDaoImpl.updateAccount(BeanConvertUtil.beanCovertMap(accountPo));

+ 5 - 113
service-fee/src/main/java/com/java110/fee/bmo/fee/IFeeBMO.java

@@ -25,72 +25,7 @@ import java.util.List;
  **/
 public interface IFeeBMO extends IApiBaseBMO {
 
-    /**
-     * 添加小区信息
-     *
-     * @param paramInJson     接口调用放传入入参
-     * @param dataFlowContext 数据上下文
-     * @return 订单服务能够接受的报文
-     */
-    public void deleteFeeConfig(JSONObject paramInJson, DataFlowContext dataFlowContext);
-
-    /**
-     * 添加物业费用
-     *
-     * @param paramInJson     接口调用放传入入参
-     * @param dataFlowContext 数据上下文
-     * @return 订单服务能够接受的报文
-     */
-    public void deleteFee(JSONObject paramInJson, DataFlowContext dataFlowContext);
-
-    public void updateFee(JSONObject paramInJson, DataFlowContext dataFlowContext);
-
-    /**
-     * 修改费用信息
-     *
-     * @param paramInJson     接口调用放传入入参
-     * @param dataFlowContext 数据上下文
-     * @return 订单服务能够接受的报文
-     */
-    public JSONObject modifyFee(JSONObject paramInJson, DataFlowContext dataFlowContext);
-
-
-    /**
-     * 修改费用信息
-     *
-     * @param paramInJson     接口调用放传入入参
-     * @param dataFlowContext 数据上下文
-     * @return 订单服务能够接受的报文
-     */
-    public JSONObject modifyOweFee(JSONObject paramInJson, DataFlowContext dataFlowContext);
-    /**
-     * 添加费用明细信息
-     *
-     * @param paramInJson     接口调用放传入入参
-     * @param dataFlowContext 数据上下文
-     * @return 订单服务能够接受的报文
-     */
-    public JSONObject addFeeDetail(JSONObject paramInJson, DataFlowContext dataFlowContext, FeeReceiptDetailPo feeReceiptDetailPo, FeeReceiptPo feeReceiptPo);
-
-    /**
-     * 添加费用明细信息
-     *
-     * @param paramInJson     接口调用放传入入参
-     * @param dataFlowContext 数据上下文
-     * @return 订单服务能够接受的报文
-     */
-    public JSONObject addOweFeeDetail(JSONObject paramInJson, DataFlowContext dataFlowContext,
-                                      List<FeeReceiptDetailPo> feeReceiptDetailPos,
-                                      List<FeeReceiptPo> feeReceiptPos);
 
-    /**
-     * 添加费用明细信息
-     *
-     * @param payFeeDetailPo  费用明细
-     * @param dataFlowContext 数据上下文
-     * @return 订单服务能够接受的报文
-     */
-    public JSONObject addSimpleFeeDetail(PayFeeDetailPo payFeeDetailPo, DataFlowContext dataFlowContext);
 
     /**
      * 添加费用明细信息
@@ -99,7 +34,7 @@ public interface IFeeBMO extends IApiBaseBMO {
      * @param
      * @return 订单服务能够接受的报文
      */
-    public JSONObject addFeePreDetail(JSONObject paramInJson);
+    JSONObject addFeePreDetail(JSONObject paramInJson);
 
     /**
      * 修改费用信息
@@ -108,36 +43,9 @@ public interface IFeeBMO extends IApiBaseBMO {
      * @param
      * @return 订单服务能够接受的报文
      */
-    public JSONObject modifyPreFee(JSONObject paramInJson);
+    JSONObject modifyPreFee(JSONObject paramInJson);
 
-    public JSONObject modifyTempCarInout(JSONObject reqJson, DataFlowContext context);
 
-    /**
-     * 添加费用明细信息
-     *
-     * @param paramInJson     接口调用放传入入参
-     * @param dataFlowContext 数据上下文
-     * @return 订单服务能够接受的报文
-     */
-    public JSONObject addFeeTempDetail(JSONObject paramInJson, DataFlowContext dataFlowContext);
-
-    /**
-     * 修改费用信息
-     *
-     * @param paramInJson     接口调用放传入入参
-     * @param dataFlowContext 数据上下文
-     * @return 订单服务能够接受的报文
-     */
-    public JSONObject modifyTempFee(JSONObject paramInJson, DataFlowContext dataFlowContext);
-
-    /**
-     * 添加小区信息
-     *
-     * @param paramInJson     接口调用放传入入参
-     * @param dataFlowContext 数据上下文
-     * @return 订单服务能够接受的报文
-     */
-    public void addFeeConfig(JSONObject paramInJson, DataFlowContext dataFlowContext);
 
     /**
      * 添加物业费用
@@ -146,7 +54,7 @@ public interface IFeeBMO extends IApiBaseBMO {
      * @param context 数据上下文
      * @return 订单服务能够接受的报文
      */
-    public JSONObject addFee(OwnerCarDto ownerCarDto, JSONObject paramInJson, ICmdDataFlowContext context);
+    JSONObject addFee(OwnerCarDto ownerCarDto, JSONObject paramInJson, ICmdDataFlowContext context);
 
 
     /**
@@ -156,17 +64,9 @@ public interface IFeeBMO extends IApiBaseBMO {
      * @param dataFlowContext 数据上下文
      * @return 订单服务能够接受的报文
      */
-    public FeeAttrPo addFeeAttr(JSONObject paramInJson, ICmdDataFlowContext dataFlowContext, String specCd, String value);
+    FeeAttrPo addFeeAttr(JSONObject paramInJson, ICmdDataFlowContext dataFlowContext, String specCd, String value);
 
 
-    /**
-     * 添加费用
-     *
-     * @param payFeePo        接口调用放传入入参
-     * @param dataFlowContext 数据上下文
-     * @return 订单服务能够接受的报文
-     */
-    public JSONObject addSimpleFee(PayFeePo payFeePo, DataFlowContext dataFlowContext);
 
     /**
      * 添加物业费用
@@ -182,14 +82,6 @@ public interface IFeeBMO extends IApiBaseBMO {
      * @param dataFlowContext 数据上下文
      * @return 订单服务能够接受的报文
      */
-    public JSONObject addContractFee(ContractDto contractDto, JSONObject paramInJson, ICmdDataFlowContext dataFlowContext);
+    JSONObject addContractFee(ContractDto contractDto, JSONObject paramInJson, ICmdDataFlowContext dataFlowContext);
 
-    /**
-     * 添加费用项信息
-     *
-     * @param paramInJson     接口调用放传入入参
-     * @param dataFlowContext 数据上下文
-     * @return 订单服务能够接受的报文
-     */
-    public void updateFeeConfig(JSONObject paramInJson, DataFlowContext dataFlowContext);
 }

+ 29 - 0
service-fee/src/main/java/com/java110/fee/bmo/fee/IFinishFeeNotify.java

@@ -0,0 +1,29 @@
+package com.java110.fee.bmo.fee;
+
+import com.alibaba.fastjson.JSONObject;
+
+public interface IFinishFeeNotify {
+
+    /**
+     * 修改 车辆结束时间
+     * @param feeId
+     * @param communityId
+     */
+    void updateCarEndTime(String feeId,String communityId);
+
+    /**
+     * 修改报修
+     * @param feeId
+     * @param communityId
+     */
+    void updateRepair(String feeId,String communityId,String receivedAmount);
+
+
+    /**
+     * 账户扣款
+     * @param paramObj
+     * @param feeId
+     * @param communityId
+     */
+    void withholdAccount(JSONObject paramObj, String feeId, String communityId);
+}

+ 1 - 410
service-fee/src/main/java/com/java110/fee/bmo/fee/impl/FeeBMOImpl.java

@@ -85,38 +85,6 @@ public class FeeBMOImpl extends ApiBaseBMO implements IFeeBMO {
     @Autowired
     private IFeeReceiptInnerServiceSMO feeReceiptInnerServiceSMOImpl;
 
-    /**
-     * 添加小区信息
-     *
-     * @param paramInJson     接口调用放传入入参
-     * @param dataFlowContext 数据上下文
-     * @return 订单服务能够接受的报文
-     */
-    public void deleteFeeConfig(JSONObject paramInJson, DataFlowContext dataFlowContext) {
-        PayFeeConfigPo payFeeConfigPo = BeanConvertUtil.covertBean(paramInJson, PayFeeConfigPo.class);
-        super.delete(dataFlowContext, payFeeConfigPo, BusinessTypeConstant.BUSINESS_TYPE_DELETE_FEE_CONFIG);
-    }
-
-    /**
-     * 添加物业费用
-     *
-     * @param paramInJson     接口调用放传入入参
-     * @param dataFlowContext 数据上下文
-     * @return 订单服务能够接受的报文
-     */
-    public void deleteFee(JSONObject paramInJson, DataFlowContext dataFlowContext) {
-        JSONObject businessUnit = new JSONObject();
-        businessUnit.put("feeId", paramInJson.getString("feeId"));
-        businessUnit.put("communityId", paramInJson.getString("communityId"));
-        PayFeePo payFeePo = BeanConvertUtil.covertBean(businessUnit, PayFeePo.class);
-        super.delete(dataFlowContext, payFeePo, BusinessTypeConstant.BUSINESS_TYPE_DELETE_FEE_INFO);
-    }
-
-    public void updateFee(JSONObject paramInJson, DataFlowContext dataFlowContext) {
-        PayFeePo payFeePo = BeanConvertUtil.covertBean(paramInJson, PayFeePo.class);
-        super.update(dataFlowContext, payFeePo, BusinessTypeConstant.BUSINESS_TYPE_UPDATE_FEE_INFO);
-    }
-
     private static Calendar getTargetEndTime(Calendar endCalender, Double cycles) {
         if (StringUtil.isInteger(cycles.toString())) {
             endCalender.add(Calendar.MONTH, new Double(cycles).intValue());
@@ -132,238 +100,6 @@ public class FeeBMOImpl extends ApiBaseBMO implements IFeeBMO {
         return endCalender;
     }
 
-    /**
-     * 添加费用明细信息
-     *
-     * @param payFeeDetailPo  费用明细
-     * @param dataFlowContext 数据上下文
-     * @return 订单服务能够接受的报文
-     */
-    public JSONObject addSimpleFeeDetail(PayFeeDetailPo payFeeDetailPo, DataFlowContext dataFlowContext) {
-        JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
-        business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_SAVE_FEE_DETAIL);
-        business.put(CommonConstant.HTTP_SEQ, DEFAULT_SEQ);
-        business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S);
-        JSONObject businessFeeDetail = JSONObject.parseObject(JSONObject.toJSONString(payFeeDetailPo));
-        business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put(PayFeeDetailPo.class.getSimpleName(), businessFeeDetail);
-        return business;
-    }
-
-    /**
-     * 添加费用明细信息
-     *
-     * @param paramInJson     接口调用放传入入参
-     * @param dataFlowContext 数据上下文
-     * @return 订单服务能够接受的报文
-     */
-    public JSONObject addFeeDetail(JSONObject paramInJson, DataFlowContext dataFlowContext, FeeReceiptDetailPo feeReceiptDetailPo, FeeReceiptPo feeReceiptPo) {
-        JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
-        business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_SAVE_FEE_DETAIL);
-        business.put(CommonConstant.HTTP_SEQ, DEFAULT_SEQ);
-        business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S);
-        JSONObject businessFeeDetail = new JSONObject();
-        businessFeeDetail.putAll(paramInJson);
-        businessFeeDetail.put("detailId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_detailId));
-        //支付方式
-        businessFeeDetail.put("primeRate", paramInJson.getString("primeRate"));
-        //计算 应收金额
-        FeeDto feeDto = new FeeDto();
-        feeDto.setFeeId(paramInJson.getString("feeId"));
-        feeDto.setCommunityId(paramInJson.getString("communityId"));
-        List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto);
-        if (feeDtos == null || feeDtos.size() != 1) {
-            throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_ERROR, "查询费用信息失败,未查到数据或查到多条数据");
-        }
-        if (!businessFeeDetail.containsKey("state") || StringUtil.isEmpty(businessFeeDetail.getString("state"))) {
-            businessFeeDetail.put("state", "1400");
-        }
-        feeDto = feeDtos.get(0);
-        businessFeeDetail.put("startTime", DateUtil.getFormatTimeString(feeDto.getEndTime(), DateUtil.DATE_FORMATE_STRING_A));
-        int hours = 0;
-        Date targetEndTime = null;
-        BigDecimal cycles = null;
-        Map feePriceAll = computeFeeSMOImpl.getFeePrice(feeDto);
-        BigDecimal feePrice = new BigDecimal(feePriceAll.get("feePrice").toString());
-        if ("-101".equals(paramInJson.getString("cycles"))) {
-            Date endTime = feeDto.getEndTime();
-            Calendar endCalender = Calendar.getInstance();
-            endCalender.setTime(endTime);
-            BigDecimal receivedAmount = new BigDecimal(Double.parseDouble(paramInJson.getString("receivedAmount")));
-            cycles = receivedAmount.divide(feePrice, 4, BigDecimal.ROUND_HALF_EVEN);
-            endCalender = getTargetEndTime(endCalender, cycles.doubleValue());
-            targetEndTime = endCalender.getTime();
-            paramInJson.put("tmpCycles", cycles.doubleValue());
-            businessFeeDetail.put("cycles", cycles.doubleValue());
-            businessFeeDetail.put("receivableAmount", receivedAmount.doubleValue());
-        } else {
-            targetEndTime = computeFeeSMOImpl.getFeeEndTimeByCycles(feeDto, paramInJson.getString("cycles"));
-            cycles = new BigDecimal(Double.parseDouble(paramInJson.getString("cycles")));
-            double tmpReceivableAmount = cycles.multiply(feePrice).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
-            businessFeeDetail.put("receivableAmount", tmpReceivableAmount);
-        }
-        businessFeeDetail.put("endTime", DateUtil.getFormatTimeString(targetEndTime, DateUtil.DATE_FORMATE_STRING_A));
-        paramInJson.put("feeInfo", feeDto);
-        business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put(PayFeeDetailPo.class.getSimpleName(), businessFeeDetail);
-        paramInJson.put("detailId", businessFeeDetail.getString("detailId"));
-
-        return business;
-    }
-
-    /**
-     * 添加费用明细信息
-     *
-     * @param paramInJson     接口调用放传入入参
-     * @param dataFlowContext 数据上下文
-     * @return 订单服务能够接受的报文
-     */
-    public JSONObject addOweFeeDetail(JSONObject paramInJson, DataFlowContext dataFlowContext,
-                                      List<FeeReceiptDetailPo> feeReceiptDetailPos,
-                                      List<FeeReceiptPo> feeReceiptPos) {
-        JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
-        business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_SAVE_FEE_DETAIL);
-        business.put(CommonConstant.HTTP_SEQ, DEFAULT_SEQ);
-        business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S);
-        JSONObject businessFeeDetail = new JSONObject();
-        businessFeeDetail.putAll(paramInJson);
-        businessFeeDetail.put("detailId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_detailId));
-        businessFeeDetail.put("primeRate", paramInJson.getString("primeRate"));
-        //计算 应收金额
-        FeeDto feeDto = new FeeDto();
-        feeDto.setFeeId(paramInJson.getString("feeId"));
-        feeDto.setCommunityId(paramInJson.getString("communityId"));
-        List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto);
-        if (feeDtos == null || feeDtos.size() != 1) {
-            throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_ERROR, "查询费用信息失败,未查到数据或查到多条数据");
-        }
-        if (!businessFeeDetail.containsKey("state") || StringUtil.isEmpty(businessFeeDetail.getString("state"))) {
-            businessFeeDetail.put("state", "1400");
-        }
-        feeDto = feeDtos.get(0);
-        businessFeeDetail.put("startTime", paramInJson.getString("startTime"));
-        BigDecimal cycles = null;
-        Map feePriceAll = computeFeeSMOImpl.getFeePrice(feeDto);
-        BigDecimal feePrice = new BigDecimal(feePriceAll.get("feePrice").toString());
-        Date endTime = feeDto.getEndTime();
-        Calendar endCalender = Calendar.getInstance();
-        endCalender.setTime(endTime);
-        BigDecimal receivedAmount = new BigDecimal(Double.parseDouble(paramInJson.getString("receivedAmount")));
-        cycles = receivedAmount.divide(feePrice, 4, BigDecimal.ROUND_HALF_EVEN);
-        businessFeeDetail.put("cycles", cycles.doubleValue());
-        businessFeeDetail.put("receivableAmount", paramInJson.getString("receivedAmount"));
-        businessFeeDetail.put("receivedAmount", paramInJson.getString("receivedAmount"));
-        businessFeeDetail.put("endTime", paramInJson.getString("endTime"));
-        paramInJson.put("feeInfo", feeDto);
-        paramInJson.put("cycles", cycles.doubleValue());
-        business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put(PayFeeDetailPo.class.getSimpleName(), businessFeeDetail);
-        paramInJson.put("detailId", businessFeeDetail.getString("detailId"));
-        FeeReceiptPo feeReceiptPo = new FeeReceiptPo();
-        FeeReceiptDetailPo feeReceiptDetailPo = new FeeReceiptDetailPo();
-        feeReceiptDetailPo.setAmount(businessFeeDetail.getString("receivedAmount"));
-        feeReceiptDetailPo.setCommunityId(feeDto.getCommunityId());
-        feeReceiptDetailPo.setCycle(businessFeeDetail.getString("cycles"));
-        feeReceiptDetailPo.setDetailId(businessFeeDetail.getString("detailId"));
-        feeReceiptDetailPo.setEndTime(businessFeeDetail.getString("endTime"));
-        feeReceiptDetailPo.setFeeId(feeDto.getFeeId());
-        feeReceiptDetailPo.setFeeName(StringUtil.isEmpty(feeDto.getImportFeeName()) ? feeDto.getFeeName() : feeDto.getImportFeeName());
-        feeReceiptDetailPo.setStartTime(businessFeeDetail.getString("startTime"));
-        feeReceiptDetailPo.setReceiptId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_receiptId));
-
-        computeFeeSMOImpl.freshFeeReceiptDetail(feeDto, feeReceiptDetailPo);
-        //查询业主信息
-        OwnerDto ownerDto = computeFeeSMOImpl.getFeeOwnerDto(feeDto);
-
-        feeReceiptDetailPos.add(feeReceiptDetailPo);
-        feeReceiptPo.setAmount(feeReceiptDetailPo.getAmount());
-        feeReceiptPo.setCommunityId(feeReceiptDetailPo.getCommunityId());
-        feeReceiptPo.setReceiptId(feeReceiptDetailPo.getReceiptId());
-        feeReceiptPo.setObjType(feeDto.getPayerObjType());
-        feeReceiptPo.setObjId(feeDto.getPayerObjId());
-        feeReceiptPo.setObjName(computeFeeSMOImpl.getFeeObjName(feeDto));
-        feeReceiptPo.setPayObjId(ownerDto.getOwnerId());
-        feeReceiptPo.setPayObjName(ownerDto.getName());
-        feeReceiptPos.add(feeReceiptPo);
-        return business;
-    }
-
-    /**
-     * 修改费用信息
-     *
-     * @param paramInJson     接口调用放传入入参
-     * @param dataFlowContext 数据上下文
-     * @return 订单服务能够接受的报文
-     */
-    public JSONObject modifyFee(JSONObject paramInJson, DataFlowContext dataFlowContext) {
-        JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
-        business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_UPDATE_FEE_INFO);
-        business.put(CommonConstant.HTTP_SEQ, DEFAULT_SEQ + 1);
-        business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S);
-        JSONObject businessFee = new JSONObject();
-        FeeDto feeInfo = (FeeDto) paramInJson.get("feeInfo");
-        Date endTime = feeInfo.getEndTime();
-        Calendar endCalender = Calendar.getInstance();
-        endCalender.setTime(endTime);
-        int hours = 0;
-        if ("-101".equals(paramInJson.getString("cycles"))) {
-            endCalender = getTargetEndTime(endCalender, Double.parseDouble(paramInJson.getString("tmpCycles")));
-        } else {
-            endCalender.add(Calendar.MONTH, Integer.parseInt(paramInJson.getString("cycles")));
-        }
-        feeInfo.setEndTime(endCalender.getTime());
-        //判断 结束时间 是否大于 费用项 结束时间,这里 容错一下,如果 费用结束时间大于 费用项结束时间 30天 走报错 属于多缴费
-        if (feeInfo.getEndTime().getTime() - feeInfo.getConfigEndTime().getTime() > 30 * 24 * 60 * 60 * 1000L) {
-            throw new IllegalArgumentException("缴费超过了 费用项结束时间");
-        }
-        Map feeMap = BeanConvertUtil.beanCovertMap(feeInfo);
-        feeMap.put("startTime", DateUtil.getFormatTimeString(feeInfo.getStartTime(), DateUtil.DATE_FORMATE_STRING_A));
-        feeMap.put("endTime", DateUtil.getFormatTimeString(feeInfo.getEndTime(), DateUtil.DATE_FORMATE_STRING_A));
-        feeMap.put("cycles", paramInJson.getString("cycles"));
-        feeMap.put("configEndTime", feeInfo.getConfigEndTime());
-        businessFee.putAll(feeMap);
-        business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put(PayFeePo.class.getSimpleName(), businessFee);
-        //为停车费单独处理
-        paramInJson.put("carFeeEndTime", feeInfo.getEndTime());
-        paramInJson.put("carPayerObjType", feeInfo.getPayerObjType());
-        paramInJson.put("carPayerObjId", feeInfo.getPayerObjId());
-        return business;
-    }
-
-    /**
-     * 修改费用信息
-     *
-     * @param paramInJson     接口调用放传入入参
-     * @param dataFlowContext 数据上下文
-     * @return 订单服务能够接受的报文
-     */
-    public JSONObject modifyOweFee(JSONObject paramInJson, DataFlowContext dataFlowContext) {
-        JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
-        business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_ONLY_UPDATE_FEE_INFO); //这里走only
-        business.put(CommonConstant.HTTP_SEQ, DEFAULT_SEQ + 1);
-        business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S);
-        JSONObject businessFee = new JSONObject();
-        FeeDto feeInfo = (FeeDto) paramInJson.get("feeInfo");
-        Map feeMap = BeanConvertUtil.beanCovertMap(feeInfo);
-        feeMap.put("startTime", DateUtil.getFormatTimeString(feeInfo.getStartTime(), DateUtil.DATE_FORMATE_STRING_A));
-        feeMap.put("endTime", paramInJson.getString("endTime"));
-        feeMap.put("cycles", paramInJson.getString("cycles"));
-        feeMap.put("configEndTime", feeInfo.getConfigEndTime());
-        if (FeeDto.FEE_FLAG_ONCE.equals(feeInfo.getFeeFlag())) { //缴费结束
-            feeMap.put("state", FeeDto.STATE_FINISH);
-        }
-        Date maxEndTime = feeInfo.getConfigEndTime();
-        if (!FeeDto.FEE_FLAG_CYCLE.equals(feeInfo.getFeeFlag())) {
-            maxEndTime = feeInfo.getDeadlineTime();
-        }
-        if (maxEndTime != null) { //这里数据问题的情况下
-            Date endTime = DateUtil.getDateFromStringA(paramInJson.getString("endTime"));
-            if (endTime.getTime() >= maxEndTime.getTime()) {
-                feeMap.put("state", FeeDto.STATE_FINISH);
-            }
-        }
-        businessFee.putAll(feeMap);
-        business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put(PayFeePo.class.getSimpleName(), businessFee);
-        return business;
-    }
-
     /**
      * 添加费用明细信息
      *
@@ -577,114 +313,6 @@ public class FeeBMOImpl extends ApiBaseBMO implements IFeeBMO {
         return business;
     }
 
-    /**
-     * 添加费用明细信息
-     *
-     * @param paramInJson     接口调用放传入入参
-     * @param dataFlowContext 数据上下文
-     * @return 订单服务能够接受的报文
-     */
-    public JSONObject addFeeTempDetail(JSONObject paramInJson, DataFlowContext dataFlowContext) {
-        JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
-        business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_SAVE_FEE_DETAIL);
-        business.put(CommonConstant.HTTP_SEQ, DEFAULT_SEQ);
-        business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S);
-        JSONObject businessFeeDetail = new JSONObject();
-        businessFeeDetail.putAll(paramInJson);
-        businessFeeDetail.put("detailId", "-1");
-        businessFeeDetail.put("primeRate", paramInJson.getString("primeRate"));
-        if (!businessFeeDetail.containsKey("state")) {
-            businessFeeDetail.put("state", "1400");
-        }
-        //计算 应收金额
-        FeeDto feeDto = new FeeDto();
-        feeDto.setFeeId(paramInJson.getString("feeId"));
-        feeDto.setCommunityId(paramInJson.getString("communityId"));
-        List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto);
-        if (feeDtos == null || feeDtos.size() != 1) {
-            throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_ERROR, "查询费用信息失败,未查到数据或查到多条数据");
-        }
-        feeDto = feeDtos.get(0);
-        paramInJson.put("feeInfo", feeDto);
-        FeeConfigDto feeConfigDto = new FeeConfigDto();
-        feeConfigDto.setFeeTypeCd(feeDto.getFeeTypeCd());
-        feeConfigDto.setConfigId(feeDto.getConfigId());
-        feeConfigDto.setCommunityId(feeDto.getCommunityId());
-        List<FeeConfigDto> feeConfigDtos = feeConfigInnerServiceSMOImpl.queryFeeConfigs(feeConfigDto);
-        if (feeConfigDtos == null || feeConfigDtos.size() != 1) {
-            throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_ERROR, "未查到费用配置信息,查询多条数据");
-        }
-        feeConfigDto = feeConfigDtos.get(0);
-        Date nowTime = new Date();
-
-        long diff = nowTime.getTime() - feeDto.getStartTime().getTime();
-        long nd = 1000 * 24 * 60 * 60;// 一天的毫秒数
-        long nh = 1000 * 60 * 60;// 一小时的毫秒数
-        long nm = 1000 * 60;// 一分钟的毫秒数
-        double day = 0;
-        double hour = 0;
-        double min = 0;
-        day = diff / nd;// 计算差多少天
-        hour = diff % nd / nh + day * 24;// 计算差多少小时
-        min = diff % nd % nh / nm + day * 24 * 60;// 计算差多少分钟
-        double money = 0.00;
-        double newHour = hour;
-        if (min > 0) { //一小时超过
-            newHour += 1;
-        }
-        if (newHour <= 2) {
-            money = Double.parseDouble(feeConfigDto.getAdditionalAmount());
-        } else {
-            BigDecimal lastHour = new BigDecimal(newHour - 2);
-            BigDecimal squarePrice = new BigDecimal(Double.parseDouble(feeDto.getSquarePrice()));
-            BigDecimal additionalAmount = new BigDecimal(Double.parseDouble(feeDto.getAdditionalAmount()));
-            money = squarePrice.multiply(lastHour).add(additionalAmount).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
-        }
-        double receivableAmount = money;
-        businessFeeDetail.put("receivableAmount", receivableAmount);
-        business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put(PayFeeDetailPo.class.getSimpleName(), businessFeeDetail);
-        paramInJson.put("receivableAmount", receivableAmount);
-        return business;
-    }
-
-    /**
-     * 修改费用信息
-     *
-     * @param paramInJson     接口调用放传入入参
-     * @param dataFlowContext 数据上下文
-     * @return 订单服务能够接受的报文
-     */
-    public JSONObject modifyTempFee(JSONObject paramInJson, DataFlowContext dataFlowContext) {
-        JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
-        business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_UPDATE_FEE_INFO);
-        business.put(CommonConstant.HTTP_SEQ, DEFAULT_SEQ + 1);
-        business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S);
-        JSONObject businessFee = new JSONObject();
-        FeeDto feeInfo = (FeeDto) paramInJson.get("feeInfo");
-        Map feeMap = BeanConvertUtil.beanCovertMap(feeInfo);
-        feeMap.put("startTime", DateUtil.getFormatTimeString(feeInfo.getStartTime(), DateUtil.DATE_FORMATE_STRING_A));
-        feeMap.put("endTime", DateUtil.getFormatTimeString(new Date(), DateUtil.DATE_FORMATE_STRING_A));
-        feeMap.put("amount", paramInJson.getString("receivableAmount"));
-        feeMap.put("state", "2009001");
-        businessFee.putAll(feeMap);
-        business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put(PayFeePo.class.getSimpleName(), businessFee);
-        return business;
-    }
-
-    /**
-     * 添加小区信息
-     *
-     * @param paramInJson     接口调用放传入入参
-     * @param dataFlowContext 数据上下文
-     * @return 订单服务能够接受的报文
-     */
-    public void addFeeConfig(JSONObject paramInJson, DataFlowContext dataFlowContext) {
-        paramInJson.put("configId", "-1");
-        paramInJson.put("isDefault", "F");
-        PayFeeConfigPo payFeeConfigPo = BeanConvertUtil.covertBean(paramInJson, PayFeeConfigPo.class);
-        super.insert(dataFlowContext, payFeeConfigPo, BusinessTypeConstant.BUSINESS_TYPE_SAVE_FEE_CONFIG);
-    }
-
     /**
      * 添加物业费用
      *
@@ -744,24 +372,7 @@ public class FeeBMOImpl extends ApiBaseBMO implements IFeeBMO {
 
     }
 
-    /**
-     * 添加费用
-     *
-     * @param payFeePo        接口调用放传入入参
-     * @param dataFlowContext 数据上下文
-     * @return 订单服务能够接受的报文
-     */
-    public JSONObject addSimpleFee(PayFeePo payFeePo, DataFlowContext dataFlowContext) {
-        JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
-        business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_SAVE_FEE_INFO);
-        business.put(CommonConstant.HTTP_SEQ, DEFAULT_SEQ + 1);
-        business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S);
-        JSONObject businessUnit = null;
-        businessUnit = JSONObject.parseObject(JSONObject.toJSONString(payFeePo));
-        businessUnit.put("userId", dataFlowContext.getRequestCurrentHeaders().get(CommonConstant.HTTP_USER_ID));
-        business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put(PayFeePo.class.getSimpleName(), businessUnit);
-        return business;
-    }
+
 
     /**
      * 添加物业费用
@@ -849,24 +460,4 @@ public class FeeBMOImpl extends ApiBaseBMO implements IFeeBMO {
         return businessUnit;
     }
 
-    /**
-     * 添加费用项信息
-     *
-     * @param paramInJson     接口调用放传入入参
-     * @param dataFlowContext 数据上下文
-     * @return 订单服务能够接受的报文
-     */
-    public void updateFeeConfig(JSONObject paramInJson, DataFlowContext dataFlowContext) {
-        FeeConfigDto feeConfigDto = new FeeConfigDto();
-        feeConfigDto.setCommunityId(paramInJson.getString("communityId"));
-        feeConfigDto.setConfigId(paramInJson.getString("configId"));
-        List<FeeConfigDto> feeConfigDtos = feeConfigInnerServiceSMOImpl.queryFeeConfigs(feeConfigDto);
-        Assert.listOnlyOne(feeConfigDtos, "未找到该费用项");
-        JSONObject businessFeeConfig = new JSONObject();
-        businessFeeConfig.putAll(paramInJson);
-        businessFeeConfig.put("isDefault", feeConfigDtos.get(0).getIsDefault());
-        PayFeeConfigPo payFeeConfigPo = BeanConvertUtil.covertBean(businessFeeConfig, PayFeeConfigPo.class);
-        super.update(dataFlowContext, payFeeConfigPo, BusinessTypeConstant.BUSINESS_TYPE_UPDATE_FEE_CONFIG);
-    }
-
 }

+ 229 - 0
service-fee/src/main/java/com/java110/fee/bmo/fee/impl/FinishFeeNotifyImpl.java

@@ -0,0 +1,229 @@
+package com.java110.fee.bmo.fee.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.core.factory.GenerateCodeFactory;
+import com.java110.dto.fee.FeeAttrDto;
+import com.java110.dto.fee.FeeConfigDto;
+import com.java110.dto.fee.FeeDto;
+import com.java110.dto.owner.OwnerCarDto;
+import com.java110.dto.parking.ParkingSpaceDto;
+import com.java110.dto.repair.RepairDto;
+import com.java110.dto.repair.RepairUserDto;
+import com.java110.fee.bmo.fee.IFinishFeeNotify;
+import com.java110.intf.acct.IAccountInnerServiceSMO;
+import com.java110.intf.community.*;
+import com.java110.intf.fee.IFeeAttrInnerServiceSMO;
+import com.java110.intf.fee.IFeeInnerServiceSMO;
+import com.java110.intf.fee.IOwnerCarNewV1InnerServiceSMO;
+import com.java110.intf.user.IOwnerCarInnerServiceSMO;
+import com.java110.po.account.AccountDetailPo;
+import com.java110.po.car.OwnerCarPo;
+import com.java110.po.owner.RepairPoolPo;
+import com.java110.po.owner.RepairUserPo;
+import com.java110.utils.exception.CmdException;
+import com.java110.utils.util.Assert;
+import com.java110.utils.util.DateUtil;
+import com.java110.utils.util.ListUtil;
+import com.java110.utils.util.StringUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+@Service
+public class FinishFeeNotifyImpl implements IFinishFeeNotify {
+
+    @Autowired
+    private IOwnerCarInnerServiceSMO ownerCarInnerServiceSMOImpl;
+
+    @Autowired
+    private IOwnerCarNewV1InnerServiceSMO ownerCarNewV1InnerServiceSMOImpl;
+
+    @Autowired
+    private IFeeInnerServiceSMO feeInnerServiceSMOImpl;
+
+    @Autowired
+    private IParkingSpaceInnerServiceSMO parkingSpaceInnerServiceSMOImpl;
+
+    @Autowired
+    private IFeeAttrInnerServiceSMO feeAttrInnerServiceSMOImpl;
+
+    @Autowired
+    private IRepairUserInnerServiceSMO repairUserInnerServiceSMO;
+
+    @Autowired
+    private IRepairInnerServiceSMO repairInnerServiceSMO;
+
+
+    @Autowired
+    private IRepairPoolV1InnerServiceSMO repairPoolV1InnerServiceSMOImpl;
+
+    @Autowired
+    private IRepairUserV1InnerServiceSMO repairUserV1InnerServiceSMOImpl;
+
+    @Autowired
+    private IAccountInnerServiceSMO accountInnerServiceSMOImpl;
+
+    @Override
+    public void updateCarEndTime(String feeId, String communityId) {
+        int flag;
+        FeeDto feeDto = new FeeDto();
+        feeDto.setFeeId(feeId);
+        feeDto.setCommunityId(communityId);
+        List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto);
+
+        if (ListUtil.isNull(feeDtos)) {
+            return;
+        }
+        if (!FeeDto.PAYER_OBJ_TYPE_CAR.equals(feeDtos.get(0).getPayerObjType())) {
+            return;
+        }
+        Date feeEndTime = feeDtos.get(0).getEndTime();
+        OwnerCarDto ownerCarDto = new OwnerCarDto();
+        ownerCarDto.setCommunityId(communityId);
+        ownerCarDto.setCarId(feeDtos.get(0).getPayerObjId());
+        ownerCarDto.setCarTypeCd("1001"); //业主车辆
+        List<OwnerCarDto> ownerCarDtos = ownerCarInnerServiceSMOImpl.queryOwnerCars(ownerCarDto);
+
+        if (ListUtil.isNull(ownerCarDtos)) {
+            return;
+        }
+        //获取车位id
+        String psId = ownerCarDtos.get(0).getPsId();
+        //todo 获取车辆状态(1001 正常状态,2002 欠费状态  3003 车位释放)
+        String carState = ownerCarDtos.get(0).getState();
+        if (!StringUtil.isEmpty(psId) && "3003".equals(carState)) {
+            ParkingSpaceDto parkingSpaceDto = new ParkingSpaceDto();
+            parkingSpaceDto.setPsId(psId);
+            List<ParkingSpaceDto> parkingSpaceDtos = parkingSpaceInnerServiceSMOImpl.queryParkingSpaces(parkingSpaceDto);
+            Assert.listOnlyOne(parkingSpaceDtos, "查询车位信息错误!");
+            //获取车位状态(出售 S,出租 H ,空闲 F)
+            String state = parkingSpaceDtos.get(0).getState();
+            if (!StringUtil.isEmpty(state) && !state.equals("F")) {
+                throw new IllegalArgumentException("车位已被使用,不能再缴费!");
+            }
+        }
+
+
+        Calendar endTimeCalendar = null;
+        //todo 车位费用续租
+        for (OwnerCarDto tmpOwnerCarDto : ownerCarDtos) {
+            //后付费 或者信用期车辆 加一个月
+            if (FeeConfigDto.PAYMENT_CD_AFTER.equals(feeDtos.get(0).getPaymentCd())
+                    || OwnerCarDto.CAR_TYPE_CREDIT.equals(tmpOwnerCarDto.getCarType())) {
+                endTimeCalendar = Calendar.getInstance();
+                endTimeCalendar.setTime(feeEndTime);
+                endTimeCalendar.add(Calendar.MONTH, 1);
+                feeEndTime = endTimeCalendar.getTime();
+            }
+            if (tmpOwnerCarDto.getEndTime().getTime() >= feeEndTime.getTime()) {
+                continue;
+            }
+            OwnerCarPo ownerCarPo = new OwnerCarPo();
+            ownerCarPo.setMemberId(tmpOwnerCarDto.getMemberId());
+            ownerCarPo.setEndTime(DateUtil.getFormatTimeString(feeEndTime, DateUtil.DATE_FORMATE_STRING_A));
+            flag = ownerCarNewV1InnerServiceSMOImpl.updateOwnerCarNew(ownerCarPo);
+            if (flag < 1) {
+                throw new CmdException("缴费失败");
+            }
+        }
+    }
+
+    @Override
+    public void updateRepair(String feeId, String communityId, String receivedAmount) {
+        //判断是否有派单属性ID
+        FeeAttrDto feeAttrDto = new FeeAttrDto();
+        feeAttrDto.setCommunityId(communityId);
+        feeAttrDto.setFeeId(feeId);
+        feeAttrDto.setSpecCd(FeeAttrDto.SPEC_CD_REPAIR);
+        List<FeeAttrDto> feeAttrDtos = feeAttrInnerServiceSMOImpl.queryFeeAttrs(feeAttrDto);
+
+        int flag = 0;
+        //修改 派单状态
+        if (ListUtil.isNull(feeAttrDtos)) {
+            return;
+        }
+
+        RepairPoolPo repairPoolPo = new RepairPoolPo();
+        repairPoolPo.setRepairId(feeAttrDtos.get(0).getValue());
+        repairPoolPo.setCommunityId(communityId);
+        repairPoolPo.setState(RepairDto.STATE_APPRAISE);
+        flag = repairPoolV1InnerServiceSMOImpl.updateRepairPoolNew(repairPoolPo);
+        if (flag < 1) {
+            throw new CmdException("修改失败");
+        }
+
+        RepairDto repairDto = new RepairDto();
+        repairDto.setRepairId(feeAttrDtos.get(0).getValue());
+        //查询报修记录
+        List<RepairDto> repairDtos = repairInnerServiceSMO.queryRepairs(repairDto);
+        Assert.listOnlyOne(repairDtos, "报修信息错误!");
+        //获取报修渠道
+        String repairChannel = repairDtos.get(0).getRepairChannel();
+        RepairUserDto repairUserDto = new RepairUserDto();
+        repairUserDto.setRepairId(feeAttrDtos.get(0).getValue());
+        repairUserDto.setState(RepairUserDto.STATE_PAY_FEE);
+        //查询待支付状态的记录
+        List<RepairUserDto> repairUserDtoList = repairUserInnerServiceSMO.queryRepairUsers(repairUserDto);
+        Assert.listOnlyOne(repairUserDtoList, "信息错误!");
+        RepairUserPo repairUserPo = new RepairUserPo();
+        repairUserPo.setRuId(repairUserDtoList.get(0).getRuId());
+        if ("Z".equals(repairChannel)) {  //如果业主是自主报修,状态就变成已支付,并新增一条待评价状态
+            repairUserPo.setState(RepairUserDto.STATE_FINISH_PAY_FEE);
+            //如果是待评价状态,就更新结束时间
+            repairUserPo.setEndTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
+            repairUserPo.setContext("已支付" + receivedAmount + "元");
+            //新增待评价状态
+            RepairUserPo repairUser = new RepairUserPo();
+            repairUser.setRuId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_ruId));
+            repairUser.setStartTime(repairUserPo.getEndTime());
+            repairUser.setState(RepairUserDto.STATE_EVALUATE);
+            repairUser.setContext("待评价");
+            repairUser.setCommunityId(communityId);
+            repairUser.setCreateTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
+            repairUser.setRepairId(repairUserDtoList.get(0).getRepairId());
+            repairUser.setStaffId(repairUserDtoList.get(0).getStaffId());
+            repairUser.setStaffName(repairUserDtoList.get(0).getStaffName());
+            repairUser.setPreStaffId(repairUserDtoList.get(0).getStaffId());
+            repairUser.setPreStaffName(repairUserDtoList.get(0).getStaffName());
+            repairUser.setPreRuId(repairUserDtoList.get(0).getRuId());
+            repairUser.setRepairEvent("auditUser");
+            flag = repairUserV1InnerServiceSMOImpl.saveRepairUserNew(repairUserPo);
+            if (flag < 1) {
+                throw new CmdException("修改失败");
+            }
+        } else {  //如果是员工代客报修或电话报修,状态就变成已支付
+            repairUserPo.setState(RepairUserDto.STATE_FINISH_PAY_FEE);
+            //如果是已支付状态,就更新结束时间
+            repairUserPo.setEndTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
+            repairUserPo.setContext("已支付" + receivedAmount + "元");
+            flag = repairUserV1InnerServiceSMOImpl.updateRepairUserNew(repairUserPo);
+            if (flag < 1) {
+                throw new CmdException("修改失败");
+            }
+        }
+    }
+
+    @Override
+    public void withholdAccount(JSONObject paramObj, String feeId, String communityId) {
+        if (!paramObj.containsKey("accountAmount")) {
+            return;
+        }
+
+        double accountAmount = paramObj.getDouble("accountAmount");
+
+        if (accountAmount <= 0) {
+            return;
+        }
+
+        AccountDetailPo accountDetailPo = new AccountDetailPo();
+        accountDetailPo.setAcctId(paramObj.getString("acctId"));
+        accountDetailPo.setAmount(accountAmount + "");
+        accountDetailPo.setDetailId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_detailId));
+        accountInnerServiceSMOImpl.withholdAccount(accountDetailPo);
+
+
+    }
+}

+ 86 - 219
service-fee/src/main/java/com/java110/fee/cmd/fee/PayOweFeeCmd.java

@@ -11,6 +11,7 @@ import com.java110.core.factory.GenerateCodeFactory;
 import com.java110.core.factory.Java110TransactionalFactory;
 import com.java110.core.log.LoggerFactory;
 import com.java110.core.smo.IComputeFeeSMO;
+import com.java110.dto.account.AccountDto;
 import com.java110.dto.app.AppDto;
 import com.java110.dto.fee.FeeAttrDto;
 import com.java110.dto.fee.FeeConfigDto;
@@ -23,11 +24,14 @@ import com.java110.dto.parking.ParkingSpaceDto;
 import com.java110.dto.repair.RepairDto;
 import com.java110.dto.repair.RepairUserDto;
 import com.java110.dto.user.UserDto;
+import com.java110.fee.bmo.fee.IFinishFeeNotify;
 import com.java110.fee.smo.impl.FeeReceiptInnerServiceSMOImpl;
+import com.java110.intf.acct.IAccountInnerServiceSMO;
 import com.java110.intf.community.*;
 import com.java110.intf.fee.*;
 import com.java110.intf.user.IOwnerCarInnerServiceSMO;
 import com.java110.intf.user.IUserV1InnerServiceSMO;
+import com.java110.po.account.AccountDetailPo;
 import com.java110.po.car.OwnerCarPo;
 import com.java110.po.fee.PayFeeDetailPo;
 import com.java110.po.fee.PayFeePo;
@@ -74,11 +78,6 @@ public class PayOweFeeCmd extends Cmd {
     @Autowired
     private IFeeReceiptDetailInnerServiceSMO feeReceiptDetailInnerServiceSMOImpl;
 
-    @Autowired
-    private IRepairUserInnerServiceSMO repairUserInnerServiceSMO;
-
-    @Autowired
-    private IRepairInnerServiceSMO repairInnerServiceSMO;
 
     @Autowired
     private IPayFeeV1InnerServiceSMO payFeeV1InnerServiceSMOImpl;
@@ -88,22 +87,16 @@ public class PayOweFeeCmd extends Cmd {
 
 
     @Autowired
-    private IRepairPoolV1InnerServiceSMO repairPoolV1InnerServiceSMOImpl;
-
-    @Autowired
-    private IRepairUserV1InnerServiceSMO repairUserV1InnerServiceSMOImpl;
-
-    @Autowired
-    private IOwnerCarNewV1InnerServiceSMO ownerCarNewV1InnerServiceSMOImpl;
+    private IComputeFeeSMO computeFeeSMOImpl;
 
     @Autowired
-    private IOwnerCarInnerServiceSMO ownerCarInnerServiceSMOImpl;
+    private IUserV1InnerServiceSMO userV1InnerServiceSMOImpl;
 
     @Autowired
-    private IComputeFeeSMO computeFeeSMOImpl;
+    private IFinishFeeNotify finishFeeNotifyImpl;
 
     @Autowired
-    private IUserV1InnerServiceSMO userV1InnerServiceSMOImpl;
+    private IAccountInnerServiceSMO accountInnerServiceSMOImpl;
 
 
     @Override
@@ -133,7 +126,7 @@ public class PayOweFeeCmd extends Cmd {
             }
             feeDto = feeDtos.get(0);
             feeObject.put("feeDto", feeDto);
-            if(!FeeDto.FEE_FLAG_CYCLE.equals(feeDto.getFeeFlag())){
+            if (!FeeDto.FEE_FLAG_CYCLE.equals(feeDto.getFeeFlag())) {
                 continue;
             }
 
@@ -141,11 +134,13 @@ public class PayOweFeeCmd extends Cmd {
             if (pageEndTime.getTime() <= feeDto.getEndTime().getTime()) {
                 throw new IllegalArgumentException("可能存在重复缴费,请刷新页面重新缴费");
             }
-
-
         }
+
+        //todo 从账户中扣款
+        ifHasAccount(reqJson, fees);
     }
 
+
     @Override
     @Java110Transactional
     public void doCmd(CmdEvent event, ICmdDataFlowContext dataFlowContext, JSONObject paramObj) throws CmdException, ParseException {
@@ -158,10 +153,6 @@ public class PayOweFeeCmd extends Cmd {
 
         String payOrderId = paramObj.getString("payOrderId");
 
-
-        //添加单元信息
-        List<FeeReceiptPo> feeReceiptPos = new ArrayList<>();
-        List<FeeReceiptDetailPo> feeReceiptDetailPos = new ArrayList<>();
         JSONArray fees = paramObj.getJSONArray("fees");
         JSONObject feeObj = null;
         String appId = dataFlowContext.getReqHeaders().get("app-id");
@@ -169,7 +160,8 @@ public class PayOweFeeCmd extends Cmd {
 
         //todo 生成收据编号
         String receiptCode = feeReceiptInnerServiceSMOImpl.generatorReceiptCode(paramObj.getString("communityId"));
-
+        //todo 根据明细ID 查询收据信息
+        JSONArray details = new JSONArray();
 
         for (int feeIndex = 0; feeIndex < fees.size(); feeIndex++) {
             feeObj = fees.getJSONObject(feeIndex);
@@ -183,128 +175,40 @@ public class PayOweFeeCmd extends Cmd {
                 feeObj.put("primeRate", "5");
                 feeObj.put("remark", "线上公众号支付");
             }
+            if (!paramObj.containsKey("primeRate")) {
+                paramObj.put("primeRate", "6");
+            }
+            logger.info("======支付方式======:" + appId + "+======+" + paramObj.containsKey("primeRate") + "======:" + JSONArray.toJSONString(dataFlowContext));
+            if (AppDto.OWNER_WECHAT_PAY.equals(appId)
+                    && FeeDetailDto.PRIME_REATE_WECHAT.equals(paramObj.getString("primeRate"))) {  //微信支付(欠费缴费无法区分小程序还是微信公众号)
+                paramObj.put("remark", "线上公众号支付");
+            } else if (AppDto.OWNER_WECHAT_PAY.equals(appId)
+                    && FeeDetailDto.PRIME_REATE_WECHAT_APP.equals(paramObj.getString("primeRate"))) {
+                paramObj.put("remark", "线上小程序支付");
+            }
+            paramObj.put("state", "1400");
+            // todo 添加交费明细
+            addOweFeeDetail(paramObj, details, userDto, receiptCode, payOrderId);
+            modifyOweFee(paramObj, dataFlowContext);
 
-            //todo 去缴费
-            getFeeReceiptDetailPo(dataFlowContext, feeObj, feeReceiptDetailPos, feeReceiptPos, userDtos.get(0), receiptCode, payOrderId);
-        }
-
+            //todo 账户扣款
+            finishFeeNotifyImpl.withholdAccount(paramObj, paramObj.getString("feeId"), paramObj.getString("communityId"));
 
+            //todo 修改车辆
+            finishFeeNotifyImpl.updateCarEndTime(paramObj.getString("feeId"), paramObj.getString("communityId"));
 
-        //根据明细ID 查询收据信息
-        JSONArray details = new JSONArray();
 
-        for (FeeReceiptDetailPo feeReceiptDetailPo : feeReceiptDetailPos) {
-            details.add(feeReceiptDetailPo.getDetailId());
+            //todo 修改报修单
+            finishFeeNotifyImpl.updateRepair(paramObj.getString("feeId"), paramObj.getString("communityId"), paramObj.getString("receivedAmount"));
         }
 
+
         JSONObject data = new JSONObject();
-        data.put("details",details);
+        data.put("details", details);
 
         dataFlowContext.setResponseEntity(ResultVo.createResponseEntity(data));
     }
 
-    private void getFeeReceiptDetailPo(ICmdDataFlowContext dataFlowContext, JSONObject paramObj,
-                                       List<FeeReceiptDetailPo> feeReceiptDetailPos,
-                                       List<FeeReceiptPo> feeReceiptPos,
-                                       UserDto userDto,
-                                       String receiptCode,
-                                       String payOrderId) {
-        int flag = 0;
-        if (!paramObj.containsKey("primeRate")) {
-            paramObj.put("primeRate", "6");
-        }
-        String appId = dataFlowContext.getReqHeaders().get("app-id");
-        logger.info("======支付方式======:" + appId + "+======+" + paramObj.containsKey("primeRate") + "======:" + JSONArray.toJSONString(dataFlowContext));
-        if (AppDto.OWNER_WECHAT_PAY.equals(appId)
-                && FeeDetailDto.PRIME_REATE_WECHAT.equals(paramObj.getString("primeRate"))) {  //微信支付(欠费缴费无法区分小程序还是微信公众号)
-            paramObj.put("remark", "线上公众号支付");
-        } else if (AppDto.OWNER_WECHAT_PAY.equals(appId)
-                && FeeDetailDto.PRIME_REATE_WECHAT_APP.equals(paramObj.getString("primeRate"))) {
-            paramObj.put("remark", "线上小程序支付");
-        }
-        paramObj.put("state", "1400");
-        // todo 添加交费明细
-        addOweFeeDetail(paramObj, dataFlowContext, feeReceiptDetailPos, feeReceiptPos, userDto, receiptCode,payOrderId);
-        modifyOweFee(paramObj, dataFlowContext);
-
-        //修改车辆
-        updateCarEndTime(paramObj);
-
-        //判断是否有派单属性ID
-        FeeAttrDto feeAttrDto = new FeeAttrDto();
-        feeAttrDto.setCommunityId(paramObj.getString("communityId"));
-        feeAttrDto.setFeeId(paramObj.getString("feeId"));
-        feeAttrDto.setSpecCd(FeeAttrDto.SPEC_CD_REPAIR);
-        List<FeeAttrDto> feeAttrDtos = feeAttrInnerServiceSMOImpl.queryFeeAttrs(feeAttrDto);
-
-        //修改 派单状态
-        if (feeAttrDtos != null && feeAttrDtos.size() > 0) {
-
-            RepairPoolPo repairPoolPo = new RepairPoolPo();
-            repairPoolPo.setRepairId(feeAttrDtos.get(0).getValue());
-            repairPoolPo.setCommunityId(paramObj.getString("communityId"));
-            repairPoolPo.setState(RepairDto.STATE_APPRAISE);
-            flag = repairPoolV1InnerServiceSMOImpl.updateRepairPoolNew(repairPoolPo);
-            if (flag < 1) {
-                throw new CmdException("修改失败");
-            }
-        }
-        //修改 派单流程状态
-        if (feeAttrDtos != null && feeAttrDtos.size() > 0) {
-
-            RepairDto repairDto = new RepairDto();
-            repairDto.setRepairId(feeAttrDtos.get(0).getValue());
-            //查询报修记录
-            List<RepairDto> repairDtos = repairInnerServiceSMO.queryRepairs(repairDto);
-            Assert.listOnlyOne(repairDtos, "报修信息错误!");
-            //获取报修渠道
-            String repairChannel = repairDtos.get(0).getRepairChannel();
-            RepairUserDto repairUserDto = new RepairUserDto();
-            repairUserDto.setRepairId(feeAttrDtos.get(0).getValue());
-            repairUserDto.setState(RepairUserDto.STATE_PAY_FEE);
-            //查询待支付状态的记录
-            List<RepairUserDto> repairUserDtoList = repairUserInnerServiceSMO.queryRepairUsers(repairUserDto);
-            Assert.listOnlyOne(repairUserDtoList, "信息错误!");
-            RepairUserPo repairUserPo = new RepairUserPo();
-            repairUserPo.setRuId(repairUserDtoList.get(0).getRuId());
-            if (repairChannel.equals("Z")) {  //如果业主是自主报修,状态就变成已支付,并新增一条待评价状态
-                repairUserPo.setState(RepairUserDto.STATE_FINISH_PAY_FEE);
-                //如果是待评价状态,就更新结束时间
-                repairUserPo.setEndTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
-                repairUserPo.setContext("已支付" + paramObj.getString("receivedAmount") + "元");
-                //新增待评价状态
-                RepairUserPo repairUser = new RepairUserPo();
-                repairUser.setRuId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_ruId));
-                repairUser.setStartTime(repairUserPo.getEndTime());
-                repairUser.setState(RepairUserDto.STATE_EVALUATE);
-                repairUser.setContext("待评价");
-                repairUser.setCommunityId(paramObj.getString("communityId"));
-                repairUser.setCreateTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
-                repairUser.setRepairId(repairUserDtoList.get(0).getRepairId());
-                repairUser.setStaffId(repairUserDtoList.get(0).getStaffId());
-                repairUser.setStaffName(repairUserDtoList.get(0).getStaffName());
-                repairUser.setPreStaffId(repairUserDtoList.get(0).getStaffId());
-                repairUser.setPreStaffName(repairUserDtoList.get(0).getStaffName());
-                repairUser.setPreRuId(repairUserDtoList.get(0).getRuId());
-                repairUser.setRepairEvent("auditUser");
-                flag = repairUserV1InnerServiceSMOImpl.saveRepairUserNew(repairUserPo);
-                if (flag < 1) {
-                    throw new CmdException("修改失败");
-                }
-            } else {  //如果是员工代客报修或电话报修,状态就变成已支付
-                repairUserPo.setState(RepairUserDto.STATE_FINISH_PAY_FEE);
-                //如果是已支付状态,就更新结束时间
-                repairUserPo.setEndTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A));
-                repairUserPo.setContext("已支付" + paramObj.getString("receivedAmount") + "元");
-                flag = repairUserV1InnerServiceSMOImpl.updateRepairUserNew(repairUserPo);
-                if (flag < 1) {
-                    throw new CmdException("修改失败");
-                }
-            }
-        }
-
-
-    }
 
     /**
      * 修改费用信息
@@ -344,21 +248,17 @@ public class PayOweFeeCmd extends Cmd {
         }
     }
 
-    public void addOweFeeDetail(JSONObject paramInJson, ICmdDataFlowContext dataFlowContext,
-                                List<FeeReceiptDetailPo> feeReceiptDetailPos,
-                                List<FeeReceiptPo> feeReceiptPos,
+    public void addOweFeeDetail(JSONObject paramInJson,
+                                JSONArray detailIds,
                                 UserDto userDto,
                                 String receiptCode,
                                 String payOrderId) {
-
         JSONObject businessFeeDetail = new JSONObject();
         businessFeeDetail.putAll(paramInJson);
         businessFeeDetail.put("detailId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_detailId));
         businessFeeDetail.put("primeRate", paramInJson.getString("primeRate"));
         FeeDto feeDto = (FeeDto) paramInJson.get("feeDto");
-        if (!businessFeeDetail.containsKey("state") || StringUtil.isEmpty(businessFeeDetail.getString("state"))) {
-            businessFeeDetail.put("state", "1400");
-        }
+
 
         businessFeeDetail.put("startTime", paramInJson.getString("startTime"));
         BigDecimal cycles = null;
@@ -394,7 +294,7 @@ public class PayOweFeeCmd extends Cmd {
         }
 
         // todo 如果 扫码枪支付 输入支付订单ID
-        if(!StringUtil.isEmpty(payOrderId)){
+        if (!StringUtil.isEmpty(payOrderId)) {
             payFeeDetailPo.setPayOrderId(payOrderId);
         }
 
@@ -410,96 +310,63 @@ public class PayOweFeeCmd extends Cmd {
         }
 
         paramInJson.put("detailId", businessFeeDetail.getString("detailId"));
-        FeeReceiptPo feeReceiptPo = new FeeReceiptPo();
-        FeeReceiptDetailPo feeReceiptDetailPo = new FeeReceiptDetailPo();
-        feeReceiptDetailPo.setAmount(businessFeeDetail.getString("receivedAmount"));
-        feeReceiptDetailPo.setCommunityId(feeDto.getCommunityId());
-        feeReceiptDetailPo.setCycle(businessFeeDetail.getString("cycles"));
-        feeReceiptDetailPo.setDetailId(businessFeeDetail.getString("detailId"));
-        feeReceiptDetailPo.setEndTime(businessFeeDetail.getString("endTime"));
-        feeReceiptDetailPo.setFeeId(feeDto.getFeeId());
-        feeReceiptDetailPo.setFeeName(StringUtil.isEmpty(feeDto.getImportFeeName()) ? feeDto.getFeeName() : feeDto.getImportFeeName());
-        feeReceiptDetailPo.setStartTime(businessFeeDetail.getString("startTime"));
-        feeReceiptDetailPo.setReceiptId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_receiptId));
-
-        computeFeeSMOImpl.freshFeeReceiptDetail(feeDto, feeReceiptDetailPo);
-        //查询业主信息
-        OwnerDto ownerDto = computeFeeSMOImpl.getFeeOwnerDto(feeDto);
-
-        feeReceiptDetailPos.add(feeReceiptDetailPo);
-        feeReceiptPo.setAmount(feeReceiptDetailPo.getAmount());
-        feeReceiptPo.setCommunityId(feeReceiptDetailPo.getCommunityId());
-        feeReceiptPo.setReceiptId(feeReceiptDetailPo.getReceiptId());
-        feeReceiptPo.setObjType(feeDto.getPayerObjType());
-        feeReceiptPo.setObjId(feeDto.getPayerObjId());
-        feeReceiptPo.setObjName(computeFeeSMOImpl.getFeeObjName(feeDto));
-        feeReceiptPo.setPayObjId(ownerDto.getOwnerId());
-        feeReceiptPo.setPayObjName(ownerDto.getName());
-        feeReceiptPos.add(feeReceiptPo);
+        detailIds.add(businessFeeDetail.getString("detailId"));
     }
 
-    private void updateCarEndTime(JSONObject paramObj) {
-        int flag;
-        FeeDto feeDto = new FeeDto();
-        feeDto.setFeeId(paramObj.getString("feeId"));
-        feeDto.setCommunityId(paramObj.getString("communityId"));
-        List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto);
 
-        if (feeDtos == null || feeDtos.size() < 1) {
+    private void ifHasAccount(JSONObject reqJson, JSONArray fees) {
+        if (!reqJson.containsKey("accountAmount")) {
             return;
         }
-        if (!FeeDto.PAYER_OBJ_TYPE_CAR.equals(feeDtos.get(0).getPayerObjType())) {
+        double accountAmount = reqJson.getDouble("accountAmount");
+        if (accountAmount <= 0) {
             return;
         }
-        Date feeEndTime = feeDtos.get(0).getEndTime();
-        OwnerCarDto ownerCarDto = new OwnerCarDto();
-        ownerCarDto.setCommunityId(paramObj.getString("communityId"));
-        ownerCarDto.setCarId(feeDtos.get(0).getPayerObjId());
-        ownerCarDto.setCarTypeCd("1001"); //业主车辆
-        List<OwnerCarDto> ownerCarDtos = ownerCarInnerServiceSMOImpl.queryOwnerCars(ownerCarDto);
-
-        if (ownerCarDtos == null || ownerCarDtos.size() < 1) {
-            return;
-        }
-        //获取车位id
-        String psId = ownerCarDtos.get(0).getPsId();
-        //获取车辆状态(1001 正常状态,2002 欠费状态  3003 车位释放)
-        String carState = ownerCarDtos.get(0).getState();
-        if (!StringUtil.isEmpty(psId) && "3003".equals(carState)) {
-            ParkingSpaceDto parkingSpaceDto = new ParkingSpaceDto();
-            parkingSpaceDto.setPsId(psId);
-            List<ParkingSpaceDto> parkingSpaceDtos = parkingSpaceInnerServiceSMOImpl.queryParkingSpaces(parkingSpaceDto);
-            Assert.listOnlyOne(parkingSpaceDtos, "查询车位信息错误!");
-            //获取车位状态(出售 S,出租 H ,空闲 F)
-            String state = parkingSpaceDtos.get(0).getState();
-            if (!StringUtil.isEmpty(state) && !state.equals("F")) {
-                throw new IllegalArgumentException("车位已被使用,不能再缴费!");
-            }
+
+        Assert.hasKeyAndValue(reqJson, "acctId", "未包含账户ID");
+        String acctId = reqJson.getString("acctId");
+        //todo 校验账户金额是否充足
+        AccountDto accountDto = new AccountDto();
+        accountDto.setAcctId(acctId);
+        List<AccountDto> accountDtos = accountInnerServiceSMOImpl.queryAccounts(accountDto);
+
+        Assert.listOnlyOne(accountDtos, "账户不存在");
+
+        if (Double.parseDouble(accountDtos.get(0).getAmount()) < accountAmount) {
+            throw new CmdException("账户余额不足");
         }
 
+        BigDecimal accountAmountDec = null;
 
-        Calendar endTimeCalendar = null;
-        //车位费用续租
-        for (OwnerCarDto tmpOwnerCarDto : ownerCarDtos) {
-            //后付费 或者信用期车辆 加一个月
-            if (FeeConfigDto.PAYMENT_CD_AFTER.equals(feeDtos.get(0).getPaymentCd())
-                    || OwnerCarDto.CAR_TYPE_CREDIT.equals(tmpOwnerCarDto.getCarType())) {
-                endTimeCalendar = Calendar.getInstance();
-                endTimeCalendar.setTime(feeEndTime);
-                endTimeCalendar.add(Calendar.MONTH, 1);
-                feeEndTime = endTimeCalendar.getTime();
-            }
-            if (tmpOwnerCarDto.getEndTime().getTime() >= feeEndTime.getTime()) {
+        // todo 从费用实际缴费中扣款
+        JSONObject feeObject = null;
+        double receivedAmount = 0.0;
+        BigDecimal receivedAmountDec = null;
+        for (int feeIndex = 0; feeIndex < fees.size(); feeIndex++) {
+            if (accountAmount == 0) {
                 continue;
             }
-            OwnerCarPo ownerCarPo = new OwnerCarPo();
-            ownerCarPo.setMemberId(tmpOwnerCarDto.getMemberId());
-            ownerCarPo.setEndTime(DateUtil.getFormatTimeString(feeEndTime, DateUtil.DATE_FORMATE_STRING_A));
-            flag = ownerCarNewV1InnerServiceSMOImpl.updateOwnerCarNew(ownerCarPo);
-            if (flag < 1) {
-                throw new CmdException("缴费失败");
+            accountAmountDec = new BigDecimal(accountAmount);
+            feeObject = fees.getJSONObject(feeIndex);
+            receivedAmount = feeObject.getDouble("receivedAmount");
+            receivedAmountDec = new BigDecimal(receivedAmount);
+            if (receivedAmount >= accountAmount) {
+                receivedAmountDec = receivedAmountDec.subtract(accountAmountDec).setScale(2, BigDecimal.ROUND_HALF_UP);
+                feeObject.put("receivedAmount", receivedAmountDec.doubleValue());
+                feeObject.put("accountAmount", accountAmount);
+                feeObject.put("acctId", acctId);
+                accountAmount = 0.00;
+                continue;
             }
+
+            feeObject.put("receivedAmount", "0");
+            feeObject.put("accountAmount", receivedAmount);
+            feeObject.put("acctId", acctId);
+
+            accountAmountDec = accountAmountDec.subtract(receivedAmountDec).setScale(2, BigDecimal.ROUND_HALF_UP);
+            accountAmount = accountAmountDec.doubleValue();
         }
-    }
 
+
+    }
 }