From 8954429263a75e3c7d19db20a60370fca005f2bd Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期二, 08 八月 2023 15:44:49 +0800
Subject: [PATCH] 优化代码
---
service-fee/src/main/java/com/java110/fee/cmd/fee/PayMonthFeeCmd.java | 453 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 450 insertions(+), 3 deletions(-)
diff --git a/service-fee/src/main/java/com/java110/fee/cmd/fee/PayMonthFeeCmd.java b/service-fee/src/main/java/com/java110/fee/cmd/fee/PayMonthFeeCmd.java
index a022a51..db81ebb 100644
--- a/service-fee/src/main/java/com/java110/fee/cmd/fee/PayMonthFeeCmd.java
+++ b/service-fee/src/main/java/com/java110/fee/cmd/fee/PayMonthFeeCmd.java
@@ -3,19 +3,103 @@
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.java110.core.annotation.Java110Cmd;
+import com.java110.core.annotation.Java110Transactional;
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.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.owner.OwnerCarDto;
+import com.java110.dto.parking.ParkingSpaceDto;
+import com.java110.dto.payFee.PayFeeDetailMonthDto;
+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.owner.RepairPoolPo;
+import com.java110.po.owner.RepairUserPo;
+import com.java110.utils.cache.CommonCache;
+import com.java110.utils.constant.FeeConfigConstant;
+import com.java110.utils.constant.FeeFlagTypeConstant;
+import com.java110.utils.constant.ResponseConstant;
import com.java110.utils.exception.CmdException;
+import com.java110.utils.exception.ListenerExecuteException;
+import com.java110.utils.lock.DistributedLock;
import com.java110.utils.util.Assert;
+import com.java110.utils.util.BeanConvertUtil;
+import com.java110.utils.util.DateUtil;
+import com.java110.utils.util.StringUtil;
+import com.java110.vo.ResultVo;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import java.math.BigDecimal;
import java.text.ParseException;
+import java.util.*;
/**
* 鎸夋湀浜よ垂
*/
@Java110Cmd(serviceCode = "fee.payMonthFee")
public class PayMonthFeeCmd extends Cmd {
+ private static Logger logger = LoggerFactory.getLogger(PayMonthFeeCmd.class);
+ @Autowired
+ private IPayFeeDetailMonthInnerServiceSMO payFeeDetailMonthInnerServiceSMOImpl;
+
+
+ @Autowired
+ private IUserV1InnerServiceSMO userV1InnerServiceSMOImpl;
+
+ @Autowired
+ private IPayFeeV1InnerServiceSMO payFeeV1InnerServiceSMOImpl;
+
+ @Autowired
+ private IPayFeeDetailV1InnerServiceSMO payFeeDetailNewV1InnerServiceSMOImpl;
+
+
+ @Autowired
+ private IFeeInnerServiceSMO feeInnerServiceSMOImpl;
+
+
+ @Autowired
+ private IOwnerCarInnerServiceSMO ownerCarInnerServiceSMOImpl;
+ @Autowired
+ private IOwnerCarNewV1InnerServiceSMO ownerCarNewV1InnerServiceSMOImpl;
+
+
+ @Autowired
+ private IParkingSpaceInnerServiceSMO parkingSpaceInnerServiceSMOImpl;
+
+ @Autowired
+ private IRepairPoolV1InnerServiceSMO repairPoolNewV1InnerServiceSMOImpl;
+ @Autowired
+ private IRepairUserV1InnerServiceSMO repairUserNewV1InnerServiceSMOImpl;
+
+ @Autowired
+ private IFeeAttrInnerServiceSMO feeAttrInnerServiceSMOImpl;
+
+
+ @Autowired
+ private IRepairUserInnerServiceSMO repairUserInnerServiceSMO;
+
+ @Autowired
+ private IRepairInnerServiceSMO repairInnerServiceSMO;
+
+ @Autowired
+ private IFeeReceiptInnerServiceSMO feeReceiptInnerServiceSMOImpl;
+
+
@Override
public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
Assert.hasKeyAndValue(reqJson, "communityId", "鏈寘鍚皬鍖轰俊鎭�");
@@ -28,13 +112,376 @@
if (selectMonthIds == null || selectMonthIds.size() < 1) {
throw new CmdException("鏈寘鍚即璐规湀浠�");
}
+ List<String> monthIds = new ArrayList<>();
+ for (int monthIndex = 0; monthIndex < selectMonthIds.size(); monthIndex++) {
+ monthIds.add(selectMonthIds.getString(monthIndex));
+ }
- // todo 妫�鏌ユ槸鍚﹁烦鏈堜簡
+ // todo 鏌ヨ闇�瑕佺即璐圭殑鏄庣粏鏈�
+ PayFeeDetailMonthDto payFeeDetailMonthDto = new PayFeeDetailMonthDto();
+ payFeeDetailMonthDto.setMonthIds(monthIds.toArray(new String[monthIds.size()]));
+ payFeeDetailMonthDto.setCommunityId(reqJson.getString("communityId"));
+ payFeeDetailMonthDto.setDetailId("-1");
+ List<PayFeeDetailMonthDto> payFeeDetailMonthDtos = payFeeDetailMonthInnerServiceSMOImpl.queryPagePayFeeDetailMonths(payFeeDetailMonthDto);
+
+ if (payFeeDetailMonthDtos == null || payFeeDetailMonthDtos.size() < 1) {
+ throw new CmdException("鏈寘鍚即璐规湀浠�");
+ }
+
+ Map<String, List<PayFeeDetailMonthDto>> feeMonths = new HashMap<>();
+
+ //todo 妫�鏌ユ槸鍚﹁烦鏈堜簡
+ PayFeeDetailMonthDto feeDetailMonthDto = null;
+ for (PayFeeDetailMonthDto tmpPayFeeDetailMonthDto : payFeeDetailMonthDtos) {
+ if (!feeMonths.containsKey(tmpPayFeeDetailMonthDto.getFeeId())) {
+ feeDetailMonthDto = new PayFeeDetailMonthDto();
+ feeDetailMonthDto.setFeeId(tmpPayFeeDetailMonthDto.getFeeId());
+ feeDetailMonthDto.setDetailId("-1");
+ feeDetailMonthDto.setCommunityId(reqJson.getString("communityId"));
+ List<PayFeeDetailMonthDto> feeDetailMonthDtos = payFeeDetailMonthInnerServiceSMOImpl.queryPayFeeDetailMonths(feeDetailMonthDto);
+ feeMonths.put(tmpPayFeeDetailMonthDto.getFeeId(), feeDetailMonthDtos);
+ }
+ //todo 鍗曟潯璐圭敤鏍¢獙鏄惁澶告湀缂磋垂
+ validateOneMonthSkipPayFee(tmpPayFeeDetailMonthDto, feeMonths);
+
+ }
+
+ reqJson.put("payFeeDetailMonthDtos", payFeeDetailMonthDtos);
+
}
- @Override
- public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
+ @Override
+ @Java110Transactional
+ public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
+ String userId = context.getReqHeaders().get("user-id");
+ UserDto userDto = new UserDto();
+ userDto.setUserId(userId);
+ List<UserDto> userDtos = userV1InnerServiceSMOImpl.queryUsers(userDto);
+ Assert.listOnlyOne(userDtos, "鐢ㄦ埛鏈櫥褰�");
+
+
+ //todo 鐢熸垚鏀舵嵁缂栧彿
+ String receiptCode = feeReceiptInnerServiceSMOImpl.generatorReceiptCode(reqJson.getString("communityId"));
+
+ List<PayFeeDetailMonthDto> payFeeDetailMonthDtos = (List<PayFeeDetailMonthDto>) reqJson.get("payFeeDetailMonthDtos");
+
+ Calendar createTimeCal = Calendar.getInstance();
+
+ Map<String, FeeDto> feeDtoMap = new HashMap<>();
+
+ JSONArray details = new JSONArray();
+ for (PayFeeDetailMonthDto payFeeDetailMonthDto : payFeeDetailMonthDtos) {
+ // todo 璐圭敤鍙煡涓�娆℃彁楂� 鏁堢巼
+ if (!feeDtoMap.containsKey(payFeeDetailMonthDto.getFeeId())) {
+ //todo 鏌ヨ璐圭敤鏄惁瀛樺湪
+ FeeDto feeDto = new FeeDto();
+ feeDto.setFeeId(payFeeDetailMonthDto.getFeeId());
+ feeDto.setCommunityId(payFeeDetailMonthDto.getCommunityId());
+ List<FeeDto> feeDtos = feeInnerServiceSMOImpl.queryFees(feeDto);
+ if (feeDtos == null || feeDtos.size() != 1) {
+ throw new CmdException("璐圭敤涓嶅瓨鍦�");
+ }
+ feeDtoMap.put(payFeeDetailMonthDto.getFeeId(), feeDtos.get(0));
+ }
+ createTimeCal.add(Calendar.SECOND, 1);
+ try {
+ doMonthFee(payFeeDetailMonthDto, context, userDtos.get(0), reqJson, createTimeCal.getTime(), feeDtoMap,receiptCode);
+ } catch (Exception e) {
+ logger.error("澶勭悊寮傚父", e);
+ throw new CmdException(e.getMessage());
+ }
+ details.add(payFeeDetailMonthDto.getDetailId());
+ }
+
+ JSONObject data = new JSONObject();
+ data.put("details", details);
+
+ context.setResponseEntity(ResultVo.createResponseEntity(data));
+ }
+
+ /**
+ * 澶勭悊 鏈堣垂鐢�
+ *
+ * @param payFeeDetailMonthDto
+ * @param context
+ * @param userDto
+ * @param reqJson
+ */
+ private void doMonthFee(PayFeeDetailMonthDto payFeeDetailMonthDto, ICmdDataFlowContext context, UserDto userDto, JSONObject reqJson, Date createTime, Map<String, FeeDto> feeDtoMap,String receiptCode) {
+ //todo 璁$畻缁撴潫鏃堕棿
+ Date startTime = DateUtil.getDateFromStringB(payFeeDetailMonthDto.getCurMonthTime());
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(startTime);
+ calendar.add(Calendar.MONTH, 1);
+ String endTime = DateUtil.getFormatTimeStringB(calendar.getTime());
+
+
+ //鑾峰彇璁㈠崟ID
+ String oId = Java110TransactionalFactory.getOId();
+
+ //寮�濮嬮攣浠g爜
+ PayFeePo payFeePo = null;
+ String requestId = DistributedLock.getLockUUID();
+ String key = this.getClass().getSimpleName() + payFeeDetailMonthDto.getFeeId();
+ try {
+ DistributedLock.waitGetDistributedLock(key, requestId);
+ //鐢熸垚浜よ垂鏄庣粏
+ PayFeeDetailPo payFeeDetailPo = addFeeDetail(payFeeDetailMonthDto, userDto, reqJson);
+ if (StringUtil.isEmpty(oId)) {
+ oId = payFeeDetailPo.getDetailId();
+ }
+ payFeeDetailPo.setPayOrderId(oId);
+ payFeeDetailPo.setEndTime(endTime);
+ // todo 鎸夋湀浜よ垂鏃� 涓昏鎸夋椂闂撮『搴忔帓搴忔椂 鑳藉鏁撮綈
+ payFeeDetailPo.setCreateTime(DateUtil.getFormatTimeStringA(createTime));
+ //todo 缂撳瓨鏀舵嵁缂栧彿
+ CommonCache.setValue(payFeeDetailPo.getDetailId()+CommonCache.RECEIPT_CODE,receiptCode,CommonCache.DEFAULT_EXPIRETIME_TWO_MIN);
+ int flag = payFeeDetailNewV1InnerServiceSMOImpl.savePayFeeDetailNew(payFeeDetailPo);
+ if (flag < 1) {
+ throw new CmdException("缂磋垂澶辫触");
+ }
+ payFeePo = modifyFee(payFeeDetailMonthDto, reqJson, feeDtoMap.get(payFeeDetailMonthDto.getFeeId()), endTime);
+
+ flag = payFeeV1InnerServiceSMOImpl.updatePayFee(payFeePo);
+ if (flag < 1) {
+ throw new CmdException("缂磋垂澶辫触");
+ }
+
+
+ //todo 灏哾etailId 杩斿洖鍑哄幓
+ payFeeDetailMonthDto.setDetailId(payFeeDetailPo.getDetailId());
+
+ } finally {
+ DistributedLock.releaseDistributedLock(key, requestId);
+ }
+ //杞﹁締寤舵湡
+ updateOwnerCarEndTime(payFeePo, reqJson, feeDtoMap.get(payFeeDetailMonthDto.getFeeId()));
+
+ //澶勭悊鎶ヤ慨鍗�
+ doDealRepairOrder(payFeeDetailMonthDto, feeDtoMap.get(payFeeDetailMonthDto.getFeeId()));
+
+
+ }
+
+
+ public PayFeePo modifyFee(PayFeeDetailMonthDto payFeeDetailMonthDto, JSONObject reqJson, FeeDto feeInfo, String endTime) {
+
+ feeInfo.setEndTime(DateUtil.getDateFromStringB(endTime));
+ Date maxEndTime = feeInfo.getDeadlineTime();
+ if (FeeDto.FEE_FLAG_CYCLE.equals(feeInfo.getFeeFlag())) {
+ maxEndTime = feeInfo.getConfigEndTime();
+ }
+ //鍒ゆ柇 缁撴潫鏃堕棿 鏄惁澶т簬 璐圭敤椤� 缁撴潫鏃堕棿锛岃繖閲� 瀹归敊涓�涓嬶紝濡傛灉 璐圭敤缁撴潫鏃堕棿澶т簬 璐圭敤椤圭粨鏉熸椂闂� 30澶� 璧版姤閿� 灞炰簬澶氱即璐�
+ if (maxEndTime != null) {
+ if (feeInfo.getEndTime().getTime() - maxEndTime.getTime() > 30 * 24 * 60 * 60 * 1000L) {
+ throw new IllegalArgumentException("缂磋垂瓒呰繃浜� 璐圭敤椤圭粨鏉熸椂闂�");
+ }
+ }
+
+ PayFeePo payFeePo = BeanConvertUtil.covertBean(feeInfo, PayFeePo.class);
+ //涓哄仠杞﹁垂鍗曠嫭澶勭悊
+ reqJson.put("carFeeEndTime", feeInfo.getEndTime());
+ reqJson.put("carPayerObjType", feeInfo.getPayerObjType());
+ reqJson.put("carPayerObjId", feeInfo.getPayerObjId());
+
+
+ // 鍛ㄦ湡鎬ф敹璐广�佺即璐瑰悗锛屽埌鏈熸棩鏈熷湪璐圭敤椤圭粓姝㈡棩鏈熷悗锛屽垯璁剧疆缂磋垂鐘舵�佺粨鏉燂紝璁剧疆缁撴潫鏃ユ湡涓鸿垂鐢ㄩ」缁堟鏃ユ湡
+ if (!FeeFlagTypeConstant.ONETIME.equals(feeInfo.getFeeFlag())) {
+ //杩欓噷 瀹归敊浜斿ぉ鏃堕棿
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(maxEndTime);
+ calendar.add(Calendar.DAY_OF_MONTH, -5);
+ maxEndTime = calendar.getTime();
+ if (feeInfo.getEndTime().after(maxEndTime)) {
+ payFeePo.setState(FeeConfigConstant.END);
+ payFeePo.setEndTime(DateUtil.getFormatTimeStringB(maxEndTime));
+ }
+ }
+
+ return payFeePo;
+ }
+
+
+ public PayFeeDetailPo addFeeDetail(PayFeeDetailMonthDto payFeeDetailMonthDto, UserDto userDto, JSONObject reqJson) {
+ PayFeeDetailPo feeDetailPo = new PayFeeDetailPo();
+ feeDetailPo.setCashierName(userDto.getName());
+ feeDetailPo.setReceivedAmount(payFeeDetailMonthDto.getReceivedAmount());
+ feeDetailPo.setDetailId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_detailId));
+ feeDetailPo.setCashierId(userDto.getUserId());
+ feeDetailPo.setFeeId(payFeeDetailMonthDto.getFeeId());
+ feeDetailPo.setCommunityId(payFeeDetailMonthDto.getCommunityId());
+ feeDetailPo.setCycles("1");
+ feeDetailPo.setStartTime(payFeeDetailMonthDto.getCurMonthTime());
+ feeDetailPo.setPayableAmount(payFeeDetailMonthDto.getReceivableAmount());
+ feeDetailPo.setPrimeRate(reqJson.getString("primeRate"));
+ feeDetailPo.setRemark(reqJson.getString("remark"));
+ feeDetailPo.setState(FeeDetailDto.STATE_NORMAL);
+ feeDetailPo.setReceivableAmount(payFeeDetailMonthDto.getReceivableAmount());
+ return feeDetailPo;
+ }
+
+ private void updateOwnerCarEndTime(PayFeePo payFeePo, JSONObject paramObj, FeeDto feeInfo) {
+ int flag;//涓哄仠杞﹁垂鍗曠嫭澶勭悊
+ if (!FeeDto.PAYER_OBJ_TYPE_CAR.equals(feeInfo.getPayerObjType())) {
+ return;
+ }
+ Date feeEndTime = DateUtil.getDateFromStringA(payFeePo.getEndTime());
+ OwnerCarDto ownerCarDto = new OwnerCarDto();
+ ownerCarDto.setCommunityId(feeInfo.getCommunityId());
+ ownerCarDto.setCarId(feeInfo.getPayerObjId());
+ ownerCarDto.setCarTypeCd("1001"); //涓氫富杞﹁締
+ List<OwnerCarDto> ownerCarDtos = ownerCarInnerServiceSMOImpl.queryOwnerCars(ownerCarDto);
+ Assert.listOnlyOne(ownerCarDtos, "鏌ヨ涓氫富閿欒锛�");
+ //鑾峰彇杞︿綅id
+ String psId = ownerCarDtos.get(0).getPsId();
+ //鑾峰彇杞﹁締鐘舵��(1001 姝e父鐘舵�侊紝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 (!"F".equals(state)) {
+ throw new IllegalArgumentException("杞︿綅宸茶浣跨敤锛屼笉鑳藉啀缂磋垂锛�");
+ }
+ }
+
+ Calendar endTimeCalendar = null;
+ //杞︿綅璐圭敤缁
+ for (OwnerCarDto tmpOwnerCarDto : ownerCarDtos) {
+ //鍚庝粯璐� 鎴栬�呬俊鐢ㄦ湡杞﹁締 鍔犱竴涓湀
+ if (FeeConfigDto.PAYMENT_CD_AFTER.equals(feeInfo.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("缂磋垂澶辫触");
+ }
+ }
+ }
+
+ private void validateOneMonthSkipPayFee(PayFeeDetailMonthDto tmpPayFeeDetailMonthDto, Map<String, List<PayFeeDetailMonthDto>> feeMonths) {
+ List<PayFeeDetailMonthDto> feeDetailMonthDtos = feeMonths.get(tmpPayFeeDetailMonthDto.getFeeId());
+ if (feeDetailMonthDtos == null || feeDetailMonthDtos.size() < 1) {
+ throw new CmdException("鏈繛缁氦璐癸紝璇疯繛缁氦璐�");
+ }
+ List<PayFeeDetailMonthDto> newFeeDetailMonthDtos = new ArrayList<>();
+ // todo 瀛樺湪 璋冩湀鐨勬儏鍐�
+ for (PayFeeDetailMonthDto tmpFeeDetailMonthDto : feeDetailMonthDtos) {
+ if (Integer.parseInt(tmpFeeDetailMonthDto.getDetailYear()) <= Integer.parseInt(tmpPayFeeDetailMonthDto.getDetailYear())
+ && Integer.parseInt(tmpFeeDetailMonthDto.getDetailMonth()) < Integer.parseInt(tmpPayFeeDetailMonthDto.getDetailMonth())) {
+ throw new CmdException("鏈繛缁即璐癸紝璇烽�夋嫨" + tmpFeeDetailMonthDto.getDetailYear() + "-" + tmpFeeDetailMonthDto.getDetailMonth()
+ + " ," + tmpPayFeeDetailMonthDto.getFeeName());
+ }
+ if (Integer.parseInt(tmpFeeDetailMonthDto.getDetailYear()) == Integer.parseInt(tmpPayFeeDetailMonthDto.getDetailYear())
+ && Integer.parseInt(tmpFeeDetailMonthDto.getDetailMonth()) == Integer.parseInt(tmpPayFeeDetailMonthDto.getDetailMonth())) {
+ continue;
+ }
+ newFeeDetailMonthDtos.add(tmpFeeDetailMonthDto);
+ }
+
+ feeMonths.put(tmpPayFeeDetailMonthDto.getFeeId(), newFeeDetailMonthDtos);
+
+ }
+
+ /**
+ * 澶勭悊鎶ヤ慨鍗�
+ *
+ * @param feeDto
+ */
+ private void doDealRepairOrder(PayFeeDetailMonthDto payFeeDetailMonthDto, FeeDto feeDto) {
+ int flag;//鍒ゆ柇鏄惁鏈夋淳鍗曞睘鎬D
+ FeeAttrDto feeAttrDto = new FeeAttrDto();
+ feeAttrDto.setCommunityId(feeDto.getCommunityId());
+ feeAttrDto.setFeeId(feeDto.getFeeId());
+ feeAttrDto.setSpecCd(FeeAttrDto.SPEC_CD_REPAIR);
+ List<FeeAttrDto> feeAttrDtos = feeAttrInnerServiceSMOImpl.queryFeeAttrs(feeAttrDto);
+ //淇敼 娲惧崟鐘舵��
+ 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();
+ RepairPoolPo repairPoolPo = new RepairPoolPo();
+ repairPoolPo.setRepairId(feeAttrDtos.get(0).getValue());
+ repairPoolPo.setCommunityId(feeDto.getCommunityId());
+ if (repairChannel.equals("Z")) { //濡傛灉鏄笟涓昏嚜涓绘姤淇紝鐘舵�佸氨鍙樻垚寰呰瘎浠�
+ repairPoolPo.setState(RepairDto.STATE_APPRAISE);
+ } else { //濡傛灉鏄憳宸ヤ唬瀹㈡姤淇垨鐢佃瘽鎶ヤ慨锛岀姸鎬佸氨鍙樻垚寰呭洖璁�
+ repairPoolPo.setState(RepairDto.STATE_RETURN_VISIT);
+ }
+ flag = repairPoolNewV1InnerServiceSMOImpl.updateRepairPoolNew(repairPoolPo);
+ if (flag < 1) {
+ throw new CmdException("鏇存柊寰俊娲惧崟姹犱俊鎭け璐�");
+ }
+
+ repairDto = new RepairDto();
+ repairDto.setRepairId(feeAttrDtos.get(0).getValue());
+ //鏌ヨ鎶ヤ慨璁板綍
+ repairDtos = repairInnerServiceSMO.queryRepairs(repairDto);
+
+ Assert.listOnlyOne(repairDtos, "鎶ヤ慨淇℃伅閿欒锛�");
+ //鑾峰彇鎶ヤ慨娓犻亾
+ 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("宸叉敮浠�" + payFeeDetailMonthDto.getReceivedAmount() + "鍏�");
+ //鏂板寰呰瘎浠风姸鎬�
+ 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(feeDto.getCommunityId());
+ 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 = repairUserNewV1InnerServiceSMOImpl.saveRepairUserNew(repairUser);
+ 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("宸叉敮浠�" + payFeeDetailMonthDto.getReceivedAmount() + "鍏�");
+ }
+ flag = repairUserNewV1InnerServiceSMOImpl.updateRepairUserNew(repairUserPo);
+ if (flag < 1) {
+ throw new CmdException("鏇存柊寰俊娲惧崟姹犱俊鎭け璐�");
+ }
+ }
}
}
--
Gitblit v1.8.0