订单回调 优化
This commit is contained in:
parent
52813b95a0
commit
ebb38883f7
|
|
@ -26,6 +26,7 @@ public interface OrdersDao extends BaseMapper<Orders> {
|
|||
Double statisticsIncomeMoney(@Param("time") String time, @Param("flag") Integer flag, @Param("ordersType") Integer ordersType);
|
||||
|
||||
Orders selectOrdersByCourseIdAndUserId(Long userId, Long courseId);
|
||||
Orders getById(Long orderId, Long userId);
|
||||
|
||||
List<Orders> selectOrdersMoneyList(Integer flag, String time);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import com.sqx.common.utils.Result;
|
|||
import com.sqx.modules.orders.dto.SummaryDTO;
|
||||
import com.sqx.modules.orders.entity.Orders;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public interface OrdersService extends IService<Orders> {
|
||||
/**
|
||||
* 处理所有订单
|
||||
|
|
@ -14,6 +16,8 @@ public interface OrdersService extends IService<Orders> {
|
|||
*/
|
||||
Result insertOrders(Orders orders);
|
||||
|
||||
Orders getById(Long orderId, Long userId);
|
||||
|
||||
Result payMoney(Long orderId);
|
||||
|
||||
Result insertCourseOrders(Long courseId, Long courseDetailsId, Long userId);
|
||||
|
|
|
|||
|
|
@ -121,6 +121,12 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersDao, Orders> implements
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Orders getById(Long orderId, Long userId) {
|
||||
return baseMapper.getById(orderId, userId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Result insertOrders(Orders orders) {
|
||||
//如果订单的种类是短剧
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|||
import com.sqx.common.annotation.Debounce;
|
||||
import com.sqx.common.annotation.Limiting;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.annotation.Login;
|
||||
import com.sqx.modules.app.service.UserMoneyDetailsService;
|
||||
import com.sqx.modules.app.service.UserMoneyService;
|
||||
import com.sqx.modules.app.service.UserService;
|
||||
|
|
@ -78,9 +79,10 @@ public class WuyouController {
|
|||
|
||||
@Debounce(interval = 1000, value = "#orderId")
|
||||
@ApiOperation("支付订单")
|
||||
@Login
|
||||
@GetMapping("/payOrder/{orderId}")
|
||||
public Result payOrder(HttpServletRequest request, @PathVariable("orderId") Long orderId, @RequestParam(value = "payType", required = false) String payType) {
|
||||
Orders order = ordersService.getById(orderId);
|
||||
public Result payOrder(HttpServletRequest request,@RequestAttribute("userId") Long userId, @PathVariable("orderId") Long orderId, @RequestParam(value = "payType", required = false) String payType) {
|
||||
Orders order = ordersService.getById(orderId,userId);
|
||||
if (order == null) {
|
||||
return Result.error("订单不存在");
|
||||
}
|
||||
|
|
@ -142,16 +144,15 @@ public class WuyouController {
|
|||
}
|
||||
|
||||
@ApiOperation("查询订单支付结果")
|
||||
@Login
|
||||
@GetMapping("/queryOrder/{orderId}")
|
||||
@Debounce(value = "#orderId")
|
||||
@Limiting(limitNum = 20)
|
||||
public Result queryOrder(HttpServletRequest request, @PathVariable("orderId") Long orderId) {
|
||||
Orders order = ordersService.getById(orderId);
|
||||
public Result queryOrder(HttpServletRequest request,@RequestAttribute("userId") Long userId, @PathVariable("orderId") Long orderId) {
|
||||
Orders order = ordersService.getById(orderId,userId);
|
||||
if (order == null) {
|
||||
return Result.error("订单不存在");
|
||||
}
|
||||
|
||||
PayDetails payDetails = payDetailsDao.selectByOrderId(order.getOrdersNo());
|
||||
PayDetails payDetails = payDetailsDao.selectByOrderIdAndUserId(order.getOrdersNo(),userId);
|
||||
if (payDetails == null) {
|
||||
return Result.error("订单支付信息不存在");
|
||||
}
|
||||
|
|
@ -160,17 +161,17 @@ public class WuyouController {
|
|||
return Result.success().put("data", 1);
|
||||
}
|
||||
|
||||
BaseResp baseResp = wuyouPay.queryOrder(payDetails.getTradeNo(), order.getUserId(), order.getPayMoney().toString(), request.getHeader("User-Agent"));
|
||||
if (baseResp.getCode() == null || baseResp.getCode() != 200) {
|
||||
return Result.success().put("data", 0);
|
||||
}
|
||||
|
||||
if ("SUCCESS".equals(baseResp.getPayStatus())) {
|
||||
payDetails.setThirdOrderNo(baseResp.getData().getOrder_sn());
|
||||
// ordersTask.updateOrderStatus(payDetails, order);
|
||||
return Result.success().put("data", 1);
|
||||
}
|
||||
|
||||
// BaseResp baseResp = wuyouPay.queryOrder(payDetails.getTradeNo(), order.getUserId(), order.getPayMoney().toString(), request.getHeader("User-Agent"));
|
||||
// if (baseResp.getCode() == null || baseResp.getCode() != 200) {
|
||||
// return Result.success().put("data", 0);
|
||||
// }
|
||||
//
|
||||
// if ("SUCCESS".equals(baseResp.getPayStatus())) {
|
||||
// payDetails.setThirdOrderNo(baseResp.getData().getOrder_sn());
|
||||
//// ordersTask.updateOrderStatus(payDetails, order);
|
||||
// return Result.success().put("data", 1);
|
||||
// }
|
||||
//
|
||||
return Result.success().put("data", 0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ public interface PayDetailsDao extends BaseMapper<PayDetails> {
|
|||
PayDetails selectByRemark(@Param("remark") String remark);
|
||||
|
||||
PayDetails selectByOrderId(@Param("orderId") String orderId);
|
||||
PayDetails selectByOrderIdAndUserId(@Param("orderId") String orderId, @Param("userId") Long userId);
|
||||
PayDetails selectOneByLimit(@Param("orderId") String ordersNo);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -165,6 +165,10 @@
|
|||
select * from orders where user_id=#{userId} and course_id=#{courseId} and status=1 order by create_time desc limit 1
|
||||
</select>
|
||||
|
||||
<select id="getById" resultType="com.sqx.modules.orders.entity.Orders">
|
||||
select * from orders where user_id=#{userId} and orders_id=#{orderId}
|
||||
</select>
|
||||
|
||||
<select id="selectOrdersMoneyList" resultType="com.sqx.modules.orders.entity.Orders">
|
||||
select o.*,c.title from orders o
|
||||
left join tb_user u on u.user_id=o.user_id
|
||||
|
|
|
|||
|
|
@ -15,6 +15,10 @@
|
|||
select * from pay_details d where d.order_id=#{orderId}
|
||||
</select>
|
||||
|
||||
<select id="selectByOrderIdAndUserId" resultType="com.sqx.modules.pay.entity.PayDetails">
|
||||
select * from pay_details d where d.order_id=#{orderId} and d.user_id=#{userId}
|
||||
</select>
|
||||
|
||||
<select id="selectOneByLimit" resultType="com.sqx.modules.pay.entity.PayDetails">
|
||||
select * from pay_details d where d.order_id=#{orderId} order by id desc limit 1
|
||||
</select>
|
||||
|
|
|
|||
Loading…
Reference in New Issue