|
|
@@ -4,12 +4,25 @@ import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.github.pagehelper.Page;
|
|
|
+import com.zhongzheng.common.exception.CustomException;
|
|
|
+import com.zhongzheng.common.type.EncryptHandler;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
+import com.zhongzheng.modules.course.domain.CourseSubject;
|
|
|
+import com.zhongzheng.modules.course.service.ICourseSubjectService;
|
|
|
+import com.zhongzheng.modules.grade.domain.ClassGradeUser;
|
|
|
+import com.zhongzheng.modules.grade.domain.UserPeriod;
|
|
|
+import com.zhongzheng.modules.grade.service.IClassGradeUserService;
|
|
|
+import com.zhongzheng.modules.grade.service.IUserPeriodService;
|
|
|
+import com.zhongzheng.modules.order.domain.OrderGoods;
|
|
|
+import com.zhongzheng.modules.order.service.IOrderGoodsService;
|
|
|
import com.zhongzheng.modules.top.goods.bo.TopOrderAddBo;
|
|
|
import com.zhongzheng.modules.top.goods.bo.TopOrderEditBo;
|
|
|
+import com.zhongzheng.modules.top.goods.bo.TopOrderGoodsQuery;
|
|
|
import com.zhongzheng.modules.top.goods.bo.TopOrderQueryBo;
|
|
|
import com.zhongzheng.modules.top.goods.domain.TopOrder;
|
|
|
import com.zhongzheng.modules.top.goods.domain.TopOrderAttachment;
|
|
|
@@ -18,12 +31,17 @@ import com.zhongzheng.modules.top.goods.mapper.TopOrderMapper;
|
|
|
import com.zhongzheng.modules.top.goods.service.ITopOrderAttachmentService;
|
|
|
import com.zhongzheng.modules.top.goods.service.ITopOrderGoodsService;
|
|
|
import com.zhongzheng.modules.top.goods.service.ITopOrderService;
|
|
|
+import com.zhongzheng.modules.top.goods.vo.TopOrderAttachmentVo;
|
|
|
+import com.zhongzheng.modules.top.goods.vo.TopOrderGoodsListVo;
|
|
|
+import com.zhongzheng.modules.top.goods.vo.TopOrderGoodsVo;
|
|
|
import com.zhongzheng.modules.top.goods.vo.TopOrderVo;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.Collection;
|
|
|
import java.util.List;
|
|
|
+import java.util.Set;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -41,46 +59,51 @@ public class TopOrderServiceImpl extends ServiceImpl<TopOrderMapper, TopOrder> i
|
|
|
@Autowired
|
|
|
private ITopOrderAttachmentService topOrderAttachmentService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IOrderGoodsService orderGoodsService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ICourseSubjectService courseSubjectService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IUserPeriodService userPeriodService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IClassGradeUserService classGradeUserService;
|
|
|
+
|
|
|
@Override
|
|
|
- public TopOrderVo queryById(Long orderId){
|
|
|
- TopOrder db = this.baseMapper.selectById(orderId);
|
|
|
- return BeanUtil.toBean(db, TopOrderVo.class);
|
|
|
+ public TopOrderVo queryById(String orderSn){
|
|
|
+ //查询视图 v_top_order
|
|
|
+ TopOrderVo orderVo = baseMapper.queryById(orderSn);
|
|
|
+ if (ObjectUtils.isNull(orderVo)){
|
|
|
+ throw new CustomException("订单号错误!");
|
|
|
+ }
|
|
|
+ //订单附件
|
|
|
+ if (orderVo.getOrderFrom() != 1){
|
|
|
+ //旧系统订单
|
|
|
+ List<TopOrderAttachment> list = topOrderAttachmentService
|
|
|
+ .list(new LambdaQueryWrapper<TopOrderAttachment>()
|
|
|
+ .eq(TopOrderAttachment::getOrderSn, orderVo.getOrderSn())
|
|
|
+ .eq(TopOrderAttachment::getStatus, 1));
|
|
|
+ if (CollectionUtils.isNotEmpty(list)){
|
|
|
+ orderVo.setAttachmentList(list.stream().map(x -> BeanUtil.toBean(x, TopOrderAttachmentVo.class)).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return orderVo;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<TopOrderVo> queryList(TopOrderQueryBo bo) {
|
|
|
- LambdaQueryWrapper<TopOrder> lqw = Wrappers.lambdaQuery();
|
|
|
- lqw.eq(StrUtil.isNotBlank(bo.getOrderSn()), TopOrder::getOrderSn, bo.getOrderSn());
|
|
|
- lqw.eq(bo.getUserId() != null, TopOrder::getUserId, bo.getUserId());
|
|
|
- lqw.eq(bo.getOrderPrice() != null, TopOrder::getOrderPrice, bo.getOrderPrice());
|
|
|
- lqw.eq(StrUtil.isNotBlank(bo.getOrderGeneral()), TopOrder::getOrderGeneral, bo.getOrderGeneral());
|
|
|
- lqw.eq(bo.getOrderStatus() != null, TopOrder::getOrderStatus, bo.getOrderStatus());
|
|
|
- lqw.eq(bo.getPayTime() != null, TopOrder::getPayTime, bo.getPayTime());
|
|
|
- lqw.eq(bo.getPayType() != null, TopOrder::getPayType, bo.getPayType());
|
|
|
- lqw.eq(StrUtil.isNotBlank(bo.getTransid()), TopOrder::getTransid, bo.getTransid());
|
|
|
- lqw.eq(bo.getCancelTime() != null, TopOrder::getCancelTime, bo.getCancelTime());
|
|
|
- lqw.eq(bo.getFinishTime() != null, TopOrder::getFinishTime, bo.getFinishTime());
|
|
|
- lqw.eq(bo.getOrderType() != null, TopOrder::getOrderType, bo.getOrderType());
|
|
|
- lqw.eq(bo.getPayPrice() != null, TopOrder::getPayPrice, bo.getPayPrice());
|
|
|
- lqw.eq(bo.getOrderFrom() != null, TopOrder::getOrderFrom, bo.getOrderFrom());
|
|
|
- lqw.like(StrUtil.isNotBlank(bo.getCreateUsername()), TopOrder::getCreateUsername, bo.getCreateUsername());
|
|
|
- lqw.eq(bo.getStatus() != null, TopOrder::getStatus, bo.getStatus());
|
|
|
- lqw.eq(bo.getCreateSysUserId() != null, TopOrder::getCreateSysUserId, bo.getCreateSysUserId());
|
|
|
- lqw.eq(StrUtil.isNotBlank(bo.getCreateNo()), TopOrder::getCreateNo, bo.getCreateNo());
|
|
|
- lqw.eq(StrUtil.isNotBlank(bo.getInputOrderSn()), TopOrder::getInputOrderSn, bo.getInputOrderSn());
|
|
|
- lqw.eq(bo.getPayStatus() != null, TopOrder::getPayStatus, bo.getPayStatus());
|
|
|
- lqw.eq(bo.getCheckStaus() != null, TopOrder::getCheckStaus, bo.getCheckStaus());
|
|
|
- lqw.eq(bo.getRefundStatus() != null, TopOrder::getRefundStatus, bo.getRefundStatus());
|
|
|
- lqw.eq(bo.getCreditStatus() != null, TopOrder::getCreditStatus, bo.getCreditStatus());
|
|
|
- lqw.eq(bo.getInvoiceStatus() != null, TopOrder::getInvoiceStatus, bo.getInvoiceStatus());
|
|
|
- lqw.eq(bo.getOrderCost() != null, TopOrder::getOrderCost, bo.getOrderCost());
|
|
|
- lqw.eq(bo.getOrderRefund() != null, TopOrder::getOrderRefund, bo.getOrderRefund());
|
|
|
- lqw.eq(bo.getOrderRefunded() != null, TopOrder::getOrderRefunded, bo.getOrderRefunded());
|
|
|
- lqw.eq(bo.getOrderUncollected() != null, TopOrder::getOrderUncollected, bo.getOrderUncollected());
|
|
|
- lqw.eq(bo.getOrderReceived() != null, TopOrder::getOrderReceived, bo.getOrderReceived());
|
|
|
- lqw.eq(StrUtil.isNotBlank(bo.getOrderBusiness()), TopOrder::getOrderBusiness, bo.getOrderBusiness());
|
|
|
- lqw.eq(StrUtil.isNotBlank(bo.getCostJson()), TopOrder::getCostJson, bo.getCostJson());
|
|
|
- return entity2Vo(this.list(lqw));
|
|
|
+ //查询视图 v_top_order
|
|
|
+ List<TopOrderVo> orderVoList = baseMapper.queryList(bo);
|
|
|
+ if (CollectionUtils.isNotEmpty(orderVoList)){
|
|
|
+ //订单业务类型
|
|
|
+ orderVoList.forEach(item -> {
|
|
|
+ List<String> businessNames = baseMapper.queryBusinessBySn(item.getOrderSn());
|
|
|
+ item.setBusinessNames(businessNames);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return orderVoList;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -149,4 +172,63 @@ public class TopOrderServiceImpl extends ServiceImpl<TopOrderMapper, TopOrder> i
|
|
|
}
|
|
|
return this.removeByIds(ids);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<TopOrderGoodsListVo> getOrderGoodsList(TopOrderGoodsQuery query) {
|
|
|
+ if (query.getOrderFrom() == 1){
|
|
|
+ //新系统订单
|
|
|
+ List<TopOrderGoodsListVo> topOrderGoodsListVos = orderGoodsService.listByOrderSn(query);
|
|
|
+ if (CollectionUtils.isNotEmpty(topOrderGoodsListVos)){
|
|
|
+ topOrderGoodsListVos.forEach(item -> {
|
|
|
+ item.setUserCount(1);
|
|
|
+ //专业
|
|
|
+ if (StringUtils.isNotBlank(item.getSubjectIds())){
|
|
|
+ List<CourseSubject> subjectList = courseSubjectService.listByIds(Arrays.asList(item.getSubjectIds().split(",")));
|
|
|
+ if (CollectionUtils.isNotEmpty(subjectList)){
|
|
|
+ item.setMajorName(subjectList.stream().map(CourseSubject::getSubjectName).collect(Collectors.joining()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //学习状态
|
|
|
+ if (ObjectUtils.isNotNull(item.getGoodsType()) && ObjectUtils.isNotNull(item.getGradeId()) && item.getGoodsType() == 1 ){
|
|
|
+ int count = userPeriodService.count(new LambdaQueryWrapper<UserPeriod>()
|
|
|
+ .eq(UserPeriod::getUserId, item.getUserId())
|
|
|
+ .eq(UserPeriod::getGradeId, item.getGradeId()));
|
|
|
+ if (count > 0){
|
|
|
+ //学完/未学完
|
|
|
+ ClassGradeUser classGradeUser = classGradeUserService.getOne(new LambdaQueryWrapper<ClassGradeUser>()
|
|
|
+ .eq(ClassGradeUser::getUserId, item.getUserId())
|
|
|
+ .eq(ClassGradeUser::getGradeId, item.getGradeId())
|
|
|
+ .last("limit 1"));
|
|
|
+ item.setStudyStatus(
|
|
|
+ ObjectUtils.isNotNull(classGradeUser.getFinishStatus()) && classGradeUser.getFinishStatus() == 1?"已结束":"学习中");
|
|
|
+ }else {
|
|
|
+ item.setStudyStatus("未开始");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return topOrderGoodsListVos;
|
|
|
+ }
|
|
|
+ //旧系统订单
|
|
|
+ List<TopOrderGoodsListVo> list = topOrderGoodsService.getListByQuery(query);
|
|
|
+ if (CollectionUtils.isNotEmpty(list)){
|
|
|
+ //学员数量
|
|
|
+ Integer userCount = 0;
|
|
|
+ List<TopOrderGoods> goodsList = topOrderGoodsService
|
|
|
+ .list(new LambdaQueryWrapper<TopOrderGoods>().eq(TopOrderGoods::getOrderSn, query.getOrderSn())
|
|
|
+ .eq(TopOrderGoods::getStatus, 1)
|
|
|
+ .ne(TopOrderGoods::getRefundStatus, 2)
|
|
|
+ .in(TopOrderGoods::getPayStatus, Arrays.asList(2, 3, 4)));
|
|
|
+ if (CollectionUtils.isNotEmpty(goodsList)){
|
|
|
+ userCount = goodsList.stream().map(TopOrderGoods::getUserCard).collect(Collectors.toSet()).size();
|
|
|
+ }
|
|
|
+ //老系统查询学习状态
|
|
|
+
|
|
|
+ //数据处理
|
|
|
+ for (TopOrderGoodsListVo item : list) {
|
|
|
+ item.setUserCount(userCount);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
}
|