|
|
@@ -1,10 +1,16 @@
|
|
|
package com.kym.service.miniapp.impl;
|
|
|
|
|
|
+import cn.dev33.satoken.stp.StpUtil;
|
|
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
|
import com.kym.entity.miniapp.Account;
|
|
|
+import com.kym.entity.miniapp.UserCoupon;
|
|
|
+import com.kym.entity.miniapp.UserRechargeRights;
|
|
|
+import com.kym.entity.miniapp.vo.UserRightsAndCouponsVo;
|
|
|
import com.kym.mapper.miniapp.AccountMapper;
|
|
|
import com.kym.service.miniapp.AccountService;
|
|
|
+import com.kym.service.miniapp.UserCouponService;
|
|
|
+import com.kym.service.miniapp.UserRechargeRightsService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
/**
|
|
|
@@ -19,10 +25,44 @@ import org.springframework.stereotype.Service;
|
|
|
@DS("db-miniapp")
|
|
|
public class AccountServiceImpl extends MPJBaseServiceImpl<AccountMapper, Account> implements AccountService {
|
|
|
|
|
|
+ private final UserRechargeRightsService userRechargeRightsService;
|
|
|
+
|
|
|
+ private final UserCouponService userCouponService;
|
|
|
+
|
|
|
+ public AccountServiceImpl(UserRechargeRightsService userRechargeRightsService, UserCouponService userCouponService) {
|
|
|
+ this.userRechargeRightsService = userRechargeRightsService;
|
|
|
+ this.userCouponService = userCouponService;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public Account getAccountByUserId(Long userId) {
|
|
|
return lambdaQuery().eq(Account::getUserId, userId).one();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取用户有效权益和优惠券
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public UserRightsAndCouponsVo listRightsAndCoupons() {
|
|
|
+ var vo = new UserRightsAndCouponsVo();
|
|
|
+ var userId = StpUtil.getLoginIdAsLong();
|
|
|
+ // 当前用户有效的充电权益
|
|
|
+ var userRechargeRight = userRechargeRightsService.lambdaQuery()
|
|
|
+ .eq(UserRechargeRights::getUserId, userId).eq(UserRechargeRights::getStatus, UserRechargeRights.STATUS_有效)
|
|
|
+ .orderByAsc(UserRechargeRights::getEndTime).list();
|
|
|
+ vo.setUserRechargeRightsList(userRechargeRight);
|
|
|
+
|
|
|
+ // 当前用户有效的优惠券列表
|
|
|
+ var usesrCouponList = userCouponService.lambdaQuery()
|
|
|
+ .eq(UserCoupon::getUserId, userId)
|
|
|
+ .eq(UserCoupon::getStatus, UserCoupon.STATUS_有效)
|
|
|
+ .orderByAsc(UserCoupon::getEndTime).list();
|
|
|
+ vo.setUserCouponList(usesrCouponList);
|
|
|
+
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|