From d09828cdec78a160f4530a8ab245216ed8671c27 Mon Sep 17 00:00:00 2001 From: liujie <liujie> Date: 星期三, 20 九月 2023 18:43:48 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- cloud-server-other/src/main/java/com/dsh/other/service/impl/SiteServiceImpl.java | 75 ++++++++++++++++++++++++++++++------- 1 files changed, 60 insertions(+), 15 deletions(-) diff --git a/cloud-server-other/src/main/java/com/dsh/other/service/impl/SiteServiceImpl.java b/cloud-server-other/src/main/java/com/dsh/other/service/impl/SiteServiceImpl.java index 3ab0282..1c5a8eb 100644 --- a/cloud-server-other/src/main/java/com/dsh/other/service/impl/SiteServiceImpl.java +++ b/cloud-server-other/src/main/java/com/dsh/other/service/impl/SiteServiceImpl.java @@ -1,5 +1,6 @@ package com.dsh.other.service.impl; +import cn.hutool.core.date.DateUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; @@ -13,10 +14,13 @@ import com.dsh.other.feignclient.activity.model.Coupon; import com.dsh.other.feignclient.activity.model.QueryUserCouponByIdAndUserId; import com.dsh.other.feignclient.activity.model.UserCoupon; +import com.dsh.other.feignclient.model.SiteChangeStateVO; import com.dsh.other.mapper.SiteMapper; import com.dsh.other.model.*; import com.dsh.other.service.*; import com.dsh.other.util.*; +import io.swagger.models.auth.In; +import org.aspectj.weaver.ast.Var; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -56,6 +60,8 @@ @Autowired private PayMoneyUtil payMoneyUtil; + @Autowired + private SiteMapper siteMapper; @@ -104,7 +110,24 @@ querySiteInfoVo.setStoreLon(store.getLon()); querySiteInfoVo.setStoreLat(store.getLat()); querySiteInfoVo.setStorePhone(store.getPhone()); + querySiteInfoVo.setImgs(site.getImgs()); querySiteInfoVo.setDistance(0D); + querySiteInfoVo.setIntroduce(site.getIntroduce()); + ArrayList<String> nextName = new ArrayList<>(); + ArrayList<String> halfName = new ArrayList<>(); + String nextName1 = site.getNextName(); + String halfName1 = site.getHalfName(); + querySiteInfoVo.setIshalf(site.getIshalf()); + String[] split = nextName1.split(","); + for (String s : split) { + nextName.add(s); + } + String[] split1 = halfName1.split(","); + for (String s : split1) { + halfName.add(s); + } + querySiteInfoVo.setHalfName(halfName); + querySiteInfoVo.setNextName(nextName); if(ToolUtil.isNotEmpty(lon) && ToolUtil.isNotEmpty(lat)){ Map<String, Double> distance = GeodesyUtil.getDistance(lon + "," + lat, store.getLon() + "," + store.getLat()); double wgs84 = new BigDecimal(distance.get("WGS84")).divide(new BigDecimal(1000)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); @@ -221,9 +244,10 @@ return ResultUtil.error("优惠券已过期"); } if(coupon.getType() == 1){//满减 +// {"conditionalAmount":50,"deductionAmount":10,"experienceName":""} JSONObject jsonObject = JSON.parseObject(coupon.getContent()); - Double num1 = jsonObject.getDouble("num1"); - Double num2 = jsonObject.getDouble("num2"); + Double num1 = jsonObject.getDouble("conditionalAmount"); + Double num2 = jsonObject.getDouble("deductionAmount"); if(payMoney.compareTo(num1) <= 0){ return ResultUtil.error("该优惠券无法使用"); } @@ -232,7 +256,7 @@ } if(coupon.getType() == 2){//代金券 JSONObject jsonObject = JSON.parseObject(coupon.getContent()); - Double num1 = jsonObject.getDouble("num1"); + Double num1 = jsonObject.getDouble("conditionalAmount"); if(payMoney.compareTo(num1) <= 0){ return ResultUtil.error("该优惠券无法使用"); } @@ -263,6 +287,11 @@ siteBooking.setStatus(0); siteBooking.setState(1); siteBooking.setInsertTime(new Date()); + + // 2.0 + siteBooking.setNextName(reservationSite.getNextName()); + siteBooking.setIsHalf(reservationSite.getIsHalf()); + siteBooking.setHalfName(reservationSite.getHalfName()); siteBookingService.save(siteBooking); if(reservationSite.getPayType() == 1){//微信支付 @@ -277,11 +306,7 @@ return ResultUtil.success(); } - public static void main(String[] args) { - String a ="2023-07-28 10:30-15:30"; - String substring = a.substring(0,a.lastIndexOf("-")); - System.out.println(substring); - } + /** * 课程微信支付 * @param paymentPrice @@ -442,7 +467,10 @@ SiteBooking siteBooking = siteBookingService.getById(queryMySiteVo.getId()); Site site = this.getById(siteBooking.getSiteId()); String[] split = siteBooking.getTimes().split(";"); - queryMySiteVo.setPlayPaiCoin(site.getPlayPaiCoin() * split.length); + if(site!=null){ + + queryMySiteVo.setPlayPaiCoin(site.getPlayPaiCoin() * split.length); + } } return queryMySiteVos; } @@ -457,6 +485,12 @@ @Override public ResultUtil cancelMySite(Integer uid, Integer id) throws Exception { SiteBooking siteBooking = siteBookingService.getById(id); + + SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); + Date startTime = siteBooking.getStartTime(); + if(format.format(new Date()).equals(format.format(startTime))){ + return ResultUtil.error("预约当天,不能取消"); + } if(siteBooking.getStatus() == 0){ return ResultUtil.error("请先进行支付"); } @@ -549,14 +583,15 @@ UserCoupon userCoupon = userCouponClient.queryUserCouponById(new QueryUserCouponByIdAndUserId(siteBooking.getUserCouponId(),appUser.getId())); Coupon coupon = couponClient.queryCouponById(userCoupon.getCouponId()); if(coupon.getType() == 1){//满减 +// {"conditionalAmount":50,"deductionAmount":10,"experienceName":""} JSONObject jsonObject = JSON.parseObject(coupon.getContent()); - Double num1 = jsonObject.getDouble("num1"); - Double num2 = jsonObject.getDouble("num2"); + Double num1 = jsonObject.getDouble("conditionalAmount"); + Double num2 = jsonObject.getDouble("deductionAmount"); payMoney = new BigDecimal(payMoney).subtract(new BigDecimal(num2)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); } if(coupon.getType() == 2){//代金券 JSONObject jsonObject = JSON.parseObject(coupon.getContent()); - Double num1 = jsonObject.getDouble("num1"); + Double num1 = jsonObject.getDouble("conditionalAmount"); payMoney = new BigDecimal(payMoney).subtract(new BigDecimal(num1)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); } userCoupon.setStatus(2); @@ -614,18 +649,28 @@ UserCoupon userCoupon = userCouponClient.queryUserCouponById(new QueryUserCouponByIdAndUserId(siteBooking.getUserCouponId(),siteBooking.getAppUserId())); Coupon coupon = couponClient.queryCouponById(userCoupon.getCouponId()); if(coupon.getType() == 1){//满减 +// {"conditionalAmount":50,"deductionAmount":10,"experienceName":""} JSONObject jsonObject = JSON.parseObject(coupon.getContent()); - Double num1 = jsonObject.getDouble("num1"); - Double num2 = jsonObject.getDouble("num2"); + Double num1 = jsonObject.getDouble("conditionalAmount"); + Double num2 = jsonObject.getDouble("deductionAmount"); payMoney = new BigDecimal(payMoney).subtract(new BigDecimal(num2)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); } if(coupon.getType() == 2){//代金券 JSONObject jsonObject = JSON.parseObject(coupon.getContent()); - Double num1 = jsonObject.getDouble("num1"); + Double num1 = jsonObject.getDouble("conditionalAmount"); payMoney = new BigDecimal(payMoney).subtract(new BigDecimal(num1)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); } } map.put("cash", payMoney); return ResultUtil.success(map); } + + @Override + public Object changeState(SiteChangeStateVO vo) { + + List<Integer> siteIds = vo.getSiteIds(); + Integer type = vo.getType(); + return siteMapper.changeState(siteIds,type); + + } } -- Gitblit v1.7.1