main
13233904609 4 months ago
parent cb22fe49f9
commit e03732d651

@ -12,7 +12,7 @@ import store from './store'
import router from './router'
import directive from './directive' // directive
import plugins from './plugins' // plugins
import { download } from '@/utils/request'
import { download,download1,download2 } from '@/utils/request'
import './assets/icons' // icon
import './permission' // permission control
@ -42,14 +42,19 @@ import Print from 'vue-print-nb'
import TreeSelect from '@/components/TreeSelect'
// 会员选择组件
import UserSelect from '@/components/UserSelect'
import { selectDictLabel, selectDictLabels} from "@/utils/ruoyi";
// 全局方法挂载
Vue.prototype.getConfigKey = getConfigKey
Vue.prototype.selectDictLabel = selectDictLabel
Vue.prototype.selectDictLabels = selectDictLabels
Vue.prototype.parseTime = parseTime
Vue.prototype.resetForm = resetForm
Vue.prototype.addDateRange = addDateRange
Vue.prototype.getName = getName
Vue.prototype.download = download
Vue.prototype.download1 = download1
Vue.prototype.download2 = download2
Vue.prototype.handleTree = handleTree
// 全局组件挂载

@ -1,14 +1,15 @@
import axios from 'axios'
import { Notification, MessageBox, Message } from 'element-ui'
import { Notification, MessageBox, Message, Loading } from 'element-ui'
import store from '@/store'
import { getToken } from '@/utils/auth'
import errorCode from '@/utils/errorCode'
import { tansParams } from "@/utils/fuint";
import cache from '@/plugins/cache'
import request from '@/utils/request'
import { blobValidate } from "@/utils/ruoyi";
// 是否显示重新登录
export let isRelogin = { show: false };
let downloadLoadingInstance;
axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'
// 创建axios实例
const service = axios.create({
@ -135,6 +136,42 @@ export function download(url, params) {
window.open(url, '_blank')
}
// 通用下载方法
export function download1(url, params) {
return request({
url: url + '?token='+ getToken() + '&'+ param(params),
method: 'get'
})
// url = process.env.VUE_APP_BASE_API + url + '?token='+ getToken() + '&'+ param(params)
// window.open(url, '_blank')
}
// 通用下载方法
export function download2(url, params, filename, config) {
downloadLoadingInstance = Loading.service({ text: "正在下载数据,请稍候", spinner: "el-icon-loading", background: "rgba(0, 0, 0, 0.7)", })
return service.post(url, params, {
transformRequest: [(params) => { return tansParams(params) }],
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
responseType: 'blob',
...config
}).then(async (data) => {
const isBlob = blobValidate(data);
if (isBlob) {
const blob = new Blob([data])
saveAs(blob, filename)
} else {
const resText = await data.text();
const rspObj = JSON.parse(resText);
const errMsg = errorCode[rspObj.code] || rspObj.msg || errorCode['default']
Message.error(errMsg);
}
downloadLoadingInstance.close();
}).catch((r) => {
console.error(r)
Message.error('下载文件出现错误,请联系管理员!')
downloadLoadingInstance.close();
})
}
// 组织参数
export function param(data) {
let url = ''

@ -91,6 +91,13 @@
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button>
<el-button
type="info"
plain
icon="el-icon-upload2"
size="mini"
@click="handleImport"
>导入</el-button>
</el-form-item>
</el-form>
@ -387,6 +394,32 @@
</div>
</el-dialog>
<!-- 退款对话框 end -->
<!-- 订单导入对话框 -->
<el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
<el-upload
ref="upload"
:limit="1"
accept=".xlsx, .xls"
:headers="upload.headers"
:action="upload.url + '?updateSupport=' + upload.updateSupport"
:disabled="upload.isUploading"
:on-progress="handleFileUploadProgress"
:on-success="handleFileSuccess"
:auto-upload="false"
drag
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处<em>点击上传</em></div>
<div class="el-upload__tip text-center" slot="tip">
<span>仅允许导入xlsxlsx格式文件</span>
<el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate"></el-link>
</div>
</el-upload>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitFileForm"> </el-button>
<el-button @click="upload.open = false"> </el-button>
</div>
</el-dialog>
</div>
</template>
@ -395,6 +428,7 @@ import { getName } from "@/utils/fuint";
import { getOrderList, updateOrderStatus, getOrderInfo, saveOrder, deleteOrder, verifyOrder, delivered } from "@/api/order";
import { doRefund } from "@/api/refund";
import orderPrintDialog from '../cashier/components/orderPrintDialog'
import { getToken } from "@/utils/auth";
export default {
name: "OrderIndex",
components: {
@ -486,7 +520,22 @@ export default {
{ required: true, message: "退款金额不能为空", trigger: "blur" },
{ pattern: /((^[1-9]\d*)|^0)(\.\d{0,2}){0,1}$/, message: `请输入正确的退款金额`, trigger: 'blur' }
]
}
},
//
upload: {
//
open: false,
//
title: "",
//
isUploading: false,
//
updateSupport: 0,
//
headers: { 'Access-Token': getToken() },
//
url: process.env.VUE_APP_BASE_API + "/backendApi/order/importData"
},
};
},
created() {
@ -768,6 +817,32 @@ export default {
break;
}
},
/** 导入按钮操作 */
handleImport() {
this.upload.title = "用户导入";
this.upload.open = true;
},
/** 下载模板操作 */
importTemplate() {
this.download2('/backendApi/order/exportTemplate', {
}, `订单模板${new Date().getTime()}.xlsx`)
},
//
handleFileUploadProgress(event, file, fileList) {
this.upload.isUploading = true;
},
//
handleFileSuccess(response, file, fileList) {
this.upload.open = false;
this.upload.isUploading = false;
this.$refs.upload.clearFiles();
this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
this.getList();
},
//
submitFileForm() {
this.$refs.upload.submit();
}
}
};
</script>

@ -34,4 +34,34 @@ public enum OrderModeEnum {
public void setValue(String value) {
this.value = value;
}
/**
* keyvalue
*
* @param key
* @return
*/
public static String getName(String key) {
final OrderModeEnum[] values = OrderModeEnum.values();
for (OrderModeEnum value : values) {
if (key.equals(value.getKey())) {
return value.getValue();
}
}
return null;
}
/**
* valuekey
*
* @return
*/
public static String getKeyName(String value) {
final OrderModeEnum[] values = OrderModeEnum.values();
for (OrderModeEnum order : values) {
if (value.equals(order.getValue())) {
return order.getKey();
}
}
return null;
}
}

@ -53,4 +53,18 @@ public enum OrderTypeEnum {
}
return null;
}
/**
* valuekey
*
* @return
*/
public static String getKeyName(String value) {
final OrderTypeEnum[] values = OrderTypeEnum.values();
for (OrderTypeEnum order : values) {
if (value.equals(order.getValue())) {
return order.getKey();
}
}
return null;
}
}

@ -37,4 +37,34 @@ public enum PayTypeEnum {
public void setValue(String value) {
this.value = value;
}
/**
* keyvalue
*
* @param key
* @return
*/
public static String getName(String key) {
final PayTypeEnum[] values = PayTypeEnum.values();
for (PayTypeEnum value : values) {
if (key.equals(value.getKey())) {
return value.getValue();
}
}
return null;
}
/**
* valuekey
*
* @return
*/
public static String getKeyName(String value) {
final PayTypeEnum[] values = PayTypeEnum.values();
for (PayTypeEnum order : values) {
if (value.equals(order.getValue())) {
return order.getKey();
}
}
return null;
}
}

