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 | 118 ++++++++++++++++++++++++----------------------------------
1 files changed, 49 insertions(+), 69 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 3a8bbfe..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
@@ -4,6 +4,7 @@
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;
@@ -170,56 +171,6 @@
*/
@Override
public List<QuerySiteTimes> querySiteTimes(Integer id, String day,String halfName,String siteName) 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()));
-//
-// 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());
-//
-// 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());
-//
-// QuerySiteTimes querySiteTimes = new QuerySiteTimes();
-//
-// querySiteTimes.setTime(start + "-" + end);
-//
-// querySiteTimes.setSelectable(1);
-//
-// 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(e_hour == hour && minute == e_minute){
-// break;
-// }
-// }
-// return list;
System.out.println("=======date======"+day);
@@ -227,9 +178,12 @@
// List<SiteBooking> siteBookings = siteClient.listBooks(id);
List<SiteBooking> siteBookings = iSiteBookingService.list(new QueryWrapper<SiteBooking>().eq("siteId", id).eq("nextName",siteName).like("times",day));
+
+
if (siteName==null|| siteName.equals("")){
siteBookings = iSiteBookingService.list(new QueryWrapper<SiteBooking>().eq("siteId", id).like("times",day));
}
+
System.out.println("=======siteBookings======"+siteBookings);
for (SiteBooking siteBooking : siteBookings) {
@@ -243,6 +197,12 @@
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) {
@@ -363,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,reservationSite.getHalfName(),reservationSite.getNextName());
for (QuerySiteTimes querySiteTime : querySiteTimes) {
if(querySiteTime.getTime().equals(time) && querySiteTime.getSelectable() == 0){
- return ResultUtil.error("【" + s + "】时间段已被使用");
+ return ResultUtil.error("【" + s + "】" +
+ "时间段已被使用");
}
}
}
@@ -388,15 +349,21 @@
Double payMoney = 0D;
if(reservationSite.getPayType() == 3){
if(reservationSite.getIsHalf()==2){
- payMoney = new BigDecimal(site.getPlayPaiCoin()).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() ;
}else {
- payMoney = new BigDecimal(site.getPlayPaiCoinOne()).multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN).doubleValue();
+ 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;
+
+ }
}
//校验优惠券
@@ -407,7 +374,7 @@
UserCoupon userCoupon = userCouponClient.queryUserCouponById(new QueryUserCouponByIdAndUserId(reservationSite.getCouponId(),uid));
- if(userCoupon.getStatus() == 2){
+ if(userCoupon!=null && userCoupon.getStatus() == 2){
return ResultUtil.error("优惠券已被核销");
}
Coupon coupon = couponClient.queryCouponById(userCoupon.getCouponId());
@@ -415,7 +382,7 @@
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("conditionalAmount");
@@ -426,7 +393,7 @@
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("conditionalAmount");
if(payMoney.compareTo(num1) <= 0){
@@ -467,8 +434,13 @@
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);
@@ -493,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
@@ -557,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
@@ -573,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;
}
@@ -592,6 +565,7 @@
siteBooking.setStatus(1);
siteBooking.setPayOrderNo(tradeNo);
siteBookingService.updateById(siteBooking);
+ System.err.println("======完成支付");
break;
}
if("WAIT_BUYER_PAY".equals(s)){
@@ -623,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);
}
@@ -765,7 +741,11 @@
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();
+ }
}
//校验优惠券
--
Gitblit v1.7.1