| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.dsh.course.entity.TCourse; |
| | | import com.dsh.course.entity.TCoursePackagePayment; |
| | | import com.dsh.course.entity.TCoursePackageType; |
| | | import com.dsh.course.feignclient.model.ExerciseVideo; |
| | | import com.dsh.course.model.*; |
| | | import com.dsh.course.service.TCoursePackagePaymentService; |
| | | import com.dsh.course.service.TCoursePackageService; |
| | | import com.dsh.course.service.TCoursePackageTypeService; |
| | | import com.dsh.course.service.TCourseService; |
| | | import com.dsh.course.util.PayMoneyUtil; |
| | | import com.dsh.course.util.ResultUtil; |
| | | import com.dsh.course.util.TokenUtil; |
| | | import io.swagger.annotations.Api; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.PrintWriter; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Api |
| | | @CrossOrigin |
| | |
| | | |
| | | @Autowired |
| | | private TCoursePackageTypeService coursePackageTypeService; |
| | | |
| | | @Autowired |
| | | private PayMoneyUtil payMoneyUtil; |
| | | |
| | | @Autowired |
| | | private TCoursePackagePaymentService coursePackagePaymentService; |
| | | |
| | | |
| | | |
| | |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/course/paymentCourse") |
| | | @ApiOperation(value = "支付课程", tags = {"APP-课程列表"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil paymentCourse(@RequestBody PaymentCourseVo paymentCourseVo){ |
| | | try { |
| | | Integer uid = tokenUtil.getUserIdFormRedis(); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 购买课程微信支付回调 |
| | | * @param request |
| | | * @param response |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/course/weChatPaymentCourseCallback") |
| | | public void weChatPaymentCourseCallback(HttpServletRequest request, HttpServletResponse response){ |
| | | try { |
| | | Map<String, String> map = payMoneyUtil.weixinpayCallback(request); |
| | | if(null != map){ |
| | | String code = map.get("out_trade_no"); |
| | | String transaction_id = map.get("transaction_id"); |
| | | String result = map.get("result"); |
| | | |
| | | List<TCoursePackagePayment> list = coursePackagePaymentService.list(new QueryWrapper<TCoursePackagePayment>().eq("state", 1).eq("code", code).eq("payType", 1)); |
| | | TCoursePackagePayment one = list.get(0); |
| | | if(one.getPayStatus() == 1){ |
| | | for (TCoursePackagePayment coursePackagePayment : list) { |
| | | coursePackagePayment.setPayStatus(2); |
| | | coursePackagePayment.setOrderNumber(transaction_id); |
| | | } |
| | | coursePackagePaymentService.updateBatchById(list); |
| | | } |
| | | PrintWriter out = response.getWriter(); |
| | | out.write(result); |
| | | out.flush(); |
| | | out.close(); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 购买课程支付宝回调 |
| | | * @param request |
| | | * @param response |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/course/aliPaymentCourseCallback") |
| | | public void aliPaymentCourseCallback(HttpServletRequest request, HttpServletResponse response){ |
| | | try { |
| | | Map<String, String> map = payMoneyUtil.alipayCallback(request); |
| | | if(null != map){ |
| | | String code = map.get("out_trade_no"); |
| | | String trade_no = map.get("trade_no"); |
| | | |
| | | List<TCoursePackagePayment> list = coursePackagePaymentService.list(new QueryWrapper<TCoursePackagePayment>().eq("state", 1).eq("code", code).eq("payType", 2)); |
| | | TCoursePackagePayment one = list.get(0); |
| | | if(one.getPayStatus() == 1){ |
| | | for (TCoursePackagePayment coursePackagePayment : list) { |
| | | coursePackagePayment.setPayStatus(2); |
| | | coursePackagePayment.setOrderNumber(trade_no); |
| | | } |
| | | coursePackagePaymentService.updateBatchById(list); |
| | | } |
| | | PrintWriter out = response.getWriter(); |
| | | out.write("success"); |
| | | out.flush(); |
| | | out.close(); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |