From ea1868377e45a89c552021944fd42ed24ad45ae1 Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期一, 01 九月 2025 09:15:38 +0800
Subject: [PATCH] bug修改
---
cloud-server-competition/src/main/java/com/dsh/competition/controller/CompetitionController.java | 733 ++++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 529 insertions(+), 204 deletions(-)
diff --git a/cloud-server-competition/src/main/java/com/dsh/competition/controller/CompetitionController.java b/cloud-server-competition/src/main/java/com/dsh/competition/controller/CompetitionController.java
index d2adf24..208c8bc 100644
--- a/cloud-server-competition/src/main/java/com/dsh/competition/controller/CompetitionController.java
+++ b/cloud-server-competition/src/main/java/com/dsh/competition/controller/CompetitionController.java
@@ -3,6 +3,7 @@
import cn.hutool.core.date.DateUtil;
import cn.hutool.poi.excel.ExcelUtil;
+import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -11,31 +12,41 @@
import com.dsh.competition.entity.PaymentCompetition;
import com.dsh.competition.entity.UserCompetition;
import com.dsh.competition.feignclient.account.AppUserClient;
+import com.dsh.competition.feignclient.account.StudentClient;
+import com.dsh.competition.feignclient.account.StudentHonorClient;
import com.dsh.competition.feignclient.account.model.AppUser;
+import com.dsh.competition.feignclient.account.model.StudentHonor;
+import com.dsh.competition.feignclient.account.model.TStudent;
import com.dsh.competition.feignclient.course.CoursePackagePaymentClient;
+import com.dsh.competition.feignclient.course.model.PaymentDeductionClassHour;
import com.dsh.competition.feignclient.model.*;
+import com.dsh.competition.feignclient.other.StoreClient;
+import com.dsh.competition.feignclient.other.model.Store;
import com.dsh.competition.model.*;
import com.dsh.competition.service.CompetitionService;
import com.dsh.competition.service.IParticipantService;
import com.dsh.competition.service.IPaymentCompetitionService;
import com.dsh.competition.service.UserCompetitionService;
-import com.dsh.competition.util.PayMoneyUtil;
-import com.dsh.competition.util.ResultUtil;
-import com.dsh.competition.util.TokenUtil;
-import com.dsh.competition.util.ToolUtil;
+import com.dsh.competition.util.*;
+import com.dsh.competition.util.wx.WxV3PayConfig;
+import com.wechat.pay.contrib.apache.httpclient.util.AesUtil;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.Synchronized;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
+import java.math.BigDecimal;
+import java.nio.charset.StandardCharsets;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
@@ -44,7 +55,7 @@
/**
* <p>
- * 前端控制器
+ * 前端控制器
* </p>
*
* @author jqs
@@ -78,19 +89,25 @@
@Autowired
private AppUserClient appUserClient;
+ @Resource
+ private StudentHonorClient studentHonorClient;
+
+
+
+
/**
* 根据门店ids 获取对应的赛事 根据赛事支付记录获取用户ids
*/
@ResponseBody
@PostMapping("/base/competition/getUserIds")
- public List<Integer> getUserIds(@RequestBody ListQuery query){
+ public List<Integer> getUserIds(@RequestBody ListQuery query) {
List<Competition> list = cttService.list(new QueryWrapper<Competition>());
// 赛事id集合
List<Integer> comIds = new ArrayList<>();
for (Integer id : query.getIds()) {
for (Competition competition : list) {
- if (competition.getStoreId().contains(id.toString())){
+ if (competition.getStoreId().contains(id.toString())) {
comIds.add(competition.getId());
}
}
@@ -98,53 +115,69 @@
// 获取到赛事id集合 去重
List<Integer> collect = comIds.stream().distinct().collect(Collectors.toList());
// 根据赛事id 查询赛事支付记录 获取用户ids
- if (collect.size() == 0){
+ if (collect.isEmpty()) {
return new ArrayList<>();
- }else{
+ } else {
List<Integer> userIds = paymentCompetitionService.list(new QueryWrapper<PaymentCompetition>()
- .in("competitionId", collect)).stream()
+ .in("competitionId", collect)
+ .eq("payStatus",2)).stream()
.map(PaymentCompetition::getAppUserId).collect(Collectors.toList());
return userIds;
}
}
+
/**
* 获取赛事报名记录
*/
@ResponseBody
@RequestMapping("/base/competition/listAllPayment")
- public List<PaymentCompetition> listAllPayment(@RequestBody CompetitionQuery query){
+ public List<PaymentCompetition> listAllPayment(@RequestBody CompetitionQuery query) {
Integer operatorId1 = query.getOperatorId();
- if (operatorId1!=null){
+ if (operatorId1 != null) {
// 赛事集合id
List<Integer> operatorId = cttService.list(new QueryWrapper<Competition>()
.eq("operatorId", operatorId1)).stream().map(Competition::getId).collect(Collectors.toList());
query.setUserIds(operatorId);
+ } else if (query.getStoreId() != null) {
+ List<Competition> list = cttService.list(new QueryWrapper<Competition>());
+ List<Integer> integers = new ArrayList<>();
+ for (Competition competition : list) {
+ for (String s : competition.getStoreId().split(",")) {
+ if (s.equals(""+query.getStoreId())){
+ integers.add(competition.getId());
+ }
+ }
+ }
+ if (integers.isEmpty()){
+ integers.add(-1);
+ }
+ query.setUserIds(integers);
}
List<PaymentCompetition> paymentCompetitions = paymentCompetitionService.listAll(query);
List<PaymentCompetition> result = new ArrayList<>();
- if (query.getOperatorId()!=null){
+ if (query.getOperatorId() != null) {
for (PaymentCompetition paymentCompetition : paymentCompetitions) {
Integer competitionId = paymentCompetition.getCompetitionId();
Competition byId = cttService.getById(competitionId);
- if (byId!=null){
+ if (byId != null) {
Integer operatorId = byId.getOperatorId();
- if (operatorId!=null){
- if (operatorId == query.getOperatorId()){
+ if (operatorId != null) {
+ if (operatorId == query.getOperatorId()) {
result.add(paymentCompetition);
}
}
}
}
return result;
- }else if (query.getStoreId()!=null){
+ } else if (query.getStoreId() != null) {
for (PaymentCompetition paymentCompetition : paymentCompetitions) {
Integer competitionId = paymentCompetition.getCompetitionId();
Competition byId = cttService.getById(competitionId);
- if (byId!=null){
+ if (byId != null) {
String storeId = byId.getStoreId();
- if (storeId.contains(query.getStoreId().toString())){
- result.add(paymentCompetition);
+ if (storeId.contains(query.getStoreId().toString())) {
+ result.add(paymentCompetition);
}
}
}
@@ -152,14 +185,15 @@
}
return paymentCompetitions;
}
+
@ResponseBody
@PostMapping("/base/competition/getPayedCompetitions")
- public BillingRequestVo getAllCompetitionPayRecord(@RequestBody BillingDataRequestVo requestVo){
+ public BillingRequestVo getAllCompetitionPayRecord(@RequestBody BillingDataRequestVo requestVo) {
BillingRequestVo billingRequestVo = new BillingRequestVo();
List<BillingRequest> integers = new ArrayList<>();
- integers = paymentCompetitionService.queryDatas(requestVo.getAppUserId(),requestVo.getMonthStart(),requestVo.getMonthEnd());
+ integers = paymentCompetitionService.queryDatas(requestVo.getAppUserId(), requestVo.getMonthStart(), requestVo.getMonthEnd());
System.out.println(integers);
- if (integers.size() > 0 ){
+ if (integers.size() > 0) {
billingRequestVo.setRequests(integers);
}
return billingRequestVo;
@@ -167,12 +201,12 @@
@ResponseBody
@PostMapping("/base/competition/getCancelOrderOfUserPay")
- public BillingRequestVo getCancelOrderOfUserPayRecord(@RequestBody BillingDataRequestVo requestVo){
+ public BillingRequestVo getCancelOrderOfUserPayRecord(@RequestBody BillingDataRequestVo requestVo) {
BillingRequestVo billingRequestVo = new BillingRequestVo();
List<BillingRequest> integers = new ArrayList<>();
- integers = paymentCompetitionService.queryCancelDatas(requestVo.getAppUserId(),requestVo.getMonthStart(),requestVo.getMonthEnd());
+ integers = paymentCompetitionService.queryCancelDatas(requestVo.getAppUserId(), requestVo.getMonthStart(), requestVo.getMonthEnd());
System.out.println(integers);
- if (integers.size() > 0 ){
+ if (integers.size() > 0) {
billingRequestVo.setRequests(integers);
}
return billingRequestVo;
@@ -180,30 +214,32 @@
@PostMapping("/base/competition/getPlayPaiFGoldPayRecord")
- public List<PaymentCompetition> getPlayPaiFGoldPayRecord(@RequestBody Integer appUserId){
+ public List<PaymentCompetition> getPlayPaiFGoldPayRecord(@RequestBody Integer appUserId) {
ArrayList<Integer> integers = new ArrayList<>();
// integers.add(1);
// integers.add(2);
integers.add(3);
+ ArrayList<Integer> pays = new ArrayList<>();
+ pays.add(2);
+ pays.add(3);
+
return paymentCompetitionService.list(new QueryWrapper<PaymentCompetition>()
- .in("payType",integers)
- .eq("appUserId",appUserId)
- .eq("payStatus",2));
+ .in("payType", integers)
+ .eq("appUserId", appUserId)
+ .in("payStatus", pays));
}
@PostMapping("/base/competition/queryByCode")
- public Integer queryByCode(@RequestBody String code){
+ public Integer queryByCode(@RequestBody String code) {
return paymentCompetitionService.queryByCode(code);
}
-
-
@PostMapping("/base/competition/getCompetitionsDetails")
- public List<PurchaseRecordVo> getStuSourseList(@RequestBody GetStuSourseList sourseList){
+ public List<PurchaseRecordVo> getStuSourseList(@RequestBody GetStuSourseList sourseList) {
List<PurchaseRecordVo> recordVos = new ArrayList<>();
@@ -211,22 +247,22 @@
integers.add(1);
integers.add(2);
List<PaymentCompetition> list = paymentCompetitionService.list(new QueryWrapper<PaymentCompetition>()
- .in("payType",integers )
+ .in("payType", integers)
.eq("appUserId", sourseList.getAppUserId())
- .eq("state",1));
- if (list.size() > 0){
+ .eq("state", 1));
+ if (list.size() > 0) {
List<Long> comIds = list.stream().map(PaymentCompetition::getId).collect(Collectors.toList());
List<UserCompetition> userCompetitions = ucttService.list(new QueryWrapper<UserCompetition>()
- .between("insertTime", sourseList.getStartTime(),sourseList.getEndTime() )
+ .between("insertTime", sourseList.getStartTime(), sourseList.getEndTime())
.eq("appUserId", sourseList.getAppUserId())
- .in("paymentCompetitionId",comIds ));
- if (userCompetitions.size() > 0){
- userCompetitions.forEach(coms ->{
+ .in("paymentCompetitionId", comIds));
+ if (userCompetitions.size() > 0) {
+ userCompetitions.forEach(coms -> {
PurchaseRecordVo recordVo = new PurchaseRecordVo();
recordVo.setPurchaseType("报名赛事");
recordVo.setPurchaseTime(dateFormat.format(coms.getInsertTime()));
PaymentCompetition paymentCompetition = paymentCompetitionService.getById(coms.getPaymentCompetitionId());
- recordVo.setPurchaseAmount("-"+paymentCompetition.getAmount());
+ recordVo.setPurchaseAmount("-" + paymentCompetition.getAmount());
recordVos.add(recordVo);
});
}
@@ -237,29 +273,29 @@
@PostMapping("/base/competition/getCompetitionsDetails1")
- public List<PurchaseRecordVo> getStuSourseList1(@RequestBody GetStuSourseList sourseList){
+ public List<PurchaseRecordVo> getStuSourseList1(@RequestBody GetStuSourseList sourseList) {
List<PurchaseRecordVo> recordVos = new ArrayList<>();
ArrayList<Integer> integers = new ArrayList<>();
integers.add(4);
List<PaymentCompetition> list = paymentCompetitionService.list(new QueryWrapper<PaymentCompetition>()
- .in("payType",integers )
+ .in("payType", integers)
.eq("appUserId", sourseList.getAppUserId())
- .eq("state",1));
- if (list.size() > 0){
+ .eq("state", 1));
+ if (list.size() > 0) {
List<Long> comIds = list.stream().map(PaymentCompetition::getId).collect(Collectors.toList());
List<UserCompetition> userCompetitions = ucttService.list(new QueryWrapper<UserCompetition>()
- .between("insertTime", sourseList.getStartTime(),sourseList.getEndTime() )
+ .between("insertTime", sourseList.getStartTime(), sourseList.getEndTime())
.eq("appUserId", sourseList.getAppUserId())
- .in("paymentCompetitionId",comIds ));
- if (userCompetitions.size() > 0){
- userCompetitions.forEach(coms ->{
+ .in("paymentCompetitionId", comIds));
+ if (userCompetitions.size() > 0) {
+ userCompetitions.forEach(coms -> {
PurchaseRecordVo recordVo = new PurchaseRecordVo();
recordVo.setPurchaseType("报名赛事");
recordVo.setPurchaseTime(dateFormat.format(coms.getInsertTime()));
PaymentCompetition paymentCompetition = paymentCompetitionService.getById(coms.getPaymentCompetitionId());
- recordVo.setPurchaseAmount("-"+paymentCompetition.getAmount());
+ recordVo.setPurchaseAmount("-" + paymentCompetition.getAmount());
recordVos.add(recordVo);
});
}
@@ -267,8 +303,6 @@
return recordVos;
}
-
-
@ResponseBody
@@ -281,16 +315,19 @@
@ApiImplicitParam(value = "排序(asc=正序,desc=倒序)", name = "heat", dataType = "String", required = false),
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
})
- public ResultUtil<List<CompetitionListVo>> queryCompetitionList(String cityCode, String content, Integer registerCondition, String heat){
+ public ResultUtil<List<CompetitionListVo>> queryCompetitionList(String cityCode, String content, Integer registerCondition, String heat) {
try {
List<CompetitionListVo> competitionListVos = cttService.queryCompetitionList(cityCode, content, registerCondition, heat);
- return ResultUtil.success(competitionListVos);
- }catch (Exception e){
+ List<CompetitionListVo> filteredList = competitionListVos.stream()
+ .filter(vo -> vo.getStatus() == 1 || vo.getStatus() == 2)
+ .collect(Collectors.toList());
+
+ return ResultUtil.success(filteredList);
+ } catch (Exception e) {
e.printStackTrace();
return ResultUtil.runErr();
}
}
-
@ResponseBody
@@ -302,27 +339,38 @@
@ApiImplicitParam(value = "纬度", name = "lat", dataType = "string", required = false),
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
})
- public ResultUtil<CompetitionInfo> queryCompetitionInfo(Integer id, String lon, String lat){
+ public ResultUtil<CompetitionInfo> queryCompetitionInfo(Integer id, String lon, String lat) {
try {
Integer uid = tokenUtil.getUserIdFormRedis();
- if(null == uid){
+ if (null == uid) {
return ResultUtil.tokenErr();
}
CompetitionInfo competitionInfo = cttService.queryCompetitionInfo(uid, id, lon, lat);
+
+
+ String dateString = competitionInfo.getRegisterEndTime();
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+ Date date = sdf.parse(dateString);
+ if (new Date().after(date)) {
+ competitionInfo.setHasPass(1);
+ } else {
+ competitionInfo.setHasPass(0);
+
+ }
+
+
return ResultUtil.success(competitionInfo);
- }catch (Exception e){
+ } catch (Exception e) {
e.printStackTrace();
return ResultUtil.runErr();
}
}
-
-
@Autowired
private CompetitionService competitionService;
@Resource
- private CoursePackagePaymentClient coursePackagePaymentClient;
+ private CoursePackagePaymentClient coursePackagePaymentClient;
@ResponseBody
@@ -332,41 +380,38 @@
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
})
-
- public synchronized ResultUtil paymentCompetition(PaymentCompetitionVo paymentCompetitionVo){
+ public synchronized ResultUtil paymentCompetition(PaymentCompetitionVo paymentCompetitionVo) {
try {
Competition byId = competitionService.getById(paymentCompetitionVo.getId());
Date date = byId.getEndTime();
- // Assuming you have a Date object
- // Check if the date is past the current time
boolean isPast = date.after(new Date());
if (!isPast) {
- return new ResultUtil(0,"已超过截至报名时间");
+ return new ResultUtil(0, "已超过截至报名时间");
}
Integer uid = tokenUtil.getUserIdFormRedis();
- if(null == uid){
+ if (null == uid) {
return ResultUtil.tokenErr();
}
- if (byId.getRegisterCondition()==3){
- Integer counts = coursePackagePaymentClient.isHave(uid);
- if (counts==0){
- return new ResultUtil(0,"当前赛事仅限已购课学员报名");
+ if (byId.getRegisterCondition() == 3) {
+ Integer counts = coursePackagePaymentClient.isHave(paymentCompetitionVo.getIds());
+ if (counts == 0) {
+ return new ResultUtil(0, "当前赛事仅限已购课学员报名");
}
}
- if (byId.getRegisterCondition()==2){
+ if (byId.getRegisterCondition() == 2) {
AppUser appUser = appUserClient.queryAppUser(uid);
- if (appUser.getIsVip()==0){
- return new ResultUtil(0,"当前赛事仅限年度会员报名");
- }else {
+ if (appUser.getIsVip() == 0) {
+ return new ResultUtil(0, "当前赛事仅限年度会员报名");
+ } else {
Date vipEndTime = appUser.getVipEndTime();
Date currentTime = new Date(); // Current time
if (vipEndTime.before(currentTime)) {
- return new ResultUtil(0,"您的年度会员已过期,请续费");
+ return new ResultUtil(0, "您的年度会员已过期,请续费");
}
}
}
return cttService.paymentCompetition(uid, paymentCompetitionVo);
- }catch (Exception e){
+ } catch (Exception e) {
e.printStackTrace();
return ResultUtil.runErr();
}
@@ -380,14 +425,14 @@
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
@ApiImplicitParam(value = "赛事id", name = "id", dataType = "int", required = true),
})
- public ResultUtil paymentCompetitionCourseList(Integer id){
+ public ResultUtil paymentCompetitionCourseList(Integer id) {
try {
Integer uid = tokenUtil.getUserIdFormRedis();
- if(null == uid){
+ if (null == uid) {
return ResultUtil.tokenErr();
}
return cttService.paymentCompetitionCourseList(uid, id);
- }catch (Exception e){
+ } catch (Exception e) {
e.printStackTrace();
return ResultUtil.runErr();
}
@@ -396,21 +441,77 @@
/**
* 报名赛事微信支付回调
+ *
+ * @param request
+ * @param response
+ */
+ @ResponseBody
+ @PostMapping("/base/competition/weChatPaymentCompetitionCallback1")
+ public void weChatPaymentCompetitionCallback1(HttpServletRequest request, HttpServletResponse response) {
+ try {
+ System.err.println("微信回调");
+ System.err.println("请求" + request);
+ BufferedReader reader = request.getReader();
+ String string1 = reader.toString();
+ System.err.println("请求reader" + string1);
+ StringBuilder requestBody = new StringBuilder();
+ String line;
+ while ((line = reader.readLine()) != null) {
+ requestBody.append(line);
+ }
+ System.err.println("全部请求体" + requestBody);
+ JSONObject jsonObject = JSONObject.parseObject(requestBody.toString());
+ JSONObject resource = jsonObject.getJSONObject("resource");
+
+ AesUtil aesUtil = new AesUtil(WxV3PayConfig.apiV3Key.getBytes(StandardCharsets.UTF_8));
+ String decryptedData = aesUtil.decryptToString(resource.getString("associated_data").getBytes(StandardCharsets.UTF_8), resource.getString("nonce").getBytes(StandardCharsets.UTF_8),
+ resource.getString("ciphertext"));
+ System.err.println("微信解密的字符串信息" + decryptedData);
+ JSONObject jsonInfo = (JSONObject) JSONObject.parse(decryptedData);
+ String code = jsonInfo.getString("out_trade_no");
+ String transaction_id = jsonInfo.getString("transaction_id");
+ String trade_state = jsonInfo.getString("trade_state");
+ if (trade_state.equals("SUCCESS")) {
+ PaymentCompetition paymentCompetition = paymentCompetitionService.getOne(new QueryWrapper<PaymentCompetition>().eq("code", code).eq("payType", 1));
+ if (paymentCompetition.getPayStatus() == 1) {
+ paymentCompetition.setAppUserId(null);
+ paymentCompetition.setPayStatus(2);
+ paymentCompetition.setPayTime(new Date());
+ paymentCompetition.setPayOrderNo(transaction_id);
+ paymentCompetitionService.updateById(paymentCompetition);
+ Competition competition = cttService.getById(paymentCompetition.getCompetitionId());
+ competition.setApplicantsNumber(competition.getApplicantsNumber() + 1);
+ cttService.updateById(competition);
+ }
+
+
+ PrintWriter out = response.getWriter();
+ out.write("SUCCESS");
+ out.flush();
+ out.close();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ /**
+ * 报名赛事微信支付回调
+ *
* @param request
* @param response
*/
@ResponseBody
@PostMapping("/base/competition/weChatPaymentCompetitionCallback")
- public void weChatPaymentCompetitionCallback(HttpServletRequest request, HttpServletResponse response){
+ public void weChatPaymentCompetitionCallback(HttpServletRequest request, HttpServletResponse response) {
try {
Map<String, String> map = payMoneyUtil.weixinpayCallback(request);
- if(null != map){
+ if (null != map) {
String code = map.get("out_trade_no");
String transaction_id = map.get("transaction_id");
String result = map.get("result");
PaymentCompetition paymentCompetition = paymentCompetitionService.getOne(new QueryWrapper<PaymentCompetition>().eq("code", code).eq("payType", 1));
- if(paymentCompetition.getPayStatus() == 1){
+ if (paymentCompetition.getPayStatus() == 1) {
paymentCompetition.setAppUserId(null);
paymentCompetition.setPayStatus(2);
paymentCompetition.setPayTime(new Date());
@@ -427,7 +528,7 @@
out.flush();
out.close();
}
- }catch (Exception e){
+ } catch (Exception e) {
e.printStackTrace();
}
}
@@ -435,26 +536,25 @@
/**
* 报名赛事支付宝支付回调
+ *
* @param request
* @param response
*/
@ResponseBody
@PostMapping("/base/competition/aliPaymentCompetitionCallback")
- public void aliPaymentCompetitionCallback(HttpServletRequest request, HttpServletResponse response){
+ public void aliPaymentCompetitionCallback(HttpServletRequest request, HttpServletResponse response) {
try {
Map<String, String> map = payMoneyUtil.alipayCallback(request);
- if(null != map){
+ if (null != map) {
String code = map.get("out_trade_no");
String trade_no = map.get("trade_no");
-
PaymentCompetition paymentCompetition = paymentCompetitionService.getOne(new QueryWrapper<PaymentCompetition>().eq("code", code).eq("payType", 2));
- if(paymentCompetition.getPayStatus() == 1){
+ if (paymentCompetition.getPayStatus() == 1) {
paymentCompetition.setAppUserId(null);
paymentCompetition.setPayStatus(2);
paymentCompetition.setPayTime(new Date());
paymentCompetition.setPayOrderNo(trade_no);
paymentCompetitionService.updateById(paymentCompetition);
-
Competition competition = cttService.getById(paymentCompetition.getCompetitionId());
competition.setApplicantsNumber(competition.getApplicantsNumber() + 1);
cttService.updateById(competition);
@@ -464,12 +564,10 @@
out.flush();
out.close();
}
- }catch (Exception e){
+ } catch (Exception e) {
e.printStackTrace();
}
}
-
-
@ResponseBody
@@ -481,20 +579,19 @@
@ApiImplicitParam(value = "页码,首页1", name = "pageNo", dataType = "int", required = true),
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
})
- public ResultUtil<List<CompetitionListVo>> queryMyCompetitionList(Integer type, Integer pageSize, Integer pageNo){
+ public ResultUtil<List<CompetitionListVo>> queryMyCompetitionList(Integer type, Integer pageSize, Integer pageNo) {
try {
Integer uid = tokenUtil.getUserIdFormRedis();
- if(null == uid){
+ if (null == uid) {
return ResultUtil.tokenErr();
}
List<CompetitionListVo> competitionListVos = paymentCompetitionService.queryMyCompetitionList(uid, type, pageSize, pageNo);
return ResultUtil.success(competitionListVos);
- }catch (Exception e){
+ } catch (Exception e) {
e.printStackTrace();
return ResultUtil.runErr();
}
}
-
@ResponseBody
@@ -504,16 +601,15 @@
@ApiImplicitParam(value = "赛事id", name = "id", dataType = "int", required = true),
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
})
- public ResultUtil<CompetitionInfo> queryMyCompetitionInfo(Long id){
+ public ResultUtil<CompetitionInfo> queryMyCompetitionInfo(Long id) {
try {
CompetitionInfo competitionInfo = paymentCompetitionService.queryMyCompetitionInfo(id);
return ResultUtil.success(competitionInfo);
- }catch (Exception e){
+ } catch (Exception e) {
e.printStackTrace();
return ResultUtil.runErr();
}
}
-
@ResponseBody
@@ -523,11 +619,11 @@
@ApiImplicitParam(value = "赛事id", name = "id", dataType = "int", required = true),
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....")
})
- public ResultUtil cancelMyCompetition(Long id){
+ public ResultUtil cancelMyCompetition(Long id) {
try {
ResultUtil resultUtil = paymentCompetitionService.cancelMyCompetition(id);
return resultUtil;
- }catch (Exception e){
+ } catch (Exception e) {
e.printStackTrace();
return ResultUtil.runErr();
}
@@ -536,20 +632,22 @@
/**
* 取消已报名赛事后微信回退金额回调
+ *
* @param request
* @param response
*/
@ResponseBody
@PostMapping("/base/competition/weChatCancelPaymentCompetitionCallback")
- public void weChatCancelPaymentCompetitionCallback(HttpServletRequest request, HttpServletResponse response){
+ public void weChatCancelPaymentCompetitionCallback(HttpServletRequest request, HttpServletResponse response) {
try {
Map<String, String> map = payMoneyUtil.wxRefundCallback(request);
- if(null != map){
+ if (null != map) {
String code = map.get("out_refund_no");
String refund_id = map.get("refund_id");
String result = map.get("result");
- PaymentCompetition paymentCompetition = paymentCompetitionService.getOne(new QueryWrapper<PaymentCompetition>().eq("code", code).eq("payType", 1));
- if(paymentCompetition.getPayStatus() == 1){
+ PaymentCompetition paymentCompetition = paymentCompetitionService.getOne(new QueryWrapper<PaymentCompetition>()
+ .eq("code", code).eq("payType", 1));
+ if (paymentCompetition.getPayStatus() == 2) {
paymentCompetition.setPayStatus(3);
paymentCompetition.setRefundTime(new Date());
paymentCompetition.setRefundOrderNo(refund_id);
@@ -559,23 +657,82 @@
Competition competition = cttService.getById(paymentCompetition.getCompetitionId());
competition.setApplicantsNumber(competition.getApplicantsNumber() - 1);
cttService.updateById(competition);
+
+ PrintWriter out = response.getWriter();
+ out.write(result);
+ out.flush();
+ out.close();
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ /**
+ * 取消已报名赛事后微信回退金额回调微信V3服务商版本
+ *
+ * @param request
+ * @param response
+ */
+ @ResponseBody
+ @PostMapping("/base/competition/weChatCancelPaymentCompetitionCallback1")
+ public void weChatCancelPaymentCompetitionCallback1(HttpServletRequest request, HttpServletResponse response) {
+ try {
+ System.err.println("微信回调");
+ System.err.println("请求" + request);
+ BufferedReader reader = request.getReader();
+ String string1 = reader.toString();
+ System.err.println("请求reader" + string1);
+ StringBuilder requestBody = new StringBuilder();
+ String line;
+ while ((line = reader.readLine()) != null) {
+ requestBody.append(line);
+ }
+ System.err.println("全部请求体" + requestBody);
+ JSONObject jsonObject = JSONObject.parseObject(requestBody.toString());
+ JSONObject resource = jsonObject.getJSONObject("resource");
+
+ AesUtil aesUtil = new AesUtil(WxV3PayConfig.apiV3Key.getBytes(StandardCharsets.UTF_8));
+ String decryptedData = aesUtil.decryptToString(resource.getString("associated_data").getBytes(StandardCharsets.UTF_8), resource.getString("nonce").getBytes(StandardCharsets.UTF_8),
+ resource.getString("ciphertext"));
+ System.err.println("微信解密的字符串信息" + decryptedData);
+ JSONObject jsonInfo = (JSONObject) JSONObject.parse(decryptedData);
+ String code = jsonInfo.getString("out_trade_no");
+ String transaction_id = jsonInfo.getString("transaction_id");
+ String refund_status = jsonInfo.getString("refund_status");
+ String out_refund_no = jsonInfo.getString("out_refund_no");
+ if (refund_status.equals("SUCCESS")) {
+ PaymentCompetition paymentCompetition = paymentCompetitionService.getOne(new QueryWrapper<PaymentCompetition>()
+ .eq("code", code).eq("payType", 1));
+ if (paymentCompetition.getPayStatus() == 2) {
+ paymentCompetition.setPayStatus(3);
+ paymentCompetition.setRefundTime(new Date());
+ paymentCompetition.setRefundOrderNo(out_refund_no);
+ paymentCompetition.setAppUserId(null);
+ paymentCompetitionService.updateById(paymentCompetition);
+
+ Competition competition = cttService.getById(paymentCompetition.getCompetitionId());
+ competition.setApplicantsNumber(competition.getApplicantsNumber() - 1);
+ cttService.updateById(competition);
+ storeClient.addBackRecord(paymentCompetition.getAmount() + "_" + paymentCompetition.getAppUserId());
+
}
PrintWriter out = response.getWriter();
- out.write(result);
+ out.write("SUCCESS");
out.flush();
out.close();
}
- }catch (Exception e){
+ } catch (Exception e) {
e.printStackTrace();
}
}
@PostMapping("/base/competition/queryById")
- public Competition queryById(@RequestBody Integer id){
+ public Competition queryById(@RequestBody Integer id) {
try {
return cttService.getById(id);
- }catch (Exception e){
+ } catch (Exception e) {
e.printStackTrace();
return null;
}
@@ -583,79 +740,83 @@
@PostMapping("/base/competition/list")
- public Page<Competition> list(@RequestBody ListQuery listQuery){
+ public Page<Competition> list(@RequestBody ListQuery listQuery) {
try {
- Page<Competition> competitionPage = new Page<>(listQuery.getOffset(),listQuery.getLimit());
+ Page<Competition> competitionPage = new Page<>(listQuery.getOffset(), listQuery.getLimit());
LambdaQueryWrapper<Competition> wrapper = new LambdaQueryWrapper<>();
- if(ToolUtil.isNotEmpty(listQuery.getProvinceCode())){
- wrapper.eq(Competition::getProvinceCode,listQuery.getProvinceCode());
+ if (ToolUtil.isNotEmpty(listQuery.getProvinceCode())) {
+ wrapper.eq(Competition::getProvinceCode, listQuery.getProvinceCode());
}
- if(ToolUtil.isNotEmpty(listQuery.getCityCode())){
- wrapper.eq(Competition::getProvinceCode,listQuery.getCityCode());
+ if (ToolUtil.isNotEmpty(listQuery.getCityCode())) {
+ wrapper.eq(Competition::getProvinceCode, listQuery.getCityCode());
}
- if(ToolUtil.isNotEmpty(listQuery.getEventName())){
- wrapper.like(Competition::getName,listQuery.getEventName());
+ if (ToolUtil.isNotEmpty(listQuery.getEventName())) {
+ wrapper.like(Competition::getName, listQuery.getEventName());
}
- if(ToolUtil.isNotEmpty(listQuery.getTime())){
- wrapper.lt(Competition::getStartTime,listQuery.getTime().split(" - ")[0]+" 00:00:00");
- wrapper.gt(Competition::getEndTime,listQuery.getTime().split(" - ")[1]+" 23:59:59");
+ if (ToolUtil.isNotEmpty(listQuery.getTime())) {
+ wrapper.lt(Competition::getStartTime, listQuery.getTime().split(" - ")[0] + " 00:00:00");
+ wrapper.gt(Competition::getEndTime, listQuery.getTime().split(" - ")[1] + " 23:59:59");
}
-
if(ToolUtil.isNotEmpty(listQuery.getRegisterCondition())){
wrapper.eq(Competition::getRegisterCondition,listQuery.getRegisterCondition());
}
-
+ // 平台查询审核通过的赛事
+ if (listQuery.getObj()==1){
+ wrapper.eq(Competition::getAuditStatus,2);
+ }
+ // 赛事审核
+ if (listQuery.getObj()==-1){
+ wrapper.ne(Competition::getAuditStatus,2);
+ }
wrapper.in(Competition::getStoreId,listQuery.getIds());
- wrapper.eq(Competition::getAuditStatus,2);
wrapper.orderByDesc(Competition::getInsertTime);
-
Page<Competition> page = cttService.page(competitionPage, wrapper);
for (Competition record : page.getRecords()) {
-
// 查询当前赛事有多少人报名了
List<UserCompetition> competitionId = ucttService.list(new QueryWrapper<UserCompetition>()
.eq("competitionId", record.getId()));
// 报名数量
int temp = competitionId.size();
String value = String.valueOf(temp);
- record.setCount(record.getApplicantsNumber()+"-"+value);
+ record.setCount(record.getApplicantsNumber() + "-" + value);
}
return page;
- }catch (Exception e){
+ } catch (Exception e) {
e.printStackTrace();
return new Page<Competition>();
}
}
+
@PostMapping("/base/competition/listAudit")
- public Page<Competition> listAudit(@RequestBody ListQuery listQuery){
+ public Page<Competition> listAudit(@RequestBody ListQuery listQuery) {
try {
- Page<Competition> competitionPage = new Page<>(listQuery.getOffset(),listQuery.getLimit());
+ Page<Competition> competitionPage = new Page<>(listQuery.getOffset(), listQuery.getLimit());
LambdaQueryWrapper<Competition> wrapper = new LambdaQueryWrapper<>();
- if(ToolUtil.isNotEmpty(listQuery.getProvinceCode())){
- wrapper.eq(Competition::getProvinceCode,listQuery.getProvinceCode());
+ if (ToolUtil.isNotEmpty(listQuery.getProvinceCode())) {
+ wrapper.eq(Competition::getProvinceCode, listQuery.getProvinceCode());
}
- if(ToolUtil.isNotEmpty(listQuery.getCityCode())){
- wrapper.eq(Competition::getCityCode,listQuery.getCityCode());
+ if (ToolUtil.isNotEmpty(listQuery.getCityCode())) {
+ wrapper.eq(Competition::getCityCode, listQuery.getCityCode());
}
- if(ToolUtil.isNotEmpty(listQuery.getEventName())){
- wrapper.like(Competition::getName,listQuery.getEventName());
+ if (ToolUtil.isNotEmpty(listQuery.getEventName())) {
+ wrapper.like(Competition::getName, listQuery.getEventName());
}
- if(ToolUtil.isNotEmpty(listQuery.getState())){
- wrapper.eq(Competition::getAuditStatus,listQuery.getState());
+ if (ToolUtil.isNotEmpty(listQuery.getState())) {
+ wrapper.eq(Competition::getAuditStatus, listQuery.getState());
}
- if(ToolUtil.isNotEmpty(listQuery.getRegisterCondition())){
- wrapper.eq(Competition::getRegisterCondition,listQuery.getRegisterCondition());
+ if (ToolUtil.isNotEmpty(listQuery.getRegisterCondition())) {
+ wrapper.eq(Competition::getRegisterCondition, listQuery.getRegisterCondition());
}
- wrapper.in(Competition::getStoreId,listQuery.getIds());
+ wrapper.in(Competition::getStoreId, listQuery.getIds());
ArrayList<Integer> integers = new ArrayList<>();
integers.add(1);
integers.add(3);
- wrapper.in(Competition::getAuditStatus,integers);
+ wrapper.in(Competition::getAuditStatus, integers);
wrapper.orderByDesc(Competition::getInsertTime);
Page<Competition> page = cttService.page(competitionPage, wrapper);
return page;
- }catch (Exception e){
+ } catch (Exception e) {
e.printStackTrace();
return new Page<Competition>();
}
@@ -663,116 +824,268 @@
@PostMapping("/base/competition/add")
- public void add(@RequestBody Competition competition){
+ public void add(@RequestBody Competition competition) {
try {
- if (competition.getStartTime().after(new Date())){
+ if (competition.getStartTime().after(new Date())) {
competition.setStatus(1);
}
- if (competition.getStartTime().before(new Date())){
- if (competition.getEndTime().after(new Date())){
+ if (competition.getStartTime().before(new Date())) {
+ if (competition.getEndTime().after(new Date())) {
competition.setStatus(2);
- }else{
+ } else {
competition.setStatus(3);
+ }
+
+ if(competition.getStatus() == 2){
+ //添加勋章数据
+ List<PaymentCompetition> list = paymentCompetitionService.list(new QueryWrapper<PaymentCompetition>()
+ .eq("competitionId", competition.getId()).eq("payStatus", 2).eq("state", 1));
+ Set<Integer> collect = list.stream().map(PaymentCompetition::getAppUserId).collect(Collectors.toSet());
+ for (Integer integer : collect) {
+ int count = paymentCompetitionService.count(new QueryWrapper<PaymentCompetition>()
+ .eq("appUserId", integer).eq("payStatus", 2).eq("state", 1));
+ StudentHonor studentHonor = new StudentHonor();
+ studentHonor.setAppUserId(integer);
+ studentHonor.setHonorType(2);
+ studentHonor.setNumber(count);
+ studentHonorClient.saveStudentHonor(studentHonor);
+ }
}
}
competition.setInsertTime(new Date());
cttService.save(competition);
- }catch (Exception e){
+
+
+ } catch (Exception e) {
e.printStackTrace();
}
}
@PostMapping("/base/competition/update")
- public void update(@RequestBody Competition competition){
+ public void update(@RequestBody Competition competition) {
try {
- if (competition.getStartTime().after(new Date())){
+ if (competition.getStartTime().after(new Date())) {
competition.setStatus(1);
}
- if (competition.getStartTime().before(new Date())){
- if (competition.getEndTime().after(new Date())){
+ if (competition.getStartTime().before(new Date())) {
+ if (competition.getEndTime().after(new Date())) {
competition.setStatus(2);
- }else{
+ } else {
competition.setStatus(3);
+ }
+
+ if(competition.getStatus() == 2){
+ //添加勋章数据
+ List<PaymentCompetition> list = paymentCompetitionService.list(new QueryWrapper<PaymentCompetition>()
+ .eq("competitionId", competition.getId()).eq("payStatus", 2).eq("state", 1));
+ Set<Integer> collect = list.stream().map(PaymentCompetition::getAppUserId).collect(Collectors.toSet());
+ for (Integer integer : collect) {
+ int count = paymentCompetitionService.count(new QueryWrapper<PaymentCompetition>()
+ .eq("appUserId", integer).eq("payStatus", 2).eq("state", 1));
+ StudentHonor studentHonor = new StudentHonor();
+ studentHonor.setAppUserId(integer);
+ studentHonor.setHonorType(2);
+ studentHonor.setNumber(count);
+ studentHonorClient.saveStudentHonor(studentHonor);
+ }
}
}
cttService.updateById(competition);
- }catch (Exception e){
+
+
+ } catch (Exception e) {
e.printStackTrace();
}
}
+ @Resource
+ private StoreClient storeClient;
+
+ @Autowired
+ private UserCompetitionService userCompetitionService;
+
+
@PostMapping("/base/competition/cancel")
- public void cancel(@RequestBody Integer id){
+ public void cancel(@RequestBody Integer id) {
try {
Competition byId = cttService.getById(id);
byId.setStatus(4);
cttService.updateById(byId);
- }catch (Exception e){
+ List<PaymentCompetition> list = paymentCompetitionService.list(new QueryWrapper<PaymentCompetition>().eq("competitionId", byId.getId()).eq("payStatus", 2));
+ for (PaymentCompetition pay : list) {
+ PaymentCompetition paymentCompetition = pay;
+
+ String code = paymentCompetition.getCode();
+ Double amount = paymentCompetition.getAmount();
+ Competition competition = competitionService.getById(paymentCompetition.getCompetitionId());
+ Store store = storeClient.queryStoreById(Integer.valueOf(competition.getStoreId().split(",")[0]));
+ String payOrderNo = paymentCompetition.getPayOrderNo();
+ if (paymentCompetition.getPayType() == 1) {//微信支付
+ if (store.getOperatorId()!=null && store.getOperatorId()!=0){
+ String smidVx= storeClient.getmerchantNumberByOperatorId(store.getOperatorId());
+ if (!StringUtils.hasLength(smidVx)){
+ System.err.println("运营商未配置微信商户号,获取支付失败!");
+ }
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
+ String codeRefund = sdf.format(new Date()) + UUIDUtil.getNumberRandom(5);// 退款单号
+ // 运营商退款
+ payMoneyUtil.weixinRefundV3(smidVx, codeRefund, pay.getPayOrderNo(), pay.getAmount().toString(), "/base/competition/weChatCancelPaymentCompetitionCallback1");
+ }else {
+ Map<String, String> map = payMoneyUtil.wxRefund(payOrderNo, code, amount.toString(), amount.toString(),
+ "/base/competition/weChatCancelPaymentCompetitionCallback");
+ String return_code = map.get("return_code");
+ if (!"SUCCESS".equals(return_code)) {
+// return ResultUtil.error(map.get("return_msg"));
+ continue;
+ }
+ String refund_id = map.get("refund_id");
+ paymentCompetition.setRefundOrderNo(refund_id);
+ paymentCompetition.setAppUserId(null);
+ paymentCompetitionService.updateById(paymentCompetition);
+ storeClient.addBackRecord(paymentCompetition.getAmount() + "_" + paymentCompetition.getAppUserId());
+ }
+ }
+ if (paymentCompetition.getPayType() == 2) {//支付宝支付
+ Map<String, String> map = payMoneyUtil.aliRefund(payOrderNo, amount.toString());
+ String return_code = map.get("code");
+ if (!"10000".equals(return_code)) {
+// return ResultUtil.error(map.get("msg"));
+ continue;
+ }
+ String refund_id = map.get("trade_no");
+ paymentCompetition.setRefundOrderNo(refund_id);
+ paymentCompetition.setRefundTime(new Date());
+ paymentCompetition.setPayStatus(3);
+ paymentCompetition.setAppUserId(null);
+ paymentCompetitionService.updateById(paymentCompetition);
+
+// competition.setApplicantsNumber(competition.getApplicantsNumber() - 1);
+ competitionService.updateById(competition);
+ }
+ if (paymentCompetition.getPayType() == 3) {//玩湃币支付
+ AppUser appUser = appUserClient.queryAppUser(paymentCompetition.getAppUserId());
+ appUser.setPlayPaiCoins(appUser.getPlayPaiCoins() + amount.intValue());
+ appUserClient.updateAppUser(appUser);
+
+ paymentCompetition.setRefundOrderNo("");
+ paymentCompetition.setRefundTime(new Date());
+ paymentCompetition.setPayStatus(3);
+ paymentCompetition.setAppUserId(null);
+ paymentCompetitionService.updateById(paymentCompetition);
+
+// competition.setApplicantsNumber(competition.getApplicantsNumber() - 1);
+ competitionService.updateById(competition);
+ }
+ if (paymentCompetition.getPayType() == 4) {//课程支付
+ List<UserCompetition> list1 = userCompetitionService.list(new QueryWrapper<UserCompetition>().eq("paymentCompetitionId", paymentCompetition.getId()));
+ for (UserCompetition userCompetition : list1) {
+// Participant participant = participantService.getById(userCompetition.getId());
+// Student student = studentClient.queryStudentByPhone(participant.getPhone());
+ PaymentDeductionClassHour paymentDeductionClassHour = new PaymentDeductionClassHour();
+ paymentDeductionClassHour.setId(userCompetition.getParticipantId());
+ paymentDeductionClassHour.setClassHour(competition.getClassPrice());
+ paymentDeductionClassHour.setCode(code);
+ coursePackagePaymentClient.rollbackPaymentDeductionClassHour(paymentDeductionClassHour);
+ }
+
+ paymentCompetition.setRefundOrderNo("");
+ paymentCompetition.setRefundTime(new Date());
+ paymentCompetition.setPayStatus(3);
+ paymentCompetition.setAppUserId(null);
+ paymentCompetitionService.updateById(paymentCompetition);
+
+// competition.setApplicantsNumber(competition.getApplicantsNumber() - 1);
+ competitionService.updateById(competition);
+ }
+
+
+ }
+
+ } catch (Exception e) {
e.printStackTrace();
}
}
@PostMapping("/base/competition/getPeopleFromId")
- public Page<CompetitionUser> getPeopleFromId(@RequestBody GetPeopleQuery getPeopleQuery){
+ public Page<CompetitionUser> getPeopleFromId(@RequestBody GetPeopleQuery getPeopleQuery) {
try {
- Page<UserCompetition> participantPage = new Page<>(getPeopleQuery.getOffset(),getPeopleQuery.getLimit());
- Page<CompetitionUser> page = participantService.getPeopleFromId(participantPage,getPeopleQuery.getId(),getPeopleQuery.getState());
+ Page<UserCompetition> participantPage = new Page<>(getPeopleQuery.getOffset(), getPeopleQuery.getLimit());
+ Page<CompetitionUser> page = participantService.getPeopleFromId(participantPage, getPeopleQuery.getId(), getPeopleQuery.getState());
return page;
- }catch (Exception e){
+ } catch (Exception e) {
e.printStackTrace();
return null;
}
}
+
+ @Resource
+ private StudentClient studentClient;
+ @PostMapping("/base/competition/getPeopleFromId1")
+ public Page<CompetitionUser> getPeopleFromId1(@RequestBody GetPeopleQuery getPeopleQuery) {
+ try {
+ Page<CompetitionUser> page = participantService.getPeopleFromId1(getPeopleQuery.getOffset(), getPeopleQuery.getLimit(), getPeopleQuery.getId(), getPeopleQuery.getState());
+ return page;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
@PostMapping("/base/competition/getPeoples")
@ResponseBody
- public List<CompetitionUser> getPeoples(@RequestBody GetPeopleQuery getPeopleQuery){
+ public List<CompetitionUser> getPeoples(@RequestBody GetPeopleQuery getPeopleQuery) {
List<CompetitionUser> list = participantService.getPeoples(
- getPeopleQuery.getId(),getPeopleQuery.getState());
+ getPeopleQuery.getId(), getPeopleQuery.getState());
return list;
}
-
@PostMapping("/base/competition/queryFee")
- public Double queryFee(@RequestBody QueryDataFee queryDataFee){
+ public Double queryFee(@RequestBody QueryDataFee queryDataFee) {
HashMap<String, Object> map = new HashMap<>();
String data = queryDataFee.getData();
List<Integer> ids = queryDataFee.getIds();
- if(ids.size()==0){
+ if (ids.size() == 0) {
ids.add(-1);
+ }else{
+ List<Competition> list1 = competitionService.list(new QueryWrapper<Competition>().in("storeId", ids).eq("auditStatus", 2).eq("state", 1).ne("status", 4));
+ ids = list1.stream().map(Competition::getId).collect(Collectors.toList());
+ if (ids.size() == 0) {
+ ids.add(-1);
+ }
}
+
LambdaQueryWrapper<PaymentCompetition> vipPaymentLambdaQueryWrapper = new LambdaQueryWrapper<>();
- if(ToolUtil.isNotEmpty(data)){
- String stime = data.split(" - ")[0]+" 00:00:00";
- String etime = data.split(" - ")[1]+" 23:59:59";
- vipPaymentLambdaQueryWrapper.between(PaymentCompetition::getInsertTime,stime,etime);
+ if (ToolUtil.isNotEmpty(data)) {
+ String stime = data.split(" - ")[0] + " 00:00:00";
+ String etime = data.split(" - ")[1] + " 23:59:59";
+ vipPaymentLambdaQueryWrapper.between(PaymentCompetition::getInsertTime, stime, etime);
}
- vipPaymentLambdaQueryWrapper.in(PaymentCompetition::getAppUserId,ids);
- vipPaymentLambdaQueryWrapper.eq(PaymentCompetition::getPayStatus,2);
+ vipPaymentLambdaQueryWrapper.in(PaymentCompetition::getCompetitionId, ids);
+ vipPaymentLambdaQueryWrapper.eq(PaymentCompetition::getPayStatus, 2);
ArrayList<Integer> objects = new ArrayList<>();
objects.add(1);
objects.add(2);
- vipPaymentLambdaQueryWrapper.in(PaymentCompetition::getPayType,objects);
+ vipPaymentLambdaQueryWrapper.in(PaymentCompetition::getPayType, objects);
List<PaymentCompetition> list = paymentCompetitionService.list(vipPaymentLambdaQueryWrapper);
double sum = list.stream().mapToDouble(PaymentCompetition::getAmount).sum();
return sum;
}
-
@ResponseBody
@PostMapping("/base/competition/actPt")
- public HashMap<String, Object> actPt(@RequestBody List<Integer> ids){
+ public HashMap<String, Object> actPt(@RequestBody List<Integer> ids) {
HashMap<String, Object> map = new HashMap<>();
- if(ids.size()==0){
+ if (ids.size() == 0) {
ids.add(-1);
}
ArrayList<Object> integers = new ArrayList<>();
int year = DateUtil.year(new Date());
for (int i = 0; i < 10; i++) {
- integers.add(year-i);
+ integers.add(year - i);
}
List<Object> collect = integers.stream().sorted().collect(Collectors.toList());
// 年
@@ -781,49 +1094,49 @@
for (Object o : collect) {
String s = o.toString();
int count = cttService.count(new LambdaQueryWrapper<Competition>().like(Competition::getInsertTime, s));
- int count1 = ucttService.count(new LambdaQueryWrapper<UserCompetition>().in(UserCompetition::getAppUserId, ids).like(UserCompetition::getInsertTime,s));
+ int count1 = ucttService.count(new LambdaQueryWrapper<UserCompetition>().in(UserCompetition::getAppUserId, ids).like(UserCompetition::getInsertTime, s));
years.add(count);
yearsUser.add(count1);
}
- map.put("yearData",years);
- map.put("yearsUser",yearsUser);
+ map.put("yearData", years);
+ map.put("yearsUser", yearsUser);
// 月
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
ArrayList<Integer> months = new ArrayList<>();
ArrayList<Integer> monthsUser = new ArrayList<>();
for (int i = 1; i <= 12; i++) {
- double sum=0.0;
- String m=i+"";
- if(i<10){
- m="0"+i;
+ double sum = 0.0;
+ String m = i + "";
+ if (i < 10) {
+ m = "0" + i;
}
String s = year + "-" + m;
int count = cttService.count(new LambdaQueryWrapper<Competition>().like(Competition::getInsertTime, s));
- int count1 = ucttService.count(new LambdaQueryWrapper<UserCompetition>().in(UserCompetition::getAppUserId, ids).like(UserCompetition::getInsertTime,s));
+ int count1 = ucttService.count(new LambdaQueryWrapper<UserCompetition>().in(UserCompetition::getAppUserId, ids).like(UserCompetition::getInsertTime, s));
months.add(count);
monthsUser.add(count1);
}
- map.put("monthData",months);
- map.put("monthsUser",monthsUser);
+ map.put("monthData", months);
+ map.put("monthsUser", monthsUser);
return map;
-
}
+
@ResponseBody
@PostMapping("/base/competition/actYys")
- public HashMap<String, Object> actYys(@RequestBody CompetionVO vo){
+ public HashMap<String, Object> actYys(@RequestBody CompetionVO vo) {
HashMap<String, Object> map = new HashMap<>();
- if(vo.getIds().size()==0){
+ if (vo.getIds().size() == 0) {
vo.getIds().add(-1);
}
ArrayList<Object> integers = new ArrayList<>();
int year = DateUtil.year(new Date());
for (int i = 0; i < 10; i++) {
- integers.add(year-i);
+ integers.add(year - i);
}
List<Object> collect = integers.stream().sorted().collect(Collectors.toList());
// 年
@@ -834,35 +1147,47 @@
.stream().map(Competition::getId).collect(Collectors.toList());
for (Object o : collect) {
String s = o.toString();
- int count = cttService.count(new LambdaQueryWrapper<Competition>().like(Competition::getInsertTime, s).eq(Competition::getOperatorId,vo.getOperatorId()));
- int count1 = ucttService.count(new LambdaQueryWrapper<UserCompetition>().in(UserCompetition::getAppUserId, vo.getIds()).like(UserCompetition::getInsertTime,s));
+ int count = cttService.count(new LambdaQueryWrapper<Competition>().like(Competition::getInsertTime, s).eq(Competition::getOperatorId, vo.getOperatorId()));
+ int count1 = ucttService.count(new LambdaQueryWrapper<UserCompetition>().in(UserCompetition::getAppUserId, vo.getIds()).like(UserCompetition::getInsertTime, s));
years.add(count);
yearsUser.add(count1);
}
- map.put("yearData",years);
- map.put("yearsUser",yearsUser);
+ map.put("yearData", years);
+ map.put("yearsUser", yearsUser);
// 月
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
ArrayList<Integer> months = new ArrayList<>();
ArrayList<Integer> monthsUser = new ArrayList<>();
for (int i = 1; i <= 12; i++) {
- double sum=0.0;
- String m=i+"";
- if(i<10){
- m="0"+i;
+ double sum = 0.0;
+ String m = i + "";
+ if (i < 10) {
+ m = "0" + i;
}
String s = year + "-" + m;
- int count = cttService.count(new LambdaQueryWrapper<Competition>().like(Competition::getInsertTime, s).ne(Competition::getOperatorId,operatorId));
- int count1 = ucttService.count(new LambdaQueryWrapper<UserCompetition>().in(UserCompetition::getAppUserId, vo.getIds()).like(UserCompetition::getInsertTime,s));
+ int count = cttService.count(new LambdaQueryWrapper<Competition>().like(Competition::getInsertTime, s).eq(Competition::getOperatorId, operatorId));
+ int count1 = ucttService.count(new LambdaQueryWrapper<UserCompetition>().in(UserCompetition::getAppUserId, vo.getIds()).like(UserCompetition::getInsertTime, s));
months.add(count);
monthsUser.add(count1);
}
- map.put("monthData",months);
- map.put("monthsUser",monthsUser);
+ map.put("monthData", months);
+ map.put("monthsUser", monthsUser);
return map;
}
+
+ @ResponseBody
+ @PostMapping("/base/competition/queryAppUserId")
+ public List<Integer> queryAppUserId(@RequestBody List<Integer> storeIds){
+ List<Competition> list = competitionService.list(new QueryWrapper<Competition>().in("storeId", storeIds).eq("auditStatus", 2).eq("state", 1));
+ List<Integer> collect = list.stream().map(Competition::getId).collect(Collectors.toList());
+ if(collect.size() == 0){
+ return new ArrayList<>();
+ }
+ List<PaymentCompetition> list1 = paymentCompetitionService.list(new QueryWrapper<PaymentCompetition>().eq("payStatus", 2).eq("state", 1).in("competitionId", collect));
+ return list1.stream().map(PaymentCompetition::getAppUserId).collect(Collectors.toList());
+ }
}
--
Gitblit v1.7.1