|
@@ -1,8 +1,12 @@
|
|
|
package com.bz.smart_city.service.impl.pay;
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.bz.smart_city.commom.exception.ServiceException;
|
|
|
import com.bz.smart_city.commom.model.ResultStatus;
|
|
|
+import com.bz.smart_city.commom.util.HttpClientUtils;
|
|
|
import com.bz.smart_city.commom.util.UserUtil;
|
|
|
import com.bz.smart_city.commom.util.Util;
|
|
|
import com.bz.smart_city.dao.pay.*;
|
|
@@ -11,7 +15,9 @@ import com.bz.smart_city.dto.pay.*;
|
|
|
import com.bz.smart_city.dto.pay.payfee.*;
|
|
|
import com.bz.smart_city.entity.pay.*;
|
|
|
import com.bz.smart_city.service.pay.PayFeeService;
|
|
|
+import lombok.extern.log4j.Log4j2;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
@@ -33,6 +39,7 @@ import java.util.stream.Collectors;
|
|
|
* @Version 1.0
|
|
|
*/
|
|
|
@Service
|
|
|
+@Log4j2
|
|
|
public class PayFeeServiceImp implements PayFeeService {
|
|
|
|
|
|
|
|
@@ -55,6 +62,11 @@ public class PayFeeServiceImp implements PayFeeService {
|
|
|
private PayAgenttransactionMapper payAgenttransactionMapper;
|
|
|
@Resource
|
|
|
private PayCheckbalanceMapper payCheckbalanceMapper;
|
|
|
+ @Resource
|
|
|
+ private PayControlRecordMapper payControlRecordMapper;
|
|
|
+
|
|
|
+ @Value("${pay.valve.conmond.url}")
|
|
|
+ private String payValveCommondUrl;
|
|
|
|
|
|
/**
|
|
|
* 柜台缴费
|
|
@@ -295,10 +307,20 @@ public class PayFeeServiceImp implements PayFeeService {
|
|
|
payTransactiondetails.setLastrecreamaing(remaining);//交易后账户余额
|
|
|
}
|
|
|
//批量保存交易明细
|
|
|
- if(transactiondetailsDtoList.size()>0)
|
|
|
+ if(transactiondetailsDtoList.size()>0){
|
|
|
payTransactiondetailsMapper.batchInsert(transactiondetailsDtoList);
|
|
|
+ }
|
|
|
+ //查询阀门状态,判断是否需要开阀
|
|
|
+ List<PayValveStateInfo> payValveStateInfos = payFeeMapper.getDeviceValveState(new BigInteger(id));
|
|
|
+ for(PayValveStateInfo payValveStateInfo : payValveStateInfos){
|
|
|
+ if(payValveStateInfo.getDebt().compareTo(BigDecimal.ZERO) ==1 && payValveStateInfo.getValveState().equals("0")){
|
|
|
+ Boolean sendValveCommondResult = this.sendValveCommond(payValveStateInfo);
|
|
|
+ if(!sendValveCommondResult){
|
|
|
+// result+="; 开阀异常:"+String.format("%.2f", transAmount)+"元";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
//返回批次号
|
|
|
-
|
|
|
PayfeeResult payfeeResult=new PayfeeResult();
|
|
|
payfeeResult.setMsg(result);
|
|
|
payfeeResult.setTransType(0);
|
|
@@ -545,11 +567,23 @@ public class PayFeeServiceImp implements PayFeeService {
|
|
|
payTransactiondetails.setLastrecreamaing(remaining);//交易后账户余额
|
|
|
}
|
|
|
//批量保存交易明细
|
|
|
- if(transactiondetailsDtoList.size()>0)
|
|
|
+ if(transactiondetailsDtoList.size()>0){
|
|
|
payTransactiondetailsMapper.batchInsert(transactiondetailsDtoList);
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询阀门状态,判断是否需要开阀
|
|
|
+ List<PayValveStateInfo> payValveStateInfos = payFeeMapper.getDeviceValveState(payCustomRechargeDto.getAccountId());
|
|
|
+ for(PayValveStateInfo payValveStateInfo : payValveStateInfos){
|
|
|
+ if(payValveStateInfo.getDebt().compareTo(BigDecimal.ZERO) ==1 && payValveStateInfo.getValveState().equals("0")){
|
|
|
+ Boolean sendValveCommondResult = this.sendValveCommond(payValveStateInfo);
|
|
|
+ if(!sendValveCommondResult){
|
|
|
+// result+="; 开阀异常:"+String.format("%.2f", transAmount)+"元";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//返回批次号
|
|
|
return payseriesno;
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/*
|
|
@@ -1202,6 +1236,17 @@ public class PayFeeServiceImp implements PayFeeService {
|
|
|
payAgenttransaction.setRemarks("银行代缴充值");
|
|
|
payAgenttransaction.setDelFlag("0");
|
|
|
payAgenttransactionMapper.insertAgenttransaction(payAgenttransaction);
|
|
|
+
|
|
|
+ //查询阀门状态,判断是否需要开阀
|
|
|
+ List<PayValveStateInfo> payValveStateInfos = payFeeMapper.getDeviceValveState(payCustomRechargeDto.getAccountId());
|
|
|
+ for(PayValveStateInfo payValveStateInfo : payValveStateInfos){
|
|
|
+ if(payValveStateInfo.getDebt().compareTo(BigDecimal.ZERO) ==1 && payValveStateInfo.getValveState().equals("0")){
|
|
|
+ Boolean sendValveCommondResult = this.sendValveCommond(payValveStateInfo);
|
|
|
+ if(!sendValveCommondResult){ //关阀失败
|
|
|
+// result+="; 开阀异常:"+String.format("%.2f", transAmount)+"元";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
return new BankPayfeeMsg("9999","交易成功");
|
|
|
}
|
|
|
|
|
@@ -1291,4 +1336,43 @@ public class PayFeeServiceImp implements PayFeeService {
|
|
|
return new BankCheckBillsMsg("9999",
|
|
|
"对账完成,对账总数:"+bankCheckBillParm.getTotalCount()+",对账成功数:"+payCheckbalances.size(),bankCheckBillList);
|
|
|
}
|
|
|
+
|
|
|
+ //缴费开阀
|
|
|
+ public Boolean sendValveCommond(PayValveStateInfo payValveStateInfo){
|
|
|
+ LoginUser loginUser =UserUtil.getCurrentUser();
|
|
|
+ JSONObject parmJson= new JSONObject();
|
|
|
+ parmJson.put("meterNo",payValveStateInfo.getMeterCode());
|
|
|
+ parmJson.put("type",1); //1开0关
|
|
|
+ parmJson.put("customerNo",payValveStateInfo.getCustomerNo());
|
|
|
+ String context=parmJson.toString();
|
|
|
+ try {
|
|
|
+ String result= HttpClientUtils.doPostWithJson(payValveCommondUrl,context);
|
|
|
+ log.info("开关阀请求结果"+result);
|
|
|
+ JSONObject jsonObject= JSON.parseObject(result);
|
|
|
+ Integer status= jsonObject.getInteger("status");
|
|
|
+ if(status .equals("000000")){ //返回正常
|
|
|
+ //添加阀控记录
|
|
|
+ PayControlRecord payControlRecord = new PayControlRecord();
|
|
|
+ payControlRecord.setAccountId(payValveStateInfo.getAccountId());
|
|
|
+ payControlRecord.setMeterId(payValveStateInfo.getMeterId());
|
|
|
+ payControlRecord.setRemarks("缴费开阀");
|
|
|
+ payControlRecord.setResult(0);//进行中
|
|
|
+ payControlRecord.setState(0);//状态为关阀
|
|
|
+ payControlRecord.setType(1);//开阀操作
|
|
|
+
|
|
|
+ payControlRecord.setCreateBy(BigInteger.valueOf(loginUser.getId()));
|
|
|
+ payControlRecord.setCreateDate(LocalDateTime.now());
|
|
|
+ payControlRecord.setUpdateBy(BigInteger.valueOf(loginUser.getId()));
|
|
|
+ payControlRecord.setUpdateDate(LocalDateTime.now());
|
|
|
+ payControlRecord.setDelFlag("0");
|
|
|
+ payControlRecord.setCustomerId(BigInteger.valueOf(loginUser.getCustomerId()));
|
|
|
+ payControlRecord.setSiteId(BigInteger.valueOf(loginUser.getSiteId()));
|
|
|
+ payControlRecordMapper.add(payControlRecord);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|