Commit b0e8a610 authored by renjie's avatar renjie

支付返送保护

parent 01ab2121
...@@ -157,6 +157,17 @@ ...@@ -157,6 +157,17 @@
<artifactId>shedlock-spring</artifactId> <artifactId>shedlock-spring</artifactId>
<version>2.1.0</version> <version>2.1.0</version>
</dependency> </dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.16</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.16</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
...@@ -271,6 +271,18 @@ public class PaymentServiceImpl implements PaymentService { ...@@ -271,6 +271,18 @@ public class PaymentServiceImpl implements PaymentService {
bill.setYear(year); bill.setYear(year);
bill.setMonth(monthValue); bill.setMonth(monthValue);
if (more != 20 || more != 45 || more != 125 || more != 300)
more = 0;
if ((more == 20 && byTradeNo.getAmount() != 100) || (more != 20 && byTradeNo.getAmount() == 100))
more = 0;
if ((more == 45 && byTradeNo.getAmount() != 200) || (more != 45 && byTradeNo.getAmount() == 200))
more = 0;
if ((more == 125 && byTradeNo.getAmount() != 500) || (more != 125 && byTradeNo.getAmount() == 500))
more = 0;
if ((more == 300 && byTradeNo.getAmount() != 1000) || (more != 300 && byTradeNo.getAmount() == 1000))
more = 0;
balance.setBalanced(balance.getBalanced() + byTradeNo.getAmount() + more); balance.setBalanced(balance.getBalanced() + byTradeNo.getAmount() + more);
userBalanceRepository.save(balance); userBalanceRepository.save(balance);
} }
......
...@@ -16,7 +16,9 @@ import com.edgec.browserbackend.browser.repository.ShopRepository; ...@@ -16,7 +16,9 @@ import com.edgec.browserbackend.browser.repository.ShopRepository;
import com.edgec.browserbackend.browser.repository.UserShopRepository; import com.edgec.browserbackend.browser.repository.UserShopRepository;
import com.edgec.browserbackend.browser.service.ShopService; import com.edgec.browserbackend.browser.service.ShopService;
import com.edgec.browserbackend.common.commons.error.ClientRequestException; import com.edgec.browserbackend.common.commons.error.ClientRequestException;
import com.edgec.browserbackend.common.utils.FileUtil;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Workbook;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -97,6 +99,8 @@ public class ShopServiceImpl implements ShopService { ...@@ -97,6 +99,8 @@ public class ShopServiceImpl implements ShopService {
@Override @Override
public List<String> addShops(String username, List<Shop> shops) { public List<String> addShops(String username, List<Shop> shops) {
Workbook workbook = FileUtil.readExcel("");
return null; return null;
} }
...@@ -234,7 +238,7 @@ public class ShopServiceImpl implements ShopService { ...@@ -234,7 +238,7 @@ public class ShopServiceImpl implements ShopService {
} }
UserShop userShop = userShopRepository.findByUsernameAndShopId(username, shopId); UserShop userShop = userShopRepository.findByUsernameAndShopId(username, shopId);
Group group = groupRepository.findById(groupId).orElse(null); Group group = groupRepository.findById(groupId).orElse(null);
if (account.getPermission() < 4 || userShop == null || !group.getOwner().equals(username)) { if (userShop == null || !group.getOwner().equals(username)) {
throw new ClientRequestException(AccountErrorCode.NOPERMISSION); throw new ClientRequestException(AccountErrorCode.NOPERMISSION);
} }
Shop shop = shopRepository.findById(shopId).orElse(null); Shop shop = shopRepository.findById(shopId).orElse(null);
......
package com.edgec.browserbackend.common.utils; package com.edgec.browserbackend.common.utils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.DateUtil;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -61,4 +66,65 @@ public class FileUtil { ...@@ -61,4 +66,65 @@ public class FileUtil {
log.debug("[" + file.getName() + "]文件写入成功"); log.debug("[" + file.getName() + "]文件写入成功");
return true; return true;
} }
//读取excel
public static Workbook readExcel(String filePath){
Workbook wb = null;
if(filePath==null){
return null;
}
String extString = filePath.substring(filePath.lastIndexOf("."));
InputStream is = null;
try {
is = new FileInputStream(filePath);
if(".xls".equals(extString)){
return wb = new HSSFWorkbook(is);
}else if(".xlsx".equals(extString)){
return wb = new XSSFWorkbook(is);
}else{
return wb = null;
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return wb;
}
public static Object getCellFormatValue(Cell cell){
Object cellValue = null;
if(cell!=null){
//判断cell类型
switch(cell.getCellType()){
case Cell.CELL_TYPE_NUMERIC:{
cellValue = String.valueOf(cell.getNumericCellValue());
break;
}
case Cell.CELL_TYPE_FORMULA:{
//判断cell是否为日期格式
if(DateUtil.isCellDateFormatted(cell)){
//转换为日期格式YYYY-mm-dd
cellValue = cell.getDateCellValue();
}else{
//数字
cellValue = String.valueOf(cell.getNumericCellValue());
}
break;
}
case Cell.CELL_TYPE_STRING:{
cellValue = cell.getRichStringCellValue().getString();
break;
}
default:
cellValue = "";
}
}else{
cellValue = "";
}
return cellValue;
}
} }
...@@ -25,6 +25,12 @@ spring: ...@@ -25,6 +25,12 @@ spring:
enable: true enable: true
resources: resources:
static-locations: classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/ static-locations: classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/
http:
servlet:
multipart:
max-file-size: 50MB
max-request-size: 50MB
security: security:
......
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