|
@@ -4,6 +4,7 @@ import cn.binarywang.wx.miniapp.api.WxMaService;
|
|
|
import cn.binarywang.wx.miniapp.api.WxMaUserService;
|
|
|
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
import com.atguigu.tingshu.common.constant.RedisConstant;
|
|
@@ -11,7 +12,11 @@ import com.atguigu.tingshu.common.rabbit.constant.MqConst;
|
|
|
import com.atguigu.tingshu.common.rabbit.service.RabbitService;
|
|
|
import com.atguigu.tingshu.common.util.AuthContextHolder;
|
|
|
import com.atguigu.tingshu.model.user.UserInfo;
|
|
|
+import com.atguigu.tingshu.model.user.UserPaidAlbum;
|
|
|
+import com.atguigu.tingshu.model.user.UserPaidTrack;
|
|
|
import com.atguigu.tingshu.user.mapper.UserInfoMapper;
|
|
|
+import com.atguigu.tingshu.user.mapper.UserPaidAlbumMapper;
|
|
|
+import com.atguigu.tingshu.user.mapper.UserPaidTrackMapper;
|
|
|
import com.atguigu.tingshu.user.service.UserInfoService;
|
|
|
import com.atguigu.tingshu.vo.user.UserInfoVo;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
@@ -24,8 +29,10 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Slf4j
|
|
|
@Service
|
|
@@ -44,6 +51,12 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> i
|
|
|
@Autowired
|
|
|
private RabbitService rabbitService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private UserPaidAlbumMapper userPaidAlbumMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UserPaidTrackMapper userPaidTrackMapper;
|
|
|
+
|
|
|
|
|
|
* 微信登录
|
|
|
*
|
|
@@ -77,7 +90,7 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> i
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
map.put("userId", userInfo.getId());
|
|
|
map.put("amount", new BigDecimal("100"));
|
|
|
- String orderNo = "ZS"+ DateUtil.today().replaceAll("-", "")+IdUtil.getSnowflakeNextId();
|
|
|
+ String orderNo = "ZS" + DateUtil.today().replaceAll("-", "") + IdUtil.getSnowflakeNextId();
|
|
|
map.put("orderNo", orderNo);
|
|
|
map.put("title", "首次注册赠送");
|
|
|
|
|
@@ -104,6 +117,7 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> i
|
|
|
|
|
|
|
|
|
* 查询指定用户基本信息
|
|
|
+ *
|
|
|
* @param userId
|
|
|
* @return
|
|
|
*/
|
|
@@ -115,6 +129,7 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> i
|
|
|
|
|
|
|
|
|
* 更新用户信息
|
|
|
+ *
|
|
|
* @param userInfoVo
|
|
|
*/
|
|
|
@Override
|
|
@@ -127,4 +142,53 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> i
|
|
|
baseMapper.updateById(userInfo);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 根据用户ID + 专辑ID + 音轨ID列表查询用户购买情况
|
|
|
+ *
|
|
|
+ * @param userId
|
|
|
+ * @param albumId
|
|
|
+ * @param needCheckBuyStateTrackIds
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Map<Long, Integer> userIsPaidTrack(Long userId, Long albumId, List<Long> needCheckBuyStateTrackIds) {
|
|
|
+ Map<Long, Integer> map = new HashMap<>();
|
|
|
+
|
|
|
+ Long count = userPaidAlbumMapper.selectCount(
|
|
|
+ new LambdaQueryWrapper<UserPaidAlbum>().eq(UserPaidAlbum::getUserId, userId)
|
|
|
+ .eq(UserPaidAlbum::getAlbumId, albumId)
|
|
|
+ );
|
|
|
+ if (count > 0) {
|
|
|
+ for (Long needCheckBuyStateTrackId : needCheckBuyStateTrackIds) {
|
|
|
+ map.put(needCheckBuyStateTrackId, 1);
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<UserPaidTrack> userPaidTrackList = userPaidTrackMapper
|
|
|
+ .selectList(
|
|
|
+ new LambdaQueryWrapper<UserPaidTrack>().eq(UserPaidTrack::getUserId, userId)
|
|
|
+ .eq(UserPaidTrack::getAlbumId, albumId)
|
|
|
+ );
|
|
|
+
|
|
|
+ if(CollUtil.isEmpty(userPaidTrackList)){
|
|
|
+ for (Long needCheckBuyStateTrackId : needCheckBuyStateTrackIds) {
|
|
|
+ map.put(needCheckBuyStateTrackId, 0);
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Long> userPaidTrackIdList = userPaidTrackList.stream().map(UserPaidTrack::getTrackId).collect(Collectors.toList());
|
|
|
+ for (Long needCheckBuyStateTrackId : needCheckBuyStateTrackIds) {
|
|
|
+
|
|
|
+
|
|
|
+ if(userPaidTrackIdList.contains(needCheckBuyStateTrackId)){
|
|
|
+ map.put(needCheckBuyStateTrackId, 1);
|
|
|
+ }else{
|
|
|
+ map.put(needCheckBuyStateTrackId, 0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
}
|