From 7b487d4c819bc67021cf224c5042066bf73df1e3 Mon Sep 17 00:00:00 2001
From: nickchange <126672920+nickchange@users.noreply.github.com>
Date: 星期六, 28 十月 2023 17:01:00 +0800
Subject: [PATCH] 10.28。2
---
cloud-server-other/src/main/java/com/dsh/other/service/impl/SiteServiceImpl.java | 367 +++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 292 insertions(+), 75 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 8f8376f..b0a16b3 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,8 +1,11 @@
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;
+import com.alipay.api.response.AlipayTradeQueryResponse;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dsh.other.entity.*;
@@ -11,11 +14,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;
@@ -23,6 +30,7 @@
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.SimpleDateFormat;
+import java.time.LocalTime;
import java.util.*;
/**
@@ -55,6 +63,11 @@
@Autowired
private PayMoneyUtil payMoneyUtil;
+ @Autowired
+ private SiteMapper siteMapper;
+
+ @Autowired
+ private TBackRecordService backRecordService;
@@ -76,7 +89,8 @@
continue;
}
Map<String, Double> distance = GeodesyUtil.getDistance(querySiteList.getLon() + "," + querySiteList.getLat(), querySiteListVo.getStoreLon() + "," + querySiteListVo.getStoreLat());
- querySiteListVo.setDistance(distance.get("WGS84"));
+ double wgs84 = new BigDecimal(distance.get("WGS84")).divide(new BigDecimal(1000)).setScale(2, RoundingMode.HALF_EVEN).doubleValue();
+ querySiteListVo.setDistance(wgs84);
}
return querySiteListVos;
}
@@ -95,6 +109,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 +118,32 @@
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();
@@ -115,6 +155,13 @@
}
+
+
+
+ @Autowired
+ private ISiteBookingService iSiteBookingService;
+ @Autowired
+ private ISiteService siteService;
/**
* 获取场地预约日期数据
* @param id
@@ -123,47 +170,148 @@
* @throws Exception
*/
@Override
- public List<QuerySiteTimes> querySiteTimes(Integer id, String day) throws Exception {
- Site site = this.getById(id);
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
- Calendar s = Calendar.getInstance();
- s.setTime(sdf.parse(day + " " + site.getAppointmentStartTime()));
- Calendar e = Calendar.getInstance();
- e.setTime(sdf.parse(day + " " + site.getAppointmentEndTime()));
+ public List<QuerySiteTimes> querySiteTimes(Integer id, String day,String halfName,String siteName) throws Exception {
- 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){
- String start = sdfs.format(s.getTime());
+ System.out.println("=======date======"+day);
- 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 = sdfs.format(s.getTime());
+ List<String> strings = new ArrayList<>();
- QuerySiteTimes querySiteTimes = new QuerySiteTimes();
- querySiteTimes.setTime(start + "-" + end);
- querySiteTimes.setSelectable(1);
+// List<SiteBooking> siteBookings = siteClient.listBooks(id);
+ List<SiteBooking> siteBookings = iSiteBookingService.list(new QueryWrapper<SiteBooking>().eq("siteId", id).eq("nextName",siteName).like("times",day));
- SiteBooking siteBooking = siteBookingService.getOne(new QueryWrapper<SiteBooking>().eq("siteId", id).eq("state", 1)
- .in("status", Arrays.asList(3, 4, 5)).last(" and DATE_FORMAT(startTime, '%Y-%m-%d %H:%i') <= '" + day + " " + start + "' and DATE_FORMAT(endTime, '%Y-%m-%d %H:%i') >= '" + day + " " + end + "'"));
- if(null != siteBooking){
- querySiteTimes.setSelectable(0);
- }
- int count = siteLockService.count(new QueryWrapper<SiteLock>().eq("siteId", id).last(" and DATE_FORMAT(startTime, '%Y-%m-%d %H:%i') <= '" + day + " " + start + "' and DATE_FORMAT(endTime, '%Y-%m-%d %H:%i') >= '" + day + " " + end + "'"));
- if(count > 0){
- querySiteTimes.setSelectable(0);
- }
- list.add(querySiteTimes);
+ if (siteName==null|| siteName.equals("")){
+ siteBookings = iSiteBookingService.list(new QueryWrapper<SiteBooking>().eq("siteId", id).like("times",day));
+ }
- if(e_hour == hour && minute == e_minute){
- break;
+
+ System.out.println("=======siteBookings======"+siteBookings);
+ for (SiteBooking siteBooking : siteBookings) {
+
+
+ String[] split = siteBooking.getTimes().split(";");
+
+ if (siteBooking.getIsHalf() == 2) {
+ for (String s : split) {
+ String convertedValue = s.substring(11);
+ strings.add(convertedValue);
+ }
+ }else {
+ if (halfName==null){
+ for (String s : split) {
+ String convertedValue = s.substring(11);
+ strings.add(convertedValue);
+ }
+ }
+
+ if (siteBooking.getHalfName().equals(halfName)){
+ for (String s : split) {
+ String convertedValue = s.substring(11);
+ strings.add(convertedValue);
+ }
+
+ }
}
}
- return list;
+ System.out.println("======strings======="+strings);
+
+
+ List<QuerySiteTimes> timeRanges = new ArrayList<>();
+
+
+ Site site = siteService.getById(id);
+ System.out.println("================"+site);
+ String appointmentStartTime = site.getAppointmentStartTime();
+ String appointmentEndTime = site.getAppointmentEndTime();
+
+ String currentTime = appointmentStartTime;
+ while (currentTime.compareTo(appointmentEndTime) < 0) {
+ String nextTime=null;
+ if("智慧场地".equals(site.getTypeName())){
+ nextTime=getNextTimeOne(currentTime);
+ }else {
+ nextTime= getNextTime(currentTime);
+ }
+
+
+ String timeRange = currentTime + "-" + nextTime;
+ QuerySiteTimes orderDto = new QuerySiteTimes();
+ orderDto.setTime(timeRange);
+
+ LocalTime currentTime1 = LocalTime.now();
+ LocalTime targetTime = LocalTime.parse(currentTime);
+
+ boolean hasExceeded = currentTime1.isAfter(targetTime);
+// if (hasExceeded){
+// orderDto.setSelectable(0);
+// }
+ if (strings.contains(timeRange)){
+
+ orderDto.setSelectable(0);
+ }else {
+
+ String stime = day+" "+currentTime;
+ String etime = day+" "+nextTime;
+ orderDto.setSelectable(1);
+ // 查出lock
+ List<SiteLock> list = siteLockService.list(new LambdaQueryWrapper<SiteLock>().eq(SiteLock::getSiteId, id));
+ for (SiteLock siteLock : list) {
+ boolean stringDateBetween = DateComparisonExample.isStringDateBetween(stime + " - " + etime, siteLock.getStartTime(), siteLock.getEndTime());
+ if(stringDateBetween){
+ orderDto.setSelectable(0);
+ }
+ }
+
+
+ }
+
+
+ timeRanges.add(orderDto);
+ currentTime = nextTime;
+ }
+ System.out.println("-------------"+timeRanges);
+
+ return timeRanges;
+
+
+
+ }
+
+
+ public static String getNextTime(String currentTime) {
+ String[] parts = currentTime.split(":");
+ int hour = Integer.parseInt(parts[0]);
+ int minute = Integer.parseInt(parts[1]);
+
+ if (minute == 30) {
+ hour++;
+ minute = 0;
+ } else {
+ minute = 30;
+ }
+
+ return String.format("%02d:%02d", hour, minute);
+
+ }
+ public static String getNextTimeOne(String currentTime) {
+
+ String[] parts = currentTime.split(":");
+ int hour = Integer.parseInt(parts[0]);
+ int minute = Integer.parseInt(parts[1]);
+
+ if (minute == 45) {
+ hour++;
+ minute = 0;
+ } else if (minute == 0){
+ minute = 15;
+ }else if (minute == 15){
+ minute = 30;
+ }else if (minute == 30){
+ minute = 45;
+ }
+
+ return String.format("%02d:%02d", hour, minute);
+
}
@@ -175,17 +323,18 @@
*/
@Override
public ResultUtil reservationSite(Integer uid, ReservationSite reservationSite) throws Exception {
+
Site site = this.getById(reservationSite.getId());
AppUser appUser = appUserClient.queryAppUser(uid);
String[] split = reservationSite.getTimes().split(";");
-
for (String s : split) {
String day = s.split(" ")[0];
String time = s.split(" ")[1];
- List<QuerySiteTimes> querySiteTimes = querySiteTimes(reservationSite.getId(), day);
+ List<QuerySiteTimes> querySiteTimes = querySiteTimes(reservationSite.getId(), day,reservationSite.getHalfName(),reservationSite.getNextName());
for (QuerySiteTimes querySiteTime : querySiteTimes) {
if(querySiteTime.getTime().equals(time) && querySiteTime.getSelectable() == 0){
- return ResultUtil.error("【" + s + "】时间段已被使用");
+ return ResultUtil.error("【" + s + "】" +
+ "时间段已被使用");
}
}
}
@@ -199,19 +348,33 @@
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() /2;
+ }
if(appUser.getPlayPaiCoins().compareTo(payMoney.intValue()) < 0){
- return ResultUtil.error("玩湃币不足");
+
+ return new ResultUtil(3,"玩湃币不足");
}
}else{
- payMoney = new BigDecimal(site.getCashPrice()).multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN).doubleValue();
+ if(reservationSite.getIsHalf()==2){
+ payMoney = new BigDecimal(site.getCashPrice()).multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN).doubleValue() ;
+ }else {
+ payMoney = new BigDecimal(site.getCashPrice()).multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN).doubleValue() / 2;
+
+ }
}
//校验优惠券
Long couponId = reservationSite.getCouponId();
+ if (couponId!=null && couponId != 0){
+
if(null != couponId && reservationSite.getPayType() != 3){
- UserCoupon userCoupon = userCouponClient.queryUserCouponById(couponId);
- if(userCoupon.getStatus() == 2){
+ UserCoupon userCoupon = userCouponClient.queryUserCouponById(new QueryUserCouponByIdAndUserId(reservationSite.getCouponId(),uid));
+
+
+ if(userCoupon!=null && userCoupon.getStatus() == 2){
return ResultUtil.error("优惠券已被核销");
}
Coupon coupon = couponClient.queryCouponById(userCoupon.getCouponId());
@@ -219,19 +382,20 @@
if(System.currentTimeMillis() >= time){
return ResultUtil.error("优惠券已过期");
}
- if(coupon.getType() == 1){//满减
+ if(userCoupon!=null && 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("该优惠券无法使用");
}
payMoney = new BigDecimal(payMoney).subtract(new BigDecimal(num2)).setScale(2, RoundingMode.HALF_EVEN).doubleValue();
}
- if(coupon.getType() == 2){//代金券
+ if(userCoupon!=null && 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("该优惠券无法使用");
}
@@ -239,6 +403,7 @@
}
userCoupon.setStatus(2);
userCouponClient.updateUserCoupon(userCoupon);
+ }
}
@@ -262,25 +427,35 @@
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){//微信支付
- return weChatPaymentSite(payMoney, siteBooking);
+ ResultUtil resultUtil = weChatPaymentSite(payMoney, siteBooking);
+
+ return resultUtil;
}
if(reservationSite.getPayType() == 2){//支付宝支付
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();
}
- 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
@@ -290,7 +465,7 @@
public ResultUtil weChatPaymentSite(Double paymentPrice, SiteBooking siteBooking) throws Exception{
String code = siteBooking.getOrderNo();
Integer id = siteBooking.getId();
- ResultUtil weixinpay = payMoneyUtil.weixinpay("预约场地", "", code, paymentPrice.toString(), "/base/site/weChatPaymentSiteCallback", "APP", "");
+ ResultUtil weixinpay = payMoneyUtil.weixinpay("预约场地", id.toString(), code, paymentPrice.toString(), "/base/site/weChatPaymentSiteCallback", "APP", "");
if(weixinpay.getCode() == 200){
new Thread(new Runnable() {
@Override
@@ -354,7 +529,7 @@
public ResultUtil aliPaymentSite(Double paymentPrice, SiteBooking siteBooking) throws Exception{
String code = siteBooking.getOrderNo();
Integer id = siteBooking.getId();
- ResultUtil alipay = payMoneyUtil.alipay("预约场地", "预约场地", "", code, paymentPrice.toString(), "/base/site/aliPaymentSiteCallback");
+ ResultUtil alipay = payMoneyUtil.alipay("预约场地", "预约场地", id.toString(), code, paymentPrice.toString(), "/base/site/aliPaymentSiteCallback");
if(alipay.getCode() == 200){
new Thread(new Runnable() {
@Override
@@ -370,17 +545,18 @@
if(siteBooking.getStatus() != 0){
break;
}
- ResultUtil<Map<String, String>> resultUtil = payMoneyUtil.queryALIOrder(code);
- if(resultUtil.getCode() == 200 && siteBooking.getStatus() == 0){
+ AlipayTradeQueryResponse resultUtil = payMoneyUtil.queryALIOrder(code);
+ if(resultUtil.getCode().equals("10000") && siteBooking.getStatus() == 0){
/**
* WAIT_BUYER_PAY(交易创建,等待买家付款)、
* TRADE_CLOSED(未付款交易超时关闭,或支付完成后全额退款)、
* TRADE_SUCCESS(交易支付成功)、
* TRADE_FINISHED(交易结束,不可退款)
*/
- Map<String, String> data1 = resultUtil.getData();
- String s = data1.get("tradeStatus");
- String tradeNo = data1.get("tradeNo");
+// Map<String, String> data1 = resultUtil.getData();
+// String s = data1.get("tradeStatus");
+ String tradeNo = resultUtil.getTradeNo();
+ String s = resultUtil.getTradeStatus();
if("TRADE_CLOSED".equals(s) || "TRADE_FINISHED".equals(s) || num == 10){
break;
}
@@ -389,6 +565,7 @@
siteBooking.setStatus(1);
siteBooking.setPayOrderNo(tradeNo);
siteBookingService.updateById(siteBooking);
+ System.err.println("======完成支付");
break;
}
if("WAIT_BUYER_PAY".equals(s)){
@@ -420,7 +597,9 @@
siteBooking.setPayTime(new Date());
siteBooking.setStatus(1);
siteBookingService.updateById(siteBooking);
- return ResultUtil.success();
+ HashMap<String, String> map = new HashMap<>();
+ map.put("siteBooking",siteBooking.getId().toString());
+ return ResultUtil.success(map);
}
@@ -441,7 +620,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;
}
@@ -456,6 +638,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("请先进行支付");
}
@@ -473,6 +661,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());
@@ -490,10 +685,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){//玩湃币
@@ -506,7 +708,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);
}
@@ -539,30 +741,35 @@
return ResultUtil.error("玩湃币不足");
}
}else{
- payMoney = new BigDecimal(site.getCashPrice()).multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN).doubleValue();
+ if(siteBooking.getIsHalf()==2){
+ payMoney = new BigDecimal(site.getCashPrice()).multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN).doubleValue();
+ }else {
+ payMoney = new BigDecimal(site.getCashPriceOne()).multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN).doubleValue();
+ }
}
//校验优惠券
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);
}
@@ -610,21 +817,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