| | |
| | | import com.java110.core.annotation.Java110Cmd; |
| | | import com.java110.core.annotation.Java110Transactional; |
| | | import com.java110.core.context.ICmdDataFlowContext; |
| | | import com.java110.core.event.cmd.AbstractServiceCmdListener; |
| | | import com.java110.core.event.cmd.Cmd; |
| | | import com.java110.core.event.cmd.CmdEvent; |
| | | import com.java110.core.factory.GenerateCodeFactory; |
| | | import com.java110.core.log.LoggerFactory; |
| | |
| | | import com.java110.intf.community.IRepairUserInnerServiceSMO; |
| | | import com.java110.intf.community.IRoomInnerServiceSMO; |
| | | import com.java110.intf.fee.*; |
| | | import com.java110.intf.fee.IFeeAccountDetailServiceSMO; |
| | | import com.java110.intf.user.IOwnerCarInnerServiceSMO; |
| | | import com.java110.po.accountDetail.AccountDetailPo; |
| | | import com.java110.po.applyRoomDiscount.ApplyRoomDiscountPo; |
| | | import com.java110.po.car.OwnerCarPo; |
| | | import com.java110.po.fee.PayFeeDetailPo; |
| | | import com.java110.po.fee.PayFeePo; |
| | | import com.java110.po.feeAccountDetail.FeeAccountDetailPo; |
| | | import com.java110.po.owner.RepairPoolPo; |
| | | import com.java110.po.owner.RepairUserPo; |
| | | import com.java110.po.payFeeDetailDiscount.PayFeeDetailDiscountPo; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | @Java110Cmd(serviceCode = "fee.payFee") |
| | | public class PayFeeCmd extends AbstractServiceCmdListener { |
| | | private static Logger logger = LoggerFactory.getLogger(PayFeeCmd.class); |
| | | public class PayFeeCmd extends Cmd { |
| | | |
| | | private static Logger logger = LoggerFactory.getLogger(PayFeeCmd.class); |
| | | |
| | | @Autowired |
| | | private IPayFeeV1InnerServiceSMO payFeeV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IPayFeeDetailNewV1InnerServiceSMO payFeeDetailNewV1InnerServiceSMOImpl; |
| | | |
| | |
| | | @Autowired |
| | | private IOwnerCarInnerServiceSMO ownerCarInnerServiceSMOImpl; |
| | | |
| | | |
| | | @Autowired |
| | | private IFeeReceiptDetailInnerServiceSMO feeReceiptDetailInnerServiceSMOImpl; |
| | | |
| | |
| | | @Autowired |
| | | private IParkingSpaceInnerServiceSMO parkingSpaceInnerServiceSMOImpl; |
| | | |
| | | |
| | | @Autowired |
| | | private IAccountDetailInnerServiceSMO accountDetailInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IAccountInnerServiceSMO accountInnerServiceSMOImpl; |
| | | |
| | | |
| | | @Autowired |
| | | private IComputeFeeSMO computeFeeSMOImpl; |
| | | |
| | | @Autowired |
| | | private IPayFeeDetailDiscountNewV1InnerServiceSMO payFeeDetailDiscountNewV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IRepairPoolNewV1InnerServiceSMO repairPoolNewV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IRepairUserNewV1InnerServiceSMO repairUserNewV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private ICouponUserV1InnerServiceSMO couponUserV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private ICouponUserDetailV1InnerServiceSMO couponUserDetailV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IOwnerCarNewV1InnerServiceSMO ownerCarNewV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IFeeAccountDetailServiceSMO feeAccountDetailServiceSMOImpl; |
| | | |
| | | @Override |
| | | public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException { |
| | |
| | | feeConfigDto.setCommunityId(reqJson.getString("communityId")); |
| | | List<FeeConfigDto> feeConfigDtos = feeConfigInnerServiceSMOImpl.queryFeeConfigs(feeConfigDto); |
| | | |
| | | if (feeConfigDtos != null && feeConfigDtos.size() == 1) { |
| | | if (feeConfigDtos == null || feeConfigDtos.size() != 1) { |
| | | throw new IllegalArgumentException("费用项不存在"); |
| | | } |
| | | //一次性费用 和间接性费用 |
| | | Date maxEndTime = feeDtos.get(0).getDeadlineTime(); |
| | | //周期性费用 |
| | | if (FeeDto.FEE_FLAG_CYCLE.equals(feeConfigDtos.get(0).getFeeFlag()) |
| | | || FeeDto.FEE_FLAG_CYCLE_ONCE.equals(feeConfigDtos.get(0).getFeeFlag())) { |
| | | try { |
| | | Date configEndTime = DateUtil.getDateFromString(feeConfigDtos.get(0).getEndTime(), DateUtil.DATE_FORMATE_STRING_A); |
| | | |
| | | Date newDate = DateUtil.stepMonth(endTime, reqJson.getInteger("cycles") - 1); |
| | | |
| | | if (newDate.getTime() > configEndTime.getTime()) { |
| | | throw new IllegalArgumentException("缴费周期超过 缴费结束时间"); |
| | | } |
| | | |
| | | maxEndTime = DateUtil.getDateFromString(feeConfigDtos.get(0).getEndTime(), DateUtil.DATE_FORMATE_STRING_A); |
| | | } catch (ParseException e) { |
| | | } catch (Exception e) { |
| | | logger.error("比较费用日期失败", e); |
| | | } |
| | | Date newDate = DateUtil.stepMonth(endTime, reqJson.getDouble("cycles").intValue()); |
| | | if (newDate.getTime() > maxEndTime.getTime()) { |
| | | throw new IllegalArgumentException("缴费周期超过 缴费结束时间"); |
| | | } |
| | | } |
| | | |
| | | String selectUserAccount = reqJson.getString("selectUserAccount"); |
| | | JSONArray params = JSONArray.parseArray(selectUserAccount); |
| | | for (int paramIndex = 0; paramIndex < params.size(); paramIndex++) { |
| | | JSONObject param = params.getJSONObject(paramIndex); |
| | | String maximumNumber = param.getString("maximumNumber"); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | @Java110Transactional |
| | |
| | | try { |
| | | DistributedLock.waitGetDistributedLock(key, requestId); |
| | | JSONObject feeDetail = addFeeDetail(paramObj); |
| | | JSONObject fee = modifyFee(paramObj); |
| | | payFeePo = BeanConvertUtil.covertBean(fee, PayFeePo.class); |
| | | PayFeeDetailPo payFeeDetailPo = BeanConvertUtil.covertBean(feeDetail, PayFeeDetailPo.class); |
| | | //判断是否有赠送规则 |
| | | if (paramObj.containsKey("selectDiscount")) { |
| | | JSONArray selectDiscount = paramObj.getJSONArray("selectDiscount"); |
| | | if (selectDiscount != null && selectDiscount.size() > 0) { |
| | | for (int index = 0; index < selectDiscount.size(); index++) { |
| | | JSONObject paramJson = selectDiscount.getJSONObject(index); |
| | | if (!StringUtil.isEmpty(paramJson.getString("ruleId")) && paramJson.getString("ruleId").equals("102020008")) { //赠送规则 |
| | | JSONArray feeDiscountSpecs = paramJson.getJSONArray("feeDiscountSpecs"); |
| | | if (feeDiscountSpecs.size() > 0) { |
| | | for (int specIndex = 0; specIndex < feeDiscountSpecs.size(); specIndex++) { |
| | | JSONObject paramIn = feeDiscountSpecs.getJSONObject(specIndex); |
| | | if (!StringUtil.isEmpty(paramIn.getString("specId")) && paramIn.getString("specId").equals("89002020980015")) { //赠送月份 |
| | | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String specValue = paramIn.getString("specValue"); |
| | | //获取费用结束时间(也就是下次费用开始时间) |
| | | Date endTime = df.parse(payFeeDetailPo.getEndTime()); |
| | | Calendar cal = Calendar.getInstance(); |
| | | cal.setTime(endTime); |
| | | cal.add(Calendar.MONTH, Integer.parseInt(specValue)); |
| | | payFeeDetailPo.setEndTime(df.format(cal.getTime())); |
| | | payFeePo.setEndTime(df.format(cal.getTime())); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //判断选择的账号 |
| | | 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); |
| | | } |
| | | } |
| | | int flag = payFeeDetailNewV1InnerServiceSMOImpl.savePayFeeDetailNew(payFeeDetailPo); |
| | | if (flag < 1) { |
| | | throw new CmdException("缴费失败"); |
| | | } |
| | | JSONObject fee = modifyFee(paramObj); |
| | | payFeePo = BeanConvertUtil.covertBean(fee, PayFeePo.class); |
| | | |
| | | flag = payFeeV1InnerServiceSMOImpl.updatePayFee(payFeePo); |
| | | if (flag < 1) { |
| | | throw new CmdException("缴费失败"); |
| | | } |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | DistributedLock.releaseDistributedLock(requestId, key); |
| | | } |
| | |
| | | JSONObject discountBusiness = null; |
| | | JSONArray selectDiscounts = paramObj.getJSONArray("selectDiscount"); |
| | | for (int discountIndex = 0; discountIndex < selectDiscounts.size(); discountIndex++) { |
| | | addPayFeeDetailDiscount(paramObj, selectDiscounts.getJSONObject(discountIndex)); |
| | | JSONObject param = selectDiscounts.getJSONObject(discountIndex); |
| | | if (!StringUtil.isEmpty(param.getString("ruleId")) && param.getString("ruleId").equals("102020008")) { |
| | | return; |
| | | } |
| | | addPayFeeDetailDiscount(paramObj, param); |
| | | } |
| | | } |
| | | |
| | |
| | | * @return 订单服务能够接受的报文 |
| | | */ |
| | | public JSONObject addFeeDetail(JSONObject paramInJson) { |
| | | String remark = paramInJson.getString("remark"); |
| | | if (!StringUtil.isEmpty(remark)) { |
| | | remark = "-" + remark; |
| | | } |
| | | paramInJson.put("remark", "现场收银台支付" + remark); |
| | | JSONObject businessFeeDetail = new JSONObject(); |
| | | businessFeeDetail.putAll(paramInJson); |
| | | businessFeeDetail.put("detailId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_detailId)); |
| | |
| | | targetEndTime = endCalender.getTime(); |
| | | paramInJson.put("tmpCycles", cycles.doubleValue()); |
| | | businessFeeDetail.put("cycles", cycles.doubleValue()); |
| | | businessFeeDetail.put("receivableAmount", receivedAmount.doubleValue()); |
| | | //处理 可能还存在 实收手工减免的情况 |
| | | if(paramInJson.containsKey("receivableAmount") && !StringUtil.isEmpty(paramInJson.getString("receivableAmount"))){ |
| | | businessFeeDetail.put("receivableAmount", paramInJson.getString("receivableAmount")); |
| | | }else { |
| | | businessFeeDetail.put("receivableAmount", receivedAmount.doubleValue()); |
| | | } |
| | | } else if ("-103".equals(paramInJson.getString("cycles"))) { //这里按缴费结束时间缴费 |
| | | String custEndTime = paramInJson.getString("custEndTime"); |
| | | Date endDates = DateUtil.getDateFromStringB(custEndTime); |
| | | Calendar c = Calendar.getInstance(); |
| | | c.setTime(endDates); |
| | | c.add(Calendar.DAY_OF_MONTH, 1); |
| | | endDates = c.getTime();//这是明天 |
| | | targetEndTime = endDates; |
| | | BigDecimal receivedAmount1 = new BigDecimal(Double.parseDouble(paramInJson.getString("receivedAmount"))); |
| | | cycles = receivedAmount1.divide(feePrice, 4, BigDecimal.ROUND_HALF_EVEN); |
| | | paramInJson.put("tmpCycles", cycles.doubleValue()); |
| | | businessFeeDetail.put("cycles", cycles.doubleValue()); |
| | | BigDecimal receivedAmount = new BigDecimal(Double.parseDouble(paramInJson.getString("receivedAmount"))); |
| | | //处理 可能还存在 实收手工减免的情况 |
| | | if(paramInJson.containsKey("receivableAmount") && !StringUtil.isEmpty(paramInJson.getString("receivableAmount"))){ |
| | | businessFeeDetail.put("receivableAmount", paramInJson.getString("receivableAmount")); |
| | | }else { |
| | | businessFeeDetail.put("receivableAmount", receivedAmount.doubleValue()); |
| | | } |
| | | } else { |
| | | targetEndTime = computeFeeSMOImpl.getFeeEndTimeByCycles(feeDto, paramInJson.getString("cycles")); |
| | | 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); |
| | | |
| | | //出租递增问题处理 |
| | | if (FeeConfigDto.COMPUTING_FORMULA_RANT_RATE.equals(feeDto.getComputingFormula())) { |
| | | computeFeeSMOImpl.dealRentRateCycle(feeDto,cycles.doubleValue()); |
| | | if(feeDto.getOweFee()> 0){ |
| | | businessFeeDetail.put("receivableAmount", feeDto.getOweFee()); |
| | | } |
| | | } |
| | | } |
| | | businessFeeDetail.put("endTime", DateUtil.getFormatTimeString(targetEndTime, DateUtil.DATE_FORMATE_STRING_A)); |
| | | paramInJson.put("feeInfo", feeDto); |
| | |
| | | Calendar endCalender = Calendar.getInstance(); |
| | | endCalender.setTime(endTime); |
| | | int hours = 0; |
| | | //-101自定义金额 -102自定义周期 -103 自定义结束时间 |
| | | if ("-101".equals(paramInJson.getString("cycles"))) { |
| | | endCalender = getTargetEndTime(endCalender, Double.parseDouble(paramInJson.getString("tmpCycles"))); |
| | | System.out.println(endCalender); |
| | | } else if ("-103".equals(paramInJson.getString("cycles"))) { |
| | | String custEndTime = paramInJson.getString("custEndTime"); |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
| | | Date endDates = null; |
| | | try { |
| | | endDates = format.parse(custEndTime); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | Calendar c = Calendar.getInstance(); |
| | | c.setTime(endDates); |
| | | c.add(Calendar.DAY_OF_MONTH, 1); |
| | | endDates = c.getTime();//这是明天 |
| | | endCalender.setTime(endDates); |
| | | } else { |
| | | endCalender.add(Calendar.MONTH, Integer.parseInt(paramInJson.getString("cycles"))); |
| | | } |
| | |
| | | feeInfo.setState(FeeDto.STATE_FINISH); |
| | | } |
| | | feeInfo.setEndTime(endCalender.getTime()); |
| | | Date maxEndTime = feeInfo.getDeadlineTime(); |
| | | if (FeeDto.FEE_FLAG_CYCLE.equals(feeInfo.getFeeFlag())) { |
| | | maxEndTime = feeInfo.getConfigEndTime(); |
| | | } |
| | | //判断 结束时间 是否大于 费用项 结束时间,这里 容错一下,如果 费用结束时间大于 费用项结束时间 30天 走报错 属于多缴费 |
| | | if (feeInfo.getEndTime().getTime() - feeInfo.getConfigEndTime().getTime() > 30 * 24 * 60 * 60 * 1000L) { |
| | | if (feeInfo.getEndTime().getTime() - maxEndTime.getTime() > 30 * 24 * 60 * 60 * 1000L) { |
| | | throw new IllegalArgumentException("缴费超过了 费用项结束时间"); |
| | | } |
| | | Map feeMap = BeanConvertUtil.beanCovertMap(feeInfo); |
| | |
| | | paramInJson.put("carPayerObjId", feeInfo.getPayerObjId()); |
| | | |
| | | // 周期性收费、缴费后,到期日期在费用项终止日期后,则设置缴费状态结束,设置结束日期为费用项终止日期 |
| | | if (FeeFlagTypeConstant.CYCLE.equals(feeInfo.getFeeFlag())) { |
| | | if (!FeeFlagTypeConstant.ONETIME.equals(feeInfo.getFeeFlag())) { |
| | | //这里 容错五天时间 |
| | | Date configEndTime = feeInfo.getConfigEndTime(); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(configEndTime); |
| | | calendar.setTime(maxEndTime); |
| | | calendar.add(Calendar.DAY_OF_MONTH, -5); |
| | | configEndTime = calendar.getTime(); |
| | | if (feeInfo.getEndTime().after(configEndTime)) { |
| | | maxEndTime = calendar.getTime(); |
| | | if (feeInfo.getEndTime().after(maxEndTime)) { |
| | | businessFee.put("state", FeeStateConstant.END); |
| | | businessFee.put("endTime", feeInfo.getConfigEndTime()); |
| | | businessFee.put("endTime", maxEndTime); |
| | | } |
| | | } |
| | | return businessFee; |
| | |
| | | if (jsonArray == null || jsonArray.size() < 1) { |
| | | return; |
| | | } |
| | | //应收款 totalFeePrice |
| | | BigDecimal totalFeePrice = new BigDecimal(paramObj.getString("totalFeePrice")); //应收款 |
| | | //实收款 receivedAmount |
| | | BigDecimal receivedAmount = new BigDecimal(paramObj.getString("receivedAmount")); //实收款(扣款金额) |
| | | |
| | | BigDecimal redepositAmount = new BigDecimal("0.00");//抵扣金额 |
| | | List<AccountDto> accountDtos = new ArrayList<>(); |
| | | for (int columnIndex = 0; columnIndex < jsonArray.size(); columnIndex++) { |
| | | //应收款 totalFeePrice |
| | | BigDecimal totalFeePrice = new BigDecimal(paramObj.getString("totalFeePrice")); //应收款 |
| | | //实收款 receivedAmount |
| | | BigDecimal receivedAmount = new BigDecimal(paramObj.getString("receivedAmount")); //实收款(扣款金额) |
| | | BigDecimal redepositAmount = new BigDecimal("0.00");//抵扣金额 |
| | | JSONObject param = jsonArray.getJSONObject(columnIndex); |
| | | if (!StringUtil.isEmpty(param.getString("acctType")) && param.getString("acctType").equals("2004")) { //积分账户 |
| | | //获取抵扣比例 |
| | | BigDecimal deductionProportion = new BigDecimal(param.getString("deductionProportion")); |
| | | //计算实收款所扣的积分 |
| | | BigDecimal multiply = receivedAmount.multiply(deductionProportion); |
| | | receivedAmount = multiply; |
| | | } |
| | | //账户金额 |
| | | BigDecimal amount = new BigDecimal(param.getString("amount")); //账户金额 |
| | | BigDecimal amount = new BigDecimal(param.getString("amount")); |
| | | int flag = amount.compareTo(receivedAmount); |
| | | if (flag == -1) {//账户金额小于实收款 |
| | | receivedAmount = receivedAmount.subtract(amount); |
| | | if (flag == -1) { //账户金额小于实收款 |
| | | redepositAmount = amount;//抵扣金额 |
| | | } else { |
| | | redepositAmount = receivedAmount;//抵扣金额 |
| | | } |
| | | //剩余金额 |
| | | amount.compareTo(receivedAmount); |
| | | if (!StringUtil.isEmpty(param.getString("acctType")) && param.getString("acctType").equals("2004")) { |
| | | //获取最大抵扣积分 |
| | | BigDecimal maximumNumber = new BigDecimal(param.getString("maximumNumber")); |
| | | //获取积分抵扣 |
| | | BigDecimal deductionProportion = new BigDecimal(param.getString("deductionProportion")); |
| | | int flag2 = amount.compareTo(maximumNumber); |
| | | if (flag2 == 1) { //账户积分大于最大使用积分,就用最大使用积分抵扣 |
| | | int flag3 = maximumNumber.compareTo(receivedAmount); |
| | | if (flag3 == 1) { //如果最大使用积分大于实收金额抵扣积分,就把实收金额抵扣积分赋值给抵扣积分 |
| | | redepositAmount = receivedAmount; |
| | | } else if (flag3 > -1) {//如果最大使用积分大于等于实收金额抵扣积分,就把实收金额抵扣积分赋值给抵扣积分 |
| | | redepositAmount = receivedAmount; |
| | | } else { |
| | | redepositAmount = maximumNumber; |
| | | } |
| | | } |
| | | if (flag2 > -1) { //账户积分大于等于最大使用积分,就用最大使用积分抵扣 |
| | | int flag3 = maximumNumber.compareTo(receivedAmount); |
| | | if (flag3 == 1) { //如果最大使用积分大于实收金额抵扣积分,就把实收金额抵扣积分赋值给抵扣积分 |
| | | redepositAmount = receivedAmount; |
| | | } else if (flag3 > -1) {//如果最大使用积分大于等于实收金额抵扣积分,就把实收金额抵扣积分赋值给抵扣积分 |
| | | redepositAmount = receivedAmount; |
| | | } else { |
| | | redepositAmount = maximumNumber; |
| | | } |
| | | } |
| | | if (flag2 == -1) { //账户积分小于最大使用积分,就用账户积分抵扣 |
| | | int flag3 = amount.compareTo(receivedAmount); |
| | | if (flag3 == 1) { //如果积分账户大于实收金额抵扣积分,就把实收金额抵扣积分赋值给抵扣积分 |
| | | redepositAmount = receivedAmount; |
| | | } else if (flag3 > -1) {//如果积分账户大于等于实收金额抵扣积分,就把实收金额抵扣积分赋值给抵扣积分 |
| | | redepositAmount = receivedAmount; |
| | | } else { |
| | | redepositAmount = amount; |
| | | } |
| | | } |
| | | if (flag2 < 1) { //账户积分小于等于最大使用积分,就用账户积分抵扣 |
| | | int flag3 = amount.compareTo(receivedAmount); |
| | | if (flag3 == 1) { //如果积分账户大于实收金额抵扣积分,就把实收金额抵扣积分赋值给抵扣积分 |
| | | redepositAmount = receivedAmount; |
| | | } else if (flag3 > -1) {//如果积分账户大于等于实收金额抵扣积分,就把实收金额抵扣积分赋值给抵扣积分 |
| | | redepositAmount = receivedAmount; |
| | | } else { |
| | | redepositAmount = amount; |
| | | } |
| | | } |
| | | if (flag2 == 0) { //账户积分等于最大使用积分 |
| | | int flag3 = amount.compareTo(receivedAmount); |
| | | if (flag3 == 1) { //如果积分账户大于实收金额抵扣积分,就把实收金额抵扣积分赋值给抵扣积分 |
| | | redepositAmount = receivedAmount; |
| | | } else if (flag3 > -1) {//如果积分账户大于等于实收金额抵扣积分,就把实收金额抵扣积分赋值给抵扣积分 |
| | | redepositAmount = receivedAmount; |
| | | } else { |
| | | redepositAmount = amount; |
| | | } |
| | | } |
| | | //计算积分换算的金额 |
| | | BigDecimal divide = redepositAmount.divide(deductionProportion); |
| | | BigDecimal divide1 = receivedAmount.divide(deductionProportion); |
| | | //计算还需支付的金额 |
| | | BigDecimal subtract = divide1.subtract(divide); |
| | | paramObj.put("receivedAmount", subtract); |
| | | } |
| | | String acctId = param.getString("acctId"); |
| | | if (StringUtil.isEmpty(acctId)) { |
| | | throw new IllegalArgumentException("账户id为空!"); |
| | |
| | | AccountDto accountDto = new AccountDto(); |
| | | accountDto.setAcctId(acctId); |
| | | //查询账户金额 |
| | | List<AccountDto> accountDtos = accountInnerServiceSMOImpl.queryAccounts(accountDto); |
| | | accountDtos = accountInnerServiceSMOImpl.queryAccounts(accountDto); |
| | | Assert.listOnlyOne(accountDtos, "查询账户金额错误!"); |
| | | if (accountDtos != null && accountDtos.size() > 0) { |
| | | AccountDto accountDto1 = accountDtos.get(0); |
| | |
| | | throw new UnsupportedOperationException("账户金额抵扣不足,请您确认账户金额!"); |
| | | } |
| | | } |
| | | |
| | | |
| | | AccountDetailPo accountDetailPo = new AccountDetailPo(); |
| | | accountDetailPo.setDetailId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_detailId)); |
| | | int flag1 = redepositAmount.compareTo(BigDecimal.ZERO); |
| | |
| | | throw new CmdException("扣款失败"); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | private static Calendar getTargetEndTime(Calendar endCalender, Double cycles) { |