|
@@ -1,18 +1,21 @@
|
|
package com.kmall.admin.service.impl;
|
|
package com.kmall.admin.service.impl;
|
|
|
|
|
|
import com.kmall.admin.dao.MallPaymentOrderDataDao;
|
|
import com.kmall.admin.dao.MallPaymentOrderDataDao;
|
|
|
|
+import com.kmall.admin.dto.AliPaymentOrderDto;
|
|
|
|
+import com.kmall.admin.dto.WxPaymentOrderDto;
|
|
import com.kmall.admin.entity.MallPaymentOrderDataEntity;
|
|
import com.kmall.admin.entity.MallPaymentOrderDataEntity;
|
|
-import com.kmall.admin.entity.compared.PayOrderInfoEntity;
|
|
|
|
import com.kmall.admin.fromcomm.entity.SysUserEntity;
|
|
import com.kmall.admin.fromcomm.entity.SysUserEntity;
|
|
import com.kmall.admin.service.MallPaymentOrderDataService;
|
|
import com.kmall.admin.service.MallPaymentOrderDataService;
|
|
-import com.kmall.admin.service.SaleRecordService;
|
|
|
|
import com.kmall.admin.utils.ShiroUtils;
|
|
import com.kmall.admin.utils.ShiroUtils;
|
|
import com.kmall.common.constant.Dict;
|
|
import com.kmall.common.constant.Dict;
|
|
|
|
+import com.kmall.common.constant.JxlsXmlTemplateName;
|
|
import com.kmall.common.utils.RRException;
|
|
import com.kmall.common.utils.RRException;
|
|
import com.kmall.common.utils.excel.ExcelExport;
|
|
import com.kmall.common.utils.excel.ExcelExport;
|
|
|
|
+import com.kmall.common.utils.excel.ExcelUtil;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -30,6 +33,9 @@ public class MallPaymentOrderDataServiceImpl implements MallPaymentOrderDataServ
|
|
@Autowired
|
|
@Autowired
|
|
private MallPaymentOrderDataDao mall2PaymentOrderDataDao;
|
|
private MallPaymentOrderDataDao mall2PaymentOrderDataDao;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private ExcelUtil excelUtil;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public MallPaymentOrderDataEntity queryObject(Integer payOrderId) {
|
|
public MallPaymentOrderDataEntity queryObject(Integer payOrderId) {
|
|
return mall2PaymentOrderDataDao.queryObject(payOrderId);
|
|
return mall2PaymentOrderDataDao.queryObject(payOrderId);
|
|
@@ -72,7 +78,6 @@ public class MallPaymentOrderDataServiceImpl implements MallPaymentOrderDataServ
|
|
if (list!=null && list.size()>0) {
|
|
if (list!=null && list.size()>0) {
|
|
for (MallPaymentOrderDataEntity paymentOrderDataEntity : list) {
|
|
for (MallPaymentOrderDataEntity paymentOrderDataEntity : list) {
|
|
|
|
|
|
-
|
|
|
|
//判断wx要进行截取
|
|
//判断wx要进行截取
|
|
if (Dict.payFlag.item_weixin.getItem().equals(payFlag)) {
|
|
if (Dict.payFlag.item_weixin.getItem().equals(payFlag)) {
|
|
try {
|
|
try {
|
|
@@ -118,6 +123,124 @@ public class MallPaymentOrderDataServiceImpl implements MallPaymentOrderDataServ
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
+ public void saveUploadExcel(MultipartFile file, String payFlag) {
|
|
|
|
+ List<WxPaymentOrderDto> wxPaymentOrderDtoList = new ArrayList<>();
|
|
|
|
+ List<AliPaymentOrderDto> aliPaymentOrderDtoList = new ArrayList<>();
|
|
|
|
+ try {
|
|
|
|
+ if (file.isEmpty()) {
|
|
|
|
+ throw new RRException("上传文件不能为空");
|
|
|
|
+ }
|
|
|
|
+ if (Dict.payFlag.item_weixin.getItem().equals(payFlag)) {
|
|
|
|
+
|
|
|
|
+ WxPaymentOrderDto wxPaymentOrderDto = new WxPaymentOrderDto();
|
|
|
|
+ Map<String, Object> beans = new HashMap<String, Object>();
|
|
|
|
+ beans.put("WxPaymentOrderDto", wxPaymentOrderDto);
|
|
|
|
+ beans.put("WxPaymentOrderDtoList", wxPaymentOrderDtoList);
|
|
|
|
+ excelUtil.readExcel(JxlsXmlTemplateName.WX_PAYMENT_ORDER_DTO_List, beans, file.getInputStream());
|
|
|
|
+ }else if (Dict.payFlag.item_alipay.getItem().equals(payFlag)){
|
|
|
|
+
|
|
|
|
+ AliPaymentOrderDto aliPaymentOrderDto = new AliPaymentOrderDto();
|
|
|
|
+ Map<String, Object> beans = new HashMap<String, Object>();
|
|
|
|
+ beans.put("AliPaymentOrderDto", aliPaymentOrderDto);
|
|
|
|
+ beans.put("AliPaymentOrderDtoList", aliPaymentOrderDtoList);
|
|
|
|
+ excelUtil.readExcel(JxlsXmlTemplateName.ALI_PAYMENT_ORDER_DTO_List, beans, file.getInputStream());
|
|
|
|
+ }
|
|
|
|
+ }catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ throw new RRException("导入失败!");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ if (Dict.payFlag.item_weixin.getItem().equals(payFlag)) {
|
|
|
|
+ saveWxData(wxPaymentOrderDtoList,payFlag);
|
|
|
|
+ }else if (Dict.payFlag.item_alipay.getItem().equals(payFlag)){
|
|
|
|
+ saveAliData(aliPaymentOrderDtoList,payFlag);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ throw new RRException(e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void saveWxData(List<WxPaymentOrderDto> list,String payFlag){
|
|
|
|
+ List<MallPaymentOrderDataEntity> insertList = new ArrayList<>();
|
|
|
|
+ SysUserEntity sysUserEntity = ShiroUtils.getUserEntity();
|
|
|
|
+ if (list!=null && list.size()>0) {
|
|
|
|
+ for (WxPaymentOrderDto wxPaymentOrderDto : list) {
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ wxPaymentOrderDto.setTimeStr(wxPaymentOrderDto.getTimeStr().split("`")[1].toString());
|
|
|
|
+ wxPaymentOrderDto.setTransactionOrder(wxPaymentOrderDto.getTransactionOrder().split("`")[1].toString());
|
|
|
|
+ wxPaymentOrderDto.setOutTradeNo(wxPaymentOrderDto.getOutTradeNo().split("`")[1].toString());
|
|
|
|
+ wxPaymentOrderDto.setAmountOrder(wxPaymentOrderDto.getAmountOrder().split("`")[1].toString());
|
|
|
|
+ wxPaymentOrderDto.setMerchantName(wxPaymentOrderDto.getMerchantName().split("`")[1].toString());
|
|
|
|
+ wxPaymentOrderDto.setPayMoney(wxPaymentOrderDto.getPayMoney().split("`")[1].toString());
|
|
|
|
+ wxPaymentOrderDto.setRefundMoney(wxPaymentOrderDto.getRefundMoney().split("`")[1].toString());
|
|
|
|
+ wxPaymentOrderDto.setRefundId(wxPaymentOrderDto.getRefundId().split("`")[1].toString());
|
|
|
|
+ wxPaymentOrderDto.setCashCoupon(wxPaymentOrderDto.getCashCoupon().split("`")[1].toString());
|
|
|
|
+ wxPaymentOrderDto.setMerRefundNumber(wxPaymentOrderDto.getMerRefundNumber().split("`")[1].toString());
|
|
|
|
+ wxPaymentOrderDto.setRefundRechargpCoupon(wxPaymentOrderDto.getRefundRechargpCoupon().split("`")[1].toString());
|
|
|
|
+ wxPaymentOrderDto.setFeeCharge(wxPaymentOrderDto.getFeeCharge().split("`")[1].toString());
|
|
|
|
+ wxPaymentOrderDto.setRate(wxPaymentOrderDto.getRate().split("`")[1].toString());
|
|
|
|
+ wxPaymentOrderDto.setApplyRefundAmount(wxPaymentOrderDto.getApplyRefundAmount().split("`")[1].toString());
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ throw new RRException("导入的数据不是微信账单!");
|
|
|
|
+ }
|
|
|
|
+ String outTradeNo = wxPaymentOrderDto.getOutTradeNo();
|
|
|
|
+ String timeStr = wxPaymentOrderDto.getTimeStr();
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
+ map.put("timeStr",timeStr);
|
|
|
|
+ map.put("outTradeNo",outTradeNo);
|
|
|
|
+
|
|
|
|
+ //根据时间和商户订单号来判断当前数据是否有重复录入
|
|
|
|
+ List<MallPaymentOrderDataEntity> timeAndTnoData = mall2PaymentOrderDataDao.queryListTimeAndTnoData(map);
|
|
|
|
+ if (timeAndTnoData.size()>0) {
|
|
|
|
+ throw new RRException("数据有重复,请检查导入数据的正确性!");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ MallPaymentOrderDataEntity mallPaymentOrderDataEntity = new MallPaymentOrderDataEntity();
|
|
|
|
+ BeanUtils.copyProperties(wxPaymentOrderDto,mallPaymentOrderDataEntity);
|
|
|
|
+ mallPaymentOrderDataEntity.setCreaterSn(sysUserEntity.getUsername());
|
|
|
|
+ mallPaymentOrderDataEntity.setCreateTime(new Date());
|
|
|
|
+ mallPaymentOrderDataEntity.setPayFlag(payFlag);
|
|
|
|
+ insertList.add(mallPaymentOrderDataEntity);
|
|
|
|
+ }
|
|
|
|
+ mall2PaymentOrderDataDao.saveBatch(insertList);
|
|
|
|
+ }else {
|
|
|
|
+ throw new RRException("导入数据信息为空,请看模版再重新导入!");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ private void saveAliData(List<AliPaymentOrderDto> list,String payFlag){
|
|
|
|
+ List<MallPaymentOrderDataEntity> insertList = new ArrayList<>();
|
|
|
|
+ SysUserEntity sysUserEntity = ShiroUtils.getUserEntity();
|
|
|
|
+ if (list!=null && list.size()>0) {
|
|
|
|
+ for (AliPaymentOrderDto aliPaymentOrderDto : list) {
|
|
|
|
+
|
|
|
|
+ String outTradeNo = aliPaymentOrderDto.getOutTradeNo();
|
|
|
|
+ String timeStr = aliPaymentOrderDto.getTimeStr();
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
+ map.put("timeStr",timeStr);
|
|
|
|
+ map.put("outTradeNo",outTradeNo);
|
|
|
|
+
|
|
|
|
+ //根据时间和商户订单号来判断当前数据是否有重复录入
|
|
|
|
+ List<MallPaymentOrderDataEntity> timeAndTnoData = mall2PaymentOrderDataDao.queryListTimeAndTnoData(map);
|
|
|
|
+ if (timeAndTnoData.size()>0) {
|
|
|
|
+ throw new RRException("数据有重复,请检查导入数据的正确性!");
|
|
|
|
+ }
|
|
|
|
+ MallPaymentOrderDataEntity mallPaymentOrderDataEntity = new MallPaymentOrderDataEntity();
|
|
|
|
+ BeanUtils.copyProperties(aliPaymentOrderDto,mallPaymentOrderDataEntity);
|
|
|
|
+ mallPaymentOrderDataEntity.setCreaterSn(sysUserEntity.getUsername());
|
|
|
|
+ mallPaymentOrderDataEntity.setCreateTime(new Date());
|
|
|
|
+ mallPaymentOrderDataEntity.setPayFlag(payFlag);
|
|
|
|
+ insertList.add(mallPaymentOrderDataEntity);
|
|
|
|
+ }
|
|
|
|
+ mall2PaymentOrderDataDao.saveBatch(insertList);
|
|
|
|
+ }else {
|
|
|
|
+ throw new RRException("导入数据信息为空,请看模版再重新导入!");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ @Override
|
|
public void exportDataFormatList(Map<String, Object> map, HttpServletResponse response) {
|
|
public void exportDataFormatList(Map<String, Object> map, HttpServletResponse response) {
|
|
List<MallPaymentOrderDataEntity> mallList = mall2PaymentOrderDataDao.queryListData(map);
|
|
List<MallPaymentOrderDataEntity> mallList = mall2PaymentOrderDataDao.queryListData(map);
|
|
String payFlag = map.get("payFlag").toString();
|
|
String payFlag = map.get("payFlag").toString();
|