| | |
| | | |
| | | |
| | | import cn.mb.cloud.common.data.controller.BaseController; |
| | | 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; |
| | |
| | | import com.dsh.course.model.vo.TQueryBenefitsVideosVO; |
| | | import com.dsh.course.service.*; |
| | | import com.dsh.course.util.*; |
| | | import com.dsh.course.util.wx.WxV3PayConfig; |
| | | import com.wechat.pay.contrib.apache.httpclient.util.AesUtil; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.BufferedReader; |
| | | import java.io.PrintWriter; |
| | | import java.math.BigDecimal; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private TCoursePackageDiscountService discountService; |
| | | |
| | | @Autowired |
| | | private ICoursePackagePaymentConfigService coursePackagePaymentConfigService; |
| | | |
| | | @Autowired |
| | | private ICoursePackageOrderService coursePackageOrderService; |
| | | |
| | | |
| | | |
| | | /** |
| | | * 上/下架 1为上架 2为下架 3为删除 |
| | |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/course/queryCoursePackageType") |
| | | @ApiOperation(value = "获取课程类型列表", tags = {"APP-课程列表"}) |
| | | @ApiImplicitParams({ |
| | | }) |
| | | public ResultUtil<List<BaseVo>> queryCoursePackageType1() { |
| | | try { |
| | | List<TCoursePackageType> coursePackageTypes = coursePackageTypeService.list(new QueryWrapper<TCoursePackageType>().eq("state", 1)); |
| | | List<BaseVo> list = new ArrayList<>(); |
| | | coursePackageTypes.forEach(c -> { |
| | | BaseVo baseVo = new BaseVo(); |
| | | BeanUtils.copyProperties(c, baseVo); |
| | | list.add(baseVo); |
| | | }); |
| | | return ResultUtil.success(list); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | |
| | | } |
| | | } |
| | | |
| | | // 2.0 |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/course/paymentCourseCouponList") |
| | | @ApiOperation(value = "支付课程--完成后优惠券列表", tags = {"APP-课程列表"}) |
| | |
| | | * @param response |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/course/weChatPaymentCourseCallback1") |
| | | public void weChatPaymentCourseCallback1(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"); |
| | | String attach = jsonInfo.getString("attach"); |
| | | if (trade_state.equals("SUCCESS")) { |
| | | |
| | | ResultUtil resultUtil = coursePackageService.paymentCourseCallback(code, transaction_id, attach); |
| | | if (resultUtil.getCode() == 200) { |
| | | PrintWriter out = response.getWriter(); |
| | | out.write("SUCCESS"); |
| | | out.flush(); |
| | | out.close(); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | @ResponseBody |
| | | @PostMapping("/base/course/weChatPaymentCourseCallback") |
| | | public void weChatPaymentCourseCallback(HttpServletRequest request, HttpServletResponse response) { |
| | | try { |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 购买课程支付宝回调 |
| | |
| | | public List<String> queryPackageById(@RequestBody Integer coursePackageId) { |
| | | ArrayList<String> strings = new ArrayList<>(); |
| | | TCoursePackage byId = coursePackageService.getById(coursePackageId); |
| | | if(null == byId){ |
| | | return null; |
| | | } |
| | | Integer coursePackageTypeId = byId.getCoursePackageTypeId(); |
| | | strings.add(coursePackageTypeService.getById(coursePackageTypeId).getName()); |
| | | strings.add(byId.getName()); |
| | | |
| | | return strings; |
| | | |
| | | } |
| | |
| | | |
| | | return map1; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 课包支付成功后排课操作 |
| | | * @param addCoursePackageOrderStudent |
| | | */ |
| | | @PostMapping("/course/addCoursePackageOrderStudent") |
| | | public void addCoursePackageOrderStudent(@RequestBody AddCoursePackageOrderStudent addCoursePackageOrderStudent){ |
| | | coursePackageService.addCoursePackageOrderStudent(addCoursePackageOrderStudent.getCoursePackageOrderId(), addCoursePackageOrderStudent.getCoursePackagePaymentConfig()); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据code获取待支付数据 |
| | | * @param code |
| | | * @return |
| | | */ |
| | | @PostMapping("/course/getCoursePackageOrderByCode") |
| | | public CoursePackageOrder getCoursePackageOrderByCode(@RequestBody String code){ |
| | | CoursePackageOrder coursePackageOrder = coursePackageOrderService.getOne(new QueryWrapper<CoursePackageOrder>() |
| | | .eq("code", code).eq("state", 1)); |
| | | return coursePackageOrder; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 修改数据 |
| | | * @param coursePackageOrder |
| | | */ |
| | | @PostMapping("/course/updateCoursePackageOrder") |
| | | public void updateCoursePackageOrder(@RequestBody CoursePackageOrder coursePackageOrder){ |
| | | coursePackageOrder.setAppUserId(null); |
| | | coursePackageOrderService.updateById(coursePackageOrder); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取课包配置 |
| | | * @param getCoursePackagePaymentConfig |
| | | * @return |
| | | */ |
| | | @PostMapping("/course/getCoursePackagePaymentConfig") |
| | | public CoursePackagePaymentConfig getCoursePackagePaymentConfig(@RequestBody GetCoursePackagePaymentConfig getCoursePackagePaymentConfig){ |
| | | CoursePackagePaymentConfig coursePackagePaymentConfig = coursePackagePaymentConfigService.getOne(new QueryWrapper<CoursePackagePaymentConfig>() |
| | | .eq("coursePackageId", getCoursePackagePaymentConfig.getCoursePackageId()) |
| | | .eq("classHours", getCoursePackagePaymentConfig.getClassHours()) |
| | | ); |
| | | return coursePackagePaymentConfig; |
| | | } |
| | | } |