From fb6d61ae9aa69b523cc259b5e9b33c278f32dc42 Mon Sep 17 00:00:00 2001 From: wangpengfei <1928057482@qq.com> Date: Fri, 19 Jan 2024 15:17:26 +0800 Subject: [PATCH] 1/19 --- .../api/customerstore/CustomerStoreVo.java | 3 + .../VegeCellarReserveOrder.java | 1 + .../VegeCellarReserveOrderDto.java | 2 + .../biz/customerstore/CustomerStoreRest.java | 12 ++- .../customerstore/CustomerStoreService.java | 98 ++++++++++++++++++- .../biz/lpkgoods/LpkGoodsService.java | 9 ++ .../VegeCellarReserveDetailsService.java | 41 +++++++- .../VegeCellarReserveOrderService.java | 46 +++++++++ .../yxt/yythmall/config/SaTokenConfigure.java | 2 + .../config/SaTokenGloableException.java | 4 + 10 files changed, 210 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/yxt/yythmall/api/customerstore/CustomerStoreVo.java b/src/main/java/com/yxt/yythmall/api/customerstore/CustomerStoreVo.java index f88070b..d4cd496 100644 --- a/src/main/java/com/yxt/yythmall/api/customerstore/CustomerStoreVo.java +++ b/src/main/java/com/yxt/yythmall/api/customerstore/CustomerStoreVo.java @@ -30,4 +30,7 @@ public class CustomerStoreVo implements Vo { // private String isGrounding; private String phone;//电话 private String name;//姓名 + private String start; + private String end; + private String reserveDate; } diff --git a/src/main/java/com/yxt/yythmall/api/vegecallerreserveorder/VegeCellarReserveOrder.java b/src/main/java/com/yxt/yythmall/api/vegecallerreserveorder/VegeCellarReserveOrder.java index cb22c8c..08230e2 100644 --- a/src/main/java/com/yxt/yythmall/api/vegecallerreserveorder/VegeCellarReserveOrder.java +++ b/src/main/java/com/yxt/yythmall/api/vegecallerreserveorder/VegeCellarReserveOrder.java @@ -25,5 +25,6 @@ public class VegeCellarReserveOrder { private String userName; private String userPhone; private String userAddress; + private String reserveCode; } diff --git a/src/main/java/com/yxt/yythmall/api/vegecallerreserveorder/VegeCellarReserveOrderDto.java b/src/main/java/com/yxt/yythmall/api/vegecallerreserveorder/VegeCellarReserveOrderDto.java index e9a5f40..f0a25d8 100644 --- a/src/main/java/com/yxt/yythmall/api/vegecallerreserveorder/VegeCellarReserveOrderDto.java +++ b/src/main/java/com/yxt/yythmall/api/vegecallerreserveorder/VegeCellarReserveOrderDto.java @@ -20,6 +20,8 @@ public class VegeCellarReserveOrderDto implements Dto { private String userAddress; private String affiliation; private List goodsVos; + private String goodsSid; + private double select; private String orderSid; private String addressName; private String cardType;//提货类型,1=提货卡;2=福利卡 diff --git a/src/main/java/com/yxt/yythmall/biz/customerstore/CustomerStoreRest.java b/src/main/java/com/yxt/yythmall/biz/customerstore/CustomerStoreRest.java index b6dfdb7..0d932fc 100644 --- a/src/main/java/com/yxt/yythmall/biz/customerstore/CustomerStoreRest.java +++ b/src/main/java/com/yxt/yythmall/biz/customerstore/CustomerStoreRest.java @@ -1,13 +1,12 @@ package com.yxt.yythmall.biz.customerstore; +import com.yxt.common.core.query.PagerQuery; import com.yxt.common.core.result.ResultBean; +import com.yxt.yythmall.api.lpkgiftcard.LpkGiftCardQuery; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; /** * @author wangpengfei @@ -27,4 +26,9 @@ public class CustomerStoreRest { public ResultBean getStoreBySid(@PathVariable String sid) { return customerStoreService.getStoreBySid(sid); } + @GetMapping("/isSaturAndSun") + @ApiOperation(value = "获取时间段的周六日") + public ResultBean isSaturAndSun() { + return customerStoreService.isSaturAndSun(); + } } diff --git a/src/main/java/com/yxt/yythmall/biz/customerstore/CustomerStoreService.java b/src/main/java/com/yxt/yythmall/biz/customerstore/CustomerStoreService.java index 078a8d9..cc40a4c 100644 --- a/src/main/java/com/yxt/yythmall/biz/customerstore/CustomerStoreService.java +++ b/src/main/java/com/yxt/yythmall/biz/customerstore/CustomerStoreService.java @@ -1,26 +1,57 @@ package com.yxt.yythmall.biz.customerstore; import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.date.DateUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.yxt.common.base.service.MybatisBaseService; import com.yxt.common.core.result.ResultBean; import com.yxt.yythmall.api.customerstore.CustomerStore; import com.yxt.yythmall.api.customerstore.CustomerStoreDto; import com.yxt.yythmall.api.customerstore.CustomerStoreVo; +import com.yxt.yythmall.api.lpkgiftcard.AppletVo; +import com.yxt.yythmall.api.lpkstore.LpkStore; +import com.yxt.yythmall.api.lpkstore.LpkStoreQuery; +import com.yxt.yythmall.api.lpkstore.LpkStoreVo; +import com.yxt.yythmall.api.lpkstore.StoreSelect; +import com.yxt.yythmall.biz.lpkstore.LpkStoreService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.text.SimpleDateFormat; +import java.time.*; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + /** * @author wangpengfei * @date 2023/11/21 15:03 */ @Service public class CustomerStoreService extends MybatisBaseService { - + @Autowired + LpkStoreService lpkStoreService; public ResultBean getStoreBySid(String customerSid) { ResultBean rb=new ResultBean().fail(); CustomerStoreVo vo=baseMapper.getStoreBySid(customerSid); + + if(null==vo){ + LpkStoreVo list= lpkStoreService.getAllStoreByQuery(new LpkStoreQuery()).getData().get(0); + CustomerStoreVo vo1=new CustomerStoreVo(); + vo1.setAddress(list.getAddress()); + vo1.setStoreSid(list.getSid()); + vo1.setBusinessHours(list.getBusinessHours()); + vo1.setStoreName(list.getName()); + vo1.setName("张三"); + vo1.setPhone("11111111111"); + vo1=getStart(vo1); + return rb.success().setData(vo1); + } + vo=getStart(vo); return rb.success().setData(vo); } + public ResultBean saveStore(CustomerStoreDto dto){ ResultBean rb=new ResultBean(); baseMapper.delete(new QueryWrapper().eq("customerSid",dto.getCustomerSid())); @@ -29,4 +60,69 @@ public class CustomerStoreService extends MybatisBaseService isSaturAndSun() { + ResultBean rb = new ResultBean().fail(); + + Date date =new Date(); + SimpleDateFormat sdf1 =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String nowDate =sdf1.format(date); + String endDate= sdf1.format(DateUtil.offsetMonth(date,12)); + LocalDate now = DateUtil.parse(nowDate).toSqlDate().toLocalDate(); + LocalDate endD = DateUtil.parse(endDate).toSqlDate().toLocalDate(); + List weekMap = new ArrayList<>(); + // 第一个星期六 + LocalDate saturday = now.with(DayOfWeek.SATURDAY); + do { + if (CollectionUtils.isEmpty(weekMap)) { + weekMap.add(saturday.toString()); + } else { + weekMap.add(saturday.toString()); + } + // 迭代一个星期 + saturday = saturday.plus(Period.ofDays(7)); + } while (saturday.compareTo(endD) < 1); + // 第一个星期天 + LocalDate sunday = now.with(DayOfWeek.SUNDAY); + do { + if (CollectionUtils.isEmpty(weekMap)) { + weekMap.add(saturday.toString()); + } else { + weekMap.add(sunday.toString()); + } + // 迭代一个星期 + sunday = sunday.plus(Period.ofDays(7)); + } while (sunday.compareTo(endD) < 1); + String nextYear = DateUtil.offsetMonth(new Date(), 12).toString(); + int y = DateUtil.year(DateUtil.parse(nextYear)); + weekMap.add(String.valueOf(y) + "-01-01"); + Object[] array = weekMap.stream().sorted().toArray(); + return rb.success().setData(array); + } + public CustomerStoreVo getStart(CustomerStoreVo vo) { + SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat sdf1 =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + LocalDate today = LocalDate.now(); // 获取今天的日期 + LocalTime timeOfDay = LocalTime.of(15, 0); // 设置下午3点的小时数为15,分钟数为0 + LocalDateTime dateAndTime = LocalDateTime.of(today, timeOfDay); // 将日期和时间合并成完整的日期时间对象 + + ZoneId zoneId = ZoneId.systemDefault(); + Date date = Date.from(dateAndTime.atZone(zoneId).toInstant()); + Date nowDate=new Date(); + String start =""; + + //1>2 1 、1<2 -1 、1=2 0 + int k= DateUtil.parse(sdf1.format(DateUtil.parse(sdf1.format(nowDate)))).compareTo(DateUtil.parse(sdf1.format(DateUtil.parse(sdf1.format(date))))); + if(String.valueOf(k).equals("1")){ + start=sdf.format(DateUtil.offsetDay(nowDate,+2)); + }else{ + start=sdf.format(DateUtil.offsetDay(nowDate,+1)); + } + String end=sdf.format(DateUtil.offsetDay(DateUtil.parse(start),4)); + + vo.setStart(start); + vo.setEnd(end); + vo.setReserveDate(start); + return vo; + } } diff --git a/src/main/java/com/yxt/yythmall/biz/lpkgoods/LpkGoodsService.java b/src/main/java/com/yxt/yythmall/biz/lpkgoods/LpkGoodsService.java index 50bb68d..0217962 100644 --- a/src/main/java/com/yxt/yythmall/biz/lpkgoods/LpkGoodsService.java +++ b/src/main/java/com/yxt/yythmall/biz/lpkgoods/LpkGoodsService.java @@ -2,6 +2,8 @@ package com.yxt.yythmall.biz.lpkgoods; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUnit; +import cn.hutool.core.date.DateUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.yxt.common.base.config.component.FileUploadComponent; @@ -23,8 +25,13 @@ import org.springframework.stereotype.Service; import java.math.BigDecimal; import java.text.DecimalFormat; import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.ZoneId; import java.util.ArrayList; import java.util.Collections; +import java.util.Date; import java.util.List; /** @@ -204,6 +211,8 @@ public class LpkGoodsService extends MybatisBaseService vo =baseMapper.getGoodsApplet(query); vo.forEach(s->{ + double i=Double.valueOf(s.getGoodsNumber()); + s.setGoodsNumber(String.valueOf((int)i)); s.setIconUrl(fileUploadComponent.getUrlPrefix()+s.getIconUrl()); }); return rb.success().setData(vo); diff --git a/src/main/java/com/yxt/yythmall/biz/vegecallerreservedetail/VegeCellarReserveDetailsService.java b/src/main/java/com/yxt/yythmall/biz/vegecallerreservedetail/VegeCellarReserveDetailsService.java index bba5efe..45d1a43 100644 --- a/src/main/java/com/yxt/yythmall/biz/vegecallerreservedetail/VegeCellarReserveDetailsService.java +++ b/src/main/java/com/yxt/yythmall/biz/vegecallerreservedetail/VegeCellarReserveDetailsService.java @@ -5,12 +5,14 @@ import cn.hutool.core.date.DateTime; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.yxt.common.base.service.MybatisBaseService; import com.yxt.common.core.result.ResultBean; +import com.yxt.yythmall.api.customerstore.CustomerStoreDto; import com.yxt.yythmall.api.empcardgiftgoods.EmpCardGiftGoodsVo; import com.yxt.yythmall.api.lpkgiftcard.AppletVo; import com.yxt.yythmall.api.lpkgiftcard.GoodsVo; import com.yxt.yythmall.api.vegecallerreservedetails.VegeCellarReserveDetails; import com.yxt.yythmall.api.vegecallerreserveorder.VegeCellarReserveOrderDto; import com.yxt.yythmall.api.vegetablecellar.VegetableCellar; +import com.yxt.yythmall.biz.customerstore.CustomerStoreService; import com.yxt.yythmall.biz.empcardgiftgoods.EmpCardGiftGoodsService; import com.yxt.yythmall.biz.lpkgiftcard.LpkGiftCardService; import com.yxt.yythmall.biz.vegetablecellar.VegetableCellarService; @@ -29,6 +31,8 @@ public class VegeCellarReserveDetailsService extends MybatisBaseService getReserveByCardSid(String carSid, String goodsSid) { @@ -51,14 +55,45 @@ public class VegeCellarReserveDetailsService extends MybatisBaseService().eq("customerSid",dto.getCustomerSid()) .eq("goodsSid",goods1.getGoodsSid()).eq("affiliation",dto.getAffiliation())).get(0); - vegetableCellar.setGoodsNumber(String.valueOf((int)(Double.valueOf(vegetableCellar.getGoodsNumber())-Double.valueOf(goods1.getSelect())))); - vegetableCellarService.updateById(vegetableCellar); + double d=Double.valueOf(vegetableCellar.getGoodsNumber()); + double c=Double.valueOf(goods1.getSelect()); + if(Double.compare(d,c)==0){ + vegetableCellarService.deleteBySid(vegetableCellar.getSid()); + }else{ + vegetableCellar.setGoodsNumber(String.valueOf((int)(Double.valueOf(vegetableCellar.getGoodsNumber())-Double.valueOf(goods1.getSelect())))); + vegetableCellarService.updateById(vegetableCellar); + } + } } - + CustomerStoreDto dto1=new CustomerStoreDto(); + dto1.setPhone(dto.getUserPhone()); + dto1.setStoreSid(dto.getStoreSid()); + dto1.setName(dto.getUserName()); + dto1.setCustomerSid(dto.getCustomerSid()); + customerStoreService.saveStore(dto1); return rb.success().setData("预约成功"); } + public ResultBean addDetail(VegeCellarReserveOrderDto dto) { + ResultBean rb = new ResultBean(); +// goods.setCardSid(dto.getSid()); + VegeCellarReserveDetails vegeCellarReserveDetails=baseMapper.selectOne(new QueryWrapper().eq("orderSid",dto.getOrderSid()) + .eq("goodsSid",dto.getGoodsSid())); + if(null==vegeCellarReserveDetails){ + VegeCellarReserveDetails goods = new VegeCellarReserveDetails(); + BeanUtil.copyProperties(dto, goods, "id", "sid"); + goods.setGoodsSid(dto.getGoodsSid()); + goods.setGoodsNumber(dto.getSelect()); + goods.setCreateTime(new DateTime()); + baseMapper.insert(goods); + }else{ + vegeCellarReserveDetails.setGoodsNumber(vegeCellarReserveDetails.getGoodsNumber()+dto.getSelect()); + baseMapper.updateById(vegeCellarReserveDetails); + } + + return rb.success().setData("预约成功"); + } public VegeCellarReserveDetails selByOrderSidAndGoodSid(String orderSid, String goodsSid) { return baseMapper.selByOrderSidAndGoodSid(orderSid,goodsSid); } diff --git a/src/main/java/com/yxt/yythmall/biz/vegecallerreserveorder/VegeCellarReserveOrderService.java b/src/main/java/com/yxt/yythmall/biz/vegecallerreserveorder/VegeCellarReserveOrderService.java index 3f72d2a..a63cf85 100644 --- a/src/main/java/com/yxt/yythmall/biz/vegecallerreserveorder/VegeCellarReserveOrderService.java +++ b/src/main/java/com/yxt/yythmall/biz/vegecallerreserveorder/VegeCellarReserveOrderService.java @@ -24,6 +24,7 @@ import com.yxt.yythmall.api.lpkstore.StoreSelect; import com.yxt.yythmall.api.vegecallerreserveorder.*; import com.yxt.yythmall.biz.lpkgiftbaggoods.LpkGiftBagGoodsService; import com.yxt.yythmall.biz.lpkgiftcard.LpkGiftCardMapper; +import com.yxt.yythmall.biz.lpkgiftcard.generateRule.UniqueIdGenerator; import com.yxt.yythmall.biz.lpkgoods.LpkGoodsService; import com.yxt.yythmall.biz.lpkstore.LpkStoreService; import com.yxt.yythmall.biz.vegecallerreservedetail.VegeCellarReserveDetailsService; @@ -75,11 +76,56 @@ public class VegeCellarReserveOrderService extends MybatisBaseService().eq("customerSid",dto.getCustomerSid()) + .eq("affiliation",dto.getAffiliation()).eq("state","0")).get(0); + if(order==null){ + BeanUtil.copyProperties(dto, order, "id", "sid"); + order.setStoreSid(dto.getStoreSid()); +// order.setCardSid(dto.getSid()); + order.setCreateTime(new DateTime()); + baseMapper.insert(order); + } + dto.setOrderSid(order.getSid()); + vegeCellarReserveDetailsService.addDetail(dto); + return rb.success().setData("预约成功"); + } + public ResultBean minusGoodsOrder(VegeCellarReserveOrderDto dto) { + ResultBean rb = new ResultBean().fail(); + boolean b=isSatAndSun(dto.getReserveDate()); + if(!b){ + return rb.setMsg("周六、周日不能预约提货"); + } + VegeCellarReserveOrder order = new VegeCellarReserveOrder(); + order=baseMapper.selectList(new QueryWrapper().eq("customerSid",dto.getCustomerSid()) + .eq("affiliation",dto.getAffiliation()).eq("state","0")).get(0); + if(order==null){ + BeanUtil.copyProperties(dto, order, "id", "sid"); + order.setStoreSid(dto.getStoreSid()); +// order.setCardSid(dto.getSid()); + order.setCreateTime(new DateTime()); + baseMapper.insert(order); + } + dto.setOrderSid(order.getSid()); + vegeCellarReserveDetailsService.addDetail(dto); + return rb.success().setData("预约成功"); + } + + + public boolean isSatAndSun(String date){ DateTime dateTime = DateUtil.parse(date);; // 获取当前时间 int dayOfWeek = dateTime.dayOfWeekEnum().getValue();// 获取星期几(1-7) diff --git a/src/main/java/com/yxt/yythmall/config/SaTokenConfigure.java b/src/main/java/com/yxt/yythmall/config/SaTokenConfigure.java index 2c5df53..22d4e28 100644 --- a/src/main/java/com/yxt/yythmall/config/SaTokenConfigure.java +++ b/src/main/java/com/yxt/yythmall/config/SaTokenConfigure.java @@ -34,6 +34,7 @@ public class SaTokenConfigure implements WebMvcConfigurer { .excludePathPatterns("/empcard/isSaturAndSun/**") .excludePathPatterns("/lpkgiftcard/getReservationBySid/**") .excludePathPatterns("/lpksreservoorder/submission") + .excludePathPatterns("/lpksreservoorders/submission") .excludePathPatterns("/empsreservoorder/submission") .excludePathPatterns("/empsreservoorder/submissionEmp") .excludePathPatterns("/empcardgift/generateCard") @@ -62,6 +63,7 @@ public class SaTokenConfigure implements WebMvcConfigurer { //2024-01-17 .excludePathPatterns("/lpkgiftcard/getAllGoodsType/**") .excludePathPatterns("/lpkgoods/getAllGoodsType/**") + .excludePathPatterns("/customerstore/isSaturAndSun") .excludePathPatterns("/lpkgiftcard/getGoodsByType/**") .excludePathPatterns("/shoppingcart/addShoppingCart") .excludePathPatterns("/shoppingcart/getGoodsWeight") diff --git a/src/main/java/com/yxt/yythmall/config/SaTokenGloableException.java b/src/main/java/com/yxt/yythmall/config/SaTokenGloableException.java index 07fa3fe..9599125 100644 --- a/src/main/java/com/yxt/yythmall/config/SaTokenGloableException.java +++ b/src/main/java/com/yxt/yythmall/config/SaTokenGloableException.java @@ -30,6 +30,10 @@ public class SaTokenGloableException extends GlobalExceptionHandler { L.error(e.getMessage(), e); return ResultBean.fireFail().setCode("5000").setMsg("系统异常::" + e.getMessage()); } + if(e.getMessage().contains("未能读取到有效 token")){ +// L.error(e.getMessage(), e); + return ResultBean.fireFail().setMsg("系统异常::" + e.getMessage()); + } } L.error(e.getMessage(), e);