java110-bean/src/main/java/com/java110/dto/reportFeeMonthStatistics/ReportFeeMonthStatisticsDto.java
@@ -123,6 +123,10 @@ //赠送金额 private String giftAmount; //账户抵扣金额 private String withholdAmount; //收费率 private String chargeRate; @@ -760,4 +764,12 @@ public void setUnitIds(String[] unitIds) { this.unitIds = unitIds; } public String getWithholdAmount() { return withholdAmount; } public void setWithholdAmount(String withholdAmount) { this.withholdAmount = withholdAmount; } } java110-db/src/main/resources/mapper/report/ReportFeeMonthStatisticsServiceDaoImplMapper.xml
@@ -1730,7 +1730,8 @@ importFeeName,t.prime_rate,d.name primeRate,fdr.discount_small_type discountSmallType,fdr.rule_name ruleName,pfdd.discount_price discountPrice,co.contract_code contractCode,pfo.`value` ownerName,cb.o_id oId, d2.name feeTypeCdName,pfc.fee_type_cd feeTypeCd,t.state,d3.name stateName,t.fee_id feeId,pft.`value` repairId, t.detail_id,t.detail_id detailId,pf.payer_obj_id,pfb.value ownerId,concat(pa.num,'停车场',ps.num,'车位') psName t.detail_id,t.detail_id detailId,pf.payer_obj_id,pfb.value ownerId,concat(pa.num,'停车场',ps.num,'车位') psName, fad.amount withholdAmount from pay_fee_detail t left JOIN pay_fee pf on t.fee_id = pf.fee_id and pf.status_cd = '0' left join pay_fee_config pfc on pf.config_id = pfc.config_id and pfc.status_cd = '0' @@ -1755,7 +1756,9 @@ "state" LEFT JOIN contract co on pf.payer_obj_id = co.contract_id and co.status_cd = '0' and pf.payer_obj_type='7777' LEFT JOIN c_business cb on t.b_id = cb.b_id where t.status_cd = '0' and pf.status_cd = '0' left join fee_account_detail fad on t.detail_id = fad.detail_id and t.community_id = fad.community_id and fad.status_cd = '0' and fad.state = '1002' where t.status_cd = '0' and pf.status_cd = '0' <if test="roomNum !=null and roomNum != ''"> and br.room_num= #{roomNum} </if> service-fee/src/main/java/com/java110/fee/cmd/fee/PayFeeCmd.java
@@ -126,6 +126,8 @@ @Autowired private IFeeAccountDetailServiceSMO feeAccountDetailServiceSMOImpl; @Override public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException { Assert.jsonObjectHaveKey(reqJson, "communityId", "请求报文中未包含communityId节点"); @@ -202,98 +204,10 @@ payFeeDetailPo.setReceivableAmount(feeDetail.getString("totalFeePrice")); //判断是否有赠送规则 hasDiscount(paramObj, payFeePo, payFeeDetailPo); //判断选择的账号 JSONArray jsonArray = paramObj.getJSONArray("selectUserAccount"); if (jsonArray == null || jsonArray.size() < 1) { FeeAccountDetailPo feeAccountDetailPo = new FeeAccountDetailPo(); feeAccountDetailPo.setFadId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_fadId)); feeAccountDetailPo.setDetailId(payFeeDetailPo.getDetailId()); feeAccountDetailPo.setCommunityId(payFeeDetailPo.getCommunityId()); feeAccountDetailPo.setState("1001"); //1001 无抵扣 1002 现金账户抵扣 1003 积分账户抵扣 1004 优惠券抵扣 feeAccountDetailPo.setAmount(paramObj.getString("receivedAmount")); feeAccountDetailServiceSMOImpl.saveFeeAccountDetail(feeAccountDetailPo); } for (int columnIndex = 0; columnIndex < jsonArray.size(); columnIndex++) { JSONObject param = jsonArray.getJSONObject(columnIndex); if (AccountDto.ACCT_TYPE_INTEGRAL.equals(param.getString("acctType"))) { //积分账户 //账户金额 BigDecimal amount = new BigDecimal(param.getString("amount")); //获取最大抵扣积分 BigDecimal maximumNumber = new BigDecimal(param.getString("maximumNumber")); //获取积分抵扣 BigDecimal deductionProportion = new BigDecimal(param.getString("deductionProportion")); int flag = amount.compareTo(maximumNumber); BigDecimal redepositAmount = new BigDecimal("0.00"); if (flag == 1) { //账户积分大于最大使用积分,就用最大使用积分抵扣 redepositAmount = maximumNumber; } if (flag > -1) { //账户积分大于等于最大使用积分,就用最大使用积分抵扣 redepositAmount = maximumNumber; } if (flag == -1) { //账户积分小于最大使用积分,就用账户积分抵扣 redepositAmount = amount; } if (flag < 1) { //账户积分小于等于最大使用积分,就用账户积分抵扣 redepositAmount = amount; } if (flag == 0) { //账户积分等于最大使用积分 redepositAmount = amount; } //计算积分换算的金额 BigDecimal divide = redepositAmount.divide(deductionProportion); BigDecimal receivedAmount = new BigDecimal(payFeeDetailPo.getReceivedAmount()); //计算实付金额 int flag2 = divide.compareTo(receivedAmount); BigDecimal subtract = new BigDecimal("0.00"); //生成抵扣明细记录 FeeAccountDetailPo feeAccountDetailPo = new FeeAccountDetailPo(); if (flag2 == -1) { //积分换算金额小于实付金额 subtract = receivedAmount.subtract(divide); feeAccountDetailPo.setAmount(divide.toString()); //积分抵扣金额 } else if (flag < 1) { //积分换算金额小于等于实付金额 subtract = receivedAmount.subtract(divide); feeAccountDetailPo.setAmount(divide.toString()); //积分抵扣金额 } else { feeAccountDetailPo.setAmount(receivedAmount.toString()); //积分抵扣金额 } payFeeDetailPo.setReceivedAmount(subtract.toString()); feeAccountDetailPo.setFadId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_fadId)); feeAccountDetailPo.setDetailId(payFeeDetailPo.getDetailId()); feeAccountDetailPo.setCommunityId(payFeeDetailPo.getCommunityId()); feeAccountDetailPo.setState("1003"); //1001 无抵扣 1002 现金账户抵扣 1003 积分账户抵扣 1004 优惠券抵扣 feeAccountDetailServiceSMOImpl.saveFeeAccountDetail(feeAccountDetailPo); } else if (!StringUtil.isEmpty(param.getString("acctType")) && param.getString("acctType").equals("2003")) { //现金账户 //账户金额 BigDecimal amount = new BigDecimal(param.getString("amount")); //实收金额 BigDecimal receivedAmount = new BigDecimal(payFeeDetailPo.getReceivedAmount()); int flag = amount.compareTo(receivedAmount); BigDecimal redepositAmount = new BigDecimal("0.00"); if (flag == 1) { //现金账户大于实收金额,就用实收金额 redepositAmount = receivedAmount; } if (flag > -1) { //现金账户大于等于实收金额,就用实收金额 redepositAmount = receivedAmount; } if (flag == -1) { //现金账户小于实收金额,就用现金账户 redepositAmount = amount; } if (flag < 1) { //现金账户小于等于实收金额,就用现金账户 redepositAmount = amount; } if (flag == 0) { //现金账户等于实收金额 redepositAmount = amount; } //生成抵扣明细记录 FeeAccountDetailPo feeAccountDetailPo = new FeeAccountDetailPo(); feeAccountDetailPo.setFadId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_fadId)); feeAccountDetailPo.setDetailId(payFeeDetailPo.getDetailId()); feeAccountDetailPo.setCommunityId(payFeeDetailPo.getCommunityId()); feeAccountDetailPo.setState("1002"); //1001 无抵扣 1002 现金账户抵扣 1003 积分账户抵扣 1004 优惠券抵扣 feeAccountDetailPo.setAmount(redepositAmount.toString()); //积分抵扣金额 feeAccountDetailServiceSMOImpl.saveFeeAccountDetail(feeAccountDetailPo); } } // todo 处理用户账户 dealUserAccount(paramObj, payFeeDetailPo); payFeeDetailPo.setPayOrderId(payFeeDetailPo.getDetailId()); int flag = payFeeDetailNewV1InnerServiceSMOImpl.savePayFeeDetailNew(payFeeDetailPo); if (flag < 1) { @@ -342,18 +256,111 @@ } } // //根据明细ID 查询收据信息 //根据明细ID 查询收据信息 FeeReceiptDetailDto feeReceiptDetailDto = new FeeReceiptDetailDto(); feeReceiptDetailDto.setDetailId(paramObj.getString("detailId")); // feeReceiptDetailDto.setCommunityId(paramObj.getString("communityId")); // List<FeeReceiptDetailDto> feeReceiptDetailDtos = feeReceiptDetailInnerServiceSMOImpl.queryFeeReceiptDetails(feeReceiptDetailDto); // // if (feeReceiptDetailDtos != null && feeReceiptDetailDtos.size() > 0) { // cmdDataFlowContext.setResponseEntity(ResultVo.createResponseEntity(feeReceiptDetailDtos.get(0))); // return; // } cmdDataFlowContext.setResponseEntity(ResultVo.createResponseEntity(feeReceiptDetailDto)); } private void dealUserAccount(JSONObject paramObj, PayFeeDetailPo payFeeDetailPo) { //判断选择的账号 JSONArray jsonArray = paramObj.getJSONArray("selectUserAccount"); if (jsonArray == null || jsonArray.size() < 1) { return; } BigDecimal integralSum = new BigDecimal(0); BigDecimal cashSum = new BigDecimal(0); for (int columnIndex = 0; columnIndex < jsonArray.size(); columnIndex++) { JSONObject param = jsonArray.getJSONObject(columnIndex); //账户金额 BigDecimal amount = new BigDecimal(param.getString("amount")); if (AccountDto.ACCT_TYPE_INTEGRAL.equals(param.getString("acctType"))) { //积分账户 //获取最大抵扣积分 BigDecimal maximumNumber = new BigDecimal(param.getString("maximumNumber")); //获取积分抵扣 BigDecimal deductionProportion = new BigDecimal(param.getString("deductionProportion")); int flag = amount.compareTo(maximumNumber); BigDecimal redepositAmount = new BigDecimal("0.00"); if (flag == 1) { //账户积分大于最大使用积分,就用最大使用积分抵扣 redepositAmount = maximumNumber; } if (flag > -1) { //账户积分大于等于最大使用积分,就用最大使用积分抵扣 redepositAmount = maximumNumber; } if (flag == -1) { //账户积分小于最大使用积分,就用账户积分抵扣 redepositAmount = amount; } if (flag < 1) { //账户积分小于等于最大使用积分,就用账户积分抵扣 redepositAmount = amount; } if (flag == 0) { //账户积分等于最大使用积分 redepositAmount = amount; } //计算积分换算的金额 BigDecimal divide = redepositAmount.divide(deductionProportion); BigDecimal receivedAmount = new BigDecimal(payFeeDetailPo.getReceivedAmount()); //计算实付金额 int flag2 = divide.compareTo(receivedAmount); BigDecimal subtract = new BigDecimal("0.00"); //生成抵扣明细记录 if (flag2 == -1) { //积分换算金额小于实付金额 subtract = receivedAmount.subtract(divide); } else if (flag < 1) { //积分换算金额小于等于实付金额 subtract = receivedAmount.subtract(divide); } integralSum = integralSum.add(subtract); payFeeDetailPo.setReceivedAmount(subtract.toString()); } else if (AccountDto.ACCT_TYPE_CASH.equals(param.getString("acctType"))) { //现金账户 //实收金额 BigDecimal receivedAmount = new BigDecimal(payFeeDetailPo.getReceivedAmount()); int flag = amount.compareTo(receivedAmount); BigDecimal redepositAmount = new BigDecimal(0.00); if (flag == 1) { //现金账户大于实收金额,就用实收金额 redepositAmount = receivedAmount; } if (flag > -1) { //现金账户大于等于实收金额,就用实收金额 redepositAmount = receivedAmount; } if (flag == -1) { //现金账户小于实收金额,就用现金账户 redepositAmount = amount; } if (flag < 1) { //现金账户小于等于实收金额,就用现金账户 redepositAmount = amount; } if (flag == 0) { //现金账户等于实收金额 redepositAmount = amount; } cashSum = cashSum.add(redepositAmount); } // todo 如果积分大于0 if (integralSum.doubleValue() > 0) { FeeAccountDetailPo feeAccountDetailPo = new FeeAccountDetailPo(); feeAccountDetailPo.setFadId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_fadId)); feeAccountDetailPo.setDetailId(payFeeDetailPo.getDetailId()); feeAccountDetailPo.setCommunityId(payFeeDetailPo.getCommunityId()); feeAccountDetailPo.setAmount(integralSum.doubleValue() + ""); feeAccountDetailPo.setState("1003"); //1001 无抵扣 1002 现金账户抵扣 1003 积分账户抵扣 1004 优惠券抵扣 feeAccountDetailServiceSMOImpl.saveFeeAccountDetail(feeAccountDetailPo); } if (cashSum.doubleValue() > 0) { //生成抵扣明细记录 FeeAccountDetailPo feeAccountDetailPo = new FeeAccountDetailPo(); feeAccountDetailPo.setFadId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_fadId)); feeAccountDetailPo.setDetailId(payFeeDetailPo.getDetailId()); feeAccountDetailPo.setCommunityId(payFeeDetailPo.getCommunityId()); feeAccountDetailPo.setState("1002"); //1001 无抵扣 1002 现金账户抵扣 1003 积分账户抵扣 1004 优惠券抵扣 feeAccountDetailPo.setAmount(cashSum.doubleValue() + ""); //现金抵扣金额 feeAccountDetailServiceSMOImpl.saveFeeAccountDetail(feeAccountDetailPo); BigDecimal receivedAmountDec = new BigDecimal(payFeeDetailPo.getReceivedAmount()); receivedAmountDec = receivedAmountDec.subtract(cashSum); payFeeDetailPo.setReceivedAmount(receivedAmountDec.doubleValue() + ""); } } } /** @@ -499,7 +506,7 @@ feeDto.setCommunityId(paramObj.getString("communityId")); List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto); if(feeDtos == null || feeDtos.size() < 1){ if (feeDtos == null || feeDtos.size() < 1) { return; } if (!FeeDto.PAYER_OBJ_TYPE_CAR.equals(feeDtos.get(0).getPayerObjType())) { @@ -536,11 +543,11 @@ //车位费用续租 for (OwnerCarDto tmpOwnerCarDto : ownerCarDtos) { //后付费 或者信用期车辆 加一个月 if(FeeConfigDto.PAYMENT_CD_AFTER.equals(feeDtos.get(0).getPaymentCd()) || OwnerCarDto.CAR_TYPE_CREDIT.equals(tmpOwnerCarDto.getCarType())){ 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); endTimeCalendar.add(Calendar.MONTH, 1); feeEndTime = endTimeCalendar.getTime(); } if (tmpOwnerCarDto.getEndTime().getTime() >= feeEndTime.getTime()) { service-fee/src/main/java/com/java110/fee/cmd/fee/PayFeeConfirmCmd.java
@@ -32,6 +32,7 @@ import com.java110.po.car.OwnerCarPo; import com.java110.po.couponUser.CouponUserPo; import com.java110.po.couponUserDetail.CouponUserDetailPo; import com.java110.po.feeAccountDetail.FeeAccountDetailPo; import com.java110.po.owner.RepairPoolPo; import com.java110.po.owner.RepairUserPo; import com.java110.po.parkingSpaceApply.ParkingSpaceApplyPo; @@ -103,6 +104,9 @@ @Autowired private IAccountInnerServiceSMO accountInnerServiceSMOImpl; @Autowired private IFeeAccountDetailServiceSMO feeAccountDetailServiceSMOImpl; //默认序列 protected static final int DEFAULT_SEQ = 1; @@ -129,11 +133,11 @@ paramObj.put("primeRate", "6"); paramObj.put("remark", "线上小程序支付"); } paramObj.put("detailId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_detailId)); //处理现金账户 dealAccount(paramObj); paramObj.put("detailId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_detailId)); //处理 优惠折扣 addDiscount(paramObj); @@ -287,6 +291,18 @@ throw new CmdException("账户金额不足"); } // 现金账户扣款记录,生成抵扣明细记录 FeeAccountDetailPo feeAccountDetailPo = new FeeAccountDetailPo(); feeAccountDetailPo.setFadId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_fadId)); feeAccountDetailPo.setDetailId(paramObj.getString("detailId")); feeAccountDetailPo.setCommunityId(paramObj.getString("communityId")); feeAccountDetailPo.setState("1002"); //1001 无抵扣 1002 现金账户抵扣 1003 积分账户抵扣 1004 优惠券抵扣 feeAccountDetailPo.setAmount(paramObj.getDouble("deductionAmount") + ""); //现金抵扣金额 feeAccountDetailServiceSMOImpl.saveFeeAccountDetail(feeAccountDetailPo); // BigDecimal receivedAmountDec = new BigDecimal(payFeeDetailPo.getReceivedAmount()); // receivedAmountDec = receivedAmountDec.subtract(cashSum); // payFeeDetailPo.setReceivedAmount(receivedAmountDec.doubleValue() + ""); paramObj.put("remark", paramObj.getString("remark") + "-现金账户抵扣" + paramObj.getDouble("deductionAmount") + "元"); } @@ -391,8 +407,8 @@ } for (OwnerCarDto tmpOwnerCarDto : ownerCarDtos) { //后付费 或者信用期车辆 加一个月 if(FeeConfigDto.PAYMENT_CD_AFTER.equals(feeDtos.get(0).getPaymentCd()) || OwnerCarDto.CAR_TYPE_CREDIT.equals(tmpOwnerCarDto.getCarType())){ 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); service-fee/src/main/java/com/java110/fee/cmd/fee/PayFeePreCmd.java
@@ -283,177 +283,7 @@ } BigDecimal money = new BigDecimal(0); BigDecimal totalAccountAmount = new BigDecimal(0); for (AccountDto tmpAccountDto : accountDtos) { if (!StringUtil.isEmpty(tmpAccountDto.getAcctType()) && tmpAccountDto.getAcctType().equals("2004")) { //积分账户 String maximum = ""; String deduction = ""; for (int index = 0; index < selectUserAccount.size(); index++) { JSONObject param = selectUserAccount.getJSONObject(index); if (!StringUtil.isEmpty(param.getString("acctType")) && param.getString("acctType").equals("2004")) { //积分账户 maximum = param.getString("maximumNumber"); deduction = param.getString("deductionProportion"); } } //账户金额 BigDecimal amount = new BigDecimal(tmpAccountDto.getAmount()); //获取最大抵扣积分 BigDecimal maximumNumber = new BigDecimal(maximum); //获取积分抵扣比例 BigDecimal deductionProportion = new BigDecimal(deduction); int flag = amount.compareTo(maximumNumber); BigDecimal redepositAmount = new BigDecimal("0.00"); BigDecimal integralAmount = new BigDecimal("0.00"); if (flag == 1) { //账户积分大于最大使用积分,就用最大使用积分抵扣 redepositAmount = maximumNumber; integralAmount = amount.subtract(maximumNumber); } if (flag > -1) { //账户积分大于等于最大使用积分,就用最大使用积分抵扣 redepositAmount = maximumNumber; integralAmount = amount.subtract(maximumNumber); } if (flag == -1) { //账户积分小于最大使用积分,就用账户积分抵扣 redepositAmount = amount; } if (flag < 1) { //账户积分小于等于最大使用积分,就用账户积分抵扣 redepositAmount = amount; } if (flag == 0) { //账户积分等于最大使用积分 redepositAmount = amount; } //更新账户信息 // AccountPo accountPo = new AccountPo(); // accountPo.setAcctId(tmpAccountDto.getAcctId()); // accountPo.setAmount(integralAmount.toString()); // accountInnerServiceSMOImpl.updateAccount(accountPo); //生成账户详情 // AccountDetailPo accountDetailPo = new AccountDetailPo(); // accountDetailPo.setDetailId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_detailId)); // accountDetailPo.setAcctId(tmpAccountDto.getAcctId()); // accountDetailPo.setDetailType("2002"); //1001 转入 2002 转出 // accountDetailPo.setRelAcctId("-1"); // accountDetailPo.setAmount(redepositAmount.toString()); // accountDetailPo.setObjType("6006"); //6006 个人 7007 商户 // accountDetailPo.setObjId(tmpAccountDto.getObjId()); // accountDetailPo.setOrderId("-1"); // accountDetailPo.setbId("-1"); // accountDetailPo.setRemark("手机端积分抵扣"); // accountDetailPo.setCreateTime(new Date()); // accountDetailInnerServiceSMOImpl.saveAccountDetails(accountDetailPo); //计算积分换算的金额 BigDecimal divide = redepositAmount.divide(deductionProportion); BigDecimal dedAmount = new BigDecimal(deductionAmount); //计算实付金额 int flag2 = divide.compareTo(dedAmount); BigDecimal subtract = new BigDecimal("0.00"); //生成抵扣明细记录 FeeAccountDetailPo feeAccountDetailPo = new FeeAccountDetailPo(); if (flag2 == -1) { //积分换算金额小于应付金额 //subtract = dedAmount.subtract(divide); BigDecimal multiply = divide.multiply(deductionProportion); feeAccountDetailPo.setAmount(multiply.toString()); //积分抵扣金额 } else if (flag < 1) { //积分换算金额小于等于应付金额 //subtract = dedAmount.subtract(divide); BigDecimal multiply = divide.multiply(deductionProportion); feeAccountDetailPo.setAmount(multiply.toString()); //积分抵扣金额 } else { BigDecimal multiply = dedAmount.multiply(deductionProportion); feeAccountDetailPo.setAmount(multiply.toString()); //积分抵扣金额 } reqJson.put("receivedMoney", divide); // feeAccountDetailPo.setFadId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_fadId)); // feeAccountDetailPo.setDetailId(accountDetailPo.getDetailId()); // feeAccountDetailPo.setCommunityId(reqJson.getString("communityId")); // feeAccountDetailPo.setState("1003"); //1001 无抵扣 1002 现金账户抵扣 1003 积分账户抵扣 1004 优惠券抵扣 // feeAccountDetailServiceSMOImpl.saveFeeAccountDetail(feeAccountDetailPo); money = divide; } else if (!StringUtil.isEmpty(tmpAccountDto.getAcctType()) && tmpAccountDto.getAcctType().equals("2003")) { //现金账户 //账户金额 BigDecimal amount = new BigDecimal(tmpAccountDto.getAmount()); //获取应收金额 BigDecimal dedAmount = new BigDecimal("0.00"); if (reqJson.containsKey("receivedMoney") && !StringUtil.isEmpty(reqJson.getString("receivedMoney"))) { dedAmount = new BigDecimal(reqJson.getString("receivedMoney")); } else { dedAmount = new BigDecimal(reqJson.getString("deductionAmount")); } int flag = amount.compareTo(dedAmount); BigDecimal redepositAmount = new BigDecimal("0.00"); BigDecimal integralAmount = new BigDecimal("0.00"); if (flag == 1) { //现金账户大于应收金额,就用应收金额抵扣 redepositAmount = dedAmount; integralAmount = amount.subtract(dedAmount); } if (flag > -1) { //现金账户大于等于应收金额,就用应收金额抵扣 redepositAmount = dedAmount; integralAmount = amount.subtract(dedAmount); } if (flag == -1) { //现金账户小于实收金额,就用现金账户抵扣 redepositAmount = amount; } if (flag < 1) { //现金账户小于等于应收金额,就用现金账户抵扣 redepositAmount = amount; } if (flag == 0) { //现金账户等于应收金额 redepositAmount = amount; } //更新账户信息 // AccountPo accountPo = new AccountPo(); // accountPo.setAcctId(tmpAccountDto.getAcctId()); // accountPo.setAmount(integralAmount.toString()); // accountInnerServiceSMOImpl.updateAccount(accountPo); //生成账户详情 // AccountDetailPo accountDetailPo = new AccountDetailPo(); // accountDetailPo.setDetailId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_detailId)); // accountDetailPo.setAcctId(tmpAccountDto.getAcctId()); // accountDetailPo.setDetailType("2002"); //1001 转入 2002 转出 // accountDetailPo.setRelAcctId("-1"); // accountDetailPo.setAmount(redepositAmount.toString()); // accountDetailPo.setObjType("6006"); //6006 个人 7007 商户 // accountDetailPo.setObjId(tmpAccountDto.getObjId()); // accountDetailPo.setOrderId("-1"); // accountDetailPo.setbId("-1"); // accountDetailPo.setRemark("手机端现金账户抵扣"); // accountDetailPo.setCreateTime(new Date()); // accountDetailInnerServiceSMOImpl.saveAccountDetails(accountDetailPo); //生成抵扣明细记录 // FeeAccountDetailPo feeAccountDetailPo = new FeeAccountDetailPo(); // feeAccountDetailPo.setFadId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_fadId)); // feeAccountDetailPo.setDetailId(accountDetailPo.getDetailId()); // feeAccountDetailPo.setCommunityId(reqJson.getString("communityId")); // feeAccountDetailPo.setState("1002"); //1001 无抵扣 1002 现金账户抵扣 1003 积分账户抵扣 1004 优惠券抵扣 // feeAccountDetailPo.setAmount(redepositAmount.toString()); //积分抵扣金额 // feeAccountDetailServiceSMOImpl.saveFeeAccountDetail(feeAccountDetailPo); money = money.add(redepositAmount); /*int flag2 = money.compareTo(amount); if (flag2 == 1) { //剩余金额大于现金账户 money = money.subtract(amount); } if (flag2 > -1) { //剩余金额大于等于现金账户 money = money.subtract(amount); } if (flag2 == -1) { //剩余金额小于现金账户 money = new BigDecimal(0); } if (flag2 < 1) { //剩余金额小于等于现金账户 money = new BigDecimal(0); } if (flag2 == 0) { //剩余金额等于现金账户 money = new BigDecimal(0); }*/ } // totalAccountAmount = totalAccountAmount.add(new BigDecimal(tmpAccountDto.getAmount())); } /* double tmpDeductionAmount = totalAccountAmount.subtract(new BigDecimal(deductionAmount)).doubleValue(); if (tmpDeductionAmount < 0) { reqJson.put("deductionAmount", totalAccountAmount.doubleValue()); reqJson.put("selectUserAccount", BeanConvertUtil.beanCovertJSONArray(accountDtos)); return totalAccountAmount.doubleValue(); } reqJson.put("deductionAmount", deductionAmount); reqJson.put("selectUserAccount", BeanConvertUtil.beanCovertJSONArray(accountDtos)); return deductionAmount;*/ reqJson.put("deductionAmount", money.doubleValue()); reqJson.put("selectUserAccount", BeanConvertUtil.beanCovertJSONArray(accountDtos)); return money.doubleValue();