微信支付回调
This commit is contained in:
parent
bc6328c38e
commit
fd71a1ac61
|
|
@ -25,7 +25,9 @@ public class SysIndexController extends BaseController
|
|||
@GetMapping({"","/"})
|
||||
public String cmsindex(ModelMap mmap)
|
||||
{
|
||||
|
||||
// 取身份信息
|
||||
SysUser user = getSysUser();
|
||||
mmap.put("user", user);
|
||||
return "web";
|
||||
}
|
||||
// 系统首页
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@ import com.ruoyi.train.course.service.ITrainCourseUserService;
|
|||
import com.ruoyi.vip.domain.VipUserOrders;
|
||||
import com.ruoyi.vip.service.IVipUserOrdersService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
|
@ -39,6 +41,8 @@ import java.util.List;
|
|||
@RestController
|
||||
@RequestMapping("/api/v1/wx/pay")
|
||||
public class ApiWxPayController extends BaseController {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger( ApiWxPayController.class );
|
||||
@Autowired
|
||||
private ITrainCourseUserService trainCourseUserService ;
|
||||
|
||||
|
|
@ -49,7 +53,9 @@ public class ApiWxPayController extends BaseController {
|
|||
private WxPayService wxService;
|
||||
@PostMapping("/notify/order")
|
||||
public String parseOrderNotifyResult(@RequestBody String xmlData) throws WxPayException {
|
||||
|
||||
final WxPayOrderNotifyResult notifyResult = this.wxService.parseOrderNotifyResult(xmlData);
|
||||
log.debug("-------------------------------支付回调中----------------------------");
|
||||
if (null != notifyResult && notifyResult.getReturnCode().equals("SUCCESS")) {
|
||||
VipUserOrders userOrders = new VipUserOrders();
|
||||
userOrders.setId(notifyResult.getOutTradeNo());
|
||||
|
|
@ -101,12 +107,14 @@ public class ApiWxPayController extends BaseController {
|
|||
request.setSpbillCreateIp( IpUtils.getIpAddr( ServletUtils.getRequest()));
|
||||
VipUserOrders userOrders = new VipUserOrders();
|
||||
userOrders.setId(request.getOutTradeNo());
|
||||
userOrders.setVipUserId(ShiroUtils.getUserId().intValue());
|
||||
userOrders.setVipUserId(Integer.parseInt(request.getOpenid()));
|
||||
userOrders.setTrainCourseId(Integer.parseInt(request.getProductId()));
|
||||
userOrders.setPrice(new BigDecimal(request.getTotalFee().intValue()/100));
|
||||
//未支付订单
|
||||
userOrders.setDelFlag("0");
|
||||
vipUserOrdersService.insert(userOrders);
|
||||
//零时存放我们自己的用户id,这儿清空
|
||||
request.setOpenid(null);
|
||||
return this.wxService.createOrder(request);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import com.ruoyi.common.utils.file.FileUtils;
|
|||
import com.ruoyi.exam.domain.ExamPractice;
|
||||
import com.ruoyi.exam.service.IExamPracticeService;
|
||||
import com.ruoyi.framework.web.util.ShiroUtils;
|
||||
import com.ruoyi.system.service.ISysConfigService;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
import com.ruoyi.train.course.domain.TrainCourse;
|
||||
import com.ruoyi.train.course.domain.TrainCourseCategory;
|
||||
|
|
@ -57,6 +58,9 @@ public class CmsController {
|
|||
@Autowired
|
||||
private IExamPracticeService examPracticeService;
|
||||
|
||||
@Autowired
|
||||
private ISysConfigService configService;
|
||||
|
||||
@RequestMapping({"", "/index", "/index.html"})
|
||||
@GetMapping()
|
||||
public String index(String parentIds, ModelMap map) {
|
||||
|
|
@ -108,11 +112,15 @@ public class CmsController {
|
|||
ExamPractice examPractice = new ExamPractice();
|
||||
examPractice.setTrainCourseId( id );
|
||||
List<ExamPractice> examPractices = examPracticeService.selectExamPracticeList( examPractice );
|
||||
|
||||
boolean courseAuth=false;
|
||||
String s = configService.selectConfigByKey( "course.days" );
|
||||
if (ShiroUtils.getSysUser() != null) {
|
||||
boolean b = trainCourseUserService.authority( ShiroUtils.getSysUser().getUserId(), id );
|
||||
map.put( "user", ShiroUtils.getSysUser() );
|
||||
map.put( "courseAuth",b);
|
||||
courseAuth = trainCourseUserService.authority( ShiroUtils.getSysUser().getUserId(), id );
|
||||
}
|
||||
map.put( "courseAuth",courseAuth);
|
||||
map.put( "user", ShiroUtils.getSysUser() );
|
||||
map.put( "courseDays", s );
|
||||
map.put( "trainCourse", trainCourse );
|
||||
map.put( "trainCourseSections", trainCourseSections );
|
||||
map.put( "examPractices", examPractices );
|
||||
|
|
|
|||
|
|
@ -168,7 +168,9 @@
|
|||
<div class="image" id="courseImage">
|
||||
<div id="view_flv" style="display:none;"></div>
|
||||
<div class="course-pro0"></div>
|
||||
<img th:src="${trainCourse.cover}" class="course-cover" onerror="this.src='/sysimg/nopic.gif'" width="480" height="290">
|
||||
<img th:if="${#strings.isEmpty(trainCourse.cover)}" th:src="@{/web/res/images/no_img.png}" th:alt="${trainCourse.name}" class="course-cover" width="480" height="290">
|
||||
<img th:if="${not #strings.isEmpty(trainCourse.cover)}" th:src="${trainCourse.cover}" th:alt="${trainCourse.name}" class="course-cover" width="480" height="290">
|
||||
|
||||
</div>
|
||||
<div class="courseInfo-right">
|
||||
<div class="name" th:text="${trainCourse.name}">
|
||||
|
|
@ -177,9 +179,9 @@
|
|||
<div class="price">
|
||||
<span class="price-info"><span th:text="'¥'+${trainCourse.price}"></span></span>
|
||||
</div>
|
||||
<div class="button">
|
||||
<div class="button" th:if="${trainCourse.price>0}">
|
||||
<input type="button" onclick="shop()" class="hb-ui-btn" value="立刻购买">
|
||||
<em>有效期:<span id="shixian">${config.getKey("course.days")}</span>(天)</em>
|
||||
<em>有效期:<span id="shixian" th:text="${courseDays}"></span>(天)</em>
|
||||
</div>
|
||||
<div class="remark" th:text="${trainCourse.description}">
|
||||
|
||||
|
|
@ -241,6 +243,8 @@
|
|||
|
||||
});
|
||||
function shop() {
|
||||
var userId="[[${user.userId}]]";
|
||||
if(userId){
|
||||
var data={
|
||||
"body":"[[${trainCourse.name}]]",
|
||||
"outTradeNo":"12344324242342342342554",
|
||||
|
|
@ -248,11 +252,12 @@
|
|||
"spbillCreateIp":"1.80.82.241",
|
||||
"notifyUrl":"http://ceshi4.yqhl.cc/api/v1/wx/pay/notify/order",
|
||||
"tradeType":"NATIVE",
|
||||
"productId":"[[${trainCourse.id}]]"
|
||||
"productId":"[[${trainCourse.id}]]",
|
||||
"openid":userId
|
||||
};
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: "/api/vi/wx/pay/createOrder",
|
||||
url: "/api/v1/wx/pay/createOrder",
|
||||
contentType: "application/json",
|
||||
dataType : 'json',
|
||||
data:JSON.stringify(data),
|
||||
|
|
@ -267,6 +272,9 @@
|
|||
}
|
||||
}
|
||||
});
|
||||
}else{
|
||||
location.href="/web/user/login.html"
|
||||
}
|
||||
|
||||
}
|
||||
function alertPayQrcode(codeUrl) {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.ruoyi.train.course.mapper;
|
|||
|
||||
import com.ruoyi.framework.web.base.MyMapper;
|
||||
import com.ruoyi.train.course.domain.TrainCourseUser;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -25,9 +26,10 @@ public interface TrainCourseUserMapper extends MyMapper<TrainCourseUser>
|
|||
|
||||
/**
|
||||
* 判断是否有权限
|
||||
* @param userId
|
||||
* @param vipUserId
|
||||
* @param trainCourseId
|
||||
* @param days 有效期
|
||||
* @return
|
||||
*/
|
||||
List<TrainCourseUser> authority(Long userId, Integer trainCourseId,Integer days);
|
||||
List<TrainCourseUser> authority(@Param("vipUserId") Long vipUserId, @Param("trainCourseId") Integer trainCourseId, @Param("days") Integer days);
|
||||
}
|
||||
Loading…
Reference in New Issue