|
@@ -52,12 +52,40 @@ public class PayFeeServiceImp implements PayFeeService {
|
|
|
@Resource
|
|
|
BaseClosingAccountInfoMapper baseClosingAccountInfoMapper;
|
|
|
|
|
|
- public PayfeeResult payFeeCounter( String id,Integer payway,BigDecimal transAmount, Integer balancetype){
|
|
|
- //交易金额不可为负数
|
|
|
+ /**
|
|
|
+ * 柜台缴费
|
|
|
+ * @param id 客户id
|
|
|
+ * @param payway 支付方式
|
|
|
+ * @param transAmount 实收金额
|
|
|
+ * @param balancetype 余额处理 1转预存 2找零
|
|
|
+ * @param debt 欠费金额
|
|
|
+ * @param ycremaining 预存金额
|
|
|
+ * @param amount 购水量
|
|
|
+ * @pram waterAmount 购水金额
|
|
|
+ */
|
|
|
+ public PayfeeResult payFeeCounter( String id,Integer payway,BigDecimal transAmount, Integer balancetype,BigDecimal debt,
|
|
|
+ BigDecimal ycremaining,Integer amount, BigDecimal waterAmount){
|
|
|
+ //实收金额不可为负数
|
|
|
if(transAmount.compareTo(BigDecimal.ZERO)!=1){
|
|
|
throw new ServiceException(ResultStatus.PAYFEE_TRANSAMOUNT_BELOW_ZERO);
|
|
|
}
|
|
|
-// String result=""; //执行结果描述
|
|
|
+ //欠费金额不能为负数
|
|
|
+ if(debt.compareTo(BigDecimal.ZERO) == -1){
|
|
|
+ throw new ServiceException(ResultStatus.PAYFEE_DEBT_BELOW_ZERO);
|
|
|
+ }
|
|
|
+ //预存金额不能为负数
|
|
|
+ if(ycremaining.compareTo(BigDecimal.ZERO) == -1){
|
|
|
+ throw new ServiceException(ResultStatus.PAYFEE_REMAINING_BELOW_ZERO);
|
|
|
+ }
|
|
|
+ //购水量不能为负数
|
|
|
+ if(amount < 0){
|
|
|
+ throw new ServiceException(ResultStatus.PAYFEE_REMAINING_BELOW_ZERO);
|
|
|
+ }
|
|
|
+ //购水金额不能为负数
|
|
|
+ if(waterAmount.compareTo(BigDecimal.ZERO) != 1){
|
|
|
+ throw new ServiceException(ResultStatus.PAYFEE_WATERAMOUNT_BELOW_ZERO);
|
|
|
+ }
|
|
|
+ //String result=""; //执行结果描述
|
|
|
String result="实收金额:"+String.format("%.2f",transAmount)+"元";
|
|
|
BigDecimal fees=BigDecimal.ZERO; //抵扣金额
|
|
|
LoginUser loginUser = UserUtil.getCurrentUser();
|
|
@@ -73,11 +101,11 @@ public class PayFeeServiceImp implements PayFeeService {
|
|
|
}
|
|
|
//根据客编或者水编获取客户信息
|
|
|
PayCustomRechargeDto payCustomRechargeDto = payFeeMapper.getCustomInfoByMeterOrAccount(id,null,null,BigInteger.valueOf(loginUser.getSiteId()),BigInteger.valueOf(loginUser.getCustomerId()));
|
|
|
-
|
|
|
+ //查询欠费信息
|
|
|
List<PayReceivable> payReceivableList =payFeeMapper.getReceivable(loginUser.getSiteId(),loginUser.getCustomerId(),payCustomRechargeDto.getAccountId(),null);
|
|
|
|
|
|
- if(payReceivableList.size() == 0){ //没有应收信息走仅充值
|
|
|
- return rechargefeeCounter(id, transAmount, payway);
|
|
|
+ if(payReceivableList.size() == 0 && debt.compareTo(BigDecimal.ZERO) ==0){ //没有应收信息走仅充值
|
|
|
+ return rechargefeeCounter(id, transAmount, payway,balancetype,waterAmount);
|
|
|
}else{
|
|
|
BigDecimal debts=BigDecimal.ZERO;
|
|
|
for(PayReceivable payReceivable: payReceivableList){
|
|
@@ -179,6 +207,8 @@ public class PayFeeServiceImp implements PayFeeService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ //实收金额 = 实收金额 - 总的欠费金额
|
|
|
+ //transAmount = transAmount.subtract(fees);
|
|
|
// result+="<br>预存款抵扣:"+String.format("%.2f",fees)+"元";
|
|
|
fees=BigDecimal.ZERO;//
|
|
|
//缴费抵扣
|
|
@@ -220,7 +250,7 @@ public class PayFeeServiceImp implements PayFeeService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- result+="; 支付金额抵扣:"+String.format("%.2f",fees)+"元";
|
|
|
+ result+="; 支付金额抵扣:"+String.format("%.2f",fees)+"元;买水:"+amount+"吨;";
|
|
|
//余额充值或划扣有余额
|
|
|
if(balancetype == 1 && transAmount.compareTo(BigDecimal.ZERO) == 1){
|
|
|
result+="; 余额转预存:"+String.format("%.2f",transAmount)+"元";
|
|
@@ -233,6 +263,18 @@ public class PayFeeServiceImp implements PayFeeService {
|
|
|
payTransactiondetails.setTranstypeLabel("账户转预存");
|
|
|
transactiondetailsDtoList.add(payTransactiondetails);
|
|
|
}else{
|
|
|
+ //找零金额 = 实收金额-欠费-购水金额
|
|
|
+ //transAmount 已划扣掉欠费
|
|
|
+ transAmount = transAmount.subtract(waterAmount);
|
|
|
+ //购水金额转预存
|
|
|
+ remaining=remaining.add(waterAmount);
|
|
|
+ //生成交易明细
|
|
|
+ PayTransactiondetails payTransactiondetails = getPayTransactiondetails(payway, paywayName,localDateTime, payCustomRechargeDto, payseriesno, month, year, waterAmount, siteId, customerId, userId );
|
|
|
+ payTransactiondetails.setName(payCustomRechargeDto.getAccountname() + payCustomRechargeDto.getAccountnumber() + "缴费");
|
|
|
+ payTransactiondetails.setTranstype(4);
|
|
|
+ payTransactiondetails.setTranstypeLabel("账户转预存");
|
|
|
+ transactiondetailsDtoList.add(payTransactiondetails);
|
|
|
+
|
|
|
result+="; 余额找零:"+String.format("%.2f", transAmount)+"元";
|
|
|
}
|
|
|
|
|
@@ -516,7 +558,7 @@ public class PayFeeServiceImp implements PayFeeService {
|
|
|
*
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public PayfeeResult rechargefeeCounter(String accountId , BigDecimal transAmount, Integer payway ){
|
|
|
+ public PayfeeResult rechargefeeCounter(String accountId , BigDecimal transAmount, Integer payway ,Integer balancetype,BigDecimal waterAmount){
|
|
|
|
|
|
//交易金额不可为负数
|
|
|
if(transAmount.compareTo(BigDecimal.ZERO)!=1){
|
|
@@ -555,14 +597,30 @@ public class PayFeeServiceImp implements PayFeeService {
|
|
|
//获取客户信息失败
|
|
|
throw new ServiceException(ResultStatus.PAYFEE_QUERY_NO_CUSTOMER);
|
|
|
}
|
|
|
+ //余额处理 1转预存 0找零
|
|
|
+ if(balancetype == 0){
|
|
|
+ //如果有找零的记录,则 充值金额=实收金额-购水金额
|
|
|
+ transAmount = transAmount.subtract(waterAmount);
|
|
|
+ }
|
|
|
+
|
|
|
//生成批次号
|
|
|
// 微信:W 现金、预存账户:C 银行:B 支付宝:A
|
|
|
- String payseriesno = recharge(transAmount, payway, siteId, customerId, userId, paywayName, localDateTime, payCustomRechargeDto);
|
|
|
+ String payseriesno = "";
|
|
|
+ if(balancetype == 0){
|
|
|
+ payseriesno = recharge(waterAmount, payway, siteId, customerId, userId, paywayName, localDateTime, payCustomRechargeDto);
|
|
|
+ }else if (balancetype == 1) {
|
|
|
+ payseriesno = recharge(transAmount, payway, siteId, customerId, userId, paywayName, localDateTime, payCustomRechargeDto);
|
|
|
+ }
|
|
|
PayfeeResult payfeeResult =new PayfeeResult();
|
|
|
payfeeResult.setPayseriesno(payseriesno);
|
|
|
payfeeResult.setTransType(1);
|
|
|
payfeeResult.setPayway(payway);
|
|
|
- payfeeResult.setMsg("充值金额:"+String.format("%.2f", transAmount)+"元");
|
|
|
+ if(balancetype == 0){
|
|
|
+ payfeeResult.setMsg("充值金额:"+String.format("%.2f", waterAmount)+"元;找零:"+transAmount+"元");
|
|
|
+ }else if (balancetype == 1){
|
|
|
+ payfeeResult.setMsg("充值金额:"+String.format("%.2f", transAmount)+"元");
|
|
|
+ }
|
|
|
+
|
|
|
return payfeeResult;
|
|
|
}
|
|
|
|
|
@@ -709,6 +767,58 @@ public class PayFeeServiceImp implements PayFeeService {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ public List<PayfeeAccountInfoDto> findPayfeeAccountInfo(BigInteger id, String condition ){
|
|
|
+ if(StringUtils.isBlank(condition)&&id == null){
|
|
|
+ throw new ServiceException(ResultStatus.PAY_CONDITION_ISNULL);
|
|
|
+ }
|
|
|
+ LoginUser loginUser = UserUtil.getCurrentUser();
|
|
|
+ //数据权限
|
|
|
+ return payFeeMapper.findPayfeeAccountInfo(id, condition ,loginUser.getSiteId(),loginUser.getCustomerId(),UserUtil.getCurrentSiteProgramItems(loginUser));
|
|
|
+ }
|
|
|
+
|
|
|
+ public PayfeeDetaileBill getPayfeeDetaileBill(BigInteger id){
|
|
|
+ if(id == null){
|
|
|
+ return new PayfeeDetaileBill();
|
|
|
+ }
|
|
|
+ PayfeeDetaileBill bill = payFeeMapper.getPayfeeDetaileBill(id);
|
|
|
+ Double debt = bill.getDebt();//原有欠费
|
|
|
+ Double remaining = bill.getRemaining();//预存金额
|
|
|
+ Double actualDebt = 0.0;//实际欠费金额
|
|
|
+ if((remaining != null && remaining>0) && (debt != null && debt > 0)){
|
|
|
+ //又有预存金额,又有欠费金额的情况下
|
|
|
+ if(remaining > debt){
|
|
|
+ //预存金额大于欠费的情况下
|
|
|
+ //预存金额 = 账户余额 - 欠费
|
|
|
+ actualDebt = remaining - debt;
|
|
|
+ BigDecimal bg = new BigDecimal(actualDebt);
|
|
|
+ remaining = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
+ bill.setRemaining(remaining);
|
|
|
+ bill.setDebt(0.0);
|
|
|
+ bill.setActualDebt(0.0);
|
|
|
+ }else if(debt > remaining){
|
|
|
+ //欠费金额大于预存金额
|
|
|
+ //实际欠费金额 = 欠费金额-预存金额
|
|
|
+ actualDebt = debt - remaining;
|
|
|
+ BigDecimal bg = new BigDecimal(actualDebt);
|
|
|
+ actualDebt = bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
+ bill.setActualDebt(actualDebt);
|
|
|
+ bill.setDebt(debt);
|
|
|
+ bill.setRemaining(0.0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return bill;
|
|
|
+ }
|
|
|
+
|
|
|
+ public PayfeeDetailed getPayfeeDetailed(BigInteger id ){
|
|
|
+ if(id == null){
|
|
|
+ return new PayfeeDetailed();
|
|
|
+ }
|
|
|
+// LoginUser loginUser = UserUtil.getCurrentUser();
|
|
|
+// //获取最新账期
|
|
|
+// BaseClosingAccountInfoDto baseClosingAccountInfoDto=baseClosingAccountInfoMapper.getLastClosingAccount(loginUser.getSiteId(),loginUser.getCustomerId());
|
|
|
+ return payFeeMapper.getPayfeeDetailed(id);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 应收生成实收信息(相对应信息)
|
|
|
* @param payReceivable 应收信息
|
|
@@ -760,32 +870,6 @@ public class PayFeeServiceImp implements PayFeeService {
|
|
|
return payReceived;
|
|
|
}
|
|
|
|
|
|
- public List<PayfeeAccountInfoDto> findPayfeeAccountInfo(BigInteger id, String condition ){
|
|
|
- if(StringUtils.isBlank(condition)&&id == null){
|
|
|
- throw new ServiceException(ResultStatus.PAY_CONDITION_ISNULL);
|
|
|
- }
|
|
|
- LoginUser loginUser = UserUtil.getCurrentUser();
|
|
|
- //数据权限
|
|
|
- return payFeeMapper.findPayfeeAccountInfo(id, condition ,loginUser.getSiteId(),loginUser.getCustomerId(),UserUtil.getCurrentSiteProgramItems(loginUser));
|
|
|
- }
|
|
|
-
|
|
|
- public PayfeeDetaileBill getPayfeeDetaileBill(BigInteger id){
|
|
|
- if(id == null){
|
|
|
- return new PayfeeDetaileBill();
|
|
|
- }
|
|
|
- return payFeeMapper.getPayfeeDetaileBill(id);
|
|
|
- }
|
|
|
-
|
|
|
- public PayfeeDetailed getPayfeeDetailed(BigInteger id ){
|
|
|
- if(id == null){
|
|
|
- return new PayfeeDetailed();
|
|
|
- }
|
|
|
-// LoginUser loginUser = UserUtil.getCurrentUser();
|
|
|
-// //获取最新账期
|
|
|
-// BaseClosingAccountInfoDto baseClosingAccountInfoDto=baseClosingAccountInfoMapper.getLastClosingAccount(loginUser.getSiteId(),loginUser.getCustomerId());
|
|
|
- return payFeeMapper.getPayfeeDetailed(id);
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 查询客户欠费信息
|
|
|
* @param accountId
|
|
@@ -853,4 +937,8 @@ public class PayFeeServiceImp implements PayFeeService {
|
|
|
return payFeeMapper.getPayinvoiceInfo(accountId, year, loginUser.getSiteId(), loginUser.getCustomerId());
|
|
|
}
|
|
|
|
|
|
+ public BigInteger getWaterPropertyId(BigInteger id){
|
|
|
+ return payFeeMapper.getWaterPropertyId(id);
|
|
|
+ }
|
|
|
+
|
|
|
}
|