|
@@ -5,6 +5,7 @@ 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.AjaxMessage;
|
|
|
import com.bz.smart_city.commom.model.ResultStatus;
|
|
|
import com.bz.smart_city.commom.util.HttpClientUtils;
|
|
|
import com.bz.smart_city.commom.util.HttpRequest;
|
|
@@ -18,6 +19,7 @@ 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.apache.commons.lang3.time.DateFormatUtils;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -25,12 +27,10 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.BigInteger;
|
|
|
+import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Iterator;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -66,6 +66,9 @@ public class PayFeeServiceImp implements PayFeeService {
|
|
|
@Resource
|
|
|
private PayControlRecordMapper payControlRecordMapper;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private PayRechargeaccountMapper payRechargeaccountMapper;
|
|
|
+
|
|
|
@Value("${Sync.Data.Url}")
|
|
|
private String payValveCommondUrl;
|
|
|
|
|
@@ -1453,4 +1456,140 @@ public class PayFeeServiceImp implements PayFeeService {
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public BankPayfeeMsg cancelPayFee(PayPayAgentbranch payPayAgentbranch,BankCancelPayFeeParm bankCancelPayFeeParm){
|
|
|
+ Integer siteId=payPayAgentbranch.getSiteId();
|
|
|
+
|
|
|
+ Integer customerId = payPayAgentbranch.getCustomerId();
|
|
|
+ //订单号查询第三方交易记录
|
|
|
+ PayAgenttransactionDto payAgenttransactionDto = payFeeMapper.selectAgenttransaction(bankCancelPayFeeParm.getOrderCode());
|
|
|
+ if(payAgenttransactionDto != null ){
|
|
|
+ //获取账期
|
|
|
+ BaseClosingAccountInfo closingAccountInfo = payFeeMapper.getLastClosingAccount(siteId,customerId);
|
|
|
+ //客户编码
|
|
|
+ String accountnumber = payAgenttransactionDto.getAccountnumber();
|
|
|
+ //生成新的批次号
|
|
|
+ String newPayseriesno = null;
|
|
|
+ //取消的批次号
|
|
|
+ String payseriesno =payAgenttransactionDto.getPayseriesno();
|
|
|
+
|
|
|
+ if(payAgenttransactionDto.getAmount() != null && payAgenttransactionDto.getAmount().compareTo(new BigDecimal(bankCancelPayFeeParm.getMoney())) == 0){
|
|
|
+ if(payAgenttransactionDto.getState() != 4){
|
|
|
+ //获取相同批次号相同的实收信息
|
|
|
+ List<PayPayReceived> payReceiveds = payPayReceivedMapper.findBySeriesno(payseriesno,siteId,customerId);
|
|
|
+ //获取同批次号的交易明细
|
|
|
+ List<PayTransactiondetails> payTransactiondetailsList = payTransactiondetailsMapper.findBySeriesno(payseriesno,siteId,customerId,null);
|
|
|
+
|
|
|
+ //获取预存账户信息
|
|
|
+ PayRechargeaccountDto rechDao = new PayRechargeaccountDto();
|
|
|
+ rechDao.setSiteId(new BigInteger(String.valueOf(siteId)));
|
|
|
+ rechDao.setCustomerId(new BigInteger(String.valueOf(customerId)));
|
|
|
+ rechDao.setAccountnumber(payAgenttransactionDto.getAccountnumber());
|
|
|
+ PayRechargeaccountDto payRechargeaccount = payRechargeaccountMapper.findByAccountInfo(rechDao);
|
|
|
+ if(payRechargeaccount == null ){
|
|
|
+ return new BankPayfeeMsg("3003","业务状态异常");
|
|
|
+ }
|
|
|
+ //作废第三方
|
|
|
+ payPayReceivedMapper.cancelCheckAgentPayseriesno(payseriesno,siteId,customerId);
|
|
|
+ payPayReceivedMapper.updateReceivedCancel(payseriesno,siteId,customerId);
|
|
|
+ LocalDateTime time = LocalDateTime.now();
|
|
|
+ //回退实收
|
|
|
+ for(PayPayReceived Received:payReceiveds){
|
|
|
+ if(StringUtils.isBlank(newPayseriesno)){
|
|
|
+ newPayseriesno=Util.getBatchNo(payseriesno.substring(0,1),Received.getAccountnumber());
|
|
|
+ }
|
|
|
+ //回退实收对应的应收
|
|
|
+ payPayReceivedMapper.updateDebtById(Received.getReceivableId(),Received.getReceivedamount());
|
|
|
+ //作废当前实收
|
|
|
+ Received.setIscanceled(1);
|
|
|
+
|
|
|
+ Received.setCancelperson(new BigInteger("1"));
|
|
|
+ Received.setCanceltime(time);
|
|
|
+ Received.setState(4);//交易状态 0待对账 1入账 2对账失败 3对账成功 4作废
|
|
|
+ Received.setUpdateBy(new BigInteger("1"));
|
|
|
+ Received.setUpdateDate(time);
|
|
|
+ Received.setId(Received.getId());
|
|
|
+ payPayReceivedMapper.update(Received);
|
|
|
+
|
|
|
+ //生成负数实收
|
|
|
+ Received.setIscanceled(0);
|
|
|
+ Received.setLadderlevel(Received.getLadderlevel());
|
|
|
+ Received.setCanceledrecordId(Received.getId());
|
|
|
+ Received.setPayseriesno(newPayseriesno);
|
|
|
+ Received.setName(Received.getName()+"取消");
|
|
|
+ Received.setReceivedamount(Received.getReceivedamount().negate());
|
|
|
+ Received.setIscanceled(0);
|
|
|
+
|
|
|
+ if(closingAccountInfo != null){
|
|
|
+ Received.setYear(closingAccountInfo.getYear());
|
|
|
+ Received.setMonth(closingAccountInfo.getMonth());
|
|
|
+ }else{
|
|
|
+ Received.setYear(time.getYear());
|
|
|
+ Received.setMonth(time.getMonthValue());
|
|
|
+ }
|
|
|
+ Received.setCreateBy(new BigInteger("1"));
|
|
|
+ Received.setCreateDate(time);
|
|
|
+ Received.setUpdateBy(new BigInteger("1"));
|
|
|
+ Received.setUpdateDate(time);
|
|
|
+ Received.setRemarks("");
|
|
|
+ Received.setDelFlag("0");
|
|
|
+ Received.setSiteId(new BigInteger(String.valueOf(siteId)));
|
|
|
+ Received.setCustomerId(new BigInteger(String.valueOf(customerId)));
|
|
|
+ payPayReceivedMapper.insert(Received);
|
|
|
+ }
|
|
|
+ //回退交易明细
|
|
|
+ for(PayTransactiondetails payTransactiondetails:payTransactiondetailsList){
|
|
|
+ //回退预存账户余额
|
|
|
+ BigDecimal remaining = payRechargeaccount.getRemaining();
|
|
|
+ BigDecimal transamount = payTransactiondetails.getTransamount();
|
|
|
+ BigDecimal backRemaining=remaining.subtract(transamount);
|
|
|
+ payRechargeaccount.setRemaining(backRemaining);
|
|
|
+ payRechargeaccountMapper.update(payRechargeaccount);
|
|
|
+
|
|
|
+ payTransactiondetails.setIscanceled(1);
|
|
|
+ payTransactiondetails.setCancelperson(new BigInteger(String.valueOf(siteId)));
|
|
|
+ payTransactiondetails.setCanceltime(LocalDateTime.now());
|
|
|
+
|
|
|
+ payTransactiondetails.setIscanceled(1);//标记为取消状态
|
|
|
+ payTransactiondetails.setCancelperson(new BigInteger("1"));
|
|
|
+ payTransactiondetails.setCanceltime(LocalDateTime.now());
|
|
|
+ payTransactiondetails.setUpdateBy(new BigInteger("1"));
|
|
|
+ payTransactiondetails.setUpdateDate(LocalDateTime.now());
|
|
|
+ payTransactiondetailsMapper.updateCancelInfo(payTransactiondetails);
|
|
|
+
|
|
|
+ payTransactiondetails.setPayseriesno(payseriesno);
|
|
|
+ payTransactiondetails.setName(payTransactiondetails.getName()+"取消");
|
|
|
+ payTransactiondetails.setIscanceled(0);
|
|
|
+ payTransactiondetails.setLastrecreamaing(payRechargeaccount.getRemaining());
|
|
|
+ payTransactiondetails.setTransamount(payTransactiondetails.getTransamount().negate());
|
|
|
+ payTransactiondetails.setTranstime(LocalDateTime.now());
|
|
|
+ if(closingAccountInfo != null){
|
|
|
+ payTransactiondetails.setYear(closingAccountInfo.getYear());
|
|
|
+ payTransactiondetails.setMonth(closingAccountInfo.getMonth());
|
|
|
+ }else{
|
|
|
+ payTransactiondetails.setYear(time.getYear());
|
|
|
+ payTransactiondetails.setMonth(time.getMonthValue());
|
|
|
+ }
|
|
|
+
|
|
|
+ payTransactiondetails.setCanceledrecordId(payTransactiondetails.getId());
|
|
|
+
|
|
|
+ if(payTransactiondetails.getTranstype()==2){
|
|
|
+ payTransactiondetails.setTranstype(4);
|
|
|
+ payTransactiondetails.setTranstypeLabel("账户转预存");
|
|
|
+ }
|
|
|
+ payTransactiondetailsMapper.insert(payTransactiondetails);
|
|
|
+ }
|
|
|
+ //修改客户状态
|
|
|
+ payFeeMapper.updateAccountState(rechDao.getAccountId());
|
|
|
+ }else{
|
|
|
+ return new BankPayfeeMsg("3001","不能多次冲正");
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ return new BankPayfeeMsg("3002","与缴费金额不一致");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return new BankPayfeeMsg("9999","缴费冲正成功");
|
|
|
+ }
|
|
|
}
|