From a1e4cfc3de4f3f3f3956b769bc7af40d097c8a4c Mon Sep 17 00:00:00 2001 From: liujie <liujie> Date: 星期二, 17 十月 2023 15:12:57 +0800 Subject: [PATCH] 修改bug --- cloud-server-other/src/main/java/com/dsh/other/service/impl/SiteServiceImpl.java | 150 ++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 126 insertions(+), 24 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 403a241..27297b4 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; @@ -11,11 +12,15 @@ import com.dsh.other.feignclient.activity.CouponClient; import com.dsh.other.feignclient.activity.UserCouponClient; 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; @@ -55,6 +60,11 @@ @Autowired private PayMoneyUtil payMoneyUtil; + @Autowired + private SiteMapper siteMapper; + + @Autowired + private TBackRecordService backRecordService; @@ -95,6 +105,7 @@ Store store = storeService.getById(site.getStoreId()); QuerySiteInfoVo querySiteInfoVo = new QuerySiteInfoVo(); querySiteInfoVo.setId(site.getId()); + querySiteInfoVo.setTypeName(site.getTypeName()); querySiteInfoVo.setName(site.getName()); querySiteInfoVo.setSiteTypeName(siteType.getName()); querySiteInfoVo.setStoreName(store.getName()); @@ -103,7 +114,29 @@ querySiteInfoVo.setStoreLon(store.getLon()); querySiteInfoVo.setStoreLat(store.getLat()); querySiteInfoVo.setStorePhone(store.getPhone()); + querySiteInfoVo.setImgs(site.getImgs()); querySiteInfoVo.setDistance(0D); + querySiteInfoVo.setCashPriceOne(site.getCashPriceOne()); + if(site.getPlayPaiCoinOne()!=null){ + querySiteInfoVo.setPlayPaiCoinOne(site.getPlayPaiCoinOne().intValue()); + } + + 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(); @@ -132,20 +165,29 @@ e.setTime(sdf.parse(day + " " + site.getAppointmentEndTime())); int hour = e.get(Calendar.HOUR_OF_DAY); + int minute = e.get(Calendar.MINUTE); + List<QuerySiteTimes> list = new ArrayList<>(); + + SimpleDateFormat sdfs = new SimpleDateFormat("HH:mm"); + while (true){ - int s_hour = s.get(Calendar.HOUR_OF_DAY); - int s_minute = s.get(Calendar.MINUTE); - String start = s_hour + ":" + s_minute; + + String start = sdfs.format(s.getTime()); s.set(Calendar.MINUTE, s.get(Calendar.MINUTE) + 30); + int e_hour = s.get(Calendar.HOUR_OF_DAY); + int e_minute = s.get(Calendar.MINUTE); - String end = e_hour + ":" + e_minute; + + String end = sdfs.format(s.getTime()); QuerySiteTimes querySiteTimes = new QuerySiteTimes(); + querySiteTimes.setTime(start + "-" + end); + querySiteTimes.setSelectable(1); SiteBooking siteBooking = siteBookingService.getOne(new QueryWrapper<SiteBooking>().eq("siteId", id).eq("state", 1) @@ -193,14 +235,18 @@ String s_time = split[0]; String e_time = split[split.length - 1]; - s_time = s_time.substring(s_time.lastIndexOf("-")); + s_time = s_time.substring(0,s_time.lastIndexOf("-")); String[] s1 = e_time.split(" "); e_time = s1[0] + " " + s1[1].split("-")[1]; SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm"); SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); Double payMoney = 0D; if(reservationSite.getPayType() == 3){ - payMoney = new BigDecimal(site.getCashPrice()).multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); + if(reservationSite.getIsHalf()==2){ + payMoney = new BigDecimal(site.getPlayPaiCoin()).multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); + }else { + payMoney = new BigDecimal(site.getPlayPaiCoinOne()).multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); + } if(appUser.getPlayPaiCoins().compareTo(payMoney.intValue()) < 0){ return ResultUtil.error("玩湃币不足"); } @@ -210,8 +256,12 @@ //校验优惠券 Long couponId = reservationSite.getCouponId(); + if (couponId!=null && couponId != 0){ + if(null != couponId && reservationSite.getPayType() != 3){ - UserCoupon userCoupon = userCouponClient.queryUserCouponById(couponId); + UserCoupon userCoupon = userCouponClient.queryUserCouponById(new QueryUserCouponByIdAndUserId(reservationSite.getCouponId(),uid)); + + if(userCoupon.getStatus() == 2){ return ResultUtil.error("优惠券已被核销"); } @@ -221,9 +271,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 +283,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("该优惠券无法使用"); } @@ -240,6 +291,7 @@ } userCoupon.setStatus(2); userCouponClient.updateUserCoupon(userCoupon); + } } @@ -263,6 +315,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){//微信支付 @@ -272,7 +329,11 @@ return aliPaymentSite(payMoney, siteBooking); } if(reservationSite.getPayType() == 3){//玩湃币支付 - return playPaiCoinPaymentSite(appUser, payMoney, siteBooking); + if(reservationSite.getIsHalf()==2){ + return playPaiCoinPaymentSite(appUser, Double.valueOf(site.getPlayPaiCoin()), siteBooking); + }else { + return playPaiCoinPaymentSite(appUser, site.getPlayPaiCoinOne(), siteBooking); + } } return ResultUtil.success(); } @@ -433,7 +494,17 @@ @Override public List<QueryMySiteVo> queryMySite(Integer uid, Integer status, Integer pageNo, Integer pageSize) throws Exception { pageNo = (pageNo - 1) * pageSize; - return this.baseMapper.queryMySite(uid, status, pageNo, pageSize); + List<QueryMySiteVo> queryMySiteVos = this.baseMapper.queryMySite(uid, status, pageNo, pageSize); + for (QueryMySiteVo queryMySiteVo : queryMySiteVos) { + SiteBooking siteBooking = siteBookingService.getById(queryMySiteVo.getId()); + Site site = this.getById(siteBooking.getSiteId()); + String[] split = siteBooking.getTimes().split(";"); + if(site!=null){ + + queryMySiteVo.setPlayPaiCoin(site.getPlayPaiCoin() * split.length); + } + } + return queryMySiteVos; } @@ -446,6 +517,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("请先进行支付"); } @@ -463,6 +540,13 @@ } siteBooking.setCancelUserId(uid); siteBookingService.updateById(siteBooking); + + TBackRecord tBackRecord = new TBackRecord(); + tBackRecord.setMoney(siteBooking.getPayMoney()); + tBackRecord.setUserId(siteBooking.getAppUserId()); + tBackRecord.setTime(new Date()); + backRecordService.save(tBackRecord); + } if(siteBooking.getPayType() == 2){//支付宝 Map<String, String> map = payMoneyUtil.aliRefund(siteBooking.getPayOrderNo(), siteBooking.getPayMoney().toString()); @@ -480,10 +564,17 @@ siteBooking.setRefundOrderNo(trade_no); siteBookingService.updateById(siteBooking); if(null != siteBooking.getUserCouponId()){ - UserCoupon userCoupon = userCouponClient.queryUserCouponById(siteBooking.getUserCouponId()); + UserCoupon userCoupon = userCouponClient.queryUserCouponById(new QueryUserCouponByIdAndUserId(siteBooking.getUserCouponId(),siteBooking.getAppUserId())); userCoupon.setStatus(1); userCouponClient.updateUserCoupon(userCoupon); } + + + TBackRecord tBackRecord = new TBackRecord(); + tBackRecord.setMoney(siteBooking.getPayMoney()); + tBackRecord.setUserId(siteBooking.getAppUserId()); + tBackRecord.setTime(new Date()); + backRecordService.save(tBackRecord); } if(siteBooking.getPayType() == 3){//玩湃币 @@ -496,7 +587,7 @@ siteBooking.setCancelTime(new Date()); siteBookingService.updateById(siteBooking); if(null != siteBooking.getUserCouponId()){ - UserCoupon userCoupon = userCouponClient.queryUserCouponById(siteBooking.getUserCouponId()); + UserCoupon userCoupon = userCouponClient.queryUserCouponById(new QueryUserCouponByIdAndUserId(siteBooking.getUserCouponId(),appUser.getId())); userCoupon.setStatus(1); userCouponClient.updateUserCoupon(userCoupon); } @@ -524,7 +615,7 @@ String[] split = siteBooking.getTimes().split(";"); Double payMoney = 0D; if(payType == 3){ - payMoney = new BigDecimal(site.getCashPrice()).multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); + payMoney = new BigDecimal(site.getPlayPaiCoin()).multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); if(appUser.getPlayPaiCoins().compareTo(payMoney.intValue()) < 0){ return ResultUtil.error("玩湃币不足"); } @@ -535,24 +626,25 @@ //校验优惠券 Long couponId = siteBooking.getUserCouponId(); if(null != couponId && payType != 3){ - UserCoupon userCoupon = userCouponClient.queryUserCouponById(couponId); + 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); userCouponClient.updateUserCoupon(userCoupon); } if(null != couponId && payType == 3){ - UserCoupon userCoupon = userCouponClient.queryUserCouponById(couponId); + UserCoupon userCoupon = userCouponClient.queryUserCouponById(new QueryUserCouponByIdAndUserId(siteBooking.getUserCouponId(),appUser.getId())); userCoupon.setStatus(1); userCouponClient.updateUserCoupon(userCoupon); } @@ -600,21 +692,31 @@ //校验优惠券 Long couponId = siteBooking.getUserCouponId(); if(null != couponId){ - UserCoupon userCoupon = userCouponClient.queryUserCouponById(couponId); + 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