From d5b3e5a413bcfccba294793ee093722f31b2448a Mon Sep 17 00:00:00 2001 From: puzhibing <393733352@qq.com> Date: 星期三, 16 八月 2023 17:02:13 +0800 Subject: [PATCH] 添加推单日志 --- user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/AppUserServiceImpl.java | 36 ++++++++++++++++++++++++------------ 1 files changed, 24 insertions(+), 12 deletions(-) diff --git a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/AppUserServiceImpl.java b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/AppUserServiceImpl.java index e371ad1..382c4f4 100644 --- a/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/AppUserServiceImpl.java +++ b/user/guns-admin/src/main/java/com/supersavedriving/user/modular/system/service/impl/AppUserServiceImpl.java @@ -39,7 +39,9 @@ import org.springframework.web.context.request.ServletRequestAttributes; import javax.servlet.http.HttpServletRequest; +import java.math.BigDecimal; import java.math.BigInteger; +import java.math.RoundingMode; import java.net.InetAddress; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -136,8 +138,8 @@ if(token.length() > 16){ key = token.substring(token.length() - 16); } - redisUtil.setStrValue(key, appUser.getId().toString(), 7 * 24 * 60 * 60); - redisUtil.setStrValue("USER_" + appUser.getPhone(), key, 7 * 24 * 60 * 60); + redisUtil.setStrValue(key, appUser.getId().toString(), 94608000); + redisUtil.setStrValue("USER_" + appUser.getPhone(), key, 94608000); return token; } return null; @@ -241,7 +243,7 @@ Transfer transfer = new Transfer(); transfer.setDepositMerOrderId(merOrderId); transfer.setToUserId(toUserId); - transfer.setAmount(String.valueOf(Double.valueOf(amount * 100).intValue())); + transfer.setAmount(new BigDecimal(amount).multiply(new BigDecimal(100)).setScale(0, RoundingMode.HALF_EVEN).longValue() + ""); transfer.setOrderName("补贴"); transfer.setNotifyUrl(notifyUrl); transfer.setParameter1(id.toString()); @@ -274,7 +276,7 @@ .eq("coupon_state", 1).eq("status", 1).gt("remaining_quantity", 0)); List<CouponWarpper> list = new ArrayList<>(); for (Coupon coupon : coupons) { - Integer num = coupon.getCouponSendQuantity() > coupon.getRemainingQuantity() ? + Long num = coupon.getCouponSendQuantity() > coupon.getRemainingQuantity() ? coupon.getRemainingQuantity() : coupon.getCouponSendQuantity(); for (int i = 0; i < num; i++) { UserToCoupon userToCoupon = new UserToCoupon(); @@ -372,7 +374,7 @@ return ResultUtil.error("充值金额必须大于0"); } SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); - String out_trade_no = sdf.format(new Date()) + UUIDUtil.getNumberRandom(3); + String out_trade_no = sdf.format(new Date()) + UUIDUtil.getNumberRandom(5); AppUser appUser = this.selectById(uid); RechargeRecord rechargeRecord = new RechargeRecord(); rechargeRecord.setType(1); @@ -386,7 +388,7 @@ PaymentOrder paymentOrder = new PaymentOrder(); paymentOrder.setBizOrderId(out_trade_no); - paymentOrder.setAmount(String.valueOf(Double.valueOf(amount * 100).intValue())); + paymentOrder.setAmount(new BigDecimal(amount).multiply(new BigDecimal(100)).setScale(0, RoundingMode.HALF_EVEN).longValue() + ""); paymentOrder.setOrderName("账户充值"); paymentOrder.setPayType("WX_MINI"); paymentOrder.setTransferType("0"); @@ -447,16 +449,21 @@ AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); accountChangeDetail.setUserType(1); accountChangeDetail.setUserId(appUser1.getId()); - accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3)); + accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(5)); accountChangeDetail.setChangeType(3); accountChangeDetail.setType(1); accountChangeDetail.setCreateTime(new Date()); accountChangeDetail.setExplain("账户充值"); accountChangeDetail.setOldData(appUser1.getAccountBalance()); - appUser1.setAccountBalance(appUser1.getAccountBalance() + rechargeRecord1.getAmount()); + appUser1.setAccountBalance(new BigDecimal(appUser1.getAccountBalance()).add(new BigDecimal(rechargeRecord1.getAmount())).setScale(2, RoundingMode.HALF_EVEN).doubleValue()); accountChangeDetail.setNewData(appUser1.getAccountBalance()); - AppUserServiceImpl.this.updateById(appUser1); accountChangeDetailService.saveData(accountChangeDetail); + SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 6)); + Double num2 = JSON.parseObject(systemConfig.getContent()).getDouble("num2"); + if(appUser1.getHavDiscount() == 0 && rechargeRecord1.getAmount().compareTo(num2) >= 0){ + appUser1.setHavDiscount(1); + } + AppUserServiceImpl.this.updateById(appUser1); rechargeRecord1.setPayTime(new Date()); rechargeRecord1.setPayStatus(2); @@ -501,16 +508,21 @@ AccountChangeDetail accountChangeDetail = new AccountChangeDetail(); accountChangeDetail.setUserType(1); accountChangeDetail.setUserId(rechargeRecord1.getUserId()); - accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3)); + accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(5)); accountChangeDetail.setChangeType(3); accountChangeDetail.setType(1); accountChangeDetail.setCreateTime(new Date()); accountChangeDetail.setExplain("余额充值"); accountChangeDetail.setOldData(appUser.getAccountBalance()); - appUser.setAccountBalance(appUser.getAccountBalance() + rechargeRecord1.getAmount()); + appUser.setAccountBalance(new BigDecimal(appUser.getAccountBalance()).add(new BigDecimal(rechargeRecord1.getAmount())).setScale(2, RoundingMode.HALF_EVEN).doubleValue()); accountChangeDetail.setNewData(appUser.getAccountBalance()); - this.updateById(appUser); accountChangeDetailService.saveData(accountChangeDetail); + SystemConfig systemConfig = systemConfigService.selectOne(new EntityWrapper<SystemConfig>().eq("type", 6)); + Double num2 = JSON.parseObject(systemConfig.getContent()).getDouble("num2"); + if(appUser.getHavDiscount() == 0 && rechargeRecord1.getAmount().compareTo(num2) >= 0){ + appUser.setHavDiscount(1); + } + this.updateById(appUser); rechargeRecord1.setPayTime(new Date()); rechargeRecord1.setPayStatus(2); -- Gitblit v1.7.1