| | |
| | | package com.dsh.other.controller; |
| | | |
| | | import com.dsh.other.model.BaseVo; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.dsh.other.entity.Site; |
| | | import com.dsh.other.entity.SiteBooking; |
| | | import com.dsh.other.model.*; |
| | | import com.dsh.other.service.ISiteBookingService; |
| | | import com.dsh.other.service.ISiteService; |
| | | import com.dsh.other.service.ISiteTypeService; |
| | | import com.dsh.other.util.PayMoneyUtil; |
| | | import com.dsh.other.util.ResultUtil; |
| | | import com.dsh.other.util.TokenUtil; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.PrintWriter; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | |
| | | @Autowired |
| | | private ISiteService siteService; |
| | | |
| | | // @Autowired |
| | | // private |
| | | // |
| | | // |
| | | // |
| | | // public ResultUtil<List<BaseVo>> querySiteType(){ |
| | | // try { |
| | | // |
| | | // }catch (Exception e){ |
| | | // e.printStackTrace(); |
| | | // return ResultUtil.runErr(); |
| | | // } |
| | | // } |
| | | @Autowired |
| | | private ISiteTypeService siteTypeService; |
| | | |
| | | @Autowired |
| | | private TokenUtil tokenUtil; |
| | | |
| | | @Autowired |
| | | private PayMoneyUtil payMoneyUtil; |
| | | |
| | | @Autowired |
| | | private ISiteBookingService siteBookingService; |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/site/querySiteType") |
| | | @ApiOperation(value = "获取场地类型", tags = {"用户—预约场地"}) |
| | | @ApiImplicitParams({ |
| | | }) |
| | | public ResultUtil<List<BaseVo>> querySiteType(){ |
| | | try { |
| | | List<BaseVo> list = siteTypeService.querySiteType(); |
| | | return ResultUtil.success(list); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/site/querySiteList") |
| | | @ApiOperation(value = "获取场地列表", tags = {"用户—预约场地"}) |
| | | @ApiImplicitParams({ |
| | | }) |
| | | public ResultUtil<List<QuerySiteListVo>> querySiteList(QuerySiteList querySiteList){ |
| | | try { |
| | | List<QuerySiteListVo> querySiteListVos = siteService.querySiteList(querySiteList); |
| | | return ResultUtil.success(querySiteListVos); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/site/querySiteInfo") |
| | | @ApiOperation(value = "获取场地详情", tags = {"用户—预约场地"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "场地id", name = "id", dataType = "int", required = true), |
| | | @ApiImplicitParam(value = "经度", name = "lon", dataType = "string", required = false), |
| | | @ApiImplicitParam(value = "纬度", name = "lat", dataType = "string", required = false), |
| | | }) |
| | | public ResultUtil<QuerySiteInfoVo> querySiteInfo(Integer id, String lon, String lat){ |
| | | try { |
| | | QuerySiteInfoVo querySiteInfoVo = siteService.querySiteInfo(id, lon, lat); |
| | | return ResultUtil.success(querySiteInfoVo); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/base/site/querySiteTimes") |
| | | @ApiOperation(value = "获取场地详情时间段数据", tags = {"用户—预约场地"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "场地id", name = "id", dataType = "int", required = true), |
| | | @ApiImplicitParam(value = "日期(2023-01-01)", name = "day", dataType = "string", required = true), |
| | | }) |
| | | public ResultUtil<List<QuerySiteTimes>> querySiteTimes(Integer id, String day){ |
| | | try { |
| | | List<QuerySiteTimes> list = siteService.querySiteTimes(id, day); |
| | | return ResultUtil.success(list); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据id获取数据 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/site/querySiteById") |
| | | public Site querySiteById(@RequestBody Integer id){ |
| | | try { |
| | | return siteService.getById(id); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | public ResultUtil reservationSite(ReservationSite reservationSite){ |
| | | try { |
| | | Integer uid = tokenUtil.getUserIdFormRedis(); |
| | | if(null == uid){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | return siteService.reservationSite(uid, reservationSite); |
| | | |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 购买课程微信支付回调 |
| | | * @param request |
| | | * @param response |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/site/weChatPaymentSiteCallback") |
| | | public void weChatPaymentSiteCallback(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"); |
| | | SiteBooking siteBooking = siteBookingService.getOne(new QueryWrapper<SiteBooking>().eq("orderNo", code).eq("state", 1)); |
| | | if(siteBooking.getStatus() == 0){ |
| | | siteBooking.setPayTime(new Date()); |
| | | siteBooking.setStatus(1); |
| | | siteBooking.setPayOrderNo(transaction_id); |
| | | siteBookingService.updateById(siteBooking); |
| | | } |
| | | PrintWriter out = response.getWriter(); |
| | | out.write(result); |
| | | out.flush(); |
| | | out.close(); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 购买课程支付宝回调 |
| | | * @param request |
| | | * @param response |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/base/site/aliPaymentSiteCallback") |
| | | public void aliPaymentSiteCallback(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"); |
| | | SiteBooking siteBooking = siteBookingService.getOne(new QueryWrapper<SiteBooking>().eq("orderNo", code).eq("state", 1)); |
| | | if(siteBooking.getStatus() == 0){ |
| | | siteBooking.setPayTime(new Date()); |
| | | siteBooking.setStatus(1); |
| | | siteBooking.setPayOrderNo(trade_no); |
| | | siteBookingService.updateById(siteBooking); |
| | | } |
| | | PrintWriter out = response.getWriter(); |
| | | out.write("success"); |
| | | out.flush(); |
| | | out.close(); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |