Kaynağa Gözat

1新增同步修改客户编码接口

Xiaojh 4 yıl önce
ebeveyn
işleme
129f0c5057

+ 1 - 0
smart-city-platform/src/main/java/com/bz/smart_city/commom/security/WebSecurityConfig.java

@@ -96,6 +96,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
                 .antMatchers("/printinvoice/InvoicePrintRequest")
                 .antMatchers("/waterMeter/getMeterByDeviceNo")
                 .antMatchers("/device/synArchies")
+                .antMatchers("/customer/synCustomer")
                 .antMatchers("/druid/**");
 
     }

+ 16 - 0
smart-city-platform/src/main/java/com/bz/smart_city/controller/pay/PaySyncDataController.java

@@ -15,6 +15,7 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 
+import org.json.JSONObject;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
@@ -105,4 +106,19 @@ public class PaySyncDataController {
 
         return new AjaxMessage<>(ResultStatus.OK);
     }
+
+
+    @ResponseBody
+    @PostMapping("/customer/synCustomer")
+    @ApiOperation(value = "客户编码同步接口")
+    public AjaxMessage synCustomer(@RequestBody(required = true) String json){
+        try {
+            JSONObject jsonObject = new JSONObject(json);
+            String oldNo = jsonObject.getString("oldNo");
+            String newNo = jsonObject.getString("newNo");
+            return paySyncDataService.synCustomer(oldNo,newNo);
+        }catch (Exception ex){
+            return new AjaxMessage<>(ResultStatus.ERROR);
+        }
+    }
 }

+ 2 - 0
smart-city-platform/src/main/java/com/bz/smart_city/dao/CustomerMapper.java

@@ -39,4 +39,6 @@ public interface CustomerMapper {
     CustomerDto getCustomerByCustomerno(@Param("customerNo") String customerNo);
 
     Customer findByName(@Param("siteId") Integer siteId, @Param("name") String name);
+
+    void updateCustomer(@Param("oldNo")String oldNo,@Param("newNo")String newNo);
 }

+ 29 - 4
smart-city-platform/src/main/java/com/bz/smart_city/service/impl/pay/PaySyncDataServiceImpl.java

@@ -2,6 +2,7 @@ package com.bz.smart_city.service.impl.pay;
 
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.TypeReference;
+import com.bz.smart_city.commom.exception.ServiceException;
 import com.bz.smart_city.commom.model.AjaxMessage;
 import com.bz.smart_city.commom.model.ResultStatus;
 import com.bz.smart_city.commom.util.HttpRequest;
@@ -11,10 +12,7 @@ import com.bz.smart_city.commom.util.UserUtil;
 import com.bz.smart_city.dao.CustomerMapper;
 import com.bz.smart_city.dao.DeviceMapper;
 import com.bz.smart_city.dao.WaterMeterReplaceLogMapper;
-import com.bz.smart_city.dto.AreaDto;
-import com.bz.smart_city.dto.CommunityDto;
-import com.bz.smart_city.dto.DeviceTypeDto;
-import com.bz.smart_city.dto.LoginUser;
+import com.bz.smart_city.dto.*;
 import com.bz.smart_city.dto.pay.InstallPlanDataDTO;
 import com.bz.smart_city.dto.pay.InstallPlanInputDTO;
 import com.bz.smart_city.dto.pay.PayBaseAccountDto;
@@ -326,4 +324,31 @@ public class PaySyncDataServiceImpl implements PaySyncDataService {
         }
         return  new AjaxMessage(ResultStatus.ERROR);
     }
+
+    @Transactional
+    public AjaxMessage synCustomer(String oldNo,String newNo){
+        try {
+            if(StringUtils.isBlank(oldNo)){
+                return new AjaxMessage(ResultStatus.ERROR,"旧客户编号不能为空");
+            }
+            if (StringUtils.isBlank(newNo)){
+                return new AjaxMessage(ResultStatus.ERROR,"新客户编号不能为空");
+            }
+            //校验旧客户编号是否存在
+            CustomerDto oldCustomer = customerMapper.getCustomerByCustomerno(oldNo);
+            if(oldCustomer == null){
+                return new AjaxMessage(ResultStatus.ERROR,"旧客户编号不存在");
+            }
+            //校验新客户编号是否已经存在
+            CustomerDto newCustomer = customerMapper.getCustomerByCustomerno(newNo);
+            if(newCustomer != null && newCustomer.getId() != null){
+                return new AjaxMessage(ResultStatus.ERROR,"新客户编号已存在,不能重复修改");
+            }
+            customerMapper.updateCustomer(oldNo,newNo);
+        }catch (Exception ex){
+            ex.printStackTrace();
+            return new AjaxMessage(ResultStatus.ERROR);
+        }
+        return new AjaxMessage(ResultStatus.OK);
+    }
 }

+ 2 - 0
smart-city-platform/src/main/java/com/bz/smart_city/service/pay/PaySyncDataService.java

@@ -25,4 +25,6 @@ public interface PaySyncDataService {
     int addReplaceRecord(WaterMeterReplaceLog waterMeterReplaceLog);
 
     AjaxMessage addJF(InstallPlanInputDTO installPlanInput, LoginUser excelloginUser);
+
+    AjaxMessage synCustomer(String oldNo,String newNo);
 }

+ 5 - 0
smart-city-platform/src/main/resources/mapper/CustomerMapper.xml

@@ -279,5 +279,10 @@
         select id,customer_name from sc_customer where status = 1 and site_id = #{siteId} and customer_name = #{name} limit 1
     </select>
 
+    <update id="updateCustomer">
+        update sc_customer set customer_no =#{newNo}
+        where customer_no =#{oldNo}
+    </update>
+
 </mapper>
 

+ 1 - 8
smart-city-platform/src/main/resources/mapper/pay/PayControlRuleMapper.xml

@@ -143,14 +143,7 @@
     </select>
 
     <select id="findUseMoeny" resultType="decimal">
-        select
-            (
-            SELECT remaining remaining from pay_pay_rechargeaccount
-            where  account_id=#{accountId})
-         -
-            (select IFNULL(SUM(debt),0) debt  from pay_pay_receivable where
-            account_id=#{accountId} and debt > 0 )
-         as remaining
+         select balance as remaining from pay_pay_rechargeaccount where account_id =#{accountId}
     </select>
 
     <select id="findOpenUse" resultType="integer">