| | |
| | | orderGoodsVO.setGoodsName(goods.getName()); |
| | | orderGoodsVO.setGoodsPic(goods.getHomePagePicture()); |
| | | orderGoodsVO.setNum(order.getNum()); |
| | | |
| | | // 获取积分兑换比例配置 |
| | | R<SysConfig> sysConfigR = sysConfigClient.getInfo(6L); |
| | | if (sysConfigR == null || sysConfigR.getData() == null) { |
| | | throw new ServiceException("获取积分兑换比例配置失败"); |
| | | } |
| | | String configValue = sysConfigR.getData().getConfigValue(); |
| | | if (StringUtils.isBlank(configValue)) { |
| | | throw new ServiceException("积分兑换比例配置值为空"); |
| | | } |
| | | // 使用BigDecimal处理比例,避免精度问题 |
| | | BigDecimal ratio = new BigDecimal(configValue.trim()); |
| | | if (ratio.compareTo(BigDecimal.ZERO) <= 0) { |
| | | throw new ServiceException("积分兑换比例必须大于0"); |
| | | } |
| | | |
| | | if (null != goodsSeckill) { |
| | | if(Objects.nonNull(goodsSeckill.getSellingPrice())){ |
| | | orderGoodsVO.setIntegral(goodsSeckill.getSellingPrice().multiply(ratio).intValue()); |
| | | }else { |
| | | orderGoodsVO.setIntegral(goodsSeckill.getIntegral()); |
| | | } |
| | | orderGoodsVO.setSellingPrice(goodsSeckill.getSellingPrice()); |
| | | orderGoodsVO.setIntegral(goodsSeckill.getIntegral()); |
| | | } else { |
| | | if(Objects.nonNull(goods.getSellingPrice())){ |
| | | orderGoodsVO.setIntegral(goods.getSellingPrice().multiply(ratio).intValue()); |
| | | }else { |
| | | orderGoodsVO.setIntegral(goods.getIntegral()); |
| | | } |
| | | orderGoodsVO.setSellingPrice(goods.getSellingPrice()); |
| | | orderGoodsVO.setIntegral(goods.getIntegral()); |
| | | } |
| | | |
| | | |
| | |
| | | confirmOrderVo.setResidualPoint(appUser.getAvailablePoint()); |
| | | //插入价格 |
| | | confirmOrderVo.setCash(good.getSellingPrice()); |
| | | confirmOrderVo.setPoint(good.getIntegral()); |
| | | |
| | | // 获取积分兑换比例配置 |
| | | R<SysConfig> sysConfigR = sysConfigClient.getInfo(6L); |
| | | if (sysConfigR == null || sysConfigR.getData() == null) { |
| | | throw new ServiceException("获取积分兑换比例配置失败"); |
| | | } |
| | | String configValue = sysConfigR.getData().getConfigValue(); |
| | | if (StringUtils.isBlank(configValue)) { |
| | | throw new ServiceException("积分兑换比例配置值为空"); |
| | | } |
| | | try { |
| | | // 使用BigDecimal处理比例,避免精度问题 |
| | | BigDecimal ratio = new BigDecimal(configValue.trim()); |
| | | if (ratio.compareTo(BigDecimal.ZERO) <= 0) { |
| | | throw new ServiceException("积分兑换比例必须大于0"); |
| | | } |
| | | // 计算积分并四舍五入取整 |
| | | int point = good.getSellingPrice().multiply(ratio).intValue(); |
| | | confirmOrderVo.setPoint(point); |
| | | } catch (NumberFormatException e) { |
| | | throw new RuntimeException("积分兑换比例配置值格式错误", e); |
| | | } catch (ArithmeticException e) { |
| | | throw new RuntimeException("积分计算结果溢出", e); |
| | | } |
| | | |
| | | //是否在秒杀活动中 |
| | | GetSeckillActivityInfo info = new GetSeckillActivityInfo(); |