修复:租金现在是 3001月,我要改 2601月

当确定商品套餐后要修改套餐数据时,希望修改后不管是新下单还是续费都跟着一起改变,当有逾期时要把逾期缴清后才可以使用修改后的套餐。急!!!
This commit is contained in:
2025-03-13 12:53:34 +08:00
parent c34960d011
commit 62dad7098f
3 changed files with 29 additions and 14 deletions

View File

@@ -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<JSONObject> responseEntity = restTemplate.postForEntity("http://battery.zfdliot.com/api/battery/batteryBindUser", param, JSONObject.class);
ResponseEntity<JSONObject> responseEntity = restTemplate.postForEntity("https://battery.zfdliot.com/api/battery/batteryBindUser", param, JSONObject.class);
JSONObject body = responseEntity.getBody();
log.info("电池更换调用第三方返回:{}", body);
return success("换电成功");

View File

@@ -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<OrderPay> get(@PathVariable("id") Integer id) {
return success(orderPayService.getById(id));
final OrderPay orderPay = orderPayService.getById(id);
final BigDecimal totalPrice = orderPay.getTotalPrice();
final List<OrderPay> list = orderPayService.list(new LambdaQueryWrapper<OrderPay>()
.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));
}

View File

@@ -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 {