Commit 88973940 authored by Administrator's avatar Administrator

Merge branch 'staging' into 'master'

Staging

See merge request !179
parents 6c09e200 b5409c9a
......@@ -101,7 +101,7 @@ public class AdministratorController {
public HashMap bankTransferInsert(@RequestBody UserBalance userBalance) {
HashMap<String, Object> map = new HashMap<>();
try {
map.put("userbalance", paymentService.bankTransferInsertion(userBalance.getUsername(), (int) userBalance.getBalanced()));
map.put("userbalance", paymentService.bankTransferInsertion(userBalance.getUsername(), (int) userBalance.getBalanced(), 3));
map.put("status", "success");
} catch (Exception e) {
map.put("status", "failed");
......
......@@ -42,6 +42,8 @@ public class AccountDto {
private List<String> whiteList = new ArrayList<>();
private List<String> userWhiteList = new ArrayList<>();
private ShopSummary shopSummary;
private IpSummary ipSummary;
......@@ -69,6 +71,7 @@ public class AccountDto {
this.setToken(account.getToken());
this.setPermission(account.getPermission());
this.setWhiteList(account.getWhiteList());
this.setUserWhiteList(account.getWhiteList());
this.setQueryIpUrlList(account.getQueryIpUrlList());
if (account.getPromotion() != null) {
this.setPromotion(account.getPromotion());
......@@ -256,4 +259,12 @@ public class AccountDto {
public void setPromotionCode(String promotionCode) {
this.promotionCode = promotionCode;
}
public List<String> getUserWhiteList() {
return userWhiteList;
}
public void setUserWhiteList(List<String> userWhiteList) {
this.userWhiteList = userWhiteList;
}
}
......@@ -41,7 +41,7 @@ public class UserPrePaidBilling {
private BillStatus status;
/**
* 0 -- 余额, 1 -- 支付宝, 2 -- 微信, 3 -- 银行转账
* 0 -- 余额, 1 -- 支付宝, 2 -- 微信, 3 -- 银行转账, 4--注册时赠送
*/
private int payMethod;
......
......@@ -18,7 +18,7 @@ public interface PaymentService {
void alipaCallback(String tradno);
UserBalance bankTransferInsertion(String username, int amount);
UserBalance bankTransferInsertion(String username, int amount, int payMethod);
UserPaymentDto h5wxPayOrder(String ip, String username, int amount);
......
......@@ -477,7 +477,7 @@ public class AccountServiceImpl implements AccountService {
list.add("184");
list.add("170");
if (!StringUtils.isEmpty(account.getPhoneNumber()) && !list.contains(account.getPhoneNumber().substring(0, 3)) && inviter != null) {
paymentService.bankTransferInsertion(account.getName(), globalFieldRepository.findAll().get(0).getRegisterGift());
paymentService.bankTransferInsertion(account.getName(), globalFieldRepository.findAll().get(0).getRegisterGift(), 4);
}
log.info("new account has been created: " + account.getName());
......
......@@ -310,7 +310,7 @@ public class PaymentServiceImpl implements PaymentService {
}
@Override
public UserBalance bankTransferInsertion(String username, int amount) {
public UserBalance bankTransferInsertion(String username, int amount, int payMethod) {
UserPayment bankOrder = new UserPayment();
bankOrder.setUsername(username);
......@@ -332,7 +332,7 @@ public class PaymentServiceImpl implements PaymentService {
bill.setAmount(0);
bill.setUnit(null);
bill.setPeriod(0);
bill.setPayMethod(3);
bill.setPayMethod(payMethod);
bill.setUsername(username);
bill.setTotal((float) amount);
bill.setStatus(BillStatus.PAID);
......
......@@ -3,7 +3,10 @@ package com.edgec.browserbackend.browser.controller;
import com.alibaba.fastjson.JSONObject;
import com.edgec.browserbackend.account.dto.ResultDto;
import com.edgec.browserbackend.browser.ErrorCode.BrowserErrorCode;
import com.edgec.browserbackend.browser.dto.*;
import com.edgec.browserbackend.browser.dto.ShopPageResultDto;
import com.edgec.browserbackend.browser.dto.ShopRequestDto;
import com.edgec.browserbackend.browser.dto.ShopResultDto;
import com.edgec.browserbackend.browser.dto.ShopStringResultDto;
import com.edgec.browserbackend.browser.service.IpAndShopService;
import com.edgec.browserbackend.browser.service.ShopService;
import com.edgec.browserbackend.common.commons.error.ClientRequestException;
......@@ -275,52 +278,6 @@ public class ShopController {
}
/**
* 店铺收藏夹
*//*
@GetMapping("/favorites/{shopId}")
public ResultDto getFavoritesByShopId(Principal principal, @PathVariable("shopId") String shopId) {
ResultDto resultDto = new ResultDto();
try {
List<FavoriteUrl> list = shopService.getFavoritesByShopId(principal.getName(), shopId);
resultDto.setData(list);
resultDto.setStatus(0);
} catch (ClientRequestException e) {
dealClientRequestException(resultDto, e);
}
return resultDto;
}
*//**
* 店铺收藏夹 删除收藏
*//*
@DeleteMapping("/favorites/{shopId}")
public ResultDto deleteFavoritesByShopId(Principal principal, @PathVariable("shopId") String shopId, @RequestBody FavoriteUrl favoriteUrl) {
ResultDto resultDto = new ResultDto();
try {
resultDto.setData(shopService.deleteFavoritesByShopId(principal.getName(), shopId, favoriteUrl));
resultDto.setStatus(0);
} catch (ClientRequestException e) {
dealClientRequestException(resultDto, e);
}
return resultDto;
}
*//**
* 店铺收藏夹 新增收藏
*//*
@PostMapping("/favorites/{shopId}")
public ResultDto saveFavoritesByShopId(Principal principal, @PathVariable("shopId") String shopId, @RequestBody FavoriteUrl favoriteUrl) {
ResultDto resultDto = new ResultDto();
try {
resultDto.setData(shopService.saveFavoritesByShopId(principal.getName(), shopId, favoriteUrl));
resultDto.setStatus(0);
} catch (ClientRequestException e) {
dealClientRequestException(resultDto, e);
}
return resultDto;
}*/
private void dealClientRequestException(ResultDto resultDto, ClientRequestException e) {
resultDto.setStatus(-1);
Map<String, Object> statusInfo = new HashMap<>();
......
......@@ -146,6 +146,11 @@ public class IpResource implements Serializable {
*/
private int period;
/**
* KCP端口号
*/
private int secondaryProxyPort = -1;
@Override
public boolean equals(Object o) {
if (this == o) {
......
package com.edgec.browserbackend.browser.domain;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import java.util.List;
/**
* @author xuxin
* @date 2020/9/25 14:54
* @description
*/
@Document(collection = "shopua")
public class ShopUA {
@Id
private String id;
private String platform;
private List<String> uaList;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getPlatform() {
return platform;
}
public void setPlatform(String platform) {
this.platform = platform;
}
public List<String> getUaList() {
return uaList;
}
public void setUaList(List<String> uaList) {
this.uaList = uaList;
}
}
......@@ -35,6 +35,8 @@ public class IpResourceDto {
private String specialLineIp;
private int secondaryProxyPort = -1;
public IpResourceDto() {
}
......@@ -52,6 +54,7 @@ public class IpResourceDto {
this.password = ipResource.getPassword();
this.protocol = ipResource.getProtocol();
this.specialLine = ipResource.isSpecialLine();
this.secondaryProxyPort = ipResource.getSecondaryProxyPort();
if (CollectionUtils.isNotEmpty(shopDtos)) {
this.bindShops = shopDtos;
this.bindShop = shopDtos.get(0);
......@@ -63,7 +66,6 @@ public class IpResourceDto {
this.bindHistories = ipResource.getBindHistory();
else
this.bindHistories = new ArrayList<>();
}
public IpResourceDto(IpResource ipResource, List<ShopDto> shopDtos, boolean useHistory, SpecialLine specialLine1) {
......@@ -84,6 +86,7 @@ public class IpResourceDto {
this.proxyPort = specialLine1.getProxyPort();
this.proxyProtocol = specialLine1.getProxyProtocol();
this.specialLine = ipResource.isSpecialLine();
this.secondaryProxyPort = ipResource.getSecondaryProxyPort();
if (CollectionUtils.isNotEmpty(shopDtos)) {
this.bindShops = shopDtos;
this.bindShop = shopDtos.get(0);
......@@ -265,4 +268,12 @@ public class IpResourceDto {
public void setBindShop(ShopDto bindShop) {
this.bindShop = bindShop;
}
public int getSecondaryProxyPort() {
return secondaryProxyPort;
}
public void setSecondaryProxyPort(int secondaryProxyPort) {
this.secondaryProxyPort = secondaryProxyPort;
}
}
......@@ -9,4 +9,6 @@ import com.edgec.browserbackend.browser.domain.WinHistory;
*/
public interface BrowserWinLogRepositoryCustom {
void addWinLog(String username, WinHistory winHistory);
void deleteBeforeWinLog(String username, int daysBefore);
}
......@@ -6,8 +6,13 @@ import org.bson.Document;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.BasicQuery;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import static org.springframework.data.mongodb.core.query.Criteria.where;
/**
......@@ -26,8 +31,18 @@ public class BrowserWinLogRepositoryCustomImpl implements BrowserWinLogRepositor
basicQuery.addCriteria(where("_id").is(username));
Update update = new Update();
update.set("_id", username);
update.push("list", winHistory);
update.addToSet("list", winHistory);
mongoTemplate.upsert(basicQuery, update, BrowserWinLog.class);
}
@Override
public void deleteBeforeWinLog(String username, int daysBefore) {
Document doc = new Document();
BasicQuery basicQuery = new BasicQuery(doc);
basicQuery.addCriteria(where("_id").is(username));
Update update = new Update();
update.pull("list", Query.query(Criteria.where("time").lte(Instant.now().minus(daysBefore, ChronoUnit.DAYS).toEpochMilli())));
mongoTemplate.upsert(basicQuery, update, BrowserWinLog.class);
}
}
package com.edgec.browserbackend.browser.repository;
import com.edgec.browserbackend.browser.domain.ShopUA;
import org.springframework.data.mongodb.repository.MongoRepository;
/**
* @author xuxin
* @date 2020/9/25 14:56
* @description
*/
public interface ShopUARepository extends MongoRepository<ShopUA, String> {
}
......@@ -148,6 +148,7 @@ public class HistoryServiceImpl implements HistoryService {
@Override
public void addBrowserWinLog(String username, WinHistory winHistory) {
browserWinLogRepository.deleteBeforeWinLog(username, 1);
browserWinLogRepository.addWinLog(username, winHistory);
}
}
......@@ -639,6 +639,9 @@ public class IpResourceServiceImpl implements IpResourceService {
return ipOperationResultDto;
}
/**********************************************************************************
* todo - D E V E L O P M E N T *
**********************************************************************************/
@Override
public IpPageResultDto getIpList(String username, int groupType, int page, int amount, IpFilterDto ipFilterDto) {
// 获取当前用户的账户
......@@ -823,15 +826,19 @@ public class IpResourceServiceImpl implements IpResourceService {
return false;
}
/**********************************************************************************
* todo - D E V E L O P M E N T *
**********************************************************************************/
@Override
public IpResourceDto queryIp(String username, IpResourceRequestDto ipResourceRequestDto) {
Account account = accountRepository.findByName(username).orElseThrow(() -> new ClientRequestException(AccountErrorCode.NAMENOTEXIST));
IpResource ipResource = null;
if (ipResourceRequestDto.getAddr() != null && ipResourceRequestDto.getAddr().size() > 0)
ipResource = ipResourceRepository.findByAddrAndIsDeleted(ipResourceRequestDto.getAddr().get(0), false);
else if (ipResourceRequestDto.getIpId() != null && ipResourceRequestDto.getIpId().size() > 0)
ipResource = ipResourceRepository.findByIdAndIsDeleted(ipResourceRequestDto.getIpId().get(0), false);
else {
else if (ipResourceRequestDto.getIpId() != null && ipResourceRequestDto.getIpId().size() > 0) {
String s = ipResourceRequestDto.getIpId().get(0);
ipResource = ipResourceRepository.findByIdAndIsDeleted(s, false);
} else {
throw new ClientRequestException(BrowserErrorCode.INFORMATIONNOTCOMPELETE);
}
......
......@@ -59,6 +59,9 @@ public class ShopServiceImpl implements ShopService {
@Autowired
SpecialLineRepository specialLineRepository;
@Autowired
ShopUARepository shopUARepository;
@Override
public String addShop(String username, ShopResultDto shopResultDto) {
// 1. 对商铺的分组信息校验
......@@ -705,6 +708,17 @@ public class ShopServiceImpl implements ShopService {
shopResultDto.setOwner(username);
shop.of(shopResultDto);
shop.setCreateTime(Instant.now().toEpochMilli());
List<ShopUA> all = shopUARepository.findAll();
List<String> uaList = new ArrayList<>();
for (ShopUA shopUA : all) {
uaList.addAll(shopUA.getUaList());
}
if (!uaList.contains(shop.getShopUA())) {
Random random = new Random();
shop.setShopUA(uaList.get(random.nextInt(uaList.size())));
}
String id = shopRepository.save(shop).getShopId();
return id;
}
......
......@@ -88,7 +88,7 @@ public class VpsServiceImpl implements VpsService {
"use redirection server name:i:0\n" +
"rdgiskdcproxy:i:0\n" +
"kdcproxyname:s:\n" +
"drivestoredirect:s:C:\\:s:D:\\\n" +
"drivestoredirect:s:C:\\;D:\\\n" +
"username:s:#VPS_USER#\n" +
"password 51:b:#VPS_PASSWORD#\n";
......
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