Просмотр исходного кода

Merge branch 'master' of http://git.homecommunity.cn/supervip/MicroCommunity

java110 лет назад: 3
Родитель
Сommit
0f88d296ba

BIN
service-community/src/main/java/com/java110/community/cmd/.DS_Store


+ 18 - 0
service-community/src/main/java/com/java110/community/cmd/room/QueryRoomsCmd.java

@@ -146,6 +146,24 @@ public class QueryRoomsCmd extends Cmd {
                 roomDto.setRoomNum("");
             }
         }
+
+        //add by wuxw 商铺 两个短线方式处理
+        if(reqJson.containsKey("roomType") && "2020602".equals(reqJson.getString("roomType"))){
+            if (reqJson.containsKey("roomNum") && !StringUtil.isEmpty(reqJson.getString("roomNum"))) {
+                String[] roomNums = reqJson.getString("roomNum").split("-", 2);
+                if (roomNums != null && roomNums.length == 2) {
+                    roomDto.setFloorNum(roomNums[0]);
+                    roomDto.setUnitNum("0");
+                    roomDto.setRoomNum(roomNums[1]);
+                } else {
+                    roomDto.setRoomNum(reqJson.getString("roomNum"));
+                }
+            } else {
+                roomDto.setUnitNum("");
+                roomDto.setFloorNum("");
+                roomDto.setRoomNum("");
+            }
+        }
         ApiRoomVo apiRoomVo = new ApiRoomVo();
         //查询总记录数
         int total = roomInnerServiceSMOImpl.queryRoomsCount(roomDto);

+ 2 - 0
service-fee/src/main/java/com/java110/fee/cmd/fee/DeleteTempCarFeeConfigCmd.java

@@ -3,6 +3,7 @@ package com.java110.fee.cmd.fee;
 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;
@@ -32,6 +33,7 @@ public class DeleteTempCarFeeConfigCmd extends Cmd {
     }
 
     @Override
+    @Java110Transactional
     public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
         TempCarFeeConfigPo tempCarFeeConfigPo = BeanConvertUtil.covertBean(reqJson, TempCarFeeConfigPo.class);
         int flag = tempCarFeeConfigV1InnerServiceSMOImpl.deleteTempCarFeeConfig(tempCarFeeConfigPo);

+ 59 - 46
service-fee/src/main/java/com/java110/fee/cmd/fee/PayFeeCmd.java

@@ -165,18 +165,14 @@ public class PayFeeCmd extends Cmd {
         //一次性费用 和间接性费用
         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())
-                || FeeDto.FEE_FLAG_ONCE.equals(feeConfigDtos.get(0).getFeeFlag())) {
-            try {
-                maxEndTime = DateUtil.getDateFromString(feeConfigDtos.get(0).getEndTime(), DateUtil.DATE_FORMATE_STRING_A);
-            } catch (ParseException e) {
-            } catch (Exception e) {
-                logger.error("比较费用日期失败", e);
-            }
+        if (maxEndTime == null) {
+            maxEndTime = DateUtil.getDateFromStringA(feeConfigDtos.get(0).getEndTime());
+        }
+
+        if (maxEndTime != null && endTime != null) {
             Date newDate = DateUtil.stepMonth(endTime, reqJson.getDouble("cycles").intValue());
             if (newDate.getTime() > maxEndTime.getTime()) {
-                throw new IllegalArgumentException("缴费周期超过 缴费结束时间");
+                throw new IllegalArgumentException("缴费周期超过 缴费结束时间,请用按结束时间方式缴费");
             }
         }
 
@@ -204,33 +200,7 @@ public class PayFeeCmd extends Cmd {
             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()));
-                                    }
-                                }
-                            }
-                        }
-                    }
-                }
-            }
+            hasDiscount(paramObj, payFeePo, payFeeDetailPo);
             //判断选择的账号
             JSONArray jsonArray = paramObj.getJSONArray("selectUserAccount");
             if (jsonArray == null || jsonArray.size() < 1) {
@@ -384,6 +354,49 @@ public class PayFeeCmd extends Cmd {
         cmdDataFlowContext.setResponseEntity(ResultVo.createResponseEntity(feeReceiptDetailDto));
     }
 
+    /**
+     * 改造赠送逻辑 if 嵌套有点多 优化
+     * @param paramObj
+     * @param payFeePo
+     * @param payFeeDetailPo
+     * @throws ParseException
+     */
+    private void hasDiscount(JSONObject paramObj, PayFeePo payFeePo, PayFeeDetailPo payFeeDetailPo) throws ParseException {
+        if (!paramObj.containsKey("selectDiscount")) {
+            return;
+        }
+        JSONArray selectDiscount = paramObj.getJSONArray("selectDiscount");
+
+        if (selectDiscount == null || selectDiscount.size() < 1) {
+            return;
+        }
+        for (int index = 0; index < selectDiscount.size(); index++) {
+            JSONObject paramJson = selectDiscount.getJSONObject(index);
+            if (!"102020008".equals(paramJson.getString("ruleId"))) { //赠送规则
+                continue;
+            }
+            JSONArray feeDiscountSpecs = paramJson.getJSONArray("feeDiscountSpecs");
+            if (feeDiscountSpecs == null || feeDiscountSpecs.size() < 1) {
+                continue;
+            }
+            for (int specIndex = 0; specIndex < feeDiscountSpecs.size(); specIndex++) {
+                JSONObject paramIn = feeDiscountSpecs.getJSONObject(specIndex);
+                if (!"89002020980015".equals(paramIn.getString("specId"))) { //赠送月份
+                    continue;
+                }
+                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()));
+            }
+        }
+    }
+
     /**
      * 处理报修单
      *
@@ -585,9 +598,9 @@ public class PayFeeCmd extends Cmd {
             paramInJson.put("tmpCycles", cycles.doubleValue());
             businessFeeDetail.put("cycles", cycles.doubleValue());
             //处理 可能还存在 实收手工减免的情况
-            if(paramInJson.containsKey("receivableAmount") && !StringUtil.isEmpty(paramInJson.getString("receivableAmount"))){
+            if (paramInJson.containsKey("receivableAmount") && !StringUtil.isEmpty(paramInJson.getString("receivableAmount"))) {
                 businessFeeDetail.put("receivableAmount", paramInJson.getString("receivableAmount"));
-            }else {
+            } else {
                 businessFeeDetail.put("receivableAmount", receivedAmount.doubleValue());
             }
         } else if ("-103".equals(paramInJson.getString("cycles"))) { //这里按缴费结束时间缴费
@@ -598,15 +611,15 @@ public class PayFeeCmd extends Cmd {
             c.add(Calendar.DAY_OF_MONTH, 1);
             endDates = c.getTime();//这是明天
             targetEndTime = endDates;
-            BigDecimal receivedAmount1 =  new BigDecimal(Double.parseDouble(paramInJson.getString("receivedAmount")));
+            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"))){
+            if (paramInJson.containsKey("receivableAmount") && !StringUtil.isEmpty(paramInJson.getString("receivableAmount"))) {
                 businessFeeDetail.put("receivableAmount", paramInJson.getString("receivableAmount"));
-            }else {
+            } else {
                 businessFeeDetail.put("receivableAmount", receivedAmount.doubleValue());
             }
         } else {
@@ -617,8 +630,8 @@ public class PayFeeCmd extends Cmd {
 
             //出租递增问题处理
             if (FeeConfigDto.COMPUTING_FORMULA_RANT_RATE.equals(feeDto.getComputingFormula())) {
-                computeFeeSMOImpl.dealRentRateCycle(feeDto,cycles.doubleValue());
-                if(feeDto.getOweFee()> 0){
+                computeFeeSMOImpl.dealRentRateCycle(feeDto, cycles.doubleValue());
+                if (feeDto.getOweFee() > 0) {
                     businessFeeDetail.put("receivableAmount", feeDto.getAmountOwed());
                 }
             }
@@ -671,7 +684,7 @@ public class PayFeeCmd extends Cmd {
             maxEndTime = feeInfo.getConfigEndTime();
         }
 
-        if(FeeDto.FEE_FLAG_CYCLE_ONCE.equals(feeInfo.getFeeFlag())){
+        if (FeeDto.FEE_FLAG_CYCLE_ONCE.equals(feeInfo.getFeeFlag())) {
             maxEndTime = feeInfo.getMaxEndTime();
         }
 
@@ -681,7 +694,7 @@ public class PayFeeCmd extends Cmd {
         }
 
         //判断 结束时间 是否大于 费用项 结束时间,这里 容错一下,如果 费用结束时间大于 费用项结束时间 30天 走报错 属于多缴费
-        if(maxEndTime != null) {
+        if (maxEndTime != null) {
             if (feeInfo.getEndTime().getTime() - maxEndTime.getTime() > 30 * 24 * 60 * 60 * 1000L) {
                 throw new IllegalArgumentException("缴费超过了 费用项结束时间");
             }

+ 7 - 2
service-fee/src/main/java/com/java110/fee/cmd/fee/SaveTempCarFeeConfigCmd.java

@@ -3,6 +3,7 @@ package com.java110.fee.cmd.fee;
 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;
@@ -60,16 +61,20 @@ public class SaveTempCarFeeConfigCmd extends Cmd {
     }
 
     @Override
+    @Java110Transactional
     public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
         reqJson.put("feeConfigId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_configId));
         reqJson.put("configId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_configId));
         TempCarFeeConfigPo tempCarFeeConfigPo = BeanConvertUtil.covertBean(reqJson, TempCarFeeConfigPo.class);
+
+        //处理房屋属性
+        dealAttr(reqJson, context);
+
         int flag = tempCarFeeConfigV1InnerServiceSMOImpl.saveTempCarFeeConfig(tempCarFeeConfigPo);
         if (flag < 1) {
             throw new CmdException("保存临时收费失败");
         }
-        //处理房屋属性
-        dealAttr(reqJson, context);
+
 
         //补费用项数据
         PayFeeConfigPo payFeeConfigPo = new PayFeeConfigPo();

+ 7 - 1
service-fee/src/main/java/com/java110/fee/cmd/fee/UpdateTempCarFeeConfigCmd.java

@@ -64,6 +64,8 @@ public class UpdateTempCarFeeConfigCmd extends Cmd {
         Assert.listOnlyOne(tempCarFeeConfigDtos, "临时车收费标准不存在");
 
         TempCarFeeConfigPo tempCarFeeConfigPo = BeanConvertUtil.covertBean(reqJson, TempCarFeeConfigPo.class);
+        updateAttr(reqJson);
+
         int flag = tempCarFeeConfigV1InnerServiceSMOImpl.updateTempCarFeeConfig(tempCarFeeConfigPo);
 
         if (flag < 1) {
@@ -80,7 +82,11 @@ public class UpdateTempCarFeeConfigCmd extends Cmd {
         updateFeeConfig(BeanConvertUtil.beanCovertJson(payFeeConfigPo), context);
 
 
-        JSONArray attrs = reqJson.getJSONArray("attrs");
+
+    }
+
+    private void updateAttr(JSONObject reqJson) {
+        int flag;JSONArray attrs = reqJson.getJSONArray("attrs");
         if (attrs == null || attrs.size() < 1) {
             return;
         }

+ 11 - 5
service-job/src/main/java/com/java110/job/adapt/hcIot/tempCarFee/AddTempCarFeeConfigToIotAdapt.java

@@ -73,11 +73,11 @@ public class AddTempCarFeeConfigToIotAdapt extends DatabusAdaptImpl {
 
     public void execute(Business business, List<Business> businesses) {
         JSONObject data = business.getData();
+        JSONArray  businessTempCarFeeConfigs = new JSONArray();
         if (data.containsKey(TempCarFeeConfigPo.class.getSimpleName())) {
             Object bObj = data.get(TempCarFeeConfigPo.class.getSimpleName());
-            JSONArray businessTempCarFeeConfigs = null;
+
             if (bObj instanceof JSONObject) {
-                businessTempCarFeeConfigs = new JSONArray();
                 businessTempCarFeeConfigs.add(bObj);
             } else if (bObj instanceof List) {
                 businessTempCarFeeConfigs = JSONArray.parseArray(JSONObject.toJSONString(bObj));
@@ -85,11 +85,17 @@ public class AddTempCarFeeConfigToIotAdapt extends DatabusAdaptImpl {
                 businessTempCarFeeConfigs = (JSONArray) bObj;
             }
             //JSONObject businessTempCarFeeConfig = data.getJSONObject("businessTempCarFeeConfig");
-            for (int bTempCarFeeConfigIndex = 0; bTempCarFeeConfigIndex < businessTempCarFeeConfigs.size(); bTempCarFeeConfigIndex++) {
-                JSONObject businessTempCarFeeConfig = businessTempCarFeeConfigs.getJSONObject(bTempCarFeeConfigIndex);
-                doSendTempCarFeeConfig(business, businessTempCarFeeConfig);
+
+        }else {
+            if (data instanceof JSONObject) {
+                businessTempCarFeeConfigs.add(data);
             }
         }
+
+        for (int bTempCarFeeConfigIndex = 0; bTempCarFeeConfigIndex < businessTempCarFeeConfigs.size(); bTempCarFeeConfigIndex++) {
+            JSONObject businessTempCarFeeConfig = businessTempCarFeeConfigs.getJSONObject(bTempCarFeeConfigIndex);
+            doSendTempCarFeeConfig(business, businessTempCarFeeConfig);
+        }
     }
 
     private void doSendTempCarFeeConfig(Business business, JSONObject businessTempCarFeeConfig) {

+ 11 - 6
service-job/src/main/java/com/java110/job/adapt/hcIot/tempCarFee/DeleteTempCarFeeConfigToIotAdapt.java

@@ -64,23 +64,28 @@ public class DeleteTempCarFeeConfigToIotAdapt extends DatabusAdaptImpl {
     @Override
     public void execute(Business business, List<Business> businesses) {
         JSONObject data = business.getData();
+        JSONArray  businessTempCarFeeConfigs = new JSONArray();
         if (data.containsKey(TempCarFeeConfigPo.class.getSimpleName())) {
             Object bObj = data.get(TempCarFeeConfigPo.class.getSimpleName());
-            JSONArray businessTempCarFeeConfigs = null;
+
             if (bObj instanceof JSONObject) {
-                businessTempCarFeeConfigs = new JSONArray();
+
                 businessTempCarFeeConfigs.add(bObj);
             } else if (bObj instanceof List) {
                 businessTempCarFeeConfigs = JSONArray.parseArray(JSONObject.toJSONString(bObj));
             } else {
                 businessTempCarFeeConfigs = (JSONArray) bObj;
             }
-            //JSONObject businessTempCarFeeConfig = data.getJSONObject("businessTempCarFeeConfig");
-            for (int bTempCarFeeConfigIndex = 0; bTempCarFeeConfigIndex < businessTempCarFeeConfigs.size(); bTempCarFeeConfigIndex++) {
-                JSONObject businessTempCarFeeConfig = businessTempCarFeeConfigs.getJSONObject(bTempCarFeeConfigIndex);
-                doSendTempCarFeeConfig(business, businessTempCarFeeConfig);
+        }else {
+            if (data instanceof JSONObject) {
+                businessTempCarFeeConfigs.add(data);
             }
         }
+        //JSONObject businessTempCarFeeConfig = data.getJSONObject("businessTempCarFeeConfig");
+        for (int bTempCarFeeConfigIndex = 0; bTempCarFeeConfigIndex < businessTempCarFeeConfigs.size(); bTempCarFeeConfigIndex++) {
+            JSONObject businessTempCarFeeConfig = businessTempCarFeeConfigs.getJSONObject(bTempCarFeeConfigIndex);
+            doSendTempCarFeeConfig(business, businessTempCarFeeConfig);
+        }
     }
 
     private void doSendTempCarFeeConfig(Business business, JSONObject businessTempCarFeeConfig) {

+ 9 - 5
service-job/src/main/java/com/java110/job/adapt/hcIot/tempCarFee/ModifyTempCarFeeConfigToIotAdapt.java

@@ -78,11 +78,10 @@ public class ModifyTempCarFeeConfigToIotAdapt extends DatabusAdaptImpl {
 
     public void execute(Business business, List<Business> businesses) {
         JSONObject data = business.getData();
+        JSONArray  businessTempCarFeeConfigs = new JSONArray();
         if (data.containsKey(TempCarFeeConfigPo.class.getSimpleName())) {
             Object bObj = data.get(TempCarFeeConfigPo.class.getSimpleName());
-            JSONArray businessTempCarFeeConfigs = null;
             if (bObj instanceof JSONObject) {
-                businessTempCarFeeConfigs = new JSONArray();
                 businessTempCarFeeConfigs.add(bObj);
             } else if (bObj instanceof List) {
                 businessTempCarFeeConfigs = JSONArray.parseArray(JSONObject.toJSONString(bObj));
@@ -90,11 +89,16 @@ public class ModifyTempCarFeeConfigToIotAdapt extends DatabusAdaptImpl {
                 businessTempCarFeeConfigs = (JSONArray) bObj;
             }
             //JSONObject businessTempCarFeeConfig = data.getJSONObject("businessTempCarFeeConfig");
-            for (int bTempCarFeeConfigIndex = 0; bTempCarFeeConfigIndex < businessTempCarFeeConfigs.size(); bTempCarFeeConfigIndex++) {
-                JSONObject businessTempCarFeeConfig = businessTempCarFeeConfigs.getJSONObject(bTempCarFeeConfigIndex);
-                doSendTempCarFeeConfig(business, businessTempCarFeeConfig);
+
+        }else {
+            if (data instanceof JSONObject) {
+                businessTempCarFeeConfigs.add(data);
             }
         }
+        for (int bTempCarFeeConfigIndex = 0; bTempCarFeeConfigIndex < businessTempCarFeeConfigs.size(); bTempCarFeeConfigIndex++) {
+            JSONObject businessTempCarFeeConfig = businessTempCarFeeConfigs.getJSONObject(bTempCarFeeConfigIndex);
+            doSendTempCarFeeConfig(business, businessTempCarFeeConfig);
+        }
     }
 
     private void doSendTempCarFeeConfig(Business business, JSONObject businessTempCarFeeConfig) {