From a8f90f717c73d7ff4d2355649f9f161a6f89aa9b Mon Sep 17 00:00:00 2001 From: puzhibing <393733352@qq.com> Date: 星期二, 05 三月 2024 14:08:15 +0800 Subject: [PATCH] 新增加管理后台功能 --- cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupServiceImpl.java | 170 +++++++++++++- cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/feignclient/other/GameClient.java | 21 + cloud-server-course/src/main/java/com/dsh/course/controller/CoursePackageOrderStudentController.java | 13 + cloud-server-course/src/main/java/com/dsh/course/model/DeductionClassHour.java | 4 cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/feignclient/course/CoursePackageOrderStudentClient.java | 11 cloud-server-communityWorldCup/src/main/resources/mapper/WorldCupPaymentParticipantMapper.xml | 4 cloud-server-other/src/main/java/com/dsh/other/controller/GameController.java | 16 + cloud-server-course/src/main/java/com/dsh/course/service/ICoursePackageOrderStudentService.java | 9 cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/model/DeductionClassHour.java | 4 cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/controller/WorldCupController.java | 55 +++ cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/feignclient/other/model/TGame.java | 91 +++++++ cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/entity/WorldCupPaymentParticipant.java | 14 + cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/util/HttpRequestUtil.java | 246 ++++++++++++++++++++ cloud-server-course/src/main/java/com/dsh/course/service/impl/CoursePackageOrderStudentServiceImpl.java | 28 ++ 14 files changed, 652 insertions(+), 34 deletions(-) diff --git a/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/controller/WorldCupController.java b/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/controller/WorldCupController.java index a768280..19e0f8b 100644 --- a/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/controller/WorldCupController.java +++ b/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/controller/WorldCupController.java @@ -3,10 +3,7 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.dsh.communityWorldCup.entity.WorldCup; -import com.dsh.communityWorldCup.entity.WorldCupCompetitor; -import com.dsh.communityWorldCup.entity.WorldCupPaymentParticipant; -import com.dsh.communityWorldCup.entity.WorldCupStore; +import com.dsh.communityWorldCup.entity.*; import com.dsh.communityWorldCup.feignclient.account.AppUserClient; import com.dsh.communityWorldCup.feignclient.account.StudentClient; import com.dsh.communityWorldCup.feignclient.account.model.AppUser; @@ -18,10 +15,7 @@ import com.dsh.communityWorldCup.feignclient.other.model.Site; import com.dsh.communityWorldCup.feignclient.other.model.Store; import com.dsh.communityWorldCup.model.*; -import com.dsh.communityWorldCup.service.IWorldCupCompetitorService; -import com.dsh.communityWorldCup.service.IWorldCupPaymentParticipantService; -import com.dsh.communityWorldCup.service.IWorldCupService; -import com.dsh.communityWorldCup.service.IWorldCupStoreService; +import com.dsh.communityWorldCup.service.*; import com.dsh.communityWorldCup.util.GDMapGeocodingUtil; import com.dsh.communityWorldCup.util.PayMoneyUtil; import com.dsh.communityWorldCup.util.ResultUtil; @@ -38,6 +32,7 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.io.IOException; import java.io.PrintWriter; import java.text.SimpleDateFormat; import java.util.*; @@ -92,6 +87,9 @@ @Autowired private GDMapGeocodingUtil gdMapGeocodingUtil; + + @Autowired + private IWorldCupPaymentService worldCupPaymentService; @@ -628,4 +626,45 @@ public void cancelWorldCupRefund(@RequestBody Integer id){ worldCupService.cancelWorldCupRefund(id); } + + + /** + * 游戏结束后的通知回调 + */ + @ResponseBody + @PostMapping("/base/worldCup/endWorldCupCallback") + public void endWorldCupCallback(){ + + } + + + /** + * 取消赛事后微信退款回调 + * @param request + * @param response + */ + @ResponseBody + @PostMapping("/base/worldCup/wxRefundWorldCupCallback") + public void wxRefundWorldCupCallback(HttpServletRequest request, HttpServletResponse response){ + Map<String, String> map = payMoneyUtil.wxRefundCallback(request); + if(null != map){ + String refund_id = map.get("refund_id"); + String out_refund_no = map.get("out_refund_no"); + String result = map.get("result"); + WorldCupPayment worldCupPayment = worldCupPaymentService.getOne(new QueryWrapper<WorldCupPayment>().eq("code", out_refund_no)); + worldCupPayment.setRefundOrderNo(refund_id); + worldCupPayment.setRefundTime(new Date()); + worldCupPayment.setPayStatus(3); + worldCupPaymentService.updateById(worldCupPayment); + PrintWriter out = null; + try { + out = response.getWriter(); + } catch (IOException e) { + throw new RuntimeException(e); + } + out.println(result); + out.flush(); + out.close(); + } + } } diff --git a/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/entity/WorldCupPaymentParticipant.java b/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/entity/WorldCupPaymentParticipant.java index 0f82011..cb5f491 100644 --- a/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/entity/WorldCupPaymentParticipant.java +++ b/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/entity/WorldCupPaymentParticipant.java @@ -4,7 +4,10 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; + +import java.util.Date; /** * @author zhibing.pu @@ -48,4 +51,15 @@ */ @TableField("alreadyEntered") private Integer alreadyEntered; + /** + * 添加时间 + */ + @TableField("createTime") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date createTime; + /** + * 课时支付存储的数据 + */ + @TableField("content") + private String content; } diff --git a/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/feignclient/course/CoursePackageOrderStudentClient.java b/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/feignclient/course/CoursePackageOrderStudentClient.java index 6b3c584..7f5c974 100644 --- a/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/feignclient/course/CoursePackageOrderStudentClient.java +++ b/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/feignclient/course/CoursePackageOrderStudentClient.java @@ -30,5 +30,14 @@ * @param deductionClassHourList */ @PostMapping("/coursePackageOrderStudent/deductionClassHour") - boolean deductionClassHour(DeductionClassHourList deductionClassHourList); + DeductionClassHourList deductionClassHour(DeductionClassHourList deductionClassHourList); + + + /** + * 回退课时后添加排课记录 + * @param deductionClassHourList + */ + @PostMapping("/coursePackageOrderStudent/backspaceClassHour") + void backspaceClassHour(DeductionClassHourList deductionClassHourList); + } diff --git a/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/feignclient/other/GameClient.java b/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/feignclient/other/GameClient.java new file mode 100644 index 0000000..33aef39 --- /dev/null +++ b/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/feignclient/other/GameClient.java @@ -0,0 +1,21 @@ +package com.dsh.communityWorldCup.feignclient.other; + +import com.dsh.communityWorldCup.feignclient.other.model.TGame; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; + +/** + * @author zhibing.pu + * @Date 2024/3/5 10:39 + */ +@FeignClient("mb-cloud-other") +public interface GameClient { + + /** + * 根据suduid获取游戏数据 + * @param sutuId + * @return + */ + @PostMapping("/api/game/getTGameBySutuId") + TGame getTGameBySutuId(String sutuId); +} diff --git a/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/feignclient/other/model/TGame.java b/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/feignclient/other/model/TGame.java new file mode 100644 index 0000000..b701e90 --- /dev/null +++ b/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/feignclient/other/model/TGame.java @@ -0,0 +1,91 @@ +package com.dsh.communityWorldCup.feignclient.other.model; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +/** + * <p> + * 智慧球场 + * </p> + * + * @author administrator + * @since 2023-09-18 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("t_game") +public class TGame extends Model<TGame> { + + private static final long serialVersionUID = 1L; + + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + /** + * 运营商id 0为平台 + */ + @TableField("operationId") + private Integer operationId; + + /** + * 省 + */ + private String province; + + /** + * 省code + */ + @TableField("provinceCode") + private String provinceCode; + + /** + * 市 + */ + private String city; + + /** + * 市code + */ + @TableField("cityCode") + private String cityCode; + + /** + * 门店id + */ + @TableField("storeId") + private Integer storeId; + + /** + * 场地id + */ + @TableField("siteId") + private Integer siteId; + + /** + * 蓝色方id + */ + private String blue; + + /** + * 红方id + */ + private String red; + + private Integer state; + + + @Override + protected Serializable pkVal() { + return this.id; + } + +} diff --git a/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/model/DeductionClassHour.java b/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/model/DeductionClassHour.java index 2ddf410..c2b0807 100644 --- a/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/model/DeductionClassHour.java +++ b/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/model/DeductionClassHour.java @@ -24,4 +24,8 @@ * 扣减课时 */ private Integer classHour; + /** + * 删除的排课数量(用户回退时重新排课) + */ + private Integer scheduledCourses; } diff --git a/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupServiceImpl.java b/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupServiceImpl.java index 5dbd7e5..30e792b 100644 --- a/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupServiceImpl.java +++ b/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupServiceImpl.java @@ -3,6 +3,7 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.alipay.api.AlipayApiException; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.dsh.communityWorldCup.entity.*; @@ -14,8 +15,10 @@ import com.dsh.communityWorldCup.feignclient.competition.model.Participant; import com.dsh.communityWorldCup.feignclient.course.CoursePackageOrderStudentClient; import com.dsh.communityWorldCup.feignclient.course.model.CoursePackageOrderStudent; +import com.dsh.communityWorldCup.feignclient.other.GameClient; import com.dsh.communityWorldCup.feignclient.other.StoreClient; import com.dsh.communityWorldCup.feignclient.other.model.Store; +import com.dsh.communityWorldCup.feignclient.other.model.TGame; import com.dsh.communityWorldCup.mapper.WorldCupMapper; import com.dsh.communityWorldCup.model.*; import com.dsh.communityWorldCup.service.*; @@ -67,6 +70,9 @@ @Resource private CoursePackageOrderStudentClient coursePackageOrderStudentClient; + @Resource + private GameClient gameClient; + @@ -110,9 +116,19 @@ if(worldCup.getStatus() == 4){ return ResultUtil.error("赛事已取消"); } + //1、通过扫码获取的sutuid查询t_game表中的红蓝方sutuid + String code = startWorldCup.getCode(); + JSONObject object = JSON.parseObject(code); + String sutu_id = object.getString("sutu_id"); + TGame tGame = gameClient.getTGameBySutuId(sutu_id); + if(null == tGame){ + return ResultUtil.error("无效的游戏二维码"); + } + String people = startWorldCup.getPeople(); JSONArray jsonArray = JSON.parseArray(people); String timeStr = UUIDUtil.getTimeStr() + UUIDUtil.getNumberRandom(3); + List<Long> ids = new ArrayList<>(); for (int i = 0; i < jsonArray.size(); i++) { JSONObject jsonObject = jsonArray.getJSONObject(i); Integer id = jsonObject.getInteger("id"); @@ -128,17 +144,29 @@ worldCupCompetitor.setParticipant("blue".equals(type) ? 1 : 2); worldCupCompetitor.setStartTime(new Date()); worldCupCompetitorService.save(worldCupCompetitor); - - - + ids.add(worldCupCompetitor.getId()); + //已参赛 + worldCupPaymentParticipant.setAlreadyEntered(1); + worldCupPaymentParticipantService.updateById(worldCupPaymentParticipant); } - //调接口开启游戏 - /** - * 1、通过扫码获取的sutuid查询t_game表中的红蓝方sutuid - * 2、调起开启游戏的接口。 - */ + //2、调起开启游戏的接口。 + HashMap<String, String> map = new HashMap<>(); + map.put("sign", "0DB011836143EEE2C2E072967C9F4E4B"); + map.put("space_id", tGame.getSiteId() + ""); + map.put("red_sutu_id", tGame.getRed()); + map.put("blue_sutu_id", tGame.getBlue()); + map.put("api_url", "http://221.182.45.100:56666/communityWorldCup/base/worldCup/endWorldCupCallback"); + map.put("custom", JSON.toJSONString(ids)); - return ResultUtil.success(); + String s = HttpRequestUtil.postRequest("https://try.daowepark.com/v7/user_api/general/batterGame", map); + JSONObject jsonObject = JSONObject.parseObject(s); + Integer code1 = jsonObject.getInteger("code"); + String message = jsonObject.getString("message"); + if (200 == code1) { + return ResultUtil.success(); + } else { + return ResultUtil.error(message); + } } @@ -432,6 +460,8 @@ worldCupPaymentParticipant.setAppUserId(paymentWorldCup.getUid()); worldCupPaymentParticipant.setParticipantType(isStudent == 0 ? 2 : 1); worldCupPaymentParticipant.setParticipantId(id); + worldCupPaymentParticipant.setAlreadyEntered(0); + worldCupPaymentParticipant.setCreateTime(new Date()); worldCupPaymentParticipantService.save(worldCupPaymentParticipant); } return ResultUtil.success(); @@ -480,12 +510,24 @@ break; } } - } - //扣减课时操作 - DeductionClassHourList deductionClassHourList = new DeductionClassHourList(); - deductionClassHourList.setDeductionClassHourList(list); - coursePackageOrderStudentClient.deductionClassHour(deductionClassHourList); + //扣减课时操作 + DeductionClassHourList deductionClassHourList = new DeductionClassHourList(); + deductionClassHourList.setDeductionClassHourList(list); + DeductionClassHourList deductionClassHourList1 = coursePackageOrderStudentClient.deductionClassHour(deductionClassHourList); + List<DeductionClassHour> deductionClassHourList2 = deductionClassHourList1.getDeductionClassHourList(); + + WorldCupPaymentParticipant worldCupPaymentParticipant = new WorldCupPaymentParticipant(); + worldCupPaymentParticipant.setWorldCupId(paymentWorldCup.getId()); + worldCupPaymentParticipant.setWorldCupPaymentId(worldCupPayment.getId()); + worldCupPaymentParticipant.setAppUserId(paymentWorldCup.getUid()); + worldCupPaymentParticipant.setParticipantType(isStudent == 0 ? 2 : 1); + worldCupPaymentParticipant.setParticipantId(id); + worldCupPaymentParticipant.setAlreadyEntered(0); + worldCupPaymentParticipant.setCreateTime(new Date()); + worldCupPaymentParticipant.setContent(JSON.toJSONString(deductionClassHourList2)); + worldCupPaymentParticipantService.save(worldCupPaymentParticipant); + } worldCupPayment.setAmount(multiply); worldCupPayment.setPayStatus(2); @@ -517,6 +559,8 @@ worldCupPaymentParticipant.setAppUserId(paymentWorldCup.getUid()); worldCupPaymentParticipant.setParticipantType(isStudent == 0 ? 2 : 1); worldCupPaymentParticipant.setParticipantId(id); + worldCupPaymentParticipant.setAlreadyEntered(0); + worldCupPaymentParticipant.setCreateTime(new Date()); worldCupPaymentParticipantService.save(worldCupPaymentParticipant); } return ResultUtil.success(); @@ -553,6 +597,8 @@ worldCupPaymentParticipant.setAppUserId(worldCupPayment.getAppUserId()); worldCupPaymentParticipant.setParticipantType(isStudent == 0 ? 2 : 1); worldCupPaymentParticipant.setParticipantId(id); + worldCupPaymentParticipant.setAlreadyEntered(0); + worldCupPaymentParticipant.setCreateTime(new Date()); worldCupPaymentParticipantService.save(worldCupPaymentParticipant); } return ResultUtil.success(); @@ -565,6 +611,102 @@ */ @Override public void cancelWorldCupRefund(Integer id) { + List<WorldCupPaymentParticipant> list = worldCupPaymentParticipantService.list(new QueryWrapper<WorldCupPaymentParticipant>() + .eq("worldCupId", id).eq("alreadyEntered", 0)); + Set<Long> collect = list.stream().map(WorldCupPaymentParticipant::getWorldCupPaymentId).collect(Collectors.toSet()); + for (Long worldCupPaymentId : collect) { + + List<WorldCupPaymentParticipant> list1 = worldCupPaymentParticipantService.list(new QueryWrapper<WorldCupPaymentParticipant>() + .eq("worldCupPaymentId", worldCupPaymentId).eq("alreadyEntered", 0)); + WorldCupPayment worldCupPayment = worldCupPaymentService.getById(worldCupPaymentId); + BigDecimal multiply = worldCupPayment.getUnitPrice().multiply(new BigDecimal(list1.size())); + //微信支付 + if(worldCupPayment.getPayType() == 1){ + Map<String, String> map = payMoneyUtil.wxRefund(worldCupPayment.getPayOrderNo(), worldCupPayment.getCode(), + worldCupPayment.getAmount().toString(), multiply.toString(), "/base/worldCup/wxRefundWorldCupCallback"); + if(!"SUCCESS".equals(map.get("return_code"))){ + System.err.println("-------------微信退款失败---------"); + System.err.println(map.get("return_msg")); + } + } + //支付宝支付 + if(worldCupPayment.getPayType() == 2){ + Map<String, String> map = null; + try { + map = payMoneyUtil.aliRefund(worldCupPayment.getPayOrderNo(), multiply.toString()); + } catch (AlipayApiException e) { + throw new RuntimeException(e); + } + if("10000".equals(map.get("code"))){ + String trade_no = map.get("trade_no"); + worldCupPayment.setRefundTime(new Date()); + worldCupPayment.setRefundOrderNo(trade_no); + worldCupPayment.setPayStatus(3); + worldCupPaymentService.updateById(worldCupPayment); + } + } + //玩湃币支付 + if(worldCupPayment.getPayType() == 3){ + Integer appUserId = worldCupPayment.getAppUserId(); + AppUser appUser = appUserClient.getAppUser(appUserId); + appUser.setPlayPaiCoins(appUser.getPlayPaiCoins() + multiply.intValue()); + appUserClient.updateAppUser(appUser); + worldCupPayment.setRefundTime(new Date()); + worldCupPayment.setRefundOrderNo(""); + worldCupPayment.setPayStatus(3); + worldCupPaymentService.updateById(worldCupPayment); + }//课时支付 + if(worldCupPayment.getPayType() == 4){ + for (WorldCupPaymentParticipant worldCupPaymentParticipant : list1) { + Integer studentId = worldCupPaymentParticipant.getParticipantId();//构建扣减课时数据 + String content = worldCupPaymentParticipant.getContent(); + List<DeductionClassHour> list2 = JSON.parseArray(content, DeductionClassHour.class); + + + + + +// Integer classHour = worldCup.getClassHour(); +// for (CoursePackageOrderStudent packageOrderStudent : coursePackageOrderStudent) { +// Integer laveClassHours = packageOrderStudent.getLaveClassHours(); +// +// DeductionClassHour deductionClassHour = new DeductionClassHour(); +// if(classHour.compareTo(laveClassHours) > 0){ +// //不够扣除,轮询直到扣除完 +// classHour = classHour - laveClassHours; +// deductionClassHour.setId(packageOrderStudent.getId()); +// deductionClassHour.setClassHour(laveClassHours); +// deductionClassHour.setStudentId(packageOrderStudent.getStudentId()); +// deductionClassHour.setCoursePackageId(packageOrderStudent.getCoursePackageId()); +// list.add(deductionClassHour); +// }else{ +// //够扣除直接跳出进行下个学员 +// deductionClassHour.setId(packageOrderStudent.getId()); +// deductionClassHour.setClassHour(classHour); +// deductionClassHour.setStudentId(packageOrderStudent.getStudentId()); +// deductionClassHour.setCoursePackageId(packageOrderStudent.getCoursePackageId()); +// list.add(deductionClassHour); +// break; +// } +// } + } + + //扣减课时操作 + DeductionClassHourList deductionClassHourList = new DeductionClassHourList(); +// deductionClassHourList.setDeductionClassHourList(list); + coursePackageOrderStudentClient.deductionClassHour(deductionClassHourList); + } + + + } + + + for (WorldCupPaymentParticipant worldCupPaymentParticipant : list) { + + + + + } } } diff --git a/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/util/HttpRequestUtil.java b/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/util/HttpRequestUtil.java new file mode 100644 index 0000000..84a33ec --- /dev/null +++ b/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/util/HttpRequestUtil.java @@ -0,0 +1,246 @@ +package com.dsh.communityWorldCup.util; + +import com.alibaba.fastjson.JSONObject; +import org.apache.commons.httpclient.HttpClient; +import org.apache.commons.httpclient.HttpException; +import org.apache.commons.httpclient.SimpleHttpConnectionManager; +import org.apache.commons.httpclient.methods.GetMethod; +import org.apache.commons.httpclient.methods.PostMethod; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; +import java.security.MessageDigest; +import java.util.Map; + +public class HttpRequestUtil { + + public static String postRequest(String url, Map<String, String> params) { + // 构造HttpClient的实例 + HttpClient httpClient = new HttpClient(); + // 创建POST方法的实例 + PostMethod postMethod = new PostMethod(url); + // 设置请求头信息 + postMethod.setRequestHeader("Connection", "close"); + postMethod.addRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8"); + // 添加参数 + for (Map.Entry<String, String> entry : params.entrySet()) { + postMethod.addParameter(entry.getKey(), entry.getValue()); + } + // 使用系统提供的默认的恢复策略,设置请求重试处理,用的是默认的重试处理:请求三次 + httpClient.getParams().setBooleanParameter("http.protocol.expect-continue", false); + // 接收处理结果 + String result = null; + try { + // 执行Http Post请求 + httpClient.executeMethod(postMethod); + // 返回处理结果 + result = postMethod.getResponseBodyAsString(); + } catch (HttpException e) { + // 发生致命的异常,可能是协议不对或者返回的内容有问题 + System.out.println("请检查输入的URL!"); + e.printStackTrace(); + } catch (IOException e) { + // 发生网络异常 + System.out.println("发生网络异常!"); + e.printStackTrace(); + } finally { + // 释放链接 + postMethod.releaseConnection(); + // 关闭HttpClient实例 + if (httpClient != null) { + ((SimpleHttpConnectionManager) httpClient.getHttpConnectionManager()).shutdown(); + httpClient = null; + } + } + return result; + } + + public static String postRequest1(String url, Map<String, String> params, String appKey, String appSecret) { + // 构造HttpClient的实例 + HttpClient httpClient = new HttpClient(); + // 创建POST方法的实例 + PostMethod postMethod = new PostMethod(url); + // 设置请求头信息 + String nonce = String.valueOf(Double.valueOf(Math.random() * 1000000.0D).intValue()); + String timeMillis = String.valueOf(System.currentTimeMillis()); + String signature = string2Sha1(appSecret + nonce + timeMillis); + postMethod.setRequestHeader("Host", "api-cn.ronghub.com"); + postMethod.setRequestHeader("App-Key", appKey); + postMethod.setRequestHeader("Signature", signature); + postMethod.setRequestHeader("Nonce", nonce); + postMethod.setRequestHeader("Timestamp", timeMillis); + postMethod.setRequestHeader("Host", "api-cn.ronghub.com"); + postMethod.addRequestHeader("Content-Type", "application/json"); + // 添加参数 + for (Map.Entry<String, String> entry : params.entrySet()) { + postMethod.addParameter(entry.getKey(), entry.getValue()); + } + // 使用系统提供的默认的恢复策略,设置请求重试处理,用的是默认的重试处理:请求三次 + httpClient.getParams().setBooleanParameter("http.protocol.expect-continue", false); + // 接收处理结果 + String result = null; + try { + // 执行Http Post请求 + httpClient.executeMethod(postMethod); + // 返回处理结果 + result = postMethod.getResponseBodyAsString(); + } catch (HttpException e) { + // 发生致命的异常,可能是协议不对或者返回的内容有问题 + System.out.println("请检查输入的URL!"); + e.printStackTrace(); + } catch (IOException e) { + // 发生网络异常 + System.out.println("发生网络异常!"); + e.printStackTrace(); + } finally { + // 释放链接 + postMethod.releaseConnection(); + // 关闭HttpClient实例 + if (httpClient != null) { + ((SimpleHttpConnectionManager) httpClient.getHttpConnectionManager()).shutdown(); + httpClient = null; + } + } + return result; + } + + private static String string2Sha1(String str) { + if (str == null || str.length() == 0) { + return null; + } + char hexDigits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + 'a', 'b', 'c', 'd', 'e', 'f'}; + try { + MessageDigest mdTemp = MessageDigest.getInstance("SHA1"); + mdTemp.update(str.getBytes("UTF-8")); + + byte[] md = mdTemp.digest(); + int j = md.length; + char buf[] = new char[j * 2]; + int k = 0; + for (int i = 0; i < j; i++) { + byte byte0 = md[i]; + buf[k++] = hexDigits[byte0 >>> 4 & 0xf]; + buf[k++] = hexDigits[byte0 & 0xf]; + } + return new String(buf); + } catch (Exception e) { + return null; + } + } + + public static String getRequest(String url, Map<String, String> params) { + // 构造HttpClient实例 + HttpClient client = new HttpClient(); + // 拼接参数 + String paramStr = ""; + for (String key : params.keySet()) { + paramStr = paramStr + "&" + key + "=" + params.get(key); + } + paramStr = paramStr.substring(1); + // 创建GET方法的实例 + GetMethod method = new GetMethod(url + "?" + paramStr); + // 接收返回结果 + String result = null; + try { + // 执行HTTP GET方法请求 + client.executeMethod(method); + // 返回处理结果 + result = method.getResponseBodyAsString(); + } catch (HttpException e) { + // 发生致命的异常,可能是协议不对或者返回的内容有问题 + System.out.println("请检查输入的URL!"); + e.printStackTrace(); + } catch (IOException e) { + // 发生网络异常 + System.out.println("发生网络异常!"); + e.printStackTrace(); + } finally { + // 释放链接 + method.releaseConnection(); + // 关闭HttpClient实例 + if (client != null) { + ((SimpleHttpConnectionManager) client + .getHttpConnectionManager()).shutdown(); + client = null; + } + } + return result; + } + + + /** + * 发送网络请求 + * + * @param url + * @return + */ + public static String sendNetRequest(String url, Map<String, String> params) { + // 构造HttpClient实例 + HttpClient client = new HttpClient(); + String paramStr = ""; + for (String key : params.keySet()) { + paramStr = paramStr + "&" + key + "=" + params.get(key); + } + paramStr = paramStr.substring(1); + System.err.println(url + "?" + paramStr); + // 创建GET方法的实例 + GetMethod method = new GetMethod(url + "?" + paramStr); + // 接收返回结果 + String result = null; + try { + // 执行HTTP GET方法请求 + client.executeMethod(method); + // 返回处理结果 + result = method.getResponseBodyAsString(); + } catch (HttpException e) { + // 发生致命的异常,可能是协议不对或者返回的内容有问题 + System.out.println("请检查输入的URL!"); + e.printStackTrace(); + } catch (IOException e) { + // 发生网络异常 + System.out.println("发生网络异常!"); + e.printStackTrace(); + } finally { + // 释放链接 + method.releaseConnection(); + // 关闭HttpClient实例 + if (client != null) { + ((SimpleHttpConnectionManager) client.getHttpConnectionManager()).shutdown(); + client = null; + } + } + return result; + } + + + /** + * jsonp跨域请求数据响应<br/> + * 方法名:responsejsonpData<br/> + * + * @param request + * @param response + * @param map void<br/> + * @throws <br/> + * @author:Mryang<br/> + * @createTime:2016年7月31日-下午11:17:31 <br/> + * @tel: 15198268054<br /> + * @since 1.0.0 + */ + public void responsejsonpData(HttpServletRequest request, HttpServletResponse response, Map<String, Object> map) { + response.setCharacterEncoding("UTF-8"); + response.setHeader("Content-Type", "text/html;Charset=utf-8"); + try { + PrintWriter writer = response.getWriter(); + String params = request.getParameter("callback"); + String json = JSONObject.toJSONString(map); + writer.print(params + "(" + json + ")"); + } catch (IOException e) { + e.printStackTrace(); + } + } + + +} diff --git a/cloud-server-communityWorldCup/src/main/resources/mapper/WorldCupPaymentParticipantMapper.xml b/cloud-server-communityWorldCup/src/main/resources/mapper/WorldCupPaymentParticipantMapper.xml index f57d0c1..55d0901 100644 --- a/cloud-server-communityWorldCup/src/main/resources/mapper/WorldCupPaymentParticipantMapper.xml +++ b/cloud-server-communityWorldCup/src/main/resources/mapper/WorldCupPaymentParticipantMapper.xml @@ -7,9 +7,9 @@ <select id="getWorldCupPaymentParticipant" resultType="com.dsh.communityWorldCup.entity.WorldCupPaymentParticipant"> select * from t_world_cup_payment_participant - where worldCupId = #{worldCupId} and participantType = #{participantType} and participantId = #{participantId} and worldCupPaymentId in ( + where alreadyEntered = 0 and worldCupId = #{worldCupId} and participantType = #{participantType} and participantId = #{participantId} and worldCupPaymentId in ( select id from t_world_cup_payment where worldCupId = #{worldCupId} and payStatus = 2 and state = 1 - ) + ) order by createTime desc limit 0, 1 </select> diff --git a/cloud-server-course/src/main/java/com/dsh/course/controller/CoursePackageOrderStudentController.java b/cloud-server-course/src/main/java/com/dsh/course/controller/CoursePackageOrderStudentController.java index 61dc217..1c6b224 100644 --- a/cloud-server-course/src/main/java/com/dsh/course/controller/CoursePackageOrderStudentController.java +++ b/cloud-server-course/src/main/java/com/dsh/course/controller/CoursePackageOrderStudentController.java @@ -42,7 +42,18 @@ */ @ResponseBody @PostMapping("/deductionClassHour") - public boolean deductionClassHour(@RequestBody DeductionClassHourList deductionClassHourList){ + public DeductionClassHourList deductionClassHour(@RequestBody DeductionClassHourList deductionClassHourList){ return coursePackageOrderStudentService.deductionClassHour(deductionClassHourList); } + + + /** + * 回退课时和回退排课数据 + * @param deductionClassHourList + */ + @ResponseBody + @PostMapping("/backspaceClassHour") + public void backspaceClassHour(DeductionClassHourList deductionClassHourList){ + coursePackageOrderStudentService.backspaceClassHour(deductionClassHourList); + } } diff --git a/cloud-server-course/src/main/java/com/dsh/course/model/DeductionClassHour.java b/cloud-server-course/src/main/java/com/dsh/course/model/DeductionClassHour.java index 78904ac..ae2cfbb 100644 --- a/cloud-server-course/src/main/java/com/dsh/course/model/DeductionClassHour.java +++ b/cloud-server-course/src/main/java/com/dsh/course/model/DeductionClassHour.java @@ -24,4 +24,8 @@ * 扣减课时 */ private Integer classHour; + /** + * 删除的排课数量(用户回退时重新排课) + */ + private Integer scheduledCourses; } diff --git a/cloud-server-course/src/main/java/com/dsh/course/service/ICoursePackageOrderStudentService.java b/cloud-server-course/src/main/java/com/dsh/course/service/ICoursePackageOrderStudentService.java index 434c338..d653b6c 100644 --- a/cloud-server-course/src/main/java/com/dsh/course/service/ICoursePackageOrderStudentService.java +++ b/cloud-server-course/src/main/java/com/dsh/course/service/ICoursePackageOrderStudentService.java @@ -29,5 +29,12 @@ * @param deductionClassHourList * @return */ - boolean deductionClassHour(DeductionClassHourList deductionClassHourList); + DeductionClassHourList deductionClassHour(DeductionClassHourList deductionClassHourList); + + + /** + * 回退课时和回退排课数据 + * @param deductionClassHourList + */ + void backspaceClassHour(DeductionClassHourList deductionClassHourList); } diff --git a/cloud-server-course/src/main/java/com/dsh/course/service/impl/CoursePackageOrderStudentServiceImpl.java b/cloud-server-course/src/main/java/com/dsh/course/service/impl/CoursePackageOrderStudentServiceImpl.java index 00bc62d..4c17f15 100644 --- a/cloud-server-course/src/main/java/com/dsh/course/service/impl/CoursePackageOrderStudentServiceImpl.java +++ b/cloud-server-course/src/main/java/com/dsh/course/service/impl/CoursePackageOrderStudentServiceImpl.java @@ -216,7 +216,7 @@ * @return */ @Override - public boolean deductionClassHour(DeductionClassHourList deductionClassHourList) { + public DeductionClassHourList deductionClassHour(DeductionClassHourList deductionClassHourList) { try { List<DeductionClassHour> list = deductionClassHourList.getDeductionClassHourList(); for (DeductionClassHour deductionClassHour : list) { @@ -251,6 +251,8 @@ List<CoursePackageScheduling> coursePackageSchedulings = packageSchedulings.subList(0, n); List<Long> collect = coursePackageSchedulings.stream().map(CoursePackageScheduling::getId).collect(Collectors.toList()); coursePackageSchedulingService.removeByIds(collect); + + deductionClassHour.setScheduledCourses(n); } this.updateById(coursePackageOrderStudent); @@ -264,10 +266,30 @@ courseCounsum.setAppUserId(coursePackageOrderStudent.getAppUserId()); courseCounsumService.save(courseCounsum); } - return true; + return deductionClassHourList; }catch (Exception e){ e.printStackTrace(); } - return false; + return null; + } + + + /** + * 回退课时和回退排课数据 + * @param deductionClassHourList + */ + @Override + public void backspaceClassHour(DeductionClassHourList deductionClassHourList) { + List<DeductionClassHour> list = deductionClassHourList.getDeductionClassHourList(); + for (DeductionClassHour deductionClassHour : list) { + CoursePackageOrderStudent coursePackageOrderStudent = this.getById(deductionClassHour.getId()); + Integer laveClassHours = coursePackageOrderStudent.getLaveClassHours(); + coursePackageOrderStudent.setLaveClassHours(coursePackageOrderStudent.getLaveClassHours() + deductionClassHour.getClassHour()); + //需要排课的节数 + Integer scheduledCourses = deductionClassHour.getScheduledCourses(); +// coursePackageService + + } + } } diff --git a/cloud-server-other/src/main/java/com/dsh/other/controller/GameController.java b/cloud-server-other/src/main/java/com/dsh/other/controller/GameController.java index 482a6be..c2ac606 100644 --- a/cloud-server-other/src/main/java/com/dsh/other/controller/GameController.java +++ b/cloud-server-other/src/main/java/com/dsh/other/controller/GameController.java @@ -18,10 +18,7 @@ import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.math.BigDecimal; @@ -411,4 +408,15 @@ } + /** + * 根据sutuid获取游戏数据 + * @param sutuId + * @return + */ + @ResponseBody + @PostMapping("/getTGameBySutuId") + public TGame getTGameBySutuId(@RequestBody String sutuId){ + return gameService.getOne(new QueryWrapper<TGame>().eq("blue", sutuId).or() + .eq("red", sutuId).eq("state", 0)); + } } -- Gitblit v1.7.1