| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.core.annotation.Java110Cmd; |
| | | import com.java110.core.annotation.Java110Transactional; |
| | | import com.java110.core.context.DataFlowContext; |
| | | import com.java110.core.context.ICmdDataFlowContext; |
| | | import com.java110.core.event.cmd.Cmd; |
| | | import com.java110.core.event.cmd.CmdEvent; |
| | | 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.app.AppDto; |
| | | import com.java110.dto.fee.FeeAttrDto; |
| | | import com.java110.dto.fee.FeeConfigDto; |
| | | import com.java110.dto.fee.FeeDetailDto; |
| | | import com.java110.dto.fee.FeeDto; |
| | | import com.java110.dto.feeReceipt.FeeReceiptDetailDto; |
| | | import com.java110.dto.fee.FeeReceiptDetailDto; |
| | | import com.java110.dto.owner.OwnerCarDto; |
| | | import com.java110.dto.owner.OwnerDto; |
| | | 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.intf.community.*; |
| | | import com.java110.intf.fee.*; |
| | | import com.java110.intf.user.IOwnerCarInnerServiceSMO; |
| | | import com.java110.intf.user.IUserV1InnerServiceSMO; |
| | | import com.java110.po.car.OwnerCarPo; |
| | | import com.java110.po.fee.PayFeeDetailPo; |
| | | import com.java110.po.fee.PayFeePo; |
| | | import com.java110.po.feeReceipt.FeeReceiptPo; |
| | | import com.java110.po.feeReceiptDetail.FeeReceiptDetailPo; |
| | | import com.java110.po.fee.FeeReceiptPo; |
| | | import com.java110.po.fee.FeeReceiptDetailPo; |
| | | import com.java110.po.owner.RepairPoolPo; |
| | | import com.java110.po.owner.RepairUserPo; |
| | | import com.java110.utils.constant.BusinessTypeConstant; |
| | | import com.java110.utils.constant.CommonConstant; |
| | | import com.java110.utils.constant.ResponseConstant; |
| | | import com.java110.utils.exception.CmdException; |
| | | import com.java110.utils.exception.ListenerExecuteException; |
| | |
| | | private IRepairUserV1InnerServiceSMO repairUserV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IOwnerCarNewV1InnerServiceSMO ownerCarNewV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IOwnerCarInnerServiceSMO ownerCarInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IComputeFeeSMO computeFeeSMOImpl; |
| | | |
| | | @Autowired |
| | | private IUserV1InnerServiceSMO userV1InnerServiceSMOImpl; |
| | | |
| | | |
| | | @Override |
| | |
| | | @Java110Transactional |
| | | public void doCmd(CmdEvent event, ICmdDataFlowContext dataFlowContext, JSONObject paramObj) throws CmdException, ParseException { |
| | | logger.info("======欠费缴费返回======:" + JSONArray.toJSONString(paramObj)); |
| | | |
| | | String userId = dataFlowContext.getReqHeaders().get("user-id"); |
| | | UserDto userDto = new UserDto(); |
| | | userDto.setUserId(userId); |
| | | List<UserDto> userDtos = userV1InnerServiceSMOImpl.queryUsers(userDto); |
| | | Assert.listOnlyOne(userDtos, "用户未登录"); |
| | | //添加单元信息 |
| | | List<FeeReceiptPo> feeReceiptPos = new ArrayList<>(); |
| | | List<FeeReceiptDetailPo> feeReceiptDetailPos = new ArrayList<>(); |
| | |
| | | for (int feeIndex = 0; feeIndex < fees.size(); feeIndex++) { |
| | | feeObj = fees.getJSONObject(feeIndex); |
| | | feeObj.put("communityId", paramObj.getString("communityId")); |
| | | if (paramObj.containsKey("oId")) { |
| | | feeObj.put("oId", paramObj.getString("oId")); |
| | | } |
| | | String remark = paramObj.getString("remark"); |
| | | feeObj.put("remark", remark); |
| | | if (!feeObj.containsKey("primeRate") && AppDto.OWNER_WECHAT_PAY.equals(appId)) { //微信公众号支付 |
| | |
| | | feeObj.put("remark", "线上公众号支付"); |
| | | } |
| | | |
| | | getFeeReceiptDetailPo(dataFlowContext, feeObj, feeReceiptDetailPos, feeReceiptPos); |
| | | //todo 去缴费 |
| | | getFeeReceiptDetailPo(dataFlowContext, feeObj, feeReceiptDetailPos, feeReceiptPos, userDtos.get(0)); |
| | | } |
| | | |
| | | //这里只是写入 收据表,暂不考虑 事务一致性问题,就算写入失败 也只是影响 收据打印,如果 贵公司对 收据要求 比较高,不能有失败的情况 请加入事务管理 |
| | |
| | | } |
| | | List<FeeReceiptDetailDto> feeReceiptDetailDtos = feeReceiptDetailInnerServiceSMOImpl.queryFeeReceiptDetails(feeReceiptDetailDto); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("receipts",feeReceiptDetailDtos); |
| | | |
| | | dataFlowContext.setResponseEntity(ResultVo.createResponseEntity(feeReceiptDetailDtos)); |
| | | dataFlowContext.setResponseEntity(ResultVo.createResponseEntity(data)); |
| | | } |
| | | |
| | | private void getFeeReceiptDetailPo(ICmdDataFlowContext dataFlowContext, JSONObject paramObj, List<FeeReceiptDetailPo> feeReceiptDetailPos, List<FeeReceiptPo> feeReceiptPos) { |
| | | private void getFeeReceiptDetailPo(ICmdDataFlowContext dataFlowContext, JSONObject paramObj, |
| | | List<FeeReceiptDetailPo> feeReceiptDetailPos, |
| | | List<FeeReceiptPo> feeReceiptPos, |
| | | UserDto userDto) { |
| | | int flag = 0; |
| | | if (!paramObj.containsKey("primeRate")) { |
| | | paramObj.put("primeRate", "6"); |
| | |
| | | paramObj.put("remark", "线上小程序支付"); |
| | | } |
| | | paramObj.put("state", "1400"); |
| | | addOweFeeDetail(paramObj, dataFlowContext, feeReceiptDetailPos, feeReceiptPos); |
| | | // todo 添加交费明细 |
| | | addOweFeeDetail(paramObj, dataFlowContext, feeReceiptDetailPos, feeReceiptPos, userDto); |
| | | modifyOweFee(paramObj, dataFlowContext); |
| | | |
| | | //修改车辆 |
| | | updateCarEndTime(paramObj); |
| | | |
| | | //判断是否有派单属性ID |
| | | FeeAttrDto feeAttrDto = new FeeAttrDto(); |
| | |
| | | repairPoolPo.setCommunityId(paramObj.getString("communityId")); |
| | | repairPoolPo.setState(RepairDto.STATE_APPRAISE); |
| | | flag = repairPoolV1InnerServiceSMOImpl.updateRepairPoolNew(repairPoolPo); |
| | | if(flag < 1){ |
| | | if (flag < 1) { |
| | | throw new CmdException("修改失败"); |
| | | } |
| | | } |
| | |
| | | repairUser.setPreRuId(repairUserDtoList.get(0).getRuId()); |
| | | repairUser.setRepairEvent("auditUser"); |
| | | flag = repairUserV1InnerServiceSMOImpl.saveRepairUserNew(repairUserPo); |
| | | if(flag < 1){ |
| | | if (flag < 1) { |
| | | throw new CmdException("修改失败"); |
| | | } |
| | | } else { //如果是员工代客报修或电话报修,状态就变成已支付 |
| | |
| | | repairUserPo.setEndTime(DateUtil.getNow(DateUtil.DATE_FORMATE_STRING_A)); |
| | | repairUserPo.setContext("已支付" + paramObj.getString("receivedAmount") + "元"); |
| | | flag = repairUserV1InnerServiceSMOImpl.updateRepairUserNew(repairUserPo); |
| | | if(flag < 1){ |
| | | if (flag < 1) { |
| | | throw new CmdException("修改失败"); |
| | | } |
| | | } |
| | |
| | | if (!FeeDto.FEE_FLAG_CYCLE.equals(feeInfo.getFeeFlag())) { |
| | | maxEndTime = feeInfo.getDeadlineTime(); |
| | | } |
| | | if(maxEndTime != null) { //这里数据问题的情况下 |
| | | if (maxEndTime != null) { //这里数据问题的情况下 |
| | | Date endTime = DateUtil.getDateFromStringA(paramInJson.getString("endTime")); |
| | | if (endTime.getTime() >= maxEndTime.getTime()) { |
| | | feeMap.put("state", FeeDto.STATE_FINISH); |
| | |
| | | } |
| | | |
| | | businessFee.putAll(feeMap); |
| | | PayFeePo payFeePo = BeanConvertUtil.covertBean(businessFee,PayFeePo.class); |
| | | PayFeePo payFeePo = BeanConvertUtil.covertBean(businessFee, PayFeePo.class); |
| | | int flag = payFeeV1InnerServiceSMOImpl.updatePayFee(payFeePo); |
| | | if (flag < 1) { |
| | | throw new CmdException("修改失败"); |
| | |
| | | } |
| | | |
| | | public void addOweFeeDetail(JSONObject paramInJson, ICmdDataFlowContext dataFlowContext, |
| | | List<FeeReceiptDetailPo> feeReceiptDetailPos, |
| | | List<FeeReceiptPo> feeReceiptPos) { |
| | | List<FeeReceiptDetailPo> feeReceiptDetailPos, |
| | | List<FeeReceiptPo> feeReceiptPos, |
| | | UserDto userDto) { |
| | | |
| | | JSONObject businessFeeDetail = new JSONObject(); |
| | | businessFeeDetail.putAll(paramInJson); |
| | |
| | | BigDecimal receivedAmount = new BigDecimal(Double.parseDouble(paramInJson.getString("receivedAmount"))); |
| | | cycles = receivedAmount.divide(feePrice, 4, BigDecimal.ROUND_HALF_EVEN); |
| | | businessFeeDetail.put("cycles", receivedAmount.divide(feePrice, 2, BigDecimal.ROUND_HALF_UP).doubleValue()); |
| | | businessFeeDetail.put("receivableAmount", paramInJson.getString("receivedAmount")); |
| | | |
| | | if (!paramInJson.containsKey("receivableAmount") || StringUtil.isEmpty(paramInJson.getString("receivableAmount"))) { |
| | | paramInJson.put("receivableAmount", paramInJson.getString("receivedAmount")); |
| | | } |
| | | |
| | | businessFeeDetail.put("receivableAmount", paramInJson.getString("receivableAmount")); |
| | | businessFeeDetail.put("receivedAmount", paramInJson.getString("receivedAmount")); |
| | | businessFeeDetail.put("payableAmount", paramInJson.getString("receivedAmount")); |
| | | businessFeeDetail.put("endTime", paramInJson.getString("endTime")); |
| | | paramInJson.put("feeInfo", feeDto); |
| | | paramInJson.put("cycles", cycles.doubleValue()); |
| | | PayFeeDetailPo payFeeDetailPo = BeanConvertUtil.covertBean(businessFeeDetail, PayFeeDetailPo.class); |
| | | if (paramInJson.containsKey("oId")) { |
| | | payFeeDetailPo.setPayOrderId(paramInJson.getString("oId")); |
| | | } else { |
| | | String oId = Java110TransactionalFactory.getOId(); |
| | | if (StringUtil.isEmpty(oId)) { |
| | | oId = payFeeDetailPo.getDetailId(); |
| | | } |
| | | payFeeDetailPo.setPayOrderId(oId); |
| | | |
| | | } |
| | | payFeeDetailPo.setCashierId(userDto.getUserId()); |
| | | payFeeDetailPo.setCashierName(userDto.getName()); |
| | | |
| | | int flag = payFeeDetailV1InnerServiceSMOImpl.savePayFeeDetailNew(payFeeDetailPo); |
| | | |
| | |
| | | feeReceiptPos.add(feeReceiptPo); |
| | | } |
| | | |
| | | 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) { |
| | | 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(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("车位已被使用,不能再缴费!"); |
| | | } |
| | | } |
| | | |
| | | |
| | | 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()) { |
| | | 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("缴费失败"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |