| | |
| | | package com.ruoyi.shop.controller.miniapp; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.shop.domain.dto.AppNearbyShopDto; |
| | | import com.ruoyi.shop.domain.vo.AppNearbyShopVo; |
| | | import com.ruoyi.shop.domain.vo.AppShopInfoVo; |
| | | import com.ruoyi.shop.service.shop.ShopAppointableTimeService; |
| | | import com.ruoyi.shop.service.shop.ShopNonAppointableTimeService; |
| | | import com.ruoyi.shop.service.shop.ShopService; |
| | | import com.ruoyi.system.api.domain.dto.AppBaseGetDto; |
| | | import com.ruoyi.system.api.domain.dto.AppointmentTimeDto; |
| | | import com.ruoyi.system.api.domain.dto.ShopAppointmentTimeDto; |
| | | import com.ruoyi.system.api.domain.poji.member.Member; |
| | | import com.ruoyi.system.api.domain.poji.shop.ShopAppointableTime; |
| | | import com.ruoyi.system.api.domain.poji.shop.ShopNonAppointableTime; |
| | | import com.ruoyi.system.api.service.RemoteMemberService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author jqs34 |
| | |
| | | @RequestMapping("/app/home") |
| | | @Log4j2 |
| | | public class AppHomeController { |
| | | |
| | | |
| | | |
| | | @Resource |
| | | private RemoteMemberService memberService; |
| | | |
| | | |
| | | |
| | | @Resource |
| | | private ShopService shopService; |
| | | |
| | | |
| | | @Resource |
| | | private ShopNonAppointableTimeService shopNonAppointableTimeService; |
| | | |
| | | @Resource |
| | | private ShopAppointableTimeService shopAppointableTimeService; |
| | | |
| | | |
| | | @RequestMapping(value = "/getNearbyShop", method = RequestMethod.POST) |
| | | @ApiOperation(value = "获取最近商户") |
| | | public R<AppNearbyShopVo> getNearbyShop(@RequestBody AppNearbyShopDto appNearbyShopDto) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | Member member = null; |
| | | if(userId!=null){ |
| | | if (userId != null) { |
| | | member = memberService.getMember(userId).getData(); |
| | | } |
| | | log.info("获取最近商户:userId=" + userId + "&appNearbyShopDto=" + JSON.toJSONString(appNearbyShopDto)); |
| | |
| | | AppNearbyShopVo appNearbyShopVo = shopService.getNearbyShop(appNearbyShopDto,member); |
| | | return R.ok(appNearbyShopVo); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @RequestMapping(value = "/getShopInfo", method = RequestMethod.POST) |
| | | @ApiOperation(value = "获取商户详情") |
| | | public R<AppShopInfoVo> getShopInfo(@RequestBody AppBaseGetDto appBaseGetDto) { |
| | | AppShopInfoVo appShopInfoVo = shopService.getAppShopInfo(Long.valueOf(appBaseGetDto.getId())); |
| | | return R.ok(appShopInfoVo); |
| | | } |
| | | |
| | | |
| | | |
| | | @RequestMapping(value = "/getShopAppointmentTime", method = RequestMethod.POST) |
| | | @ApiOperation(value = "获取商户不可预约时间段【2.0】") |
| | | public R<List<ShopNonAppointableTime>> getShopAppointmentTime(@RequestBody ShopAppointmentTimeDto dto) { |
| | | List<ShopNonAppointableTime> list = shopNonAppointableTimeService.list(new QueryWrapper<ShopNonAppointableTime>().eq("shop_id", dto.getId()) |
| | | .last(" and '" + dto.getDate() + "' like CONCAT('%', non_appointable_start_time, '%') order by non_appointable_start_time")); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | @RequestMapping(value = "/appointmentTime", method = RequestMethod.POST) |
| | | @ApiOperation(value = "门店详情预约操作【2.0】") |
| | | public R appointmentTime(@RequestBody AppointmentTimeDto dto) { |
| | | ShopAppointableTime one = shopAppointableTimeService.getOne(new LambdaQueryWrapper<ShopAppointableTime>().eq(ShopAppointableTime::getShopId, dto.getShopId()) |
| | | .eq(ShopAppointableTime::getAppointableTime, dto.getTime())); |
| | | if (null != one) { |
| | | return R.fail("不能重复预约"); |
| | | } |
| | | Long userId = SecurityUtils.getUserId(); |
| | | one = new ShopAppointableTime(); |
| | | one.setShopId(dto.getShopId()); |
| | | one.setAppointableTime(dto.getTime()); |
| | | one.setUserId(userId); |
| | | one.setStatus(1); |
| | | one.setCreateTime(LocalDateTime.now()); |
| | | shopAppointableTimeService.save(one); |
| | | return R.ok(); |
| | | } |
| | | } |