|
@@ -0,0 +1,121 @@
|
|
|
+package com.zhongzheng.modules.order.service.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import com.zhongzheng.common.utils.DateUtils;
|
|
|
+import com.zhongzheng.modules.order.bo.OrderInvoiceAddBo;
|
|
|
+import com.zhongzheng.modules.order.bo.OrderInvoiceEditBo;
|
|
|
+import com.zhongzheng.modules.order.bo.OrderInvoiceQueryBo;
|
|
|
+import com.zhongzheng.modules.order.domain.OrderInvoice;
|
|
|
+import com.zhongzheng.modules.order.mapper.OrderInvoiceMapper;
|
|
|
+import com.zhongzheng.modules.order.service.IOrderInvoiceService;
|
|
|
+import com.zhongzheng.modules.order.vo.OrderInvoiceVo;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.github.pagehelper.Page;
|
|
|
+
|
|
|
+import java.util.Collection;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 订单发票Service业务层处理
|
|
|
+ *
|
|
|
+ * @author hjl
|
|
|
+ * @date 2022-03-28
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class OrderInvoiceServiceImpl extends ServiceImpl<OrderInvoiceMapper, OrderInvoice> implements IOrderInvoiceService {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public OrderInvoiceVo queryById(Long invoiceId){
|
|
|
+ OrderInvoice db = this.baseMapper.selectById(invoiceId);
|
|
|
+ return BeanUtil.toBean(db, OrderInvoiceVo.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<OrderInvoiceVo> queryList(OrderInvoiceQueryBo bo) {
|
|
|
+ LambdaQueryWrapper<OrderInvoice> lqw = Wrappers.lambdaQuery();
|
|
|
+ lqw.eq(bo.getType() != null, OrderInvoice::getType, bo.getType());
|
|
|
+ lqw.eq(StrUtil.isNotBlank(bo.getInvoiceTitle()), OrderInvoice::getInvoiceTitle, bo.getInvoiceTitle());
|
|
|
+ lqw.eq(StrUtil.isNotBlank(bo.getTelphone()), OrderInvoice::getTelphone, bo.getTelphone());
|
|
|
+ lqw.eq(StrUtil.isNotBlank(bo.getEmail()), OrderInvoice::getEmail, bo.getEmail());
|
|
|
+ lqw.eq(bo.getPeriodStatus() != null, OrderInvoice::getPeriodStatus, bo.getPeriodStatus());
|
|
|
+ lqw.eq(bo.getSubject() != null, OrderInvoice::getSubject, bo.getSubject());
|
|
|
+ lqw.eq(bo.getUserId() != null, OrderInvoice::getUserId, bo.getUserId());
|
|
|
+ lqw.eq(StrUtil.isNotBlank(bo.getTaxRegistryNumber()), OrderInvoice::getTaxRegistryNumber, bo.getTaxRegistryNumber());
|
|
|
+ lqw.eq(bo.getStatus() != null, OrderInvoice::getStatus, bo.getStatus());
|
|
|
+ lqw.eq(bo.getInvoiceStatus() != null, OrderInvoice::getInvoiceStatus, bo.getInvoiceStatus());
|
|
|
+ lqw.eq(bo.getAmount() != null, OrderInvoice::getAmount, bo.getAmount());
|
|
|
+ lqw.eq(StrUtil.isNotBlank(bo.getInvoiceCode()), OrderInvoice::getInvoiceCode, bo.getInvoiceCode());
|
|
|
+ lqw.eq(bo.getUploadInvoice() != null, OrderInvoice::getUploadInvoice, bo.getUploadInvoice());
|
|
|
+ lqw.eq(bo.getSendInvoice() != null, OrderInvoice::getSendInvoice, bo.getSendInvoice());
|
|
|
+ lqw.eq(StrUtil.isNotBlank(bo.getTrackingNum()), OrderInvoice::getTrackingNum, bo.getTrackingNum());
|
|
|
+ lqw.eq(bo.getMakeOutTime() != null, OrderInvoice::getMakeOutTime, bo.getMakeOutTime());
|
|
|
+ lqw.eq(bo.getApplyTime() != null, OrderInvoice::getApplyTime, bo.getApplyTime());
|
|
|
+ lqw.eq(StrUtil.isNotBlank(bo.getPeriodReason()), OrderInvoice::getPeriodReason, bo.getPeriodReason());
|
|
|
+ return entity2Vo(this.list(lqw));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 实体类转化成视图对象
|
|
|
+ *
|
|
|
+ * @param collection 实体类集合
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<OrderInvoiceVo> entity2Vo(Collection<OrderInvoice> collection) {
|
|
|
+ List<OrderInvoiceVo> voList = collection.stream()
|
|
|
+ .map(any -> BeanUtil.toBean(any, OrderInvoiceVo.class))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (collection instanceof Page) {
|
|
|
+ Page<OrderInvoice> page = (Page<OrderInvoice>)collection;
|
|
|
+ Page<OrderInvoiceVo> pageVo = new Page<>();
|
|
|
+ BeanUtil.copyProperties(page,pageVo);
|
|
|
+ pageVo.addAll(voList);
|
|
|
+ voList = pageVo;
|
|
|
+ }
|
|
|
+ return voList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean insertByAddBo(OrderInvoiceAddBo bo) {
|
|
|
+ OrderInvoice add = BeanUtil.toBean(bo, OrderInvoice.class);
|
|
|
+ validEntityBeforeSave(add);
|
|
|
+ add.setCreateTime(DateUtils.getNowTime());
|
|
|
+ add.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ return this.save(add);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean updateByEditBo(OrderInvoiceEditBo bo) {
|
|
|
+ OrderInvoice update = BeanUtil.toBean(bo, OrderInvoice.class);
|
|
|
+ validEntityBeforeSave(update);
|
|
|
+ update.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ return this.updateById(update);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存前的数据校验
|
|
|
+ *
|
|
|
+ * @param entity 实体类数据
|
|
|
+ */
|
|
|
+ private void validEntityBeforeSave(OrderInvoice entity){
|
|
|
+ //TODO 做一些数据校验,如唯一约束
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
|
+ if(isValid){
|
|
|
+ //TODO 做一些业务上的校验,判断是否需要校验
|
|
|
+ }
|
|
|
+ return this.removeByIds(ids);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<OrderInvoiceVo> selectList(OrderInvoiceQueryBo bo) {
|
|
|
+ return baseMapper.selectList(bo);
|
|
|
+ }
|
|
|
+}
|