| | |
| | | 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; |
| | |
| | | franchiseeLambdaQueryWrapper = StringUtils.isNotBlank(name) ? franchiseeLambdaQueryWrapper.like(Franchisee::getName, name) : franchiseeLambdaQueryWrapper; |
| | | franchiseeLambdaQueryWrapper = StringUtils.isNotBlank(head) ? franchiseeLambdaQueryWrapper.like(Franchisee::getHead, head) : franchiseeLambdaQueryWrapper; |
| | | franchiseeLambdaQueryWrapper = StringUtils.isNotBlank(phone) ? franchiseeLambdaQueryWrapper.like(Franchisee::getHeadPhone, phone) : franchiseeLambdaQueryWrapper; |
| | | franchiseeLambdaQueryWrapper = StringUtils.isNotBlank(city) ? franchiseeLambdaQueryWrapper.like(Franchisee::getCity, city) : franchiseeLambdaQueryWrapper; |
| | | List<Franchisee> list = franchiseeService.list(franchiseeLambdaQueryWrapper); |
| | | if (org.springframework.util.StringUtils.hasLength(city)){ |
| | | String[] cityCodes = city.split(","); |
| | | franchiseeLambdaQueryWrapper.and(e->{ |
| | | List<String> list = Arrays.asList(cityCodes); |
| | | e.like(Franchisee::getCityCode,list.get(0)); |
| | | for (int i = 1; i < list.size(); i++) { |
| | | e.or().like(Franchisee::getCityCode,list.get(i)); |
| | | } |
| | | }); |
| | | } List<Franchisee> list = franchiseeService.list(franchiseeLambdaQueryWrapper); |
| | | List<Integer> collect = list.stream().map(Franchisee::getId).collect(Collectors.toList()); |
| | | if (collect.isEmpty())collect.add(-1); |
| | | for (Franchisee franchisee : list) { |
| | |
| | | |
| | | |
| | | 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())); |
| | |
| | | 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-加盟商列表余额"}) |
| | |
| | | // 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())); |
| | |
| | | // 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())); |
| | |
| | | wrapper = StringUtils.isNotBlank(dto.getPhone()) ? wrapper.like(Franchisee::getHeadPhone, dto.getPhone()) : wrapper; |
| | | if (org.springframework.util.StringUtils.hasLength(dto.getCity())){ |
| | | String[] cityCodes = dto.getCity().split(","); |
| | | wrapper.and(wrapperLike -> { |
| | | Arrays.stream(cityCodes) |
| | | .forEach(code -> wrapperLike.like(Franchisee::getCityCode, code)); |
| | | wrapper.and(e->{ |
| | | List<String> list = Arrays.asList(cityCodes); |
| | | e.like(Franchisee::getCityCode,list.get(0)); |
| | | for (int i = 1; i < list.size(); i++) { |
| | | e.or().like(Franchisee::getCityCode,list.get(i)); |
| | | } |
| | | }); |
| | | } |
| | | // if (StringUtils.isNotBlank(dto.getCity())) { |
| | | // String[] cityCodes = Arrays.stream(dto.getCity().split(",")) |
| | | // .map(String::trim) |
| | | // .filter(StringUtils::isNotBlank) |
| | | // .distinct() |
| | | // .toArray(String[]::new); |
| | | // |
| | | // if (cityCodes.length > 0) { |
| | | // wrapper.and(andWrapper -> { |
| | | // Arrays.stream(cityCodes).forEach(code -> |
| | | // andWrapper.or() |
| | | // .apply("CONCAT(',', city_code, ',') LIKE CONCAT('%,', {0}, ',%')", code) |
| | | // ); |
| | | // }); |
| | | // } |
| | | // } |
| | | |
| | | Page<Franchisee> page = wrapper.eq(Franchisee::getIsDelete, 0) |
| | | .orderByDesc(Franchisee::getCreateTime).page(Page.of(dto.getPageNum(), dto.getPageSize())); |
| | | |
| | | |
| | | |
| | | 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(","))); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | 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(); |
| | | } |
| | | |
| | | |
| | | } |