diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/receiveBill/domain/ReceiveBill.java b/smart-switch-service/src/main/java/com/ruoyi/ss/receiveBill/domain/ReceiveBill.java index 0da36f90..5cba22e0 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/receiveBill/domain/ReceiveBill.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/receiveBill/domain/ReceiveBill.java @@ -4,6 +4,8 @@ import java.math.BigDecimal; import java.time.LocalDateTime; import java.util.Date; import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonView; +import com.ruoyi.common.core.domain.JsonViewProfile; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import org.apache.commons.lang3.builder.ToStringBuilder; @@ -23,36 +25,45 @@ public class ReceiveBill extends BaseEntity private static final long serialVersionUID = 1L; /** 账单ID */ + @JsonView(JsonViewProfile.App.class) private Long billId; /** 用户ID */ @Excel(name = "用户ID") + @JsonView(JsonViewProfile.App.class) private Long userId; /** 设备ID */ @Excel(name = "设备ID") + @JsonView(JsonViewProfile.App.class) private Long deviceId; /** 账单类型 */ @Excel(name = "账单类型") + @JsonView(JsonViewProfile.App.class) private String type; /** 账单状态 */ @Excel(name = "账单状态") + @JsonView(JsonViewProfile.App.class) private String status; /** 出账时间 */ @Excel(name = "出账时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + @JsonView(JsonViewProfile.App.class) private LocalDateTime billTime; /** 账单金额 */ @Excel(name = "账单金额") + @JsonView(JsonViewProfile.App.class) private BigDecimal amount; /** 账单描述 */ @Excel(name = "账单描述") + @JsonView(JsonViewProfile.App.class) private String description; @ApiModelProperty("已收金额") + @JsonView(JsonViewProfile.App.class) private BigDecimal receivedAmount; } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/receiveBill/domain/ReceiveBillVO.java b/smart-switch-service/src/main/java/com/ruoyi/ss/receiveBill/domain/ReceiveBillVO.java index 2ed95523..cc90cde5 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/receiveBill/domain/ReceiveBillVO.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/receiveBill/domain/ReceiveBillVO.java @@ -1,5 +1,7 @@ package com.ruoyi.ss.receiveBill.domain; +import com.fasterxml.jackson.annotation.JsonView; +import com.ruoyi.common.core.domain.JsonViewProfile; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -11,12 +13,15 @@ import lombok.Data; public class ReceiveBillVO extends ReceiveBill{ @ApiModelProperty("用户名称") + @JsonView(JsonViewProfile.App.class) private String userName; @ApiModelProperty("设备名称") + @JsonView(JsonViewProfile.App.class) private String deviceName; @ApiModelProperty("设备SN") + @JsonView(JsonViewProfile.App.class) private String deviceNo; } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/store/service/StoreValidator.java b/smart-switch-service/src/main/java/com/ruoyi/ss/store/service/StoreValidator.java index 2a18c684..05e6893f 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/store/service/StoreValidator.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/store/service/StoreValidator.java @@ -2,6 +2,7 @@ package com.ruoyi.ss.store.service; import com.ruoyi.common.core.domain.ValidateResult; import com.ruoyi.ss.store.domain.Store; +import com.ruoyi.ss.store.domain.StoreVo; import java.util.List; @@ -66,6 +67,11 @@ public interface StoreValidator { */ boolean isStoreBelongUser(List storeId, Long userId); + /** + * 判断店铺是否属于用户 + */ + boolean isStoreBelongUser(Store store, Long userId); + /** * 判断店铺是否存在 * @param storeIds diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/store/service/impl/StoreValidatorImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/store/service/impl/StoreValidatorImpl.java index 5a6a1fa3..41ec7739 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/store/service/impl/StoreValidatorImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/store/service/impl/StoreValidatorImpl.java @@ -2,6 +2,7 @@ package com.ruoyi.ss.store.service.impl; import com.ruoyi.common.core.domain.BaseValidator; import com.ruoyi.common.core.domain.ValidateResult; +import com.ruoyi.common.utils.ServiceUtil; import com.ruoyi.common.utils.collection.CollectionUtils; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.ss.device.domain.DeviceQuery; @@ -164,18 +165,22 @@ public class StoreValidatorImpl extends BaseValidator implements StoreValidator return result; } + StoreVo old = storeService.selectSmStoreById(data.getStoreId()); + if (old == null) { + return error("待修改的店铺不存在"); + } + // 前台用户更新校验 // 判断是否是当前用户的店铺 - if (!this.isStoreBelongUser(Collections.singletonList(data.getStoreId()), SecurityUtils.getUserId())) { + if (!this.isStoreBelongUser(old, SecurityUtils.getUserId())) { return error("当前店铺不属于当前用户"); } - // TODO 判断店铺是否正在变更中 - if (this.isApproving(data)) { + // 判断店铺是否正在变更中 + if (this.isApproving(old)) { return error("当前店铺正在变更中,请稍后重试"); } - return success(); } @@ -223,13 +228,23 @@ public class StoreValidatorImpl extends BaseValidator implements StoreValidator public boolean isStoreBelongUser(List storeIds, Long userId) { List stores = storeService.selectStoreByIds(storeIds); for (StoreVo item : stores) { - if (!Objects.equals(item.getUserId(), userId)) { + if (!this.isStoreBelongUser(item, userId)) { return false; } } return true; } + /** + * 判断店铺是否属于用户 + * + */ + @Override + public boolean isStoreBelongUser(Store store, Long userId) { + return store != null && store.getUserId() != null && store.getUserId().equals(userId); + } + + /** * 判断店铺是否存在 * diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/suit/domain/Suit.java b/smart-switch-service/src/main/java/com/ruoyi/ss/suit/domain/Suit.java index 12b37266..2f16945c 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/suit/domain/Suit.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/suit/domain/Suit.java @@ -65,8 +65,10 @@ public class Suit extends BaseEntity private String timeUnit; @ApiModelProperty("用户ID") + @JsonView(JsonViewProfile.AppMch.class) private Long userId; @ApiModelProperty("排序顺序,越小越靠前") + @JsonView(JsonViewProfile.AppMch.class) private Integer sort; } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/suit/domain/SuitVO.java b/smart-switch-service/src/main/java/com/ruoyi/ss/suit/domain/SuitVO.java index bc76ccb3..19033a62 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/suit/domain/SuitVO.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/suit/domain/SuitVO.java @@ -17,6 +17,7 @@ import java.util.List; public class SuitVO extends Suit { @ApiModelProperty("用户名称") + @JsonView(JsonViewProfile.AppMch.class) private String userName; @ApiModelProperty("应用的设备列表") diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/suit/service/impl/SuitAssemblerImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/suit/service/impl/SuitAssemblerImpl.java index 16f6dab4..3b095525 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/suit/service/impl/SuitAssemblerImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/suit/service/impl/SuitAssemblerImpl.java @@ -12,10 +12,7 @@ import lombok.Data; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; /** @@ -42,7 +39,7 @@ public class SuitAssemblerImpl implements SuitAssembler { for (SuitVO suit : list) { List deviceSuitList = group.get(suit.getSuitId()); if (deviceSuitList != null) { - suit.setDeviceList(deviceSuitList.stream().map(DeviceSuitVO::getDevice).collect(Collectors.toList())); + suit.setDeviceList(deviceSuitList.stream().map(DeviceSuitVO::getDevice).filter(Objects::nonNull).collect(Collectors.toList())); } else { suit.setDeviceList(Collections.emptyList()); } 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 789faf67..7867cf1e 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 @@ -87,6 +87,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and stb.user_id = #{query.userId} + and stb.bill_no like concat('%', #{query.billNo}, '%') and stb.bill_id = #{query.billId} and stb.device_id = #{query.deviceId} and stb.type = #{query.type} diff --git a/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppReceiveBillController.java b/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppReceiveBillController.java index 8e99f45e..21eee157 100644 --- a/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppReceiveBillController.java +++ b/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppReceiveBillController.java @@ -1,9 +1,13 @@ package com.ruoyi.web.controller.app; +import com.fasterxml.jackson.annotation.JsonView; 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.page.TableDataInfo; import com.ruoyi.ss.receiveBill.domain.ReceiveBillQuery; import com.ruoyi.ss.receiveBill.service.ReceiveBillService; +import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -20,9 +24,13 @@ public class AppReceiveBillController extends BaseController { @Autowired private ReceiveBillService receiveBillService; + @ApiOperation("查询本人应付账单") @GetMapping("/list") - public AjaxResult list(ReceiveBillQuery query) { - return success(); + @JsonView(JsonViewProfile.App.class) + public TableDataInfo list(ReceiveBillQuery query) { + query.setUserId(getUserId()); + startPage(); + return getDataTable(receiveBillService.selectReceiveBillList(query)); } } 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 36147e68..774c17b3 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 @@ -112,12 +112,12 @@ public class AppTransactionBillController extends BaseController @ApiOperation("查询本人收款的订单列表") @GetMapping("/incomeList") @JsonView(JsonViewProfile.AppMch.class) - public TableDataInfo incomeList(TransactionBillQuery smTransactionBill) + public TableDataInfo incomeList(TransactionBillQuery query) { startPage(); - smTransactionBill.setMchId(getUserId()); - smTransactionBill.setType(TransactionBillType.RECHARGE.getType()); - List list = smTransactionBillService.selectSmTransactionBillList(smTransactionBill); + query.setMchId(getUserId()); + query.setType(TransactionBillType.RECHARGE.getType()); + List list = smTransactionBillService.selectSmTransactionBillList(query); transactionAssembler.assembleChannelName(list); return getDataTable(list); } diff --git a/smart-switch-web/src/main/java/com/ruoyi/web/controller/mch/MchStoreApplyController.java b/smart-switch-web/src/main/java/com/ruoyi/web/controller/mch/MchStoreApplyController.java index e4b3c9e4..dc306302 100644 --- a/smart-switch-web/src/main/java/com/ruoyi/web/controller/mch/MchStoreApplyController.java +++ b/smart-switch-web/src/main/java/com/ruoyi/web/controller/mch/MchStoreApplyController.java @@ -5,6 +5,7 @@ import com.github.pagehelper.PageHelper; 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.page.TableDataInfo; import com.ruoyi.ss.store.service.StoreValidator; import com.ruoyi.ss.storeApply.domain.StoreApplyQuery; import com.ruoyi.ss.storeApply.domain.StoreApplyVO; @@ -64,4 +65,21 @@ public class MchStoreApplyController extends BaseController { return toAjax(storeApplyService.cancel(id)); } + @ApiOperation("查询本人提交的店铺申请") + @GetMapping("/list") + public TableDataInfo list(StoreApplyQuery query) { + startPage(); + query.setUserId(getUserId()); + return getDataTable(storeApplyService.selectStoreApplyList(query)); + } + @ApiOperation("查询本人提交的店铺申请详情") + @GetMapping("/{id}") + public AjaxResult detail(@PathVariable Long id) { + StoreApplyVO apply = storeApplyService.selectStoreApplyById(id); + if (!storeApplyValidator.isBelong(apply, getUserId())) { + return success(); + } + return success(apply); + } + } diff --git a/smart-switch-web/src/main/java/com/ruoyi/web/controller/mch/MchSuitController.java b/smart-switch-web/src/main/java/com/ruoyi/web/controller/mch/MchSuitController.java index 96851242..7039e50f 100644 --- a/smart-switch-web/src/main/java/com/ruoyi/web/controller/mch/MchSuitController.java +++ b/smart-switch-web/src/main/java/com/ruoyi/web/controller/mch/MchSuitController.java @@ -1,9 +1,13 @@ package com.ruoyi.web.controller.mch; +import com.fasterxml.jackson.annotation.JsonView; 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.page.TableDataInfo; import com.ruoyi.ss.suit.domain.SuitQuery; +import com.ruoyi.ss.suit.domain.SuitVO; +import com.ruoyi.ss.suit.service.SuitAssembler; import com.ruoyi.ss.suit.service.SuitService; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; @@ -11,6 +15,8 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.List; + /** * @author wjh * 2024/7/30 @@ -22,12 +28,18 @@ public class MchSuitController extends BaseController { @Autowired private SuitService suitService; + @Autowired + private SuitAssembler suitAssembler; + @ApiOperation("获取用户的套餐列表") @GetMapping("/list") + @JsonView(JsonViewProfile.AppMch.class) public TableDataInfo list(SuitQuery query) { startPage(); query.setUserId(getUserId()); - return getDataTable(suitService.selectSuitList(query)); + List list = suitService.selectSuitList(query); + suitAssembler.assembleDeviceList(list); + return getDataTable(list); } }