@ -0,0 +1,74 @@
package com.fuint.common.excelDto;
import com.fuint.common.dto.*;
import com.fuint.repository.model.MtRefund;
import com.fuint.repository.model.MtStore;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
*
*
* Created by FSQ
* CopyRight https://www.fuint.cn
*/
@Getter
@Setter
public class UserOrderExcelDto implements Serializable {
@ApiModelProperty("订单类型")
private String type;
@ApiModelProperty("支付类型")
private String payType;
@ApiModelProperty("订单模式")
private String orderMode;
@ApiModelProperty("订单号")
private String orderSn;
@ApiModelProperty("所属商户")
private String merchantName;
@ApiModelProperty("所属店铺")
private String storeName;
@ApiModelProperty("用户手机号")
private String userName;
@ApiModelProperty("是否游客")
private String isVisitor;
@ApiModelProperty("订单金额")
private BigDecimal amount;
@ApiModelProperty("支付金额")
private BigDecimal payAmount;
@ApiModelProperty("使用积分数量")
private Integer usePoint;
@ApiModelProperty("积分金额")
private BigDecimal pointAmount;
@ApiModelProperty("折扣金额")
private BigDecimal discount;
@ApiModelProperty("配送费用")
private BigDecimal deliveryFee;
@ApiModelProperty("支付时间")
private Date payTime;
@ApiModelProperty("操作员工")
private String staffName;
}

@ -9,6 +9,8 @@ import com.fuint.framework.exception.BusinessCheckException;
import com.fuint.framework.pagination.PaginationResponse;
import com.fuint.repository.model.MtCart;
import com.fuint.repository.model.MtOrder;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.Date;
@ -239,4 +241,20 @@ public interface OrderService extends IService<MtOrder> {
* @return
* */
List<MtOrder> getTobeCommissionOrderList(String dateTime) throws BusinessCheckException;
/**
*
*
* @param file excel
* @param request
* */
String saveExcelFile(MultipartFile file, HttpServletRequest request) throws Exception;
/**
*
*
* @param file excel
* @param operator
* */
String importSendCoupon(MultipartFile file, String operator, String filePath) throws BusinessCheckException;
}

@ -1,5 +1,6 @@
package com.fuint.common.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@ -7,13 +8,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fuint.common.Constants;
import com.fuint.common.dto.*;
import com.fuint.common.enums.*;
import com.fuint.common.excelDto.UserOrderExcelDto;
import com.fuint.common.param.OrderListParam;
import com.fuint.common.param.SettlementParam;
import com.fuint.common.service.*;
import com.fuint.common.util.CommonUtil;
import com.fuint.common.util.DateUtil;
import com.fuint.common.util.SeqUtil;
import com.fuint.common.util.TokenUtil;
import com.fuint.common.util.*;
import com.fuint.framework.annoation.OperationServiceLog;
import com.fuint.framework.exception.BusinessCheckException;
import com.fuint.framework.pagination.PaginationResponse;
@ -30,14 +29,20 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.core.env.Environment;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ResourceUtils;
import org.springframework.web.multipart.MultipartFile;
import weixin.popular.util.JsonUtil;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.*;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
/**
@ -169,6 +174,11 @@ public class OrderServiceImpl extends ServiceImpl<MtOrderMapper, MtOrder> implem
* */
private PaymentService paymentService;
/**
*
* */
private Environment env;
/**
*
* @param orderListParam
@ -2116,4 +2126,153 @@ public class OrderServiceImpl extends ServiceImpl<MtOrderMapper, MtOrder> implem
public List<MtOrder> getTobeCommissionOrderList(String dateTime) {
return mtOrderMapper.getTobeCommissionOrderList(dateTime);
}
/**
*
*
* @param file excel
* @param request
* */
public String saveExcelFile(MultipartFile file, HttpServletRequest request) throws Exception {
String fileName = file.getOriginalFilename();
String imageName = fileName.substring(fileName.lastIndexOf("."));
String pathRoot = env.getProperty("images.root");
if (pathRoot == null || StringUtil.isEmpty(pathRoot)) {
pathRoot = ResourceUtils.getURL("classpath:").getPath();
}
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
String filePath = "/static/uploadFiles/"+ DateUtil.formatDate(new Date(), "yyyyMMdd")+"/";
String path = filePath + uuid + imageName;
try {
File tempFile = new File(pathRoot + path);
if (!tempFile.getParentFile().exists()) {
tempFile.getParentFile().mkdirs();
}
CommonUtil.saveMultipartFile(file, pathRoot + path);
} catch (Exception e) {
//empty
}
return path;
}
/**
*
*
* @param file excel
* @param operator
* */
@Override
@Transactional(rollbackFor = Exception.class)
@OperationServiceLog(description = "导入订单列表")
public String importSendCoupon(MultipartFile file, String operator, String filePath) throws BusinessCheckException {
String originalFileName = file.getOriginalFilename();
boolean isExcel2003 = XlsUtil.isExcel2003(originalFileName);
boolean isExcel2007 = XlsUtil.isExcel2007(originalFileName);
if (!isExcel2003 && !isExcel2007) {
logger.error("importSendCouponController->uploadFile{}", "文件类型不正确");
throw new BusinessCheckException("文件类型不正确");
}
List<List<String>> content = new ArrayList<>();
try {
content = XlsUtil.readExcelContent(file.getInputStream(), isExcel2003, 1, null, null, null);
} catch (IOException e) {
logger.error("CouponGroupServiceImpl->parseExcelContent{}", e);
throw new BusinessCheckException("导入失败"+e.getMessage());
} catch (Exception e) {
e.printStackTrace();
}
StringBuffer errorMsg = new StringBuffer();
StringBuffer errorMsgNoGroup = new StringBuffer();
StringBuffer errorMsgNoNum = new StringBuffer();
StringBuffer errorMsgNoRegister = new StringBuffer();
List<MtOrder> rows = new ArrayList<>();
for (int i = 0; i < content.size(); i++) {
List<Integer> groupIdArr = new ArrayList<>();
List<Integer> numArr = new ArrayList<>();
List<String> rowContent = content.get(i);
MtOrder order = new MtOrder();
String type = rowContent.get(0);
if(StringUtil.isNotEmpty(type)){
String keyName = OrderTypeEnum.getKeyName(type);
if(StringUtil.isNotEmpty(keyName)){
type = keyName;
}
}
order.setType(type);
String payType = rowContent.get(1);
if(StringUtil.isNotEmpty(payType)){
String keyName = PayTypeEnum.getKeyName(payType);
if(StringUtil.isNotEmpty(keyName)){
payType = keyName;
}
}
order.setPayType(payType);
String orderMode = rowContent.get(2);
if(StringUtil.isNotEmpty(orderMode)){
String keyName = OrderModeEnum.getKeyName(orderMode);
if(StringUtil.isNotEmpty(keyName)){
orderMode = keyName;
}
}
order.setOrderMode(orderMode);
String orderSn = rowContent.get(3);
order.setOrderSn(orderSn);
String merchantName = rowContent.get(4);
// order.setMerchantId();
String storeName = rowContent.get(5);
if(StringUtil.isNotEmpty(storeName)){
StoreDto storeDto = storeService.queryStoreByName(storeName);
if(ObjectUtil.isNotEmpty(storeDto)){
order.setStoreId(storeDto.getId());
}
}
String userName = rowContent.get(6);
String isVisitor = rowContent.get(7);
order.setIsVisitor(isVisitor);
String amount = rowContent.get(8);
if(StringUtil.isNotEmpty(amount)){
order.setAmount(new BigDecimal(amount));
}
String payAmount = rowContent.get(9);
if(StringUtil.isNotEmpty(payAmount)){
order.setPayAmount(new BigDecimal(payAmount));
}
String usePoint = rowContent.get(10);
if(StringUtil.isNotEmpty(usePoint)){
order.setUsePoint(Integer.valueOf(usePoint));
}
String pointAmount = rowContent.get(11);
if(StringUtil.isNotEmpty(pointAmount)){
order.setPointAmount(new BigDecimal(pointAmount));
}
String discount = rowContent.get(12);
if(StringUtil.isNotEmpty(discount)){
order.setDiscount(new BigDecimal(discount));
}
String deliveryFee = rowContent.get(13);
if(StringUtil.isNotEmpty(deliveryFee)){
order.setDeliveryFee(new BigDecimal(deliveryFee));
}
String payTime = rowContent.get(14);
String staffName = rowContent.get(15);
// order.setStaffId();
mtOrderMapper.insert(order);
}
// 导入批次
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
return uuid;
}
}

