Commit 34530148 authored by renjie's avatar renjie

admin接口

推广礼金提现
parent 7e4e6398
......@@ -412,7 +412,6 @@ public class AccountController {
@RequestParam(value = "coporationPlace") String coporationPlace,
@RequestParam(value = "coporationLicense_front") MultipartFile coporationLicense_front,
@RequestParam(value = "coporationLicense_back") MultipartFile coporationLicense_back,
@RequestParam(value = "realController", defaultValue = "0") int realController,
@RequestParam(value = "writePerson", defaultValue = "0") int writePerson,
@RequestParam(value = "agency_front", required = false) MultipartFile agency_front,
@RequestParam(value = "agency_back", required = false) MultipartFile agency_back) {
......@@ -453,7 +452,7 @@ public class AccountController {
@RequestMapping(path = "/ali/login", method = RequestMethod.GET)
public String save(HttpServletRequest request,HttpServletResponse response) {
//页面回调地址 必须与应用中的设置一样
String return_url = "http://localhost:1729/alipay/withdraw";
String return_url = "http://https://www.fangguanlian.cn/ali/withdraw";
//回调地址必须经encode
return_url = java.net.URLEncoder.encode(return_url);
//重定向到授权页面
......@@ -461,25 +460,41 @@ public class AccountController {
return "redirect:"+ VpsAlipayConfig.ALIPAY_AUTH_URL + "?app_id=" + alipayConfig.getAPPID() + "&scope=auth_user&redirect_uri=" + return_url;
}
@RequestMapping(path = "/ali/withdraw")
public void alipayWithdraw(HttpServletRequest request, HttpServletResponse response) {
//获取支付宝GET过来反馈信息
Map<String,String> params = new HashMap<String,String>();
Map requestParams = request.getParameterMap();
for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext();) {
String name = (String) iter.next();
String[] values = (String[]) requestParams.get(name);
String valueStr = "";
for (int i = 0; i < values.length; i++) {
valueStr = (i == (values.length-1)) ? valueStr + values[i]:valueStr + values[i] + ",";
}
params.put(name, valueStr);
}
@RequestMapping(path = "/ali/withdraw", method = RequestMethod.PUT)
public ResultDto alipayWithdraw(Principal principal, @RequestParam("account") String account, @RequestParam("realName") String realName, @RequestParam("amount") int amount) {
// //获取支付宝GET过来反馈信息
// Map<String,String> params = new HashMap<String,String>();
// Map requestParams = request.getParameterMap();
// for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext();) {
// String name = (String) iter.next();
// String[] values = (String[]) requestParams.get(name);
// String valueStr = "";
// for (int i = 0; i < values.length; i++) {
// valueStr = (i == (values.length-1)) ? valueStr + values[i]:valueStr + values[i] + ",";
// }
// params.put(name, valueStr);
// }
//
// String accessToken= AlipaySubmit.buildRequest(params);
// if(accessToken!=null && accessToken!=""){
// String uid = AlipaySubmit.get(accessToken);
// logger.error(uid);
// paymentService.alipayWithdraw(request.getUserPrincipal().getName(), uid, )
// }
String accessToken= AlipaySubmit.buildRequest(params);
if(accessToken!=null && accessToken!=""){
String imf = AlipaySubmit.get(accessToken);
System.out.println(imf);
ResultDto resultDto = new ResultDto();
try {
if (paymentService.alipayWithdraw(principal.getName(), account, realName, amount))
resultDto.setStatus(0);
else
resultDto.setStatus(-1);
} catch (ClientRequestException e) {
resultDto.setStatus(-1);
Map<String, Object> statusInfo = new HashMap<>();
statusInfo.put("code", e.getErrorCode());
statusInfo.put("message", e.getMessage());
resultDto.setStatusInfo(statusInfo);
}
return resultDto;
}
}
......@@ -114,7 +114,7 @@ public class AdministratorController {
@PreAuthorize("hasRole('ADMIN')")
@RequestMapping(path ="/0xadministrator/searchuserbill/{name}",method = RequestMethod.GET)
public BillQueryResultDto getUserBillByName(@PathVariable String name, @RequestParam("page") int page, @RequestParam("size") int size){
return administratorService.getUserBillingByName(name, page, size);
return administratorService.getUserBillingByName(name);
}
......@@ -181,9 +181,9 @@ public class AdministratorController {
//查询某时段内增加的用户
@PreAuthorize("hasRole('ADMIN')")
@RequestMapping(path ="/0xadministrator/searchperioduser",method = RequestMethod.GET)
public Page<Account> searchCreateAccount(@RequestParam(value="page") int page, @RequestParam(value="size") int size, @RequestParam(value="strDate1") String strDate1, @RequestParam(value="strDate2") String strDate2 ){
public Page<Account> searchCreateAccount(@RequestParam(value="page") int page, @RequestParam(value="size") int size, @RequestParam(value="strDate1") String strDate1, @RequestParam(value="strDate2") String strDate2, @RequestParam("isAuthorized") boolean isAuthorized ){
Pageable pageable = PageRequest.of(page, size);
return administratorService.searchCreateAccountBetween(pageable,strDate1,strDate2);
return administratorService.searchCreateAccountBetween(pageable,strDate1,strDate2,isAuthorized);
}
//search company earnings detail by month tested
......@@ -332,7 +332,7 @@ public class AdministratorController {
return resultDto;
}
//获取用户企业认证的信息
//添加推广码
@PreAuthorize(Securitys.ADMIN_EL)
@RequestMapping(path = "/0xadministrator/promotioncode/add", method = RequestMethod.PUT)
public ResultDto addPromotionCode(Principal principal, @RequestParam("username") String username, @RequestParam("promotionCode") String promotionCode) {
......
package com.edgec.browserbackend.account.domain;
public class AliTransfer {
/**
* 逻辑单号
*/
private String out_biz_no;
/**
* 收款方账户类型
*/
private String payee_type;
/**
* 收款方支付宝账号
*/
private String payee_account;
/**
* 转账金额
*/
private String amount;
/**
* 转账名称
*/
private String payer_show_name;
/**
* 提现用户的真实姓名
*/
private String payee_real_name;
/**
* 转账备注
*/
private String remark;
public String getAmount() {
return amount;
}
public void setAmount(String amount) {
this.amount = amount;
}
public String getOut_biz_no() {
return out_biz_no;
}
public void setOut_biz_no(String out_biz_no) {
this.out_biz_no = out_biz_no;
}
public String getPayee_account() {
return payee_account;
}
public void setPayee_account(String payee_account) {
this.payee_account = payee_account;
}
public String getPayee_real_name() {
return payee_real_name;
}
public void setPayee_real_name(String payee_real_name) {
this.payee_real_name = payee_real_name;
}
public String getPayee_type() {
return payee_type;
}
public void setPayee_type(String payee_type) {
this.payee_type = payee_type;
}
public String getPayer_show_name() {
return payer_show_name;
}
public void setPayer_show_name(String payer_show_name) {
this.payer_show_name = payer_show_name;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
}
......@@ -19,6 +19,8 @@ public class Promotion {
private double gift;
//所有未提现金额
private double allGift;
//已提现金额
private double withdrawn;
public int getCommission() {
return commission;
......@@ -75,4 +77,12 @@ public class Promotion {
public void setAllGift(double allGift) {
this.allGift = allGift;
}
public double getWithdrawn() {
return withdrawn;
}
public void setWithdrawn(double withdrawn) {
this.withdrawn = withdrawn;
}
}
......@@ -37,7 +37,7 @@ public class UserPrePaidBilling {
private BillStatus status;
//0 -- 余额, 1 -- 支付宝, 2 -- 微信
//0 -- 余额, 1 -- 支付宝, 2 -- 微信, 3 -- 银行转账
private int payMethod;
private boolean isPrepaid;
......
......@@ -6,31 +6,77 @@ import org.springframework.data.domain.Page;
import java.util.List;
public class BillQueryResultDto {
Page<UserPrePaidBilling> userPrePaidBillingList;
double totalExpense;
double totalEarn;
double parentExpense;
double parentWithdrawn;
double parentBalanced;
double parentBankTransfer;
public double getTotalEarn() {
return totalEarn;
double childExpense;
double childWithdraw;
double childBalanced;
double childBankTransfer;
public double getParentExpense() {
return parentExpense;
}
public void setParentExpense(double parentExpense) {
this.parentExpense = parentExpense;
}
public double getParentWithdrawn() {
return parentWithdrawn;
}
public void setParentWithdrawn(double parentWithdrawn) {
this.parentWithdrawn = parentWithdrawn;
}
public double getParentBalanced() {
return parentBalanced;
}
public void setParentBalanced(double parentBalanced) {
this.parentBalanced = parentBalanced;
}
public double getParentBankTransfer() {
return parentBankTransfer;
}
public void setParentBankTransfer(double parentBankTransfer) {
this.parentBankTransfer = parentBankTransfer;
}
public double getChildBalanced() {
return childBalanced;
}
public void setChildBalanced(double childBalanced) {
this.childBalanced = childBalanced;
}
public double getChildBankTransfer() {
return childBankTransfer;
}
public void setTotalEarn(double totalEarn) {
this.totalEarn = totalEarn;
public void setChildBankTransfer(double childBankTransfer) {
this.childBankTransfer = childBankTransfer;
}
public double getTotalExpense() {
return totalExpense;
public double getChildExpense() {
return childExpense;
}
public void setTotalExpense(double totalExpense) {
this.totalExpense = totalExpense;
public void setChildExpense(double childExpense) {
this.childExpense = childExpense;
}
public Page<UserPrePaidBilling> getUserPrePaidBillingList() {
return userPrePaidBillingList;
public double getChildWithdraw() {
return childWithdraw;
}
public void setUserPrePaidBillingList(Page<UserPrePaidBilling> userPrePaidBillingList) {
this.userPrePaidBillingList = userPrePaidBillingList;
public void setChildWithdraw(double childWithdraw) {
this.childWithdraw = childWithdraw;
}
}
......@@ -31,6 +31,8 @@ public interface AccountRepository extends MongoRepository<Account, String>, Acc
Page<Account> findAllBySignupDateBetweenAndParentIsNull(Pageable pageable, Date startDate, Date endDate);
Page<Account> findAllBySignupDateBetweenAndParentIsNullAndAuthorizedNot(Pageable pageable, Date startDate, Date endDate, int authorized);
Page<Account> findAll(Pageable pageable);
List<Account> findByNameIn(List<String> names);
......
......@@ -27,6 +27,8 @@ public interface UserPrePaidBillingRepository extends MongoRepository<UserPrePai
List<UserPrePaidBilling> findByUsernameAndPayMethodIn(String username, List<Integer> payMethod);
List<UserPrePaidBilling> findByUsernameAndPayMethod(String username, int payMethod);
List<UserPrePaidBilling> findByUsernameAndChargeType(String username, int chargeType);
List<UserPrePaidBilling> findByYearAndMonth(int year, int month);
......
package com.edgec.browserbackend.account.repository;
import com.edgec.browserbackend.account.domain.UserWithdraw;
import org.springframework.data.mongodb.repository.MongoRepository;
public interface UserWithdrawRepository extends MongoRepository<UserWithdraw, String> {
}
......@@ -23,7 +23,7 @@ public interface AdministratorService {
Account getAccountByEmail(String target);
BillQueryResultDto getUserBillingByName(String name, int page, int size);
BillQueryResultDto getUserBillingByName(String name);
Account unLockLockedAccount(String name, Account account);
......@@ -33,7 +33,7 @@ public interface AdministratorService {
Page<UserPrePaidBilling> searchAllUserBillingPage(int page, int year1, int month1, int year2, int month2);
Page<Account> searchCreateAccountBetween(Pageable pageable, String strDate1, String strDate2);
Page<Account> searchCreateAccountBetween(Pageable pageable, String strDate1, String strDate2, boolean isAuthorized);
List<UserPrePaidBilling> getServiceFeeOwedUserInfo();
......
......@@ -22,6 +22,6 @@ public interface PaymentService {
UserPaymentDto h5wxPayOrder(String ip, String username, int amount);
boolean alipayWithdraw(String username, String account, String realName);
boolean alipayWithdraw(String username, String account, String realName, int amount);
}
......@@ -102,25 +102,55 @@ public class AdministratorServiceImpl implements AdministratorService {
@Override
public BillQueryResultDto getUserBillingByName(String name, int page, int size) {
if (size > 100)
size = 100;
Pageable pageable = PageRequest.of(page, size);
Page<UserPrePaidBilling> userBillingList = userPrePaidBillingRepository.findAllByUsername(name, pageable);
if (userBillingList == null)
throw new ClientRequestException(AccountErrorCode.NAMENOTEXIST, "Username does not exist: " + name);
public BillQueryResultDto getUserBillingByName(String name) {
Account account = accountRepository.findByName(name);
if (account == null)
throw new ClientRequestException(AccountErrorCode.NAMENOTEXIST);
List<UserPrePaidBilling> userPrePaidBillings = userPrePaidBillingRepository.findByUsernameAndPayMethodIn(name, Arrays.asList(1,2));
double totalexpense = 0;
double parentexpense = 0;
if (userPrePaidBillings != null)
totalexpense = userPrePaidBillings.stream().mapToDouble(UserPrePaidBilling::getTotal).sum();
List<UserPrePaidBilling> userPrePaidBillings1 = userPrePaidBillingRepository.findByUsernameAndChargeType(name, 4);
double totalearn = 0;
parentexpense = userPrePaidBillings.stream().mapToDouble(UserPrePaidBilling::getTotal).sum();
double parentwithdrawn = account.getPromotion().getWithdrawn();
UserBalance userBalance = userBalanceRepository.findById(name).orElse(null);
double parentbalanced = 0;
if (userBalance != null)
parentbalanced = userBalance.getBalanced();
List<UserPrePaidBilling> userPrePaidBillings1 = userPrePaidBillingRepository.findByUsernameAndPayMethod(name, 3);
double parentbanktransfer = 0;
if (userPrePaidBillings1 != null)
totalearn = userPrePaidBillings1.stream().mapToDouble(UserPrePaidBilling::getTotal).sum();
parentbanktransfer = userPrePaidBillings1.stream().mapToDouble(UserPrePaidBilling::getTotal).sum();
double childexpense = 0;
double childwithdrawn = 0;
double childbalanced = 0;
double childbanktransfer = 0;
if (account.getParent() == null) {
List<Account> children = accountRepository.findByParent(account.getName());
for (Account child : children) {
List<UserPrePaidBilling> userPrePaidBillings_child = userPrePaidBillingRepository.findByUsernameAndPayMethodIn(child.getName(), Arrays.asList(1,2));
if (userPrePaidBillings_child != null)
childexpense += userPrePaidBillings_child.stream().mapToDouble(UserPrePaidBilling::getTotal).sum();
childwithdrawn += child.getPromotion().getWithdrawn();
UserBalance userBalance_child = userBalanceRepository.findById(child.getName()).orElse(null);
if (userBalance_child != null)
childbalanced += userBalance_child.getBalanced();
List<UserPrePaidBilling> userPrePaidBillings1_child = userPrePaidBillingRepository.findByUsernameAndPayMethod(name, 3);
if (userPrePaidBillings1_child != null)
childbanktransfer += userPrePaidBillings1_child.stream().mapToDouble(UserPrePaidBilling::getTotal).sum();
}
}
BillQueryResultDto billQueryResultDto = new BillQueryResultDto();
billQueryResultDto.setUserPrePaidBillingList(userBillingList);
billQueryResultDto.setTotalEarn(totalearn);
billQueryResultDto.setTotalExpense(totalexpense);
billQueryResultDto.setChildExpense(childexpense);
billQueryResultDto.setChildBankTransfer(childbanktransfer);
billQueryResultDto.setChildBalanced(childbalanced);
billQueryResultDto.setChildWithdraw(childwithdrawn);
billQueryResultDto.setParentExpense(parentexpense);
billQueryResultDto.setParentBalanced(parentbalanced);
billQueryResultDto.setParentBankTransfer(parentbanktransfer);
billQueryResultDto.setParentWithdrawn(parentwithdrawn);
return billQueryResultDto;
}
......@@ -168,14 +198,16 @@ public class AdministratorServiceImpl implements AdministratorService {
}
@Override
public Page<Account> searchCreateAccountBetween(Pageable pageable, String strDate1, String strDate2 ) {
public Page<Account> searchCreateAccountBetween(Pageable pageable, String strDate1, String strDate2, boolean isAuthorized ) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
Page<Account> accounts = null;
try {
Date dateTime1 = formatter.parse(strDate1);
Date dateTime2 = formatter.parse(strDate2);
accounts = accountRepository.findAllBySignupDateBetweenAndParentIsNull(pageable, dateTime1, dateTime2);
if (isAuthorized)
accounts = accountRepository.findAllBySignupDateBetweenAndParentIsNullAndAuthorizedNot(pageable, dateTime1, dateTime2, 0);
else
accounts = accountRepository.findAllBySignupDateBetweenAndParentIsNull(pageable, dateTime1, dateTime2);
}catch (ParseException e){
e.printStackTrace();
}
......
......@@ -4,16 +4,15 @@ import com.alibaba.fastjson.JSONObject;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.request.AlipayFundTransToaccountTransferRequest;
import com.alipay.api.request.AlipayFundTransUniTransferRequest;
import com.alipay.api.request.AlipayTradePagePayRequest;
import com.alipay.api.request.AlipayTradeQueryRequest;
import com.alipay.api.response.AlipayFundTransToaccountTransferResponse;
import com.alipay.api.response.AlipayFundTransUniTransferResponse;
import com.alipay.api.response.AlipayTradePagePayResponse;
import com.alipay.api.response.AlipayTradeQueryResponse;
import com.edgec.browserbackend.account.exception.AccountErrorCode;
import com.edgec.browserbackend.account.repository.AccountRepository;
import com.edgec.browserbackend.account.repository.UserBalanceRepository;
import com.edgec.browserbackend.account.repository.UserPaymentRepository;
import com.edgec.browserbackend.account.repository.UserPrePaidBillingRepository;
import com.edgec.browserbackend.account.repository.*;
import com.edgec.browserbackend.account.service.AccountService;
import com.edgec.browserbackend.account.service.PaymentService;
import com.edgec.browserbackend.account.controller.AccountController;
......@@ -23,10 +22,12 @@ import com.edgec.browserbackend.account.service.UserPrePaidBillingService;
import com.edgec.browserbackend.alipay.AlipayConfig;
import com.edgec.browserbackend.alipay.CloudamAlipayConfig;
import com.edgec.browserbackend.alipay.VpsAlipayConfig;
import com.edgec.browserbackend.browser.ErrorCode.BrowserErrorCode;
import com.edgec.browserbackend.browser.domain.PayBack;
import com.edgec.browserbackend.browser.repository.PayBackRepository;
import com.edgec.browserbackend.common.commons.error.ClientRequestException;
import com.edgec.browserbackend.wxpay.*;
import com.google.gson.Gson;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -64,6 +65,9 @@ public class PaymentServiceImpl implements PaymentService {
@Autowired
private AccountRepository accountRepository;
@Autowired
private UserWithdrawRepository userWithdrawRepository;
@Override
public String wechatPayCallback(String tradno) {
......@@ -560,13 +564,16 @@ public class PaymentServiceImpl implements PaymentService {
}
@Override
public boolean alipayWithdraw(String username, String account, String realName) {
public boolean alipayWithdraw(String username, String account, String realName, int amount) {
Account byName = accountService.findByName(username);
if (byName == null)
throw new ClientRequestException(AccountErrorCode.NAMENOTEXIST, "account does not exist: " + username);
boolean isVpsClient = true;
if (amount > byName.getPromotion().getAllGift())
throw new ClientRequestException(AccountErrorCode.NOTENOUGHBALANCE);
UserWithdraw internalOrder = new UserWithdraw();
internalOrder.setAmount(byName.getPromotion().getCommission());
internalOrder.setWithdrawMethod(PaymentMethod.ALIPAY);
......@@ -575,45 +582,81 @@ public class PaymentServiceImpl implements PaymentService {
try {
byName.getPromotion().setAllGift(byName.getPromotion().getAllGift() - amount);
byName.getPromotion().setWithdrawn(byName.getPromotion().getWithdrawn() + amount);
accountRepository.save(byName);
AlipayConfig alipayConfig = isVpsClient ? new VpsAlipayConfig() : new CloudamAlipayConfig();
AlipayClient alipayClient = new DefaultAlipayClient(alipayConfig.getURL(), alipayConfig.getAPPID(), alipayConfig.getAPP_PRIVATE_KEY(),
DefaultAlipayClient alipayClient = new DefaultAlipayClient(alipayConfig.getURL(), alipayConfig.getAPPID(), alipayConfig.getAPP_PRIVATE_KEY(),
"json", alipayConfig.getCHARSET(), alipayConfig.getALIPAY_PUBLIC_KEY(), alipayConfig.getSIGN_TYPE());
AlipayFundTransToaccountTransferRequest alipayRequest = new AlipayFundTransToaccountTransferRequest();
// String out_biz_no = internalOrder.getTradeNo();
// String product_code = "TRANS_ACCOUNT_NO_PWD";
// String trans_amount = "" + byName.getPromotion().getCommission() + ".00";
// String subject = "订单" + out_trade_no;
// String body = "";
//
// alipayRequest.setBizContent(""
// + "{"
// + "\"out_biz_no\":\"" + out_biz_no + "\","
// + "\"product_code\":\"" + product_code + "\","
// + "\"trans_amount\":\"" + trans_amount + "\","
// + "\"subject\":\"" + subject + "\","
// + "\"body\":\"" + body + "\""
// + "}"
// );
// AlipayFundTransToaccountTransferResponse response = alipayClient.pageExecute(alipayRequest);
// if("10000".equals(response.getCode())){
// resultMap.put("success", "true");
// resultMap.put("des", "转账成功");
// }else{
// resultMap.put("success", "false");
// resultMap.put("des", response.getSubMsg());
// }
// userPaymentRepository.save(internalOrder);
//
// String form = response.getBody();
// return form;
String out_biz_no = internalOrder.getTradeNo();
String trans_amount = "" + amount + ".00";
String identity_type = "ALIPAY_LOGONID";
String subject = "礼金提现" + out_biz_no;
AliTransfer aliTransfer = new AliTransfer();
aliTransfer.setOut_biz_no(internalOrder.getTradeNo());
aliTransfer.setPayee_type(identity_type);
aliTransfer.setAmount(trans_amount);
aliTransfer.setPayer_show_name("防关联浏览器");
aliTransfer.setPayee_account(account);
aliTransfer.setPayee_real_name(realName);
aliTransfer.setRemark(subject);
String json = new Gson().toJson(aliTransfer);
alipayRequest.setBizContent(json);
AlipayFundTransToaccountTransferResponse response = alipayClient.execute(alipayRequest);
if (response == null)
throw new ClientRequestException(BrowserErrorCode.UNKNOWN);
if(response.isSuccess()){
internalOrder.setSucceed(true);
userWithdrawRepository.save(internalOrder);
UserPrePaidBilling bill = new UserPrePaidBilling();
if (byName != null && byName.getParent() != null)
bill.setAdministrator(byName.getParent());
else
bill.setAdministrator(byName.getName());
bill.setTradeNo(new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())+ SmsUtils.createRandom(true, 4));
bill.setChargeType(4);
bill.setAmount(0);
bill.setUnit(null);
bill.setPeriod(0);
bill.setPayMethod(1);
bill.setUsername(username);
bill.setTotal((float) amount);
bill.setStatus(BillStatus.PAID);
bill.setPrepaid(true);
bill.setTimestamp(Instant.now().toEpochMilli());
final YearMonth lastmonth = YearMonth.now();
int monthValue = lastmonth.getMonthValue();
int year = lastmonth.getYear();
bill.setYear(year);
bill.setMonth(monthValue);
userPrePaidBillingRepository.save(bill);
return true;
}else{
byName.getPromotion().setAllGift(byName.getPromotion().getAllGift() + amount);
byName.getPromotion().setWithdrawn(byName.getPromotion().getWithdrawn() - amount);
accountRepository.save(byName);
internalOrder.setSucceed(false);
userWithdrawRepository.save(internalOrder);
log.error(response.getBody());
return false;
}
} catch (Exception e) {
log.error("Alypay payment order generation fails", e);
throw new ClientRequestException(AccountErrorCode.ALIPAYERROR, "Alypay payment order error");
log.error("Alipay payment order generation fails", e);
throw new ClientRequestException(AccountErrorCode.ALIPAYERROR, "Alipay payment order error");
}
return false;
}
}
......@@ -52,7 +52,7 @@ public class AlipaySubmit {
try {
AlipayUserInfoShareResponse userinfoShareResponse = alipayClient.execute(request, accessToken);
return userinfoShareResponse.getBody();
return userinfoShareResponse.getUserId();
} catch (AlipayApiException e) {
//处理异常
e.printStackTrace();
......
......@@ -20,7 +20,7 @@ public class ResourceServerConfiguration extends ResourceServerConfigurerAdapter
http
.authorizeRequests()
.antMatchers("/oauth/**").permitAll()
.antMatchers("/shop/*","/ip/*","/group/*","/0xadministrator/*","/user/*","/history/*").authenticated()
.antMatchers("/shop/**","/ip/**","/group/**","/0xadministrator/**","/user/**","/history/**").authenticated()
.and()
//关闭跨站请求防护
.csrf().disable();
......
......@@ -37,15 +37,28 @@ public class PromotionTask {
String code = account.getPromotion().getCode();
List<Account> promotes = accountRepository.findByPromotionCode(code);
double totalCommission = 0;
double secondCommission = 0;
for (Account promote : promotes) {
List<UserPrePaidBilling> userPrePaidBillings = userPrePaidBillingRepository.findByUsernameAndYearAndMonthAndPayMethodIn(promote.getName(),
YearMonth.now().minusMonths(1).getYear(),
YearMonth.now().minusMonths(1).getMonthValue(), Arrays.asList(1,2));
totalCommission += userPrePaidBillings.stream().mapToDouble(UserPrePaidBilling::getTotal).sum();
if (account.getPromotion().isSale() && promote.getParent() == null) {
List<Account> secondPromotes = accountRepository.findByPromotionCode(promote.getPromotion().getCode());
for (Account secondPromote : secondPromotes) {
List<UserPrePaidBilling> userPrePaidBillings1 = userPrePaidBillingRepository.findByUsernameAndYearAndMonthAndPayMethodIn(promote.getName(),
YearMonth.now().minusMonths(1).getYear(),
YearMonth.now().minusMonths(1).getMonthValue(), Arrays.asList(1,2));
secondCommission += userPrePaidBillings.stream().mapToDouble(UserPrePaidBilling::getTotal).sum();
}
}
}
Promotion promotion = account.getPromotion();
promotion.setCommissionLastMonth((int)totalCommission);
promotion.setGift(totalCommission * 8/100);
promotion.setGift(totalCommission * 0.08);
if (account.getPromotion().isSale()) {
promotion.setGift(totalCommission * 0.1 + secondCommission * 0.02);
}
promotion.setAllGift(promotion.getAllGift() + promotion.getGift());
accountRepository.save(account);
}
......
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