Commit 168395c9 authored by renjie's avatar renjie

本地ip bug

parent 02f88ce8
...@@ -45,7 +45,7 @@ public class UserPrePaidBilling { ...@@ -45,7 +45,7 @@ public class UserPrePaidBilling {
private String user; private String user;
private float total; private float total;
//0 -- 充值, 1 -- newip, 2 --renew, 3 --ipkeptfee, 4 --deleteip, //0 -- 充值, 1 -- newip, 2 -- renew, 3 -- return
private int chargeType; private int chargeType;
private String unit = "month"; private String unit = "month";
...@@ -193,4 +193,12 @@ public class UserPrePaidBilling { ...@@ -193,4 +193,12 @@ public class UserPrePaidBilling {
public void setPayMethod(int payMethod) { public void setPayMethod(int payMethod) {
this.payMethod = payMethod; this.payMethod = payMethod;
} }
public String getTradeNo() {
return tradeNo;
}
public void setTradeNo(String tradeNo) {
this.tradeNo = tradeNo;
}
} }
package com.edgec.browserbackend.account.dto;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@JsonIgnoreProperties(ignoreUnknown = true)
public class UserPrePaidBillingRequestDto {
private int day;
private int page;
private int amount;
// 0 -- 全部, 1 -- 充值, 2 -- 余额扣费, 3 -- 微信扣费, 4 -- 支付宝扣费
private int tradeType;
public int getDay() {
return day;
}
public void setDay(int day) {
this.day = day;
}
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
public int getAmount() {
return amount;
}
public void setAmount(int amount) {
this.amount = amount;
}
public int getTradeType() {
return tradeType;
}
public void setTradeType(int tradeType) {
this.tradeType = tradeType;
}
}
...@@ -24,4 +24,6 @@ public interface UserPrePaidBillingRepository extends MongoRepository<UserPrePai ...@@ -24,4 +24,6 @@ public interface UserPrePaidBillingRepository extends MongoRepository<UserPrePai
List<UserPrePaidBilling> findByStatus(BillStatus status); List<UserPrePaidBilling> findByStatus(BillStatus status);
Page<UserPrePaidBilling> findByUsernameAndTimestampGreaterThanOrderByTimestamp(String username, long time, Pageable pageable);
} }
...@@ -66,6 +66,8 @@ public interface AccountService { ...@@ -66,6 +66,8 @@ public interface AccountService {
List<UserBillList> getUserBills(String name, Services services); List<UserBillList> getUserBills(String name, Services services);
Page<UserPrePaidBilling> getUserPrePaidBills(String name, UserPrePaidBillingRequestDto userPrePaidBillingRequestDto);
void resetPasswordWithOtp(UserDto user); void resetPasswordWithOtp(UserDto user);
IpChargeResultDto preChargeByMoney(String name, double money); IpChargeResultDto preChargeByMoney(String name, double money);
......
...@@ -8,6 +8,7 @@ import com.edgec.browserbackend.account.domain.*; ...@@ -8,6 +8,7 @@ import com.edgec.browserbackend.account.domain.*;
import com.edgec.browserbackend.account.exception.AccountErrorCode; import com.edgec.browserbackend.account.exception.AccountErrorCode;
import com.edgec.browserbackend.account.repository.*; import com.edgec.browserbackend.account.repository.*;
import com.edgec.browserbackend.account.service.EmailService; import com.edgec.browserbackend.account.service.EmailService;
import com.edgec.browserbackend.account.service.SmsUtils;
import com.edgec.browserbackend.account.utils.AccountServicePool; import com.edgec.browserbackend.account.utils.AccountServicePool;
import com.edgec.browserbackend.auth.exception.AuthErrorCode; import com.edgec.browserbackend.auth.exception.AuthErrorCode;
import com.edgec.browserbackend.auth.repository.UserRepository; import com.edgec.browserbackend.auth.repository.UserRepository;
...@@ -35,6 +36,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -35,6 +36,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.thymeleaf.util.StringUtils; import org.thymeleaf.util.StringUtils;
import java.text.SimpleDateFormat;
import java.time.Instant; import java.time.Instant;
import java.time.YearMonth; import java.time.YearMonth;
import java.time.ZoneOffset; import java.time.ZoneOffset;
...@@ -140,6 +142,28 @@ public class AccountServiceImpl implements AccountService { ...@@ -140,6 +142,28 @@ public class AccountServiceImpl implements AccountService {
return result; return result;
} }
@Override
public Page<UserPrePaidBilling> getUserPrePaidBills(String name, UserPrePaidBillingRequestDto userPrePaidBillingRequestDto) {
if (userPrePaidBillingRequestDto.getAmount() > 100)
userPrePaidBillingRequestDto.setAmount(100);
Pageable pageable = PageRequest.of(userPrePaidBillingRequestDto.getPage(), userPrePaidBillingRequestDto.getAmount());
long time = Instant.now().atZone(ZoneOffset.UTC).minusDays(userPrePaidBillingRequestDto.getDay()).toInstant().toEpochMilli();
Page<UserPrePaidBilling> userPrePaidBillings;
switch (userPrePaidBillingRequestDto.getTradeType()) {
case 0:
userPrePaidBillings = prePaidBillingRepository.findByUsernameAndTimestampGreaterThanOrderByTimestamp(name, time, pageable);
break;
case 1:
default:
userPrePaidBillings = prePaidBillingRepository.findByUsernameAndTimestampGreaterThanOrderByTimestamp(name, time, pageable);
break;
}
return userPrePaidBillings;
}
@Override @Override
public IpChargeResultDto chargeByMoney(String name, double money, IpChargeRequestDto requestDto) { public IpChargeResultDto chargeByMoney(String name, double money, IpChargeRequestDto requestDto) {
IpChargeResultDto charge = new IpChargeResultDto(); IpChargeResultDto charge = new IpChargeResultDto();
...@@ -165,6 +189,7 @@ public class AccountServiceImpl implements AccountService { ...@@ -165,6 +189,7 @@ public class AccountServiceImpl implements AccountService {
charge.setSuccess(true); charge.setSuccess(true);
UserPrePaidBilling bill = new UserPrePaidBilling(); UserPrePaidBilling bill = new UserPrePaidBilling();
bill.setTradeNo(new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())+ SmsUtils.createRandom(true, 4));
bill.setChargeType(requestDto.getChargeType()); bill.setChargeType(requestDto.getChargeType());
bill.setAmount(requestDto.getAmount()); bill.setAmount(requestDto.getAmount());
bill.setUnit(requestDto.getUnit()); bill.setUnit(requestDto.getUnit());
......
...@@ -30,8 +30,10 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -30,8 +30,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.time.Instant; import java.time.Instant;
import java.time.YearMonth; import java.time.YearMonth;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
...@@ -154,6 +156,7 @@ public class PaymentServiceImpl implements PaymentService { ...@@ -154,6 +156,7 @@ public class PaymentServiceImpl implements PaymentService {
if (chargeType == 0) { if (chargeType == 0) {
UserPrePaidBilling bill = new UserPrePaidBilling(); UserPrePaidBilling bill = new UserPrePaidBilling();
bill.setTradeNo(new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())+ SmsUtils.createRandom(true, 4));
bill.setChargeType(0); bill.setChargeType(0);
bill.setAmount(0); bill.setAmount(0);
bill.setUnit(null); bill.setUnit(null);
...@@ -262,6 +265,7 @@ public class PaymentServiceImpl implements PaymentService { ...@@ -262,6 +265,7 @@ public class PaymentServiceImpl implements PaymentService {
if (chargeType == 0) { if (chargeType == 0) {
UserPrePaidBilling bill = new UserPrePaidBilling(); UserPrePaidBilling bill = new UserPrePaidBilling();
bill.setTradeNo(new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())+ SmsUtils.createRandom(true, 4));
bill.setChargeType(0); bill.setChargeType(0);
bill.setAmount(0); bill.setAmount(0);
bill.setUnit(null); bill.setUnit(null);
......
...@@ -571,9 +571,11 @@ public class IpResourceServiceImpl implements IpResourceService { ...@@ -571,9 +571,11 @@ public class IpResourceServiceImpl implements IpResourceService {
} }
if (StringUtils.isNotBlank(x.getAddr())) { if (StringUtils.isNotBlank(x.getAddr())) {
if (x.getValidTime() <= Instant.now().plusSeconds(60*60*24*7).toEpochMilli() && x.getValidTime() >Instant.now().toEpochMilli()) { if (x.getValidTime() <= Instant.now().plusSeconds(60*60*24*7).toEpochMilli() && x.getValidTime() >Instant.now().toEpochMilli()) {
if (x.getStatus() != 5) {
x.setStatus(2); x.setStatus(2);
ipResourceRepository.save(x); ipResourceRepository.save(x);
} }
}
else if (x.getValidTime() <= Instant.now().minusSeconds(60*60*24*7).toEpochMilli()) { else if (x.getValidTime() <= Instant.now().minusSeconds(60*60*24*7).toEpochMilli()) {
if (x.getIpType() == IpType.VENDOR) { if (x.getIpType() == IpType.VENDOR) {
IpResourceRequestDto ipResourceRequestDto = new IpResourceRequestDto(); IpResourceRequestDto ipResourceRequestDto = new IpResourceRequestDto();
...@@ -591,7 +593,7 @@ public class IpResourceServiceImpl implements IpResourceService { ...@@ -591,7 +593,7 @@ public class IpResourceServiceImpl implements IpResourceService {
ipResourceRepository.save(x); ipResourceRepository.save(x);
} }
else { else {
if (x.getStatus() != 4 && x.getStatus() != 5) { if (x.getStatus() == 0 && x.getStatus() == 1 && x.getStatus() == 2) {
x.setStatus(0); x.setStatus(0);
ipResourceRepository.save(x); ipResourceRepository.save(x);
} }
......
...@@ -4,8 +4,6 @@ package com.edgec.browserbackend.common.charge; ...@@ -4,8 +4,6 @@ package com.edgec.browserbackend.common.charge;
public interface ChargeType { public interface ChargeType {
//0 -- 充值, 1 -- newip, 2 --renew, 3 --ipkeptfee, 4 --deleteip,
int payment = 0; // 充值 int payment = 0; // 充值
int newip = 1; // 购买vps, ip int newip = 1; // 购买vps, ip
int renew = 2; // 续费ip int renew = 2; // 续费ip
......
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