|
@@ -5,10 +5,16 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.xunwang.commonutils.JwtUtils;
|
|
|
import com.xunwang.commonutils.R;
|
|
|
import com.xunwang.payment.entity.OrderInfo;
|
|
|
+import com.xunwang.payment.entity.vo.MyOrder;
|
|
|
+import com.xunwang.payment.enums.OrderStatus;
|
|
|
+import com.xunwang.payment.feign.MsgFeign;
|
|
|
import com.xunwang.payment.feign.UserFeign;
|
|
|
+import com.xunwang.payment.mapper.OrderInfoMapper;
|
|
|
import com.xunwang.payment.service.OrderInfoService;
|
|
|
+import com.xunwang.payment.service.WxPayService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
@@ -18,7 +24,9 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
* <p>
|
|
@@ -39,9 +47,16 @@ public class OrderInfoController {
|
|
|
@Resource
|
|
|
private UserFeign userFeign;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private MsgFeign msgFeign;
|
|
|
+
|
|
|
@Resource
|
|
|
private StringRedisTemplate stringRedisTemplate;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private OrderInfoMapper orderInfoMapper;
|
|
|
+
|
|
|
+
|
|
|
@ApiOperation("根据openId返回订单列表")
|
|
|
@GetMapping("/list/{openId}")
|
|
|
public R list(@PathVariable String openId) {
|
|
@@ -62,15 +77,15 @@ public class OrderInfoController {
|
|
|
String uid = JwtUtils.getUIdByJwtToken(request);
|
|
|
R openIdByUid = userFeign.getOpenIdByUid(uid);
|
|
|
String openid = (String) openIdByUid.getData().get("openid");
|
|
|
- List<OrderInfo> orderInfos = orderInfoService.listOrderByCreateTimeDesc(openid);
|
|
|
- return R.ok().data("list", orderInfos);
|
|
|
+ List<MyOrder> myOrderList = orderInfoMapper.getMyOrderList(openid);
|
|
|
+ return R.ok().data("list", myOrderList);
|
|
|
}
|
|
|
|
|
|
@ApiOperation("获取订单倒计时")
|
|
|
@GetMapping("/getCountDown")
|
|
|
public R getCountDown(HttpServletRequest request) {
|
|
|
- String inviteId = request.getParameter("inviteId");
|
|
|
- Long expire = stringRedisTemplate.opsForValue().getOperations().getExpire("countdown:" + inviteId);
|
|
|
+ String orderId = request.getParameter("orderId");
|
|
|
+ Long expire = stringRedisTemplate.opsForValue().getOperations().getExpire("countdown:" + orderId);
|
|
|
return R.ok().data("time", expire);
|
|
|
}
|
|
|
|
|
@@ -82,4 +97,41 @@ public class OrderInfoController {
|
|
|
return R.ok().data("one", one);
|
|
|
}
|
|
|
|
|
|
+ @GetMapping("/queryOrderStatus")
|
|
|
+ @ApiOperation("查询支付中本地订单状态")
|
|
|
+ public R queryOrderStatus(HttpServletRequest request) {
|
|
|
+ String orderId = request.getParameter("orderId");
|
|
|
+ OrderInfo one = orderInfoService.getOne(new LambdaQueryWrapper<OrderInfo>().eq(OrderInfo::getOrderId, orderId));
|
|
|
+ String status = one.getStatus();
|
|
|
+ String studentId = one.getStudentId();
|
|
|
+ String inviteId = one.getInviteId();
|
|
|
+ if (OrderStatus.SUCCESS.getType().equals(status)) {
|
|
|
+
|
|
|
+ msgFeign.notifyPaymentSuccess(studentId, orderId);
|
|
|
+
|
|
|
+ stringRedisTemplate.delete("countdown:" + orderId);
|
|
|
+ return R.ok().message("支付成功");
|
|
|
+ }
|
|
|
+ return R.ok().message("支付中");
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/queryIsRefundOrder")
|
|
|
+ @ApiOperation("查询是否退款订单")
|
|
|
+ public R queryIsRefundOrder(HttpServletRequest request) {
|
|
|
+ String orderId = request.getParameter("orderId");
|
|
|
+ OrderInfo one = orderInfoService.getOne(new LambdaQueryWrapper<OrderInfo>().eq(OrderInfo::getOrderId, orderId));
|
|
|
+ String status = one.getStatus();
|
|
|
+ if ("已退款".equals(status)) {
|
|
|
+ return R.ok().message("已退款");
|
|
|
+ }
|
|
|
+ return R.ok().message("退款中");
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("更改申请退款状态")
|
|
|
+ @GetMapping("/updateIsRefund/{orderId}")
|
|
|
+ public void updateIsRefund(@PathVariable String orderId) {
|
|
|
+ OrderInfo orderInfo = new OrderInfo().setIsRefund(1);
|
|
|
+ orderInfoService.update(orderInfo, new LambdaQueryWrapper<OrderInfo>().eq(OrderInfo::getOrderId, orderId));
|
|
|
+ }
|
|
|
+
|
|
|
}
|