From 62dad7098fd83914413bbb83b364e9a024ff9fb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com> Date: Thu, 13 Mar 2025 12:53:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E7=A7=9F=E9=87=91?= =?UTF-8?q?=E7=8E=B0=E5=9C=A8=E6=98=AF=203001=E6=9C=88=EF=BC=8C=E6=88=91?= =?UTF-8?q?=E8=A6=81=E6=94=B9=202601=E6=9C=88=20=20=20=20=E5=BD=93?= =?UTF-8?q?=E7=A1=AE=E5=AE=9A=E5=95=86=E5=93=81=E5=A5=97=E9=A4=90=E5=90=8E?= =?UTF-8?q?=E8=A6=81=E4=BF=AE=E6=94=B9=E5=A5=97=E9=A4=90=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E5=B8=8C=E6=9C=9B=E4=BF=AE=E6=94=B9=E5=90=8E?= =?UTF-8?q?=E4=B8=8D=E7=AE=A1=E6=98=AF=E6=96=B0=E4=B8=8B=E5=8D=95=E8=BF=98?= =?UTF-8?q?=E6=98=AF=E7=BB=AD=E8=B4=B9=E9=83=BD=E8=B7=9F=E7=9D=80=E4=B8=80?= =?UTF-8?q?=E8=B5=B7=E6=94=B9=E5=8F=98=EF=BC=8C=E5=BD=93=E6=9C=89=E9=80=BE?= =?UTF-8?q?=E6=9C=9F=E6=97=B6=E8=A6=81=E6=8A=8A=E9=80=BE=E6=9C=9F=E7=BC=B4?= =?UTF-8?q?=E6=B8=85=E5=90=8E=E6=89=8D=E5=8F=AF=E4=BB=A5=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=90=8E=E7=9A=84=E5=A5=97=E9=A4=90=E3=80=82?= =?UTF-8?q?=E6=80=A5!!!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/OpenEquipmentController.java | 8 +++--- .../shop/controller/OrderPayController.java | 27 ++++++++++++++++--- src/test/java/com/gxwebsoft/TestMain.java | 8 +----- 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/gxwebsoft/open/controller/OpenEquipmentController.java b/src/main/java/com/gxwebsoft/open/controller/OpenEquipmentController.java index 64bd4c8..1845291 100644 --- a/src/main/java/com/gxwebsoft/open/controller/OpenEquipmentController.java +++ b/src/main/java/com/gxwebsoft/open/controller/OpenEquipmentController.java @@ -376,12 +376,12 @@ public class OpenEquipmentController extends BaseController { * } */ JSONObject param = new JSONObject(); - param.put("userId", loginUser.getUserId()); - param.put("userName", loginUser.getNickname()); - param.put("userPhone", loginUser.getPhone()); + param.put("userId", order.getUserId()); + param.put("userName", order.getNickname()); + param.put("userPhone", order.getPhone()); param.put("battery_sn", one.getEquipmentCode()); System.out.println("param2 = " + param); - ResponseEntity responseEntity = restTemplate.postForEntity("http://battery.zfdliot.com/api/battery/batteryBindUser", param, JSONObject.class); + ResponseEntity responseEntity = restTemplate.postForEntity("https://battery.zfdliot.com/api/battery/batteryBindUser", param, JSONObject.class); JSONObject body = responseEntity.getBody(); log.info("电池更换调用第三方返回:{}", body); return success("换电成功"); diff --git a/src/main/java/com/gxwebsoft/shop/controller/OrderPayController.java b/src/main/java/com/gxwebsoft/shop/controller/OrderPayController.java index d9ba024..c810a72 100644 --- a/src/main/java/com/gxwebsoft/shop/controller/OrderPayController.java +++ b/src/main/java/com/gxwebsoft/shop/controller/OrderPayController.java @@ -4,6 +4,7 @@ import cn.hutool.core.bean.copier.BeanCopier; import cn.hutool.core.bean.copier.CopyOptions; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.date.DateField; +import cn.hutool.core.date.DateUnit; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.StrUtil; @@ -17,6 +18,7 @@ import com.gxwebsoft.common.core.utils.JSONUtil; import com.gxwebsoft.common.core.web.BaseController; import com.gxwebsoft.common.system.entity.User; import com.gxwebsoft.shop.entity.FreezeOrder; +import com.gxwebsoft.shop.entity.GoodsService; import com.gxwebsoft.shop.entity.Order; import com.gxwebsoft.shop.service.FreezeOrderService; import com.gxwebsoft.shop.service.OrderPayService; @@ -38,6 +40,7 @@ import java.math.BigDecimal; import java.util.Date; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Stream; import static com.gxwebsoft.common.core.constants.OrderConstants.ORDER_STATUS_OVER; import static com.gxwebsoft.common.core.constants.OrderConstants.PAY_STATUS_NO_PAY; @@ -57,8 +60,6 @@ public class OrderPayController extends BaseController { private OrderPayService orderPayService; @Resource private FreezeOrderService freezeOrderService; - - @Resource private OrderService orderService; @@ -98,7 +99,27 @@ public class OrderPayController extends BaseController { @GetMapping("/{id}") public ApiResult get(@PathVariable("id") Integer id) { - return success(orderPayService.getById(id)); + final OrderPay orderPay = orderPayService.getById(id); + final BigDecimal totalPrice = orderPay.getTotalPrice(); + final List list = orderPayService.list(new LambdaQueryWrapper() + .eq(OrderPay::getUserId,orderPay.getUserId()) + .eq(OrderPay::getPayStatus, PAY_STATUS_NO_PAY) + ); + System.out.println("list.size = " + list.size()); + final Integer goodsId = orderPay.getGoodsId(); + final EquipmentGoods goods = equipmentGoodsService.getByIdRel(goodsId); + final BigDecimal batteryRent = goods.getBatteryRent(); + System.out.println("batteryRent = " + batteryRent); + orderPay.setTotalPrice(batteryRent); + + list.forEach(d -> { + final long between = DateUtil.between(new Date(), d.getExpirationTime(), DateUnit.DAY, false); + System.out.println("item.. = " + between); + if(between < 0){ + orderPay.setTotalPrice(totalPrice); + } + }); + return success(orderPay); // 使用关联查询 //return success(orderPayService.getByIdRel(id)); } diff --git a/src/test/java/com/gxwebsoft/TestMain.java b/src/test/java/com/gxwebsoft/TestMain.java index 6b5ec29..dfe8e75 100644 --- a/src/test/java/com/gxwebsoft/TestMain.java +++ b/src/test/java/com/gxwebsoft/TestMain.java @@ -6,7 +6,6 @@ import com.alipay.api.AlipayApiException; import com.alipay.api.DefaultAlipayClient; import com.alipay.api.request.AlipayFundAuthOrderUnfreezeRequest; import com.alipay.api.response.AlipayFundAuthOrderUnfreezeResponse; -import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import com.gxwebsoft.apps.service.HualalaService; import com.gxwebsoft.apps.service.TestDataService; import com.gxwebsoft.common.core.utils.AlipayConfigUtil; @@ -15,7 +14,6 @@ import com.gxwebsoft.common.system.mapper.UserMapper; import com.gxwebsoft.common.system.service.SettingService; import com.gxwebsoft.common.system.service.UserService; import com.gxwebsoft.love.service.CertificateService; -import com.gxwebsoft.shop.entity.FreezeOrder; import com.gxwebsoft.shop.mapper.OrderGoodsMapper; import com.gxwebsoft.shop.mapper.OrderMapper; import com.gxwebsoft.shop.service.FreezeOrderService; @@ -23,14 +21,10 @@ import com.gxwebsoft.shop.service.OrderService; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.data.redis.core.StringRedisTemplate; -import org.springframework.util.CollectionUtils; import javax.annotation.Resource; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; /** * Created by WebSoft on 2020-03-23 23:37 @@ -300,7 +294,7 @@ public class TestMain { @Test public void close() throws AlipayApiException { - + DefaultAlipayClient alipayClient = null; try {