From 7a2c07f1cf3e124d0d710d6787b030031eeba2ea Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期三, 21 八月 2024 14:45:18 +0800 Subject: [PATCH] 代码提交 --- ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppCouponController.java | 19 ++++++++++++++----- 1 files changed, 14 insertions(+), 5 deletions(-) diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppCouponController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppCouponController.java index 4cf21b6..66a5d67 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppCouponController.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppCouponController.java @@ -14,6 +14,7 @@ import com.ruoyi.account.service.TAppUserCarService; import com.ruoyi.chargingPile.api.feignClient.ChargingPileClient; import com.ruoyi.chargingPile.api.vo.SiteInfoVO; +import com.ruoyi.chargingPile.api.feignClient.ChargingPileClient; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.web.domain.AjaxResult; import com.ruoyi.common.core.web.page.BasePage; @@ -27,6 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; @@ -45,8 +47,6 @@ public class TAppCouponController { @Autowired private TAppCouponService tAppCouponService; - @Autowired - private OtherClient otherClient; @Autowired private TAppUserCarService appUserCarService; @@ -72,9 +72,9 @@ * 查询用户可用优惠券数量 * @return */ - @ApiOperation(value = "通过桩编号获取电站详情", tags = {"小程序-扫一扫"}) + @ApiOperation(value = "通过桩编号和预付金额获取电站详情", tags = {"小程序-扫一扫"}) @GetMapping(value = "/scan/siteInfo") - public AjaxResult<SiteInfoVO> siteInfo(String number) { + public AjaxResult<SiteInfoVO> siteInfo(String number,BigDecimal money) { SiteInfoVO data = chargingPileClient.getSiteInfoByNumber(number).getData(); List<TAppUserCar> cars = appUserCarService.list(new QueryWrapper<TAppUserCar>() .eq("app_user_id",tokenService.getLoginUserApplet().getUserId()) @@ -96,6 +96,15 @@ } } } + BigDecimal electrovalence = data.getElectrovalence(); + BigDecimal vipElectrovalence = data.getVipElectrovalence(); + // 计算预付金额能充多少度普通电 + BigDecimal divide1 = money.divide(electrovalence, 2, BigDecimal.ROUND_HALF_UP); + // 计算冲会员电能充多少度会员电 + BigDecimal divide = vipElectrovalence.divide(electrovalence, 2, BigDecimal.ROUND_HALF_UP); + BigDecimal subtract = divide.subtract(divide1); + // 优惠金额 + data.setMoney(subtract.multiply(vipElectrovalence).setScale(2, BigDecimal.ROUND_HALF_UP)); return AjaxResult.ok(data); } /** @@ -126,7 +135,7 @@ * @return 优惠券ids 查询每个优惠券的发放数量 */ @PostMapping("/getCountByCouponIds") - public R<List<Integer>> getCountByCouponIds(String couponIds) { + public R<List<Integer>> getCountByCouponIds(@RequestParam("couponIds") String couponIds) { // 最终结果 和优惠券id一一对应 List<Integer> res = new ArrayList<>(); String[] split = couponIds.split(","); -- Gitblit v1.7.1