From 78577db9b3ac489bb8221b043a88949e872a111b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A2=A8=E5=A4=A7=E5=8F=94?= <494979559@qq.com> Date: Tue, 15 Oct 2024 17:58:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E6=88=B7=E4=B8=AD=E5=BF=83=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/core/domain/entity/SmUser.java | 3 +++ .../domain/TransactionBillQuery.java | 3 +++ .../mapper/TransactionBillMapper.xml | 1 + .../service/TransactionBillValidator.java | 4 ++++ .../impl/TransactionBillValidatorImpl.java | 5 ++++ .../ruoyi/ss/user/service/UserConverter.java | 15 ++++++++++++ .../user/service/impl/UserConverterImpl.java | 23 +++++++++++++++++++ .../user/service/impl/UserValidatorImpl.java | 2 +- .../app/AppTransactionBillController.java | 2 +- .../web/controller/app/AppUserController.java | 12 ++++++++++ .../mch/MchTransactionBillController.java | 2 +- 11 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 smart-switch-service/src/main/java/com/ruoyi/ss/user/service/UserConverter.java create mode 100644 smart-switch-service/src/main/java/com/ruoyi/ss/user/service/impl/UserConverterImpl.java diff --git a/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/core/domain/entity/SmUser.java b/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/core/domain/entity/SmUser.java index c554284c..22c01465 100644 --- a/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/core/domain/entity/SmUser.java +++ b/smart-switch-ruoyi/smart-switch-common/src/main/java/com/ruoyi/common/core/domain/entity/SmUser.java @@ -204,10 +204,12 @@ public class SmUser extends BaseEntity @ApiModelProperty("用户类型") @NotNull(message = "用户类型不允许为空", groups = {ValidGroup.Create.class}) + @JsonView(JsonViewProfile.AppMch.class) private String type; @Excel(name = "代理商服务费比例") @ApiModelProperty("代理商服务费比例") + @JsonView(JsonViewProfile.AppMch.class) private BigDecimal agentServiceRate; @Excel(name = "到账延迟时间", readConverterExp = "小=时") @@ -231,6 +233,7 @@ public class SmUser extends BaseEntity @Excel(name = "代理商默认设备服务费率") @ApiModelProperty("代理商默认设备服务费率") + @JsonView(JsonViewProfile.AppMch.class) private BigDecimal agentDeviceService; } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/domain/TransactionBillQuery.java b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/domain/TransactionBillQuery.java index c3fc34f6..eaf5ee22 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/domain/TransactionBillQuery.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/domain/TransactionBillQuery.java @@ -124,4 +124,7 @@ public class TransactionBillQuery extends TransactionBill { @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @ApiModelProperty("创建时间(结束)") private LocalDateTime createTimeEnd; + + @ApiModelProperty("收入人ID") + private Long incomeUserId; } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/mapper/TransactionBillMapper.xml b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/mapper/TransactionBillMapper.xml index 82e8dedd..05096402 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/mapper/TransactionBillMapper.xml +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/mapper/TransactionBillMapper.xml @@ -161,6 +161,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and stb.user_id = #{query.userId} + and (stb.mch_id = #{query.incomeUserId} or stb.agent_id = #{query.incomeUserId}) and stb.bill_no like concat('%', #{query.billNo}, '%') and stb.bill_id = #{query.billId} and stb.device_id = #{query.deviceId} diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/TransactionBillValidator.java b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/TransactionBillValidator.java index e5a6ac1f..c09d5790 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/TransactionBillValidator.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/TransactionBillValidator.java @@ -55,4 +55,8 @@ public interface TransactionBillValidator { */ ValidateResult prePayDeposit(RechargePayDepositBO bo); + /** + * 判断用户是否是订单的代理商 + */ + boolean isAgent(TransactionBillVO bill, Long userId); } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/TransactionBillValidatorImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/TransactionBillValidatorImpl.java index 25f29196..c26a7893 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/TransactionBillValidatorImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/TransactionBillValidatorImpl.java @@ -315,4 +315,9 @@ public class TransactionBillValidatorImpl extends BaseValidator implements Trans return success(); } + + @Override + public boolean isAgent(TransactionBillVO bill, Long userId) { + return bill != null && userId != null && Objects.equals(bill.getAgentId(), userId); + } } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/UserConverter.java b/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/UserConverter.java new file mode 100644 index 00000000..29cee47e --- /dev/null +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/UserConverter.java @@ -0,0 +1,15 @@ +package com.ruoyi.ss.user.service; + +import com.ruoyi.common.core.domain.entity.SmUser; + +/** + * @author wjh + * 2024/10/15 + */ +public interface UserConverter { + /** + * 用户设置 + */ + SmUser toUserSettingByApp(SmUser data); + +} diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/impl/UserConverterImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/impl/UserConverterImpl.java new file mode 100644 index 00000000..27483cd9 --- /dev/null +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/impl/UserConverterImpl.java @@ -0,0 +1,23 @@ +package com.ruoyi.ss.user.service.impl; + +import com.ruoyi.common.core.domain.entity.SmUser; +import com.ruoyi.ss.user.service.UserConverter; +import org.springframework.stereotype.Service; + +/** + * @author wjh + * 2024/10/15 + */ +@Service +public class UserConverterImpl implements UserConverter { + @Override + public SmUser toUserSettingByApp(SmUser data) { + if (data == null) { + return null; + } + SmUser po = new SmUser(); + po.setUserId(data.getUserId()); + po.setAgentDeviceService(data.getAgentDeviceService()); + return po; + } +} diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/impl/UserValidatorImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/impl/UserValidatorImpl.java index ee4732c5..e559ef96 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/impl/UserValidatorImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/user/service/impl/UserValidatorImpl.java @@ -137,7 +137,7 @@ public class UserValidatorImpl extends BaseValidator implements UserValidator { BigDecimal agentRate = vo.getAgentServiceRate(); BigDecimal deviceRate = vo.getAgentDeviceService(); ServiceUtil.assertion(agentRate != null && deviceRate != null && agentRate.compareTo(deviceRate) > 0, - "代理服务费不允许大于代理默认设备服务费:" + deviceRate + "%"); + String.format("代理服务费(%s%%)不允许大于默认设备服务费(%s%%)", agentRate, deviceRate)); // 代理服务费不允许大于目前最大的设备服务费 DeviceQuery query = new DeviceQuery(); diff --git a/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppTransactionBillController.java b/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppTransactionBillController.java index d42d53e7..a8ab24e7 100644 --- a/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppTransactionBillController.java +++ b/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppTransactionBillController.java @@ -121,7 +121,7 @@ public class AppTransactionBillController extends BaseController public TableDataInfo incomeList(TransactionBillQuery query) { startPage(); - query.setMchId(getUserId()); + query.setIncomeUserId(getUserId()); query.setType(TransactionBillType.RECHARGE.getType()); List list = transactionBillService.selectSmTransactionBillList(query); transactionAssembler.assembleChannelName(list); diff --git a/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppUserController.java b/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppUserController.java index 90b74c77..7a1dcdcf 100644 --- a/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppUserController.java +++ b/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppUserController.java @@ -5,6 +5,7 @@ import com.ruoyi.common.constant.HttpStatus; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.JsonViewProfile; +import com.ruoyi.common.core.domain.entity.SmUser; import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.ServiceUtil; @@ -17,6 +18,7 @@ import com.ruoyi.ss.user.domain.dto.UserRealNameDTO; import com.ruoyi.ss.user.domain.dto.UserUpdatePasswordDTO; import com.ruoyi.ss.user.service.ISmUserService; import com.ruoyi.ss.user.service.UserAssembler; +import com.ruoyi.ss.user.service.UserConverter; import com.ruoyi.system.domain.enums.verificationCode.CodeBusinessType; import com.ruoyi.system.service.IVerificationCodeService; import io.swagger.annotations.Api; @@ -54,6 +56,9 @@ public class AppUserController extends BaseController { @Autowired private TokenService tokenService; + @Autowired + private UserConverter userConvert; + @ApiOperation("获取当前登录前台用户的信息") @GetMapping("/userInfo") @JsonView(JsonViewProfile.AppMch.class) @@ -147,4 +152,11 @@ public class AppUserController extends BaseController { public AjaxResult bindWxMobile(@ApiParam("微信手机号临时授权码") String mobileCode) { return toAjax(userService.bindWxMobile(getUserId(), mobileCode)); } + + @ApiOperation("修改用户设置") + @PutMapping("/updateSetting") + public AjaxResult updateSetting(@RequestBody SmUser data) { + data.setUserId(getUserId()); + return toAjax(userService.updateSmUser(userConvert.toUserSettingByApp(data))); + } } diff --git a/smart-switch-web/src/main/java/com/ruoyi/web/controller/mch/MchTransactionBillController.java b/smart-switch-web/src/main/java/com/ruoyi/web/controller/mch/MchTransactionBillController.java index c2ffccc9..12aa32e8 100644 --- a/smart-switch-web/src/main/java/com/ruoyi/web/controller/mch/MchTransactionBillController.java +++ b/smart-switch-web/src/main/java/com/ruoyi/web/controller/mch/MchTransactionBillController.java @@ -50,7 +50,7 @@ public class MchTransactionBillController extends BaseController { @JsonView(JsonViewProfile.AppMch.class) public AjaxResult detail(@PathVariable Long billId) { TransactionBillVO bill = transactionBillService.selectSmTransactionBillByBillId(billId); - if (bill == null || !transactionBillValidator.isMch(bill, getUserId())) { + if (!transactionBillValidator.isMch(bill, getUserId()) && !transactionBillValidator.isAgent(bill, getUserId())) { return success(); } transactionAssembler.assembleChannelName(Collections.singletonList(bill));