| | |
| | | import com.ruoyi.errand.object.vo.sys.OrderSysDetailVO; |
| | | import com.ruoyi.errand.object.vo.sys.UserStatsVO; |
| | | import com.ruoyi.errand.service.OrderService; |
| | | import com.ruoyi.errand.service.VipOrderService; |
| | | import com.ruoyi.errand.utils.RefundCallbackResult; |
| | | import com.ruoyi.errand.utils.UniPayCallbackResult; |
| | | import com.ruoyi.errand.utils.wx.PayResult; |
| | | import com.ruoyi.errand.utils.wx.WechatPayService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.Valid; |
| | | import java.io.IOException; |
| | |
| | | public class OrderController { |
| | | @Autowired |
| | | private OrderService orderService; |
| | | |
| | | @Autowired |
| | | private WechatPayService wechatPayService; |
| | | @Autowired |
| | | private VipOrderService vipOrderService; |
| | | |
| | | /** |
| | | * 下单 |
| | |
| | | * 订单支付回调通知 |
| | | */ |
| | | @ResponseBody |
| | | @GetMapping("/orderPaymentCallback") |
| | | public void orderPaymentCallback(UniPayCallbackResult uniPayCallbackResult, HttpServletResponse response){ |
| | | String jsonString = JSONObject.toJSONString(uniPayCallbackResult); |
| | | log.info("订单支付回调json:{}", jsonString); |
| | | R callback = orderService.orderPaymentCallback(uniPayCallbackResult); |
| | | @PostMapping("/orderPaymentCallback") |
| | | public void orderPaymentCallback(HttpServletRequest request, HttpServletResponse response){ |
| | | System.err.println("11111111111"); |
| | | PayResult payResult= null; |
| | | try { |
| | | payResult = wechatPayService.processNotify(request); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | System.out.println("1111111111111111111111"); |
| | | R callback = orderService.orderPaymentCallback(payResult); |
| | | if(callback.getCode() == 200){ |
| | | response.setStatus(200); |
| | | PrintWriter out = null; |
| | |
| | | @GetMapping("/getAppUserOrderList") |
| | | @ApiOperation(value = "订单列表",tags = "app用户端-订单页面") |
| | | public R<IPage<AppUserOrderListVO>> getAppUserOrderList( |
| | | @RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum, |
| | | @RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize, |
| | | @RequestParam(value = "pageNum",defaultValue = "1",required = false) Integer pageNum, |
| | | @RequestParam(value = "pageSize",defaultValue = "10",required = false) Integer pageSize, |
| | | @RequestParam(value = "orderStatus",required = false) Integer orderStatus) { |
| | | return R.ok(orderService.getAppUserOrderList(pageNum,pageSize,orderStatus)); |
| | | } |
| | |
| | | |
| | | /** |
| | | * 订单取消支付回退 |
| | | * |
| | | * @param refundCallbackResult |
| | | * @param response |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @GetMapping("/refundPayMoneyCallback") |
| | | public void refundPayMoneyCallback(RefundCallbackResult refundCallbackResult, HttpServletResponse response) { |
| | | R callback = orderService.refundPayMoneyCallback(refundCallbackResult); |
| | | public String refundPayMoneyCallback( @RequestBody(required = false) String xmlData) { |
| | | R callback = orderService.refundPayMoneyCallback(xmlData); |
| | | if (callback.getCode() == 200) { |
| | | response.setStatus(200); |
| | | PrintWriter out = null; |
| | | try { |
| | | out = response.getWriter(); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | out.println("success"); |
| | | out.flush(); |
| | | out.close(); |
| | | return "<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>"; |
| | | }else { |
| | | System.err.println("支付回退错误:"+callback.getMsg()); |
| | | return "<xml><return_code><![CDATA[FAIL]]></return_code></xml>"; |
| | | } |
| | | } |
| | | /** |
| | |
| | | @GetMapping("/detail") |
| | | @PreAuthorize("@ss.hasPermi('system:order:list')") |
| | | @ApiOperation(value = "订单管理-订单详情", tags = "系统后台-订单管理") |
| | | public R<OrderSysDetailVO> detail(@RequestParam("id") Integer id) { |
| | | public R<OrderSysDetailVO> detail(@RequestParam("id") Integer id,@RequestParam("type") Integer type) { |
| | | if (type==2){ |
| | | return R.ok(orderService.detail(id)); |
| | | }else { |
| | | return R.ok(vipOrderService.detail(id)); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |