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 {