Commit 9ec882e0 authored by renjie's avatar renjie

费用明细增加余额

parent 2f215f01
package com.edgec.browserbackend.account.domain; package com.edgec.browserbackend.account.domain;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
/** /**
* @Desc * @Desc
* @Author jason * @Author jason
* @CreateTime 2020/3/12 3:14 下午 * @CreateTime 2020/3/12 3:14 下午
**/ **/
@JsonIgnoreProperties(ignoreUnknown = true)
public class Promotion { public class Promotion {
private String code; private String code;
private int invitedUsers; private int invitedUsers;
private int commission; private int commission;
private boolean isSale;
public int getCommission() { public int getCommission() {
return commission; return commission;
...@@ -33,4 +37,12 @@ public class Promotion { ...@@ -33,4 +37,12 @@ public class Promotion {
public void setCode(String code) { public void setCode(String code) {
this.code = code; this.code = code;
} }
public boolean isSale() {
return isSale;
}
public void setSale(boolean sale) {
isSale = sale;
}
} }
...@@ -50,6 +50,8 @@ public class UserPrePaidBilling { ...@@ -50,6 +50,8 @@ public class UserPrePaidBilling {
private String administrator; private String administrator;
private float balanced;
private List<DeductionRecord> deductionRecords = new ArrayList<>(); private List<DeductionRecord> deductionRecords = new ArrayList<>();
public float getRate() { public float getRate() {
...@@ -199,4 +201,12 @@ public class UserPrePaidBilling { ...@@ -199,4 +201,12 @@ public class UserPrePaidBilling {
public void setAdministrator(String administrator) { public void setAdministrator(String administrator) {
this.administrator = administrator; this.administrator = administrator;
} }
public float getBalanced() {
return balanced;
}
public void setBalanced(float balanced) {
this.balanced = balanced;
}
} }
...@@ -252,6 +252,7 @@ public class AccountServiceImpl implements AccountService { ...@@ -252,6 +252,7 @@ public class AccountServiceImpl implements AccountService {
int year = lastmonth.getYear(); int year = lastmonth.getYear();
bill.setYear(year); bill.setYear(year);
bill.setMonth(monthValue); bill.setMonth(monthValue);
bill.setBalanced(userBalance.getBalanced());
prePaidBillingRepository.save(bill); prePaidBillingRepository.save(bill);
} }
......
...@@ -160,6 +160,10 @@ public class PaymentServiceImpl implements PaymentService { ...@@ -160,6 +160,10 @@ public class PaymentServiceImpl implements PaymentService {
balance.setUsername(byTradeNo.getUsername()); balance.setUsername(byTradeNo.getUsername());
} }
PayBack payBack = payBackRepository.findByPay(byTradeNo.getAmount());
if (payBack == null)
payBack = new PayBack();
if (chargeType == 0) { if (chargeType == 0) {
UserPrePaidBilling bill = new UserPrePaidBilling(); UserPrePaidBilling bill = new UserPrePaidBilling();
Account account = accountRepository.findByName(byTradeNo.getUsername()); Account account = accountRepository.findByName(byTradeNo.getUsername());
...@@ -178,6 +182,7 @@ public class PaymentServiceImpl implements PaymentService { ...@@ -178,6 +182,7 @@ public class PaymentServiceImpl implements PaymentService {
bill.setStatus(BillStatus.PAID); bill.setStatus(BillStatus.PAID);
bill.setPrepaid(true); bill.setPrepaid(true);
bill.setTimestamp(Instant.now().toEpochMilli()); bill.setTimestamp(Instant.now().toEpochMilli());
bill.setBalanced(balance.getBalanced() + byTradeNo.getAmount() + payBack.getBack());
final YearMonth lastmonth = YearMonth.now(); final YearMonth lastmonth = YearMonth.now();
...@@ -189,9 +194,6 @@ public class PaymentServiceImpl implements PaymentService { ...@@ -189,9 +194,6 @@ public class PaymentServiceImpl implements PaymentService {
userPrePaidBillingRepository.save(bill); userPrePaidBillingRepository.save(bill);
} }
PayBack payBack = payBackRepository.findByPay(byTradeNo.getAmount());
if (payBack == null)
payBack = new PayBack();
balance.setBalanced(balance.getBalanced() + byTradeNo.getAmount() + payBack.getBack()); balance.setBalanced(balance.getBalanced() + byTradeNo.getAmount() + payBack.getBack());
userBalanceRepository.save(balance); userBalanceRepository.save(balance);
} }
...@@ -274,6 +276,10 @@ public class PaymentServiceImpl implements PaymentService { ...@@ -274,6 +276,10 @@ public class PaymentServiceImpl implements PaymentService {
balance.setUsername(byTradeNo.getUsername()); balance.setUsername(byTradeNo.getUsername());
} }
PayBack payBack = payBackRepository.findByPay(byTradeNo.getAmount());
if (payBack == null)
payBack = new PayBack();
if (chargeType == 0) { if (chargeType == 0) {
UserPrePaidBilling bill = new UserPrePaidBilling(); UserPrePaidBilling bill = new UserPrePaidBilling();
Account account = accountRepository.findByName(byTradeNo.getUsername()); Account account = accountRepository.findByName(byTradeNo.getUsername());
...@@ -292,6 +298,7 @@ public class PaymentServiceImpl implements PaymentService { ...@@ -292,6 +298,7 @@ public class PaymentServiceImpl implements PaymentService {
bill.setStatus(BillStatus.PAID); bill.setStatus(BillStatus.PAID);
bill.setPrepaid(true); bill.setPrepaid(true);
bill.setTimestamp(Instant.now().toEpochMilli()); bill.setTimestamp(Instant.now().toEpochMilli());
bill.setBalanced(balance.getBalanced() + byTradeNo.getAmount() + payBack.getBack());
final YearMonth lastmonth = YearMonth.now(); final YearMonth lastmonth = YearMonth.now();
...@@ -301,9 +308,6 @@ public class PaymentServiceImpl implements PaymentService { ...@@ -301,9 +308,6 @@ public class PaymentServiceImpl implements PaymentService {
bill.setMonth(monthValue); bill.setMonth(monthValue);
} }
PayBack payBack = payBackRepository.findByPay(byTradeNo.getAmount());
if (payBack == null)
payBack = new PayBack();
balance.setBalanced(balance.getBalanced() + byTradeNo.getAmount() + payBack.getBack()); balance.setBalanced(balance.getBalanced() + byTradeNo.getAmount() + payBack.getBack());
userBalanceRepository.save(balance); userBalanceRepository.save(balance);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment