From ea6289bd36f4c880b480cd38b12d4226c97de736 Mon Sep 17 00:00:00 2001 From: SjS Date: Tue, 6 May 2025 19:52:11 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=AE=8C=E5=96=84=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E9=80=80=E6=AC=BE=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ruoyi/bst/booth/domain/BoothVO.java | 9 ++++ .../booth/service/impl/BoothServiceImpl.java | 6 ++- .../domain/enums/ChangeRecordBstType.java | 12 ++--- .../mapper/ChangeRecordMapper.xml | 16 +++---- .../ruoyi/bst/device/domain/DeviceQuery.java | 2 + .../ruoyi/bst/device/mapper/DeviceMapper.xml | 4 +- .../domain/dto/GiftLightingNumDTO.java | 26 ++++++++++ .../service/LightingNumService.java | 5 ++ .../service/impl/LightingNumServiceImpl.java | 40 ++++++++++++++++ .../com/ruoyi/bst/order/domain/Order.java | 5 +- .../ruoyi/bst/order/mapper/OrderMapper.java | 2 + .../ruoyi/bst/order/service/OrderService.java | 10 ++++ .../order/service/impl/OrderPayHandler.java | 3 -- .../bst/pay/service/impl/PayServiceImpl.java | 7 +++ .../ruoyi/bst/refund/mapper/RefundMapper.xml | 1 + .../ruoyi/system/user/mapper/UserMapper.xml | 2 - .../system/user/service/UserService.java | 10 ++++ .../user/service/impl/UserServiceImpl.java | 19 ++++---- .../com/ruoyi/web/app/AppBoothController.java | 4 +- .../web/app/AppChangRecordController.java | 47 +++++++++++++++++++ .../com/ruoyi/web/app/AppUserController.java | 38 +++++++++++++++ .../com/ruoyi/web/bst/BoothController.java | 10 +++- .../ruoyi/web/bst/LightingNumController.java | 28 ++++++++++- 23 files changed, 266 insertions(+), 40 deletions(-) create mode 100644 ruoyi-service/src/main/java/com/ruoyi/bst/lightingNum/domain/dto/GiftLightingNumDTO.java create mode 100644 ruoyi-web/src/main/java/com/ruoyi/web/app/AppChangRecordController.java create mode 100644 ruoyi-web/src/main/java/com/ruoyi/web/app/AppUserController.java diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/booth/domain/BoothVO.java b/ruoyi-service/src/main/java/com/ruoyi/bst/booth/domain/BoothVO.java index bf5b799..070e18d 100644 --- a/ruoyi-service/src/main/java/com/ruoyi/bst/booth/domain/BoothVO.java +++ b/ruoyi-service/src/main/java/com/ruoyi/bst/booth/domain/BoothVO.java @@ -1,9 +1,13 @@ package com.ruoyi.bst.booth.domain; +import com.ruoyi.bst.device.domain.Device; +import com.ruoyi.bst.device.domain.DeviceVO; import com.ruoyi.common.annotation.Excel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.util.List; + @Data public class BoothVO extends Booth{ @@ -23,4 +27,9 @@ public class BoothVO extends Booth{ @ApiModelProperty("店铺ID") private Long storeId; + @Excel(name = "卡座设备") + @ApiModelProperty("卡座设备") + private List devices; + + } diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/booth/service/impl/BoothServiceImpl.java b/ruoyi-service/src/main/java/com/ruoyi/bst/booth/service/impl/BoothServiceImpl.java index 4c55923..0d8ff28 100644 --- a/ruoyi-service/src/main/java/com/ruoyi/bst/booth/service/impl/BoothServiceImpl.java +++ b/ruoyi-service/src/main/java/com/ruoyi/bst/booth/service/impl/BoothServiceImpl.java @@ -178,12 +178,15 @@ public class BoothServiceImpl implements BoothService @Override public int lighting(BoothVO booth,Long userId) { + // 操作校验 + ServiceUtil.assertion(booth.getStoreId()==null,"当前卡座未绑定店铺"); + ServiceUtil.assertion(booth.getExpiredTime().isBefore(LocalDateTime.now()), "请重新绑定卡座"); + // 判断当前用户是否在该店铺下有余额 LightingNumVO vo = lightingNumMapper.selectLightingNumByUserId(userId,booth.getStoreId()); ServiceUtil.assertion(vo == null,"请先购买余额"); ServiceUtil.assertion(vo.getNumber()<=0,"余额不足,请充值"); - // 爆灯 Integer result = transactionTemplate.execute(status -> { @@ -199,6 +202,7 @@ public class BoothServiceImpl implements BoothService // 新建变化记录表 ChangeRecord changeRecord = new ChangeRecord(); changeRecord.setBstType(ChangeRecordBstType.LIGHTING.getCode()); + changeRecord.setBstId(booth.getBoothId()); changeRecord.setUserId(userId); changeRecord.setStoreId(booth.getStoreId()); changeRecord.setNumber(1); diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/changeRecord/domain/enums/ChangeRecordBstType.java b/ruoyi-service/src/main/java/com/ruoyi/bst/changeRecord/domain/enums/ChangeRecordBstType.java index 0206157..52fc580 100644 --- a/ruoyi-service/src/main/java/com/ruoyi/bst/changeRecord/domain/enums/ChangeRecordBstType.java +++ b/ruoyi-service/src/main/java/com/ruoyi/bst/changeRecord/domain/enums/ChangeRecordBstType.java @@ -9,20 +9,14 @@ import lombok.Getter; @AllArgsConstructor public enum ChangeRecordBstType { - ORDER("ORDER", "订单"), - WITHDRAW("WITHDRAW", "提现"), LIGHTING("LIGHTING", "爆灯"), - SMS("SMS", "短信"); + RECHARGE("RECHARGE", "充值"), + GIFT("GIFT", "赠送"), + REFUND("REFUND", "退款"); private final String code; private final String name; - public static ChangeRecordBstType parseByBonusBstType(String bstType) { - if (LightingBstType.ORDER.getType().equals(bstType)) { - return ORDER; - } - return null; - } } diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/changeRecord/mapper/ChangeRecordMapper.xml b/ruoyi-service/src/main/java/com/ruoyi/bst/changeRecord/mapper/ChangeRecordMapper.xml index 439ce11..305c6ea 100644 --- a/ruoyi-service/src/main/java/com/ruoyi/bst/changeRecord/mapper/ChangeRecordMapper.xml +++ b/ruoyi-service/src/main/java/com/ruoyi/bst/changeRecord/mapper/ChangeRecordMapper.xml @@ -42,14 +42,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - and user_id = #{query.userId} - and store_id = #{query.storeId} - and number = #{query.number} - and before_num = #{query.beforeNum} - and after_num = #{query.afterNum} - and bst_type = #{query.bstType} - and bst_id = #{query.bstId} - and reason = #{query.reason} + and bcr.user_id = #{query.userId} + and bcr.store_id = #{query.storeId} + and bcr.number = #{query.number} + and bcr.before_num = #{query.beforeNum} + and bcr.after_num = #{query.afterNum} + and bcr.bst_type = #{query.bstType} + and bcr.bst_id = #{query.bstId} + and bcr.reason = #{query.reason} and bs.user_name like concat('%',#{query.userName},'%') and bs.store_name like concat('%',#{query.storeName},'%') ${@com.ruoyi.framework.util.DataScopeUtil@create(query.scope) diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/device/domain/DeviceQuery.java b/ruoyi-service/src/main/java/com/ruoyi/bst/device/domain/DeviceQuery.java index 082fefa..2e03f1c 100644 --- a/ruoyi-service/src/main/java/com/ruoyi/bst/device/domain/DeviceQuery.java +++ b/ruoyi-service/src/main/java/com/ruoyi/bst/device/domain/DeviceQuery.java @@ -11,5 +11,7 @@ public class DeviceQuery extends DeviceVO{ @ApiModelProperty("设备id列表") private List deviceIds; + @ApiModelProperty("店铺id") + private Long storeId; } diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/device/mapper/DeviceMapper.xml b/ruoyi-service/src/main/java/com/ruoyi/bst/device/mapper/DeviceMapper.xml index a14a1e5..23da89e 100644 --- a/ruoyi-service/src/main/java/com/ruoyi/bst/device/mapper/DeviceMapper.xml +++ b/ruoyi-service/src/main/java/com/ruoyi/bst/device/mapper/DeviceMapper.xml @@ -93,17 +93,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" from bst_device bd left join bst_model bm on bd.model_id = bm.model_id left join sys_user su on bd.user_id = su.user_id - left join bst_booth bb on bd.booth_id = bb.user_id + left join bst_booth bb on bd.booth_id = bb.booth_id left join bst_part bp on bb.part_id = bp.part_id left join bst_store bs on bp.store_id = bs.store_id and bd.device_no = #{query.deviceNo} + and bs.store_id = #{query.storeId} and bd.booth_id = #{query.boothId} and bd.user_id = #{query.userId} and bd.model_id = #{query.modelId} and bd.device_name like concat('%', #{query.deviceName}, '%') + and bs.store_name like concat('%', #{query.storeName}, '%') and bd.mac = #{query.mac} and bd.mac2 = #{query.mac2} and bd.total_electri_quantity = #{query.totalElectriQuantity} diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/lightingNum/domain/dto/GiftLightingNumDTO.java b/ruoyi-service/src/main/java/com/ruoyi/bst/lightingNum/domain/dto/GiftLightingNumDTO.java new file mode 100644 index 0000000..d038f49 --- /dev/null +++ b/ruoyi-service/src/main/java/com/ruoyi/bst/lightingNum/domain/dto/GiftLightingNumDTO.java @@ -0,0 +1,26 @@ +package com.ruoyi.bst.lightingNum.domain.dto; + +import com.ruoyi.common.core.interfaces.LogBizParam; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.*; +import java.math.BigDecimal; + +@Data +public class GiftLightingNumDTO { + + @ApiModelProperty("店铺ID") + private Long storeId; + + @ApiModelProperty("用户ID") + private Long userId; + + @Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号格式错误") + private String phone; + + @ApiModelProperty("爆灯次数") + @NotNull(message = "爆灯次数不能为空") + private Integer number; + +} diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/lightingNum/service/LightingNumService.java b/ruoyi-service/src/main/java/com/ruoyi/bst/lightingNum/service/LightingNumService.java index 997f7f7..8aabfbd 100644 --- a/ruoyi-service/src/main/java/com/ruoyi/bst/lightingNum/service/LightingNumService.java +++ b/ruoyi-service/src/main/java/com/ruoyi/bst/lightingNum/service/LightingNumService.java @@ -4,9 +4,12 @@ import java.util.List; import com.ruoyi.bst.lightingNum.domain.LightingNum; import com.ruoyi.bst.lightingNum.domain.LightingNumVO; import com.ruoyi.bst.lightingNum.domain.LightingNumQuery; +import com.ruoyi.bst.lightingNum.domain.dto.GiftLightingNumDTO; import com.ruoyi.bst.order.domain.OrderQuery; import org.apache.ibatis.annotations.Param; +import javax.validation.Valid; + /** * 爆灯次数列表Service接口 * @@ -78,4 +81,6 @@ public interface LightingNumService public int reduceLightingNumByQuery(@Param("data") LightingNum data,@Param("query") OrderQuery query); + + int giftLightingNum(@Valid GiftLightingNumDTO dto); } diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/lightingNum/service/impl/LightingNumServiceImpl.java b/ruoyi-service/src/main/java/com/ruoyi/bst/lightingNum/service/impl/LightingNumServiceImpl.java index c29ffd8..da6835a 100644 --- a/ruoyi-service/src/main/java/com/ruoyi/bst/lightingNum/service/impl/LightingNumServiceImpl.java +++ b/ruoyi-service/src/main/java/com/ruoyi/bst/lightingNum/service/impl/LightingNumServiceImpl.java @@ -3,10 +3,19 @@ package com.ruoyi.bst.lightingNum.service.impl; import java.util.List; import com.github.pagehelper.PageHelper; +import com.ruoyi.bst.changeRecord.domain.ChangeRecord; +import com.ruoyi.bst.changeRecord.domain.enums.ChangeRecordBstType; +import com.ruoyi.bst.changeRecord.mapper.ChangeRecordMapper; +import com.ruoyi.bst.changeRecord.service.ChangeRecordService; +import com.ruoyi.bst.lightingNum.domain.dto.GiftLightingNumDTO; import com.ruoyi.bst.order.domain.OrderQuery; +import com.ruoyi.bst.store.domain.StoreVO; +import com.ruoyi.bst.store.service.StoreService; +import com.ruoyi.common.core.domain.vo.UserVO; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.ServiceUtil; import com.ruoyi.common.utils.collection.CollectionUtils; +import com.ruoyi.system.user.service.UserService; import org.apache.ibatis.annotations.Param; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -27,6 +36,16 @@ public class LightingNumServiceImpl implements LightingNumService { @Autowired private LightingNumMapper lightingNumMapper; + @Autowired + private UserService userService; + @Autowired + private StoreService storeService; + @Autowired + private LightingNumService lightingNumService; + @Autowired + private ChangeRecordService changeRecordService; + @Autowired + private ChangeRecordMapper changeRecordMapper; /** * 查询爆灯次数列表 @@ -126,4 +145,25 @@ public class LightingNumServiceImpl implements LightingNumService public int reduceLightingNumByQuery( LightingNum data, OrderQuery query) { return lightingNumMapper.reduceLightingNum(data,query); } + + @Override + public int giftLightingNum(GiftLightingNumDTO dto) { + Long storeId = dto.getStoreId(); + Integer number = dto.getNumber(); + + // 校验店铺是否存在 + StoreVO store = storeService.selectStoreById(storeId); + ServiceUtil.assertion(store == null,"当前店铺不存在"); + + UserVO user = null; + // 校验用户是否存在 + if (dto.getPhone() != null) { + user = userService.selectUserByPhonenumber(dto.getPhone()); + ServiceUtil.assertion(user == null,"当前用户不存在"); + }else { + user = userService.selectUserById(dto.getUserId()); + } + // 增加用户爆灯次数并生成记录 + return userService.addLightingNum( user.getUserId(), storeId, number,ChangeRecordBstType.GIFT.getCode(),storeId,"商户赠送爆灯次数"+number); + } } diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/order/domain/Order.java b/ruoyi-service/src/main/java/com/ruoyi/bst/order/domain/Order.java index f4a5522..8bf94d1 100644 --- a/ruoyi-service/src/main/java/com/ruoyi/bst/order/domain/Order.java +++ b/ruoyi-service/src/main/java/com/ruoyi/bst/order/domain/Order.java @@ -60,11 +60,14 @@ public class Order extends BaseEntity @ApiModelProperty("套餐ID") private Long suitId; - @Excel(name = "套餐次数") @ApiModelProperty("套餐次数") private Integer suitNum; + @Excel(name = "已退款次数") + @ApiModelProperty("已退款次数") + private Integer refundNum; + @Excel(name = "套餐金额", readConverterExp = "单=位:元") @ApiModelProperty("套餐金额") private BigDecimal suitAmount; diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/order/mapper/OrderMapper.java b/ruoyi-service/src/main/java/com/ruoyi/bst/order/mapper/OrderMapper.java index fc95782..7cc92b2 100644 --- a/ruoyi-service/src/main/java/com/ruoyi/bst/order/mapper/OrderMapper.java +++ b/ruoyi-service/src/main/java/com/ruoyi/bst/order/mapper/OrderMapper.java @@ -89,4 +89,6 @@ public interface OrderMapper int updateByQuery(@Param("data") Order data, @Param("query") OrderQuery query); OrderVO selectOrderByBstId(@Param("bstId") Long bstId); + + int addRefundNum(@Param("id") Long id, @Param("number") Integer number); } diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/order/service/OrderService.java b/ruoyi-service/src/main/java/com/ruoyi/bst/order/service/OrderService.java index 08044c6..494a45b 100644 --- a/ruoyi-service/src/main/java/com/ruoyi/bst/order/service/OrderService.java +++ b/ruoyi-service/src/main/java/com/ruoyi/bst/order/service/OrderService.java @@ -1,5 +1,6 @@ package com.ruoyi.bst.order.service; +import java.math.BigDecimal; import java.util.List; import com.ruoyi.bst.order.domain.Order; import com.ruoyi.bst.order.domain.OrderVO; @@ -7,6 +8,7 @@ import com.ruoyi.bst.order.domain.OrderQuery; import com.ruoyi.bst.order.domain.dto.OrderCreateDTO; import com.ruoyi.bst.order.domain.dto.OrderRefundDTO; import com.ruoyi.bst.pay.domain.vo.DoPayVO; +import org.apache.ibatis.annotations.Param; /** * 订单列表Service接口 @@ -118,4 +120,12 @@ public interface OrderService */ public int refund(OrderRefundDTO dto); + + /** + * 增加退款的爆灯次数 + * @param id 支付单ID + * @param number 退款爆灯数 + * @return 结果 + */ + int addRefundNum(Long id, Integer number); } diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/order/service/impl/OrderPayHandler.java b/ruoyi-service/src/main/java/com/ruoyi/bst/order/service/impl/OrderPayHandler.java index e826422..5ea76d7 100644 --- a/ruoyi-service/src/main/java/com/ruoyi/bst/order/service/impl/OrderPayHandler.java +++ b/ruoyi-service/src/main/java/com/ruoyi/bst/order/service/impl/OrderPayHandler.java @@ -34,9 +34,6 @@ public class OrderPayHandler implements PayHandler { @Autowired private UserService userService; - /** - * TODO 支付成功后处理 - */ @Override public boolean onPaySuccess(PayVO pay) { diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/pay/service/impl/PayServiceImpl.java b/ruoyi-service/src/main/java/com/ruoyi/bst/pay/service/impl/PayServiceImpl.java index d3e0d71..466a85e 100644 --- a/ruoyi-service/src/main/java/com/ruoyi/bst/pay/service/impl/PayServiceImpl.java +++ b/ruoyi-service/src/main/java/com/ruoyi/bst/pay/service/impl/PayServiceImpl.java @@ -7,6 +7,7 @@ import com.ruoyi.bst.channel.domain.ChannelVO; import com.ruoyi.bst.channel.domain.enums.ChannelApiType; import com.ruoyi.bst.channel.service.ChannelConverter; import com.ruoyi.bst.channel.service.ChannelService; +import com.ruoyi.bst.order.service.OrderService; import com.ruoyi.bst.pay.domain.Pay; import com.ruoyi.bst.pay.domain.PayQuery; import com.ruoyi.bst.pay.domain.PayVO; @@ -75,6 +76,8 @@ public class PayServiceImpl implements PayService { @Autowired private RefundConverter refundConverter; + @Autowired + private OrderService orderService; /** * 查询支付订单 @@ -492,6 +495,10 @@ public class PayServiceImpl implements PayService { int addRefunding = payMapper.addRefundingAmount(dto.getId(), dto.getRefundAmount()); ServiceUtil.assertion(addRefunding != 1, "记录退款中的金额失败"); + // 增加退款的次数 + int addRefundNum = orderService.addRefundNum(dto.getId(),dto.getNumber()); + ServiceUtil.assertion(addRefundNum != 1, "记录退款中的次数失败"); + // 创建退款订单 Refund refundPo = refundConverter.toPo(dto, pay); int refund = refundService.createRefund(refundPo); diff --git a/ruoyi-service/src/main/java/com/ruoyi/bst/refund/mapper/RefundMapper.xml b/ruoyi-service/src/main/java/com/ruoyi/bst/refund/mapper/RefundMapper.xml index bebeda2..a6666b8 100644 --- a/ruoyi-service/src/main/java/com/ruoyi/bst/refund/mapper/RefundMapper.xml +++ b/ruoyi-service/src/main/java/com/ruoyi/bst/refund/mapper/RefundMapper.xml @@ -13,6 +13,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" br.pay_id, br.amount, br.create_time, + br.number, br.status, br.reason, br.user_id, diff --git a/ruoyi-service/src/main/java/com/ruoyi/system/user/mapper/UserMapper.xml b/ruoyi-service/src/main/java/com/ruoyi/system/user/mapper/UserMapper.xml index 749d1c0..ac2c9d9 100644 --- a/ruoyi-service/src/main/java/com/ruoyi/system/user/mapper/UserMapper.xml +++ b/ruoyi-service/src/main/java/com/ruoyi/system/user/mapper/UserMapper.xml @@ -40,7 +40,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select u.user_id, - u.agent_id, u.point, u.dept_id, u.user_name, @@ -65,7 +64,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" u.balance, u.withdraw_service_type, u.withdraw_service_value, - u.area_id, u.bonus_delay, d.dept_id, d.parent_id, diff --git a/ruoyi-service/src/main/java/com/ruoyi/system/user/service/UserService.java b/ruoyi-service/src/main/java/com/ruoyi/system/user/service/UserService.java index 25f93dc..5d2fc7b 100644 --- a/ruoyi-service/src/main/java/com/ruoyi/system/user/service/UserService.java +++ b/ruoyi-service/src/main/java/com/ruoyi/system/user/service/UserService.java @@ -244,6 +244,16 @@ public interface UserService public int addLightingNum(Order order); + /** + * + * @param userId 用户ID + * @param storeId 店铺ID + * @param number 爆灯次数 + * @return + */ + public int addLightingNum(Long userId, Long storeId, Integer number ,String bstType , Long bstId ,String reason); + + /** * 减少余额 diff --git a/ruoyi-service/src/main/java/com/ruoyi/system/user/service/impl/UserServiceImpl.java b/ruoyi-service/src/main/java/com/ruoyi/system/user/service/impl/UserServiceImpl.java index 19ebbc1..919f99e 100644 --- a/ruoyi-service/src/main/java/com/ruoyi/system/user/service/impl/UserServiceImpl.java +++ b/ruoyi-service/src/main/java/com/ruoyi/system/user/service/impl/UserServiceImpl.java @@ -700,6 +700,12 @@ public class UserServiceImpl implements UserService Long userId = order.getUserId(); Integer number = order.getSuitNum(); Long storeId = order.getStoreId(); + Long orderId = order.getId(); + return addLightingNum(userId, storeId, number, ChangeRecordBstType.RECHARGE.getCode(),orderId,"用户充值,订单次数增加"+number); + } + + + public int addLightingNum(Long userId, Long storeId, Integer number ,String bstType ,Long bstId ,String reason) { if (userId == null || number == null || storeId == null) { return 0; } @@ -739,22 +745,17 @@ public class UserServiceImpl implements UserService record.setUserId(userId); record.setStoreId(storeId); record.setNumber(number); - if (lightingNumber == 0){ - record.setBeforeNum(0); - }else { - record.setBeforeNum(lightingNumber); - } + record.setBeforeNum(lightingNumber); record.setAfterNum(lightingNumber+number); - record.setBstId(order.getId()); - record.setBstType(ChangeRecordBstType.ORDER.getCode()); - record.setReason("用户充值,爆灯次数增加"+number); + record.setBstId(bstId); + record.setReason(reason); + record.setBstType(bstType); record.setCreateTime(DateUtils.getNowDate()); int recordInsert = changeRecordMapper.insertChangeRecord(record); ServiceUtil.assertion(recordInsert != 1, "新增爆灯次数记录失败"); } return rows; }); - return result == null ? 0 : result; } diff --git a/ruoyi-web/src/main/java/com/ruoyi/web/app/AppBoothController.java b/ruoyi-web/src/main/java/com/ruoyi/web/app/AppBoothController.java index ad36d38..df9763e 100644 --- a/ruoyi-web/src/main/java/com/ruoyi/web/app/AppBoothController.java +++ b/ruoyi-web/src/main/java/com/ruoyi/web/app/AppBoothController.java @@ -38,10 +38,8 @@ public class AppBoothController extends BaseController { } BoothVO booth = boothService.selectBoothByBoothId(boothId); ServiceUtil.assertion(booth==null,"当前卡座信息不存在"); - ServiceUtil.assertion(booth.getStoreId()==null,"当前卡座未绑定店铺"); ServiceUtil.assertion(booth.getUserId()==null,"请先绑定该卡座后再进行操作"); - ServiceUtil.assertion(booth.getExpiredTime().isBefore(LocalDateTime.now()), "请重新绑定卡座"); - ServiceUtil.assertion(!booth.getUserId().equals(getUserId()),"您操作当前卡座设备"); + ServiceUtil.assertion(!booth.getUserId().equals(getUserId()),"您无权操作当前卡座设备"); return toAjax(boothService.lighting(booth,getUserId())); } diff --git a/ruoyi-web/src/main/java/com/ruoyi/web/app/AppChangRecordController.java b/ruoyi-web/src/main/java/com/ruoyi/web/app/AppChangRecordController.java new file mode 100644 index 0000000..5a29254 --- /dev/null +++ b/ruoyi-web/src/main/java/com/ruoyi/web/app/AppChangRecordController.java @@ -0,0 +1,47 @@ +package com.ruoyi.web.app; + +import com.fasterxml.jackson.annotation.JsonView; +import com.github.pagehelper.PageHelper; +import com.ruoyi.bst.changeRecord.domain.ChangeRecordQuery; +import com.ruoyi.bst.changeRecord.domain.enums.ChangeRecordBstType; +import com.ruoyi.bst.changeRecord.service.ChangeRecordService; +import com.ruoyi.bst.channel.domain.ChannelQuery; +import com.ruoyi.bst.channel.service.ChannelService; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.domain.JsonViewProfile; +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; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/app/changeRecord") +public class AppChangRecordController extends BaseController { + + @Autowired + private ChangeRecordService changeRecordService; + + @ApiOperation("获取使用记录列表") + @GetMapping("/lightingRecord") + public TableDataInfo lightingRecord(ChangeRecordQuery query) { + startPage(); + PageHelper.orderBy("create_time desc"); + query.setUserId(getUserId()); + query.setBstType(ChangeRecordBstType.LIGHTING.getCode()); + return getDataTable(changeRecordService.selectChangeRecordList(query)); + } + + @ApiOperation("获取充值记录列表") + @GetMapping("/rechargeRecord") + public TableDataInfo rechargeRecord(ChangeRecordQuery query) { + startPage(); + PageHelper.orderBy("create_time desc"); + query.setUserId(getUserId()); + query.setBstType(ChangeRecordBstType.RECHARGE.getCode()); + return getDataTable(changeRecordService.selectChangeRecordList(query)); + } + +} diff --git a/ruoyi-web/src/main/java/com/ruoyi/web/app/AppUserController.java b/ruoyi-web/src/main/java/com/ruoyi/web/app/AppUserController.java new file mode 100644 index 0000000..d15b9ff --- /dev/null +++ b/ruoyi-web/src/main/java/com/ruoyi/web/app/AppUserController.java @@ -0,0 +1,38 @@ +package com.ruoyi.web.app; + +import com.ruoyi.bst.booth.domain.BoothVO; +import com.ruoyi.bst.booth.service.BoothService; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.entity.User; +import com.ruoyi.common.core.domain.vo.UserVO; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.enums.LogBizType; +import com.ruoyi.common.utils.ServiceUtil; +import com.ruoyi.system.user.service.UserConverter; +import com.ruoyi.system.user.service.UserService; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequestMapping("/app/user") +@Slf4j +public class AppUserController extends BaseController { + + @Autowired + private UserService userService; + + @ApiOperation("用户编辑基础信息") + @PutMapping("/editInfo") + public AjaxResult editInfo(@RequestBody User user) { + UserVO vo = new UserVO(); + vo.setNickName(user.getNickName()); + vo.setSex(user.getSex()); + return toAjax(userService.updateUser(vo)); + } + +} diff --git a/ruoyi-web/src/main/java/com/ruoyi/web/bst/BoothController.java b/ruoyi-web/src/main/java/com/ruoyi/web/bst/BoothController.java index ab3b7db..0a2fad9 100644 --- a/ruoyi-web/src/main/java/com/ruoyi/web/bst/BoothController.java +++ b/ruoyi-web/src/main/java/com/ruoyi/web/bst/BoothController.java @@ -92,7 +92,15 @@ public class BoothController extends BaseController { @PreAuthorize("@ss.hasPermi('bst:booth:query')") @GetMapping(value = "/{boothId}") public AjaxResult getInfo(@PathVariable("boothId") Long boothId) { - return success(boothService.selectBoothByBoothId(boothId, true)); + BoothVO booth = boothService.selectBoothByBoothId(boothId, true); + // 查询卡座下的设备信息 + DeviceQuery deviceQuery = new DeviceQuery(); + deviceQuery.setBoothId(boothId); + List devices = deviceService.selectDeviceList(deviceQuery); + if (devices != null && !devices.isEmpty()) { + booth.setDevices(devices); + } + return success(booth); } /** diff --git a/ruoyi-web/src/main/java/com/ruoyi/web/bst/LightingNumController.java b/ruoyi-web/src/main/java/com/ruoyi/web/bst/LightingNumController.java index 18ee317..e8ab64c 100644 --- a/ruoyi-web/src/main/java/com/ruoyi/web/bst/LightingNumController.java +++ b/ruoyi-web/src/main/java/com/ruoyi/web/bst/LightingNumController.java @@ -3,18 +3,23 @@ package com.ruoyi.web.bst; import com.ruoyi.bst.lightingNum.domain.LightingNum; import com.ruoyi.bst.lightingNum.domain.LightingNumQuery; import com.ruoyi.bst.lightingNum.domain.LightingNumVO; +import com.ruoyi.bst.lightingNum.domain.dto.GiftLightingNumDTO; import com.ruoyi.bst.lightingNum.service.LightingNumService; +import com.ruoyi.bst.store.service.StoreValidator; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.system.user.service.UserValidator; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; import java.util.List; /** @@ -29,6 +34,10 @@ public class LightingNumController extends BaseController { @Autowired private LightingNumService lightingNumService; + @Autowired + private StoreValidator storeValidator; + @Autowired + private UserValidator userValidator; /** * 查询爆灯次数列表列表 @@ -69,14 +78,29 @@ public class LightingNumController extends BaseController } /** - * 修改爆灯次数列表 + * 修改爆灯次数 */ @PreAuthorize("@ss.hasPermi('bst:lightingNum:edit')") - @Log(title = "爆灯次数列表", businessType = BusinessType.UPDATE) + @Log(title = "修改爆灯次数", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody LightingNum lightingNum) { return toAjax(lightingNumService.updateLightingNum(lightingNum)); } + /** + * 赠送用户爆灯次数 + */ + @PreAuthorize("@ss.hasPermi('bst:lightingNum:gift')") + @Log(title = "赠送用户爆灯次数", businessType = BusinessType.UPDATE) + @PutMapping("/giftLightingNum") + public AjaxResult giftLightingNum(@Valid @RequestBody GiftLightingNumDTO dto) + { + // 权限校验 + if (!storeValidator.canEdit(dto.getStoreId())){ + return error("您无权限操作当前店铺信息"); + } + return toAjax(lightingNumService.giftLightingNum(dto)); + } + }