|
@@ -1,13 +1,16 @@
|
|
|
package com.zhongzheng.modules.goods.service.impl;
|
|
package com.zhongzheng.modules.goods.service.impl;
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.lang.Validator;
|
|
import cn.hutool.core.lang.Validator;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.zhongzheng.common.annotation.DataScope;
|
|
import com.zhongzheng.common.annotation.DataScope;
|
|
|
|
|
+import com.zhongzheng.common.core.redis.RedisCache;
|
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
import com.zhongzheng.common.utils.ServletUtils;
|
|
import com.zhongzheng.common.utils.ServletUtils;
|
|
@@ -34,10 +37,12 @@ import com.zhongzheng.modules.order.service.IOrderGoodsService;
|
|
|
import com.zhongzheng.modules.system.domain.SysConfig;
|
|
import com.zhongzheng.modules.system.domain.SysConfig;
|
|
|
import com.zhongzheng.modules.system.service.ISysConfigService;
|
|
import com.zhongzheng.modules.system.service.ISysConfigService;
|
|
|
import com.zhongzheng.modules.user.bo.SubjectStudyRecordQueryBo;
|
|
import com.zhongzheng.modules.user.bo.SubjectStudyRecordQueryBo;
|
|
|
|
|
+import com.zhongzheng.modules.user.bo.UserPhoneBo;
|
|
|
import com.zhongzheng.modules.user.domain.User;
|
|
import com.zhongzheng.modules.user.domain.User;
|
|
|
import com.zhongzheng.modules.user.service.IUserService;
|
|
import com.zhongzheng.modules.user.service.IUserService;
|
|
|
import com.zhongzheng.modules.user.service.IUserStudyRecordService;
|
|
import com.zhongzheng.modules.user.service.IUserStudyRecordService;
|
|
|
import com.zhongzheng.modules.user.vo.SubjectStudyRecordVo;
|
|
import com.zhongzheng.modules.user.vo.SubjectStudyRecordVo;
|
|
|
|
|
+import com.zhongzheng.modules.user.vo.UserVo;
|
|
|
import net.polyv.common.v1.util.StringUtils;
|
|
import net.polyv.common.v1.util.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -49,6 +54,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
@@ -123,6 +129,9 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private ISysConfigService iSysConfigService;
|
|
private ISysConfigService iSysConfigService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private RedisCache redisCache;
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public GoodsVo queryById(Long goodsId) {
|
|
public GoodsVo queryById(Long goodsId) {
|
|
|
Goods db = this.baseMapper.selectById(goodsId);
|
|
Goods db = this.baseMapper.selectById(goodsId);
|
|
@@ -941,6 +950,48 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
|
|
return voList;
|
|
return voList;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public String getGoodsStudyUrl(GoodsStudyUrlBo bo) {
|
|
|
|
|
+ String url = "";
|
|
|
|
|
+ String domain = "http://192.168.1.222:6002/";
|
|
|
|
|
+ GoodsVo goods = baseMapper.queryGoodsByIdTenant(bo.getGoodsId(),bo.getTenantId());
|
|
|
|
|
+ if (ObjectUtils.isNull(goods)){
|
|
|
|
|
+ throw new CustomException("商品不存在!");
|
|
|
|
|
+ }
|
|
|
|
|
+ User user = iUserService.queryUserByTelphoneTenant(bo.getTelphone(),bo.getTenantId());
|
|
|
|
|
+ if (ObjectUtils.isNull(user)){
|
|
|
|
|
+ throw new CustomException("用户不存在!");
|
|
|
|
|
+ }
|
|
|
|
|
+ //校验当前商品是否用户购买
|
|
|
|
|
+ UserOrderGoodsVo vo = baseMapper.countUserOrderGoods(bo.getGoodsId(),user.getUserId(),bo.getTenantId());
|
|
|
|
|
+ if (ObjectUtils.isNull(vo)){
|
|
|
|
|
+ throw new CustomException("用户没有购买该商品!");
|
|
|
|
|
+ }
|
|
|
|
|
+ //当前时间戳
|
|
|
|
|
+ Long nowTime = DateUtils.getNowTime();
|
|
|
|
|
+ if (bo.getSkipPort() == 1){
|
|
|
|
|
+ //PC端
|
|
|
|
|
+ if (goods.getGoodsType() == 2){
|
|
|
|
|
+ //题库
|
|
|
|
|
+ url = String.format("%sperson-center/my-bank/index?goodsId=%s&skipPort=%s",domain,vo.getGoodsId(),nowTime);
|
|
|
|
|
+ }else if (goods.getGoodsType() == 6){
|
|
|
|
|
+ //直播
|
|
|
|
|
+ url = String.format("%sperson-center/my-live?goodsId=%s&skipPort=%s",domain,vo.getGoodsId(),nowTime);
|
|
|
|
|
+ }else {
|
|
|
|
|
+ //视频
|
|
|
|
|
+ url = String.format("%smy-course-detail/%s?gradeId=%s&orderGoodsId=%s&skipPort=%s",domain,vo.getGoodsId(),vo.getGradeId(),vo.getOrderGoodsId(),nowTime);
|
|
|
|
|
+ }
|
|
|
|
|
+ }else {
|
|
|
|
|
+ //H5
|
|
|
|
|
+ }
|
|
|
|
|
+ UserPhoneBo phoneBo = new UserPhoneBo();
|
|
|
|
|
+ phoneBo.setTelphone(user.getTelphone());
|
|
|
|
|
+ phoneBo.setTenantId(bo.getTenantId());
|
|
|
|
|
+ //缓存用户手机号码 30分钟失效
|
|
|
|
|
+ redisCache.setCacheObject(nowTime.toString(), JSONObject.toJSONString(phoneBo),30, TimeUnit.MINUTES);
|
|
|
|
|
+ return url;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 获取商品规格模板列表
|
|
* 获取商品规格模板列表
|
|
|
*
|
|
*
|