puzhibing
2024-08-21 6b53b5915b10b0568bb5b44ee35679ece3c476ce
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppCouponController.java
@@ -30,6 +30,7 @@
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
@@ -78,9 +79,9 @@
     * 查询用户可用优惠券数量
     * @return
     */
    @ApiOperation(value = "通过桩编号获取电站详情", tags = {"小程序-扫一扫"})
    @ApiOperation(value = "通过充电枪id和预付金额获取电站详情", tags = {"小程序-扫一扫"})
    @GetMapping(value = "/scan/siteInfo")
    public AjaxResult<SiteInfoVO> siteInfo(Integer id) {
    public AjaxResult<SiteInfoVO> siteInfo(Integer id, BigDecimal money) {
        TChargingGun chargingGun = chargingGunClient.getChargingGunById(id).getData();
        TChargingPile chargingPile = chargingPileClient.getChargingPileById(chargingGun.getChargingPileId()).getData();
        SiteInfoVO data = chargingPileClient.getSiteInfoByNumber(chargingPile.getNumber().toString()).getData();
@@ -105,6 +106,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);
    }
    /**
@@ -135,7 +145,7 @@
     * @return 优惠券ids 查询每个优惠券的发放数量
     */
    @PostMapping("/getCountByCouponIds")
    public R<List<Integer>> getCountByCouponIds(@RequestParam("couponIds") String couponIds) {
    public R<List<Integer>> getCountByCouponIds( String couponIds) {
        // 最终结果 和优惠券id一一对应
        List<Integer> res = new ArrayList<>();
        String[] split = couponIds.split(",");