From c6d53fb96a2e7ac88108155b604ddcef83f2fb37 Mon Sep 17 00:00:00 2001 From: xuhy <3313886187@qq.com> Date: 星期六, 30 八月 2025 10:49:09 +0800 Subject: [PATCH] 加盟商新增时撤回密码默认修改 --- ruoyi-service/ruoyi-admin/src/main/java/com/ruoyi/admin/controller/FranchiseeController.java | 71 ++++++++++++++++++++++++++++++----- 1 files changed, 61 insertions(+), 10 deletions(-) diff --git a/ruoyi-service/ruoyi-admin/src/main/java/com/ruoyi/admin/controller/FranchiseeController.java b/ruoyi-service/ruoyi-admin/src/main/java/com/ruoyi/admin/controller/FranchiseeController.java index 2c10d0e..e50a75a 100644 --- a/ruoyi-service/ruoyi-admin/src/main/java/com/ruoyi/admin/controller/FranchiseeController.java +++ b/ruoyi-service/ruoyi-admin/src/main/java/com/ruoyi/admin/controller/FranchiseeController.java @@ -29,6 +29,7 @@ import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.security.annotation.RequiresPermissions; import com.ruoyi.common.security.service.TokenService; +import com.ruoyi.common.security.utils.SecurityUtils; import com.wechat.pay.contrib.apache.httpclient.auth.PrivateKeySigner; import com.wechat.pay.contrib.apache.httpclient.util.PemUtil; import com.wechat.pay.java.core.exception.MalformedMessageException; @@ -51,6 +52,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -407,7 +409,7 @@ TFranchiseeBalanceChange tFranchiseeBalanceChange = new TFranchiseeBalanceChange(); - tFranchiseeBalanceChange.setAmount(money.multiply(new BigDecimal("0.9972")).setScale(2,BigDecimal.ROUND_DOWN)); + tFranchiseeBalanceChange.setAmount(money.multiply(new BigDecimal("0.9962")).setScale(2,BigDecimal.ROUND_DOWN)); tFranchiseeBalanceChange.setIs_pay(0); tFranchiseeBalanceChange.setFranchiseeName(byId.getName()); tFranchiseeBalanceChange.setFranchiseeId(String.valueOf(byId.getId())); @@ -450,7 +452,7 @@ BigDecimal money = new BigDecimal(2); - System.err.println(money.multiply(new BigDecimal("0.9972")).setScale(2,BigDecimal.ROUND_DOWN)); + System.err.println(money.multiply(new BigDecimal("0.9962")).setScale(2,BigDecimal.ROUND_DOWN)); } @ApiOperation(value = "扫码支付",tags = {"后台2.0-加盟商列表余额"}) @@ -509,7 +511,7 @@ // com.wechat.pay.java.service.payments.nativepay.model.PrepayResponse prepay = nativePayService.prepay(prepayRequest); //预支付成功,创建预支付订单 TFranchiseeBalanceChange tFranchiseeBalanceChange = new TFranchiseeBalanceChange(); - tFranchiseeBalanceChange.setAmount(money.multiply(new BigDecimal("0.9972")).setScale(2,BigDecimal.ROUND_DOWN)); + tFranchiseeBalanceChange.setAmount(money.multiply(new BigDecimal("0.9962")).setScale(2,BigDecimal.ROUND_DOWN)); tFranchiseeBalanceChange.setIs_pay(0); tFranchiseeBalanceChange.setFranchiseeName(byId.getName()); tFranchiseeBalanceChange.setFranchiseeId(String.valueOf(byId.getId())); @@ -591,7 +593,7 @@ // com.wechat.pay.java.service.payments.nativepay.model.PrepayResponse prepay = nativePayService.prepay(prepayRequest); //预支付成功,创建预支付订单 TFranchiseeBalanceChange tFranchiseeBalanceChange = new TFranchiseeBalanceChange(); - tFranchiseeBalanceChange.setAmount(money.multiply(new BigDecimal("0.9972")).setScale(2,BigDecimal.ROUND_DOWN)); + tFranchiseeBalanceChange.setAmount(money.multiply(new BigDecimal("0.9962")).setScale(2,BigDecimal.ROUND_DOWN)); tFranchiseeBalanceChange.setIs_pay(0); tFranchiseeBalanceChange.setFranchiseeName(byId.getName()); tFranchiseeBalanceChange.setFranchiseeId(String.valueOf(byId.getId())); @@ -777,12 +779,12 @@ wrapper.eq(Franchisee::getIsDelete, 0).orderByDesc(Franchisee::getCreateTime); Page<Franchisee> page = wrapper.page(Page.of(dto.getPageNum(), dto.getPageSize())); for (Franchisee record : page.getRecords()) { - if (record.getSiteIds()!=null){ - String[] split = record.getSiteIds().split(","); - List<Site> list = siteService.lambdaQuery().in(Site::getId, split).list(); - //用 , 拼接 - record.setSiteStr(list.stream().map(Site::getSiteName).collect(Collectors.joining(","))); - } + if (record.getSiteIds()!=null){ + String[] split = record.getSiteIds().split(","); + List<Site> list = siteService.lambdaQuery().in(Site::getId, split).list(); + //用 , 拼接 + record.setSiteStr(list.stream().map(Site::getSiteName).collect(Collectors.joining(","))); + } } @@ -906,6 +908,11 @@ .eq(SysUser::getIsEnable, 1).eq(SysUser::getIsDelete, 0).list(); if(!list1.isEmpty()){ return R.passwordError("该管理员账号已存在!"); + } + // 设置加盟商初始密码 + List<Franchisee> franchiseeList = franchiseeService.list(); + if (!CollectionUtils.isEmpty(franchiseeList)){ + franchisee.setPayPassword(franchiseeList.get(0).getPayPassword()); } boolean save = franchiseeService.save(franchisee); // 生成sysUser账号 @@ -1060,4 +1067,48 @@ return franchiseeService.updateBatchById(list) ? R.ok() : R.fail(); } + /** + * 设置加盟商操作密码 + * + */ + @ApiOperation(value = "设置加盟商操作密码【202506】", tags = {"后台-加盟商管理"}) + @PutMapping(value = "/setPayPassword") + public R<String> setPayPassword(@RequestParam(value = "payPassword") String payPassword) { + List<Franchisee> franchisee = franchiseeService.list(); + for (Franchisee franchisee1 : franchisee) { + franchisee1.setPayPassword(payPassword); + } + return franchiseeService.updateBatchById(franchisee) ? R.ok() : R.fail(); + } + @ApiOperation(value = "获取加盟商操作密码", tags = {"后台-加盟商管理"}) + @PutMapping(value = "/getPayPassword") + public R<String> getPayPassword() { + List<Franchisee> franchisee = franchiseeService.list(); + if (!franchisee.isEmpty()){ + return R.ok(franchisee.get(0).getPayPassword()); + } + return R.ok(); + } + + /** + * 设置加盟商操作密码 + * + */ + @ApiOperation(value = "加盟商余额扣除撤回【202506】", tags = {"后台-加盟商管理"}) + @PutMapping(value = "/balanceWithdraw") + public R<String> balanceWithdraw(@RequestParam(value = "id") Integer id, + @RequestParam(value = "payPassword") String payPassword) { + TFranchiseeBalanceChange balanceChange = balanceChangeService.getById(id); + Franchisee franchisee = franchiseeService.getById(balanceChange.getFranchiseeId()); + if(!payPassword.equals(franchisee.getPayPassword())){ + return R.fail("密码错误!"); + } + franchisee.setBalance(franchisee.getBalance().add(balanceChange.getAmount())); + franchiseeService.updateById(franchisee); + // 删除操作记录 + balanceChangeService.removeById(id); + return R.ok(); + } + + } -- Gitblit v1.7.1