|
@@ -1,17 +1,22 @@
|
|
package com.gree.mall.contest.logic.order;
|
|
package com.gree.mall.contest.logic.order;
|
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.lang.TypeReference;
|
|
import cn.hutool.core.lang.TypeReference;
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
+import com.gree.mall.contest.bean.ExcelData;
|
|
|
|
+import com.gree.mall.contest.bean.admin.AdminUserCom;
|
|
import com.gree.mall.contest.bean.order.OrderDetailBean;
|
|
import com.gree.mall.contest.bean.order.OrderDetailBean;
|
|
|
|
+import com.gree.mall.contest.bean.tax.OrderTaxExcelBean;
|
|
|
|
+import com.gree.mall.contest.bean.tax.RspOrderTax;
|
|
|
|
+import com.gree.mall.contest.commonmapper.CommonMapper;
|
|
import com.gree.mall.contest.constant.Constant;
|
|
import com.gree.mall.contest.constant.Constant;
|
|
import com.gree.mall.contest.exception.RemoteServiceException;
|
|
import com.gree.mall.contest.exception.RemoteServiceException;
|
|
import com.gree.mall.contest.logic.common.CommonLogic;
|
|
import com.gree.mall.contest.logic.common.CommonLogic;
|
|
|
|
+import com.gree.mall.contest.plus.entity.GoodsCategory;
|
|
import com.gree.mall.contest.plus.entity.OrderTax;
|
|
import com.gree.mall.contest.plus.entity.OrderTax;
|
|
-import com.gree.mall.contest.plus.service.GoodsCategoryService;
|
|
|
|
-import com.gree.mall.contest.plus.service.GoodsService;
|
|
|
|
-import com.gree.mall.contest.plus.service.GoodsSpecService;
|
|
|
|
import com.gree.mall.contest.plus.service.OrderTaxService;
|
|
import com.gree.mall.contest.plus.service.OrderTaxService;
|
|
import com.gree.mall.contest.utils.RedisUtil;
|
|
import com.gree.mall.contest.utils.RedisUtil;
|
|
import com.gree.mall.contest.utils.email.EmailUtilsNew;
|
|
import com.gree.mall.contest.utils.email.EmailUtilsNew;
|
|
@@ -23,26 +28,28 @@ import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.poi.hssf.usermodel.HSSFFont;
|
|
import org.apache.poi.hssf.usermodel.HSSFFont;
|
|
import org.apache.poi.ss.usermodel.IndexedColors;
|
|
import org.apache.poi.ss.usermodel.IndexedColors;
|
|
import org.apache.poi.xssf.usermodel.*;
|
|
import org.apache.poi.xssf.usermodel.*;
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
import java.io.*;
|
|
import java.io.*;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
@Slf4j
|
|
@Slf4j
|
|
@RequiredArgsConstructor
|
|
@RequiredArgsConstructor
|
|
public class OrderTaxLogic {
|
|
public class OrderTaxLogic {
|
|
private final OrderTaxService orderTaxService;
|
|
private final OrderTaxService orderTaxService;
|
|
- private final GoodsService goodsService;
|
|
|
|
- private final GoodsSpecService goodsSpecService;
|
|
|
|
- private final GoodsCategoryService goodsCategoryService;
|
|
|
|
private final RedisUtil redisUtil;
|
|
private final RedisUtil redisUtil;
|
|
private final CommonLogic commonLogic;
|
|
private final CommonLogic commonLogic;
|
|
- OrderLogic orderLogic;
|
|
|
|
|
|
+ private final CommonMapper commonMapper;
|
|
|
|
+ private final OrderLogic orderLogic;
|
|
@Value("${tax.token.appid}")
|
|
@Value("${tax.token.appid}")
|
|
private String clientId;
|
|
private String clientId;
|
|
@Value("${tax.token.appSecret}")
|
|
@Value("${tax.token.appSecret}")
|
|
@@ -81,7 +88,7 @@ public class OrderTaxLogic {
|
|
return orderTaxBean;
|
|
return orderTaxBean;
|
|
}
|
|
}
|
|
|
|
|
|
- public void updateTax(OrderTax orderTaxBean) {
|
|
|
|
|
|
+ public void miniUpdateTax(OrderTax orderTaxBean) {
|
|
orderTaxService.lambdaUpdate().eq(OrderTax::getOrderTaxId, orderTaxBean.getOrderTaxId())
|
|
orderTaxService.lambdaUpdate().eq(OrderTax::getOrderTaxId, orderTaxBean.getOrderTaxId())
|
|
.set(StringUtils.isNotBlank(orderTaxBean.getAccount()), OrderTax::getAccount, orderTaxBean.getAccount())
|
|
.set(StringUtils.isNotBlank(orderTaxBean.getAccount()), OrderTax::getAccount, orderTaxBean.getAccount())
|
|
.set(orderTaxBean.getType() != null, OrderTax::getType, orderTaxBean.getType())
|
|
.set(orderTaxBean.getType() != null, OrderTax::getType, orderTaxBean.getType())
|
|
@@ -118,10 +125,11 @@ public class OrderTaxLogic {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- public IPage<OrderTax> page(String userId, Integer pageNum, Integer pageSize) {
|
|
|
|
|
|
+ public IPage<OrderTax> miniPage(String userId, Integer pageNum, Integer pageSize) {
|
|
return orderTaxService.lambdaQuery()
|
|
return orderTaxService.lambdaQuery()
|
|
.eq(StringUtils.isNotBlank(userId), OrderTax::getUserId, userId)
|
|
.eq(StringUtils.isNotBlank(userId), OrderTax::getUserId, userId)
|
|
- .orderByDesc(OrderTax::getCreateTime).page(new Page(pageNum, pageSize));
|
|
|
|
|
|
+ .orderByDesc(OrderTax::getCreateTime)
|
|
|
|
+ .page(new Page(pageNum, pageSize));
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -306,5 +314,125 @@ public class OrderTaxLogic {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public void updateTax(String orderTaxId, String taxlink) {
|
|
|
|
+ orderTaxService.lambdaUpdate().eq(StringUtils.isNotBlank(orderTaxId), OrderTax::getOrderTaxId, orderTaxId)
|
|
|
|
+ .set(StringUtils.isNotBlank(taxlink), OrderTax::getTaxLink, taxlink)
|
|
|
|
+ .set(OrderTax::getStatus, true)
|
|
|
|
+ .update();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 线下处理发票
|
|
|
|
+ */
|
|
|
|
+ public void offline(String orderTaxId) throws RemoteServiceException {
|
|
|
|
+ OrderTax orderTax = orderTaxService.getById(orderTaxId);
|
|
|
|
+ if (!orderTax.getTaxType()) {
|
|
|
|
+ throw new RemoteServiceException("非专票不可处理");
|
|
|
|
+ }
|
|
|
|
+ orderTax.setStatus(true);
|
|
|
|
+ orderTax.updateById();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public IPage<RspOrderTax> page(Boolean status, String orderId, Integer pageNum, Integer pageSize, HttpServletRequest request) {
|
|
|
|
+ AdminUserCom adminUser = commonLogic.getAdminUser(request);
|
|
|
|
+
|
|
|
|
+ IPage page = orderTaxService.lambdaQuery()
|
|
|
|
+ .like(StringUtils.isNotEmpty(orderId), OrderTax::getOrderId, orderId)
|
|
|
|
+ .in(CollectionUtil.isNotEmpty(adminUser.getCompanyWechatIds()), OrderTax::getCompanyWechatId, adminUser.getCompanyWechatIds())
|
|
|
|
+ ////.//in(CollectionUtils.isNotEmpty(adminUser.getAdminWebsitIds()),OrderTax::getWebsitId,adminUser.getAdminWebsitIds())
|
|
|
|
+ .eq(status != null, OrderTax::getStatus, status)
|
|
|
|
+ .orderByDesc(OrderTax::getCreateTime).page(new Page(pageNum, pageSize));
|
|
|
|
+
|
|
|
|
+ List<RspOrderTax> list = new ArrayList<>();
|
|
|
|
+ for (Object o : page.getRecords()) {
|
|
|
|
+ OrderTax tax = (OrderTax) o;
|
|
|
|
+ RspOrderTax rspOrderTax = new RspOrderTax();
|
|
|
|
+ BeanUtils.copyProperties(tax, rspOrderTax);
|
|
|
|
+ List<GoodsCategory> goodsCategories = commonMapper.queryGoodsCategoryByOrderId(tax.getOrderId());
|
|
|
|
+ if (goodsCategories.size() == 0) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ List<String> categoryNames = goodsCategories.stream().map(GoodsCategory::getName).distinct().collect(Collectors.toList());
|
|
|
|
+ rspOrderTax.setCategoryNames(StringUtils.join(categoryNames, ","));
|
|
|
|
+ list.add(rspOrderTax);
|
|
|
|
+ }
|
|
|
|
+ page.setRecords(list);
|
|
|
|
+ return page;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void updateInfo(String orderTaxId, String name, String taxNo, String receiverName, String receiverPhone, String receiveEmail, String receiverAddress) throws RemoteServiceException {
|
|
|
|
|
|
|
|
+ //判断是否允许修改,已开票的不许修改
|
|
|
|
+ OrderTax orderTax = orderTaxService.getById(orderTaxId);
|
|
|
|
+ if (!orderTax.getStatus()) {
|
|
|
|
+ throw new RemoteServiceException("已开票的不许修改");
|
|
|
|
+ }
|
|
|
|
+ //修改
|
|
|
|
+ orderTaxService.lambdaUpdate()
|
|
|
|
+ .eq(OrderTax::getStatus, false)
|
|
|
|
+ .eq(OrderTax::getOrderTaxId, orderTaxId)
|
|
|
|
+ .set(StringUtils.isNotEmpty(name), OrderTax::getName, name)
|
|
|
|
+ .set(StringUtils.isNotEmpty(taxNo), OrderTax::getTaxNo, taxNo)
|
|
|
|
+ .set(StringUtils.isNotEmpty(receiverName), OrderTax::getReceiverName, receiverName)
|
|
|
|
+ .set(StringUtils.isNotEmpty(receiverPhone), OrderTax::getReceiverPhone, receiverPhone)
|
|
|
|
+ .set(StringUtils.isNotEmpty(receiveEmail), OrderTax::getReceiverEmail, receiveEmail)
|
|
|
|
+ .set(StringUtils.isNotEmpty(receiverAddress), OrderTax::getReceiverAddress, receiverAddress)
|
|
|
|
+ .update();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void exportOrderTax(Boolean status, String orderId, HttpServletRequest request, HttpServletResponse response) throws Exception {
|
|
|
|
+
|
|
|
|
+ AdminUserCom adminUser = commonLogic.getAdminUser(request);
|
|
|
|
+ List<String> companyWechatIds = adminUser.getCompanyWechatIds();
|
|
|
|
+ List<String> adminWebsitIds = adminUser.getAdminWebsitIds();
|
|
|
|
+
|
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat();
|
|
|
|
+ List<List<Object>> rowList = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ ExcelData excelData = new ExcelData();
|
|
|
|
+ excelData.setRows(rowList);
|
|
|
|
+ excelData.setName("发票");
|
|
|
|
+ excelData.setTitles(
|
|
|
|
+ Arrays.asList(
|
|
|
|
+ "发票编号", "订单编号", "用户编号", "公司/个人", "专票/普票", "公司名称或个人名", "纳税人识别号",
|
|
|
|
+ "公司注册地址", "公司注册电话", "开户银行", "银行账号", "接收电话", "接收邮箱", "收票人名称",
|
|
|
|
+ "收票人地址", "发票内容", "已开票/未开票", "电子发票下载链接", "创建时间", "商品分类", "订单支付时间"
|
|
|
|
+ )
|
|
|
|
+ );
|
|
|
|
+ adminWebsitIds = null;
|
|
|
|
+ List<OrderTaxExcelBean> orderTaxExcelBeanList = commonMapper.queryOrderTaxExcelMsg(companyWechatIds, adminWebsitIds, status, orderId);
|
|
|
|
+ for (OrderTaxExcelBean orderTaxExcelBean : orderTaxExcelBeanList
|
|
|
|
+ ) {
|
|
|
|
+ List<Object> row = new ArrayList<>();
|
|
|
|
+ rowList.add(row);
|
|
|
|
+
|
|
|
|
+ row.add(orderTaxExcelBean.getOrderTaxId());
|
|
|
|
+ row.add(orderTaxExcelBean.getOrderId());
|
|
|
|
+ row.add(orderTaxExcelBean.getUserId());
|
|
|
|
+ row.add(orderTaxExcelBean.getType() == null ? "" : (orderTaxExcelBean.getType() ? "公司" : "个人"));
|
|
|
|
+ row.add(orderTaxExcelBean.getTaxType() == null ? "" : (orderTaxExcelBean.getTaxType() ? "专票" : "普票"));
|
|
|
|
+ row.add(orderTaxExcelBean.getName());
|
|
|
|
+ row.add(orderTaxExcelBean.getTaxNo());
|
|
|
|
+ row.add(orderTaxExcelBean.getRegisterAddress());
|
|
|
|
+ row.add(orderTaxExcelBean.getRegisterPhone());
|
|
|
|
+ row.add(orderTaxExcelBean.getBank());
|
|
|
|
+ row.add(orderTaxExcelBean.getAccount());
|
|
|
|
+ row.add(orderTaxExcelBean.getReceiverPhone());
|
|
|
|
+ row.add(orderTaxExcelBean.getReceiverEmail());
|
|
|
|
+ row.add(orderTaxExcelBean.getReceiverName());
|
|
|
|
+ row.add(orderTaxExcelBean.getReceiverAddress());
|
|
|
|
+ row.add(orderTaxExcelBean.getContent());
|
|
|
|
+ row.add(orderTaxExcelBean.getStatus() == null ? "" : (orderTaxExcelBean.getStatus() ? "已开" : "待开"));
|
|
|
|
+ row.add(orderTaxExcelBean.getTaxLink());
|
|
|
|
+ row.add(orderTaxExcelBean.getCreateTime() == null ? "" : DateUtil.formatDate(orderTaxExcelBean.getCreateTime()));
|
|
|
|
+ row.add(orderTaxExcelBean.getCategoryNames());
|
|
|
|
+ row.add(orderTaxExcelBean.getPayTime() == null ? "" : DateUtil.formatDate(orderTaxExcelBean.getPayTime()));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ ExcelUtils.exportExcel(request, response, String.format("发票导出%s.xlsx", simpleDateFormat.format(new Date())), excelData);
|
|
|
|
+
|
|
|
|
+ }
|
|
}
|
|
}
|