@ -585,7 +585,7 @@ public class BackendOrderController extends BaseController {
* @throws BusinessCheckException
*/
@ApiOperation(value = "导出模板文件")
@RequestMapping(value = "/exportTemplate", method = RequestMethod.GET)
@RequestMapping(value = "/exportTemplate", method = RequestMethod.POST)
@CrossOrigin
public void exportTemplate(HttpServletRequest request, HttpServletResponse response) throws BusinessCheckException {
ClassLoader classLoader = this.getClass().getClassLoader();
@ -594,9 +594,9 @@ public class BackendOrderController extends BaseController {
ExcelExportDto excelExportDto = new ExcelExportDto();
excelExportDto.setSrcPath(srcTemplateFilePath);
excelExportDto.setSrcTemplateFileName("template" + File.separator + "importTemplate.xlsx");
excelExportDto.setSrcTemplateFileName("template" + File.separator + "订单导入模板.xlsx");
String filename = "订单模板" + ".xlsx";
String filename = "订单导入模板" + ".xlsx";
try {
OutputStream out = response.getOutputStream();
XlsUtil.setXlsHeader(request, response, filename);
@ -608,45 +608,25 @@ public class BackendOrderController extends BaseController {
}
}
/**
*
*
* @param request
* @throws
*/
@ApiOperation(value = "上传文件")
@RequestMapping(value = "/importData", method = RequestMethod.POST, produces = "text/html;charset=UTF-8")
@CrossOrigin
public ResponseObject uploadFile(HttpServletRequest request, @RequestParam("file") MultipartFile file) throws Exception {
String token = request.getHeader("Access-Token");
AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
if (accountInfo == null) {
return getFailureResult(1001, "请先登录");
}
// @PreAuthorize("@ss.hasPermi('system:user:import')")
// @PostMapping("/importData")
// public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
// {
// ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
// List<SysUser> userList = util.importExcel(file.getInputStream());
// LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
// String operName = loginUser.getUsername();
// String message = userService.importUser(userList, updateSupport, operName);
// return AjaxResult.success(message);
// }
//
// @GetMapping("/importTemplate")
// public AjaxResult importTemplate()
// {
// ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
// return util.importTemplateExcel("用户数据");
// }
// /**
// * 上传文件
// *
// * @param request
// * @throws
// */
// @ApiOperation(value = "上传文件")
// @RequestMapping(value = "/upload/", method = RequestMethod.POST, produces = "text/html;charset=UTF-8")
// @CrossOrigin
// public ResponseObject uploadFile(HttpServletRequest request, @RequestParam("fileInput") MultipartFile file) throws Exception {
// String token = request.getHeader("Access-Token");
// AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
// if (accountInfo == null) {
// return getFailureResult(1001, "请先登录");
// }
//
// String filePath = couponGroupService.saveExcelFile(file, request);
// String uuid = couponGroupService.importSendCoupon(file, accountInfo.getAccountName(), filePath);
// return getSuccessResult(uuid);
// }
String filePath = orderService.saveExcelFile(file, request);
String uuid = orderService.importSendCoupon(file, accountInfo.getAccountName(), filePath);
return getSuccessResult(uuid);
}
}

Loading…
Cancel
Save