From 8f5aa8192e7e208fe68ac39409669ef6fcb6b53b Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Tue, 13 Apr 2021 19:56:31 +0800
Subject: [PATCH] 20210413 后台订单管理修改
---
zq-erp/src/main/resources/templates/views/admin/shop/shopOrder-list.html | 20 +++
zq-erp/src/main/resources/templates/views/admin/shop/logisticsImport-form.html | 125 +++++++++++++++++++++++++
zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopOrderAction.java | 110 ++++++++++++++++++++++
zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopOrderDao.xml | 7 +
zq-erp/src/main/java/com/matrix/system/shopXcx/dao/ShopOrderDao.java | 2
zq-erp/src/main/java/com/matrix/system/shopXcx/vo/LogisticsImportVo.java | 16 +++
6 files changed, 277 insertions(+), 3 deletions(-)
diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopOrderAction.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopOrderAction.java
index 32d7e0c..3185e15 100644
--- a/zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopOrderAction.java
+++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopOrderAction.java
@@ -1,7 +1,10 @@
package com.matrix.system.shopXcx.action;
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.ObjectUtil;
import com.google.gson.Gson;
+import com.matrix.component.rabbitmq.RabiitMqTemplate;
import com.matrix.core.anotations.RemoveRequestToken;
import com.matrix.core.anotations.SaveRequestToken;
import com.matrix.core.constance.MatrixConstance;
@@ -19,21 +22,30 @@
import com.matrix.system.hive.action.BaseController;
import com.matrix.system.hive.action.util.QueryUtil;
import com.matrix.system.hive.bean.SysShopInfo;
+import com.matrix.system.hive.bean.SysVipInfo;
import com.matrix.system.hive.dao.SysShopInfoDao;
+import com.matrix.system.hive.service.SysVipInfoService;
import com.matrix.system.shopXcx.bean.*;
import com.matrix.system.shopXcx.dao.*;
import com.matrix.system.shopXcx.dto.DiscountExplain;
+import com.matrix.system.shopXcx.mqTask.MQTaskRouting;
import com.matrix.system.shopXcx.pojo.ShopOrderQueryPOJO;
import com.matrix.system.shopXcx.shopEnum.OrderStatusEnum;
+import com.matrix.system.shopXcx.vo.LogisticsImportVo;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
+import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.math.BigDecimal;
@@ -61,10 +73,108 @@
private WxApplyOrderRelateDao wxApplyOrderRelateDao;
@Autowired
private SysShopInfoDao sysShopInfoDao;
+ @Autowired
+ private SysVipInfoService vipInfoService;
+ @Autowired
+ private RabiitMqTemplate rabiitMqTemplate;
//记录编辑前的值Before_Edit_Value
public static final String BEV = "ShopOrder_BEV";
+ @Value("${evn}")
+ private String evn;
+
+ /**
+ * 导入快递单
+ */
+ @RequestMapping(value = "/logisticsImport")
+ @ResponseBody
+ public AjaxResult logisticsImport(HttpServletResponse response, HttpServletRequest request,
+ @RequestParam(value = "file", required = false) MultipartFile file) throws IOException {
+
+ String fileName = file.getOriginalFilename();
+ String dirPath = PropertiesUtil.getString(AppConstance.FILES_TORAGE_PATH);
+// String dirPath = "E:/xcshop";
+ File fileDir = new File(dirPath);
+ LogUtil.info("#----->{}#", fileDir.exists());
+ if (!fileDir.exists()) {
+ fileDir.mkdirs();
+ }
+ File saveFile = new File(dirPath + "/" + fileName);
+ file.transferTo(saveFile);
+
+ String infoRemind = "提示:";
+ AjaxResult ajaxResult = new AjaxResult();
+ List<LogisticsImportVo> logisticsImportVos = logisticsImportFile(saveFile);
+ if(CollUtil.isNotEmpty(logisticsImportVos)){
+ for(LogisticsImportVo logisticsImportVo : logisticsImportVos){
+ infoRemind = infoRemind + logisticsImportVo.getRemark()+";//r//n";
+ }
+ ajaxResult = AjaxResult.buildSuccessInstance(infoRemind);
+ ajaxResult.setStatus(AjaxResult.STATUS_SUCCESS);
+ }else{
+ ajaxResult = AjaxResult.buildSuccessInstance("导入成功");
+ ajaxResult.setStatus(AjaxResult.STATUS_FAIL);
+ }
+ return ajaxResult;
+ }
+
+ public List<LogisticsImportVo> logisticsImportFile(File file) throws IOException {
+ SysUsers sysUsers = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
+ List<ExcelSheetPO> excelList = ExcelUtil.readExcel(file, null,null);
+ ArrayList<LogisticsImportVo> logisticsImportVos = new ArrayList<>();
+ for (int i = 0; i < excelList.size(); i++) {
+ List<List<Object>> dataList = excelList.get(i).getDataList();
+ List<SysVipInfo> vipInfos = new ArrayList<>();
+ if (CollectionUtils.isNotEmpty(dataList)) {
+ for (int j = 1; j < dataList.size(); j++) {
+ /**
+ * 订单处于【待付款】【待配送】【待收货】都可以导入
+ * 其他状态生成一个提示
+ */
+ List<Object> objects = dataList.get(j);
+ ShopDeliveryInfo shopDeliveryInfo = new ShopDeliveryInfo();
+ //订单编号
+ String orderNo = objects.get(0).toString();
+ ShopOrder shopOrder = shopOrderDao.selectShopOrderByOrderNo(orderNo);
+ if(ObjectUtil.isNotEmpty(shopOrder) &&
+ (shopOrder.getOrderStatus() == ShopOrder.ORDER_STATUS_WAIT_SEND ||
+ shopOrder.getOrderStatus() == ShopOrder.ORDER_STATUS_WAIT_RECEIVE )){
+ //物流公司编码
+ String logisticsCompanyCode = objects.get(1).toString();
+ //物流公司名称
+ String logisticsCompany = objects.get(2).toString();
+ //快递单号
+ String waybillNo = objects.get(3).toString();
+ shopDeliveryInfo.setOrderNo(orderNo);
+ shopDeliveryInfo.setLogisticsCompanyCode(logisticsCompanyCode);
+ shopDeliveryInfo.setLogisticsCompany(logisticsCompany);
+ shopDeliveryInfo.setWaybillNo(waybillNo);
+ shopDeliveryInfo.setUpdateBy(sysUsers.getSuName());
+ shopDeliveryInfo.setLogisticsStatus(AppConstance.LOGISTICS_STATUS_OF_RECEIVE);
+ shopDeliveryInfo.setDeliveryTime(new Date());
+ shopDeliveryInfoDao.updateByModel(shopDeliveryInfo);
+
+ //构建需要修改订单信息Map
+ Map<String, Object> modifyMap = new HashMap<>();
+ modifyMap.put("id", shopOrder.getId());
+ modifyMap.put("orderStatus", ShopOrder.ORDER_STATUS_WAIT_RECEIVE);
+ shopOrderDao.updateByMap(modifyMap);
+
+ //发送创建订单的消息
+ rabiitMqTemplate.sendMsg(MQTaskRouting.ORDER_OUT_SOTORE+evn, orderNo);
+ }else{
+ LogisticsImportVo logisticsImportVo = new LogisticsImportVo();
+ logisticsImportVo.setWaybillNo(orderNo);
+ logisticsImportVo.setColNum(j);
+ logisticsImportVo.setRemark("第"+j+"行导入失败");
+ logisticsImportVos.add(logisticsImportVo);
+ }
+ }
+ }
+ }
+ return logisticsImportVos;
+ }
/**
* 导出Excel
diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/dao/ShopOrderDao.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/dao/ShopOrderDao.java
index 5d925ad..a161313 100644
--- a/zq-erp/src/main/java/com/matrix/system/shopXcx/dao/ShopOrderDao.java
+++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/dao/ShopOrderDao.java
@@ -74,5 +74,7 @@
public int batchUpdateOrderStatus(@Param("list") List<ShopOrder> list);
+ public ShopOrder selectShopOrderByOrderNo(@Param("orderNo")String orderNo);
+
}
\ No newline at end of file
diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/vo/LogisticsImportVo.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/vo/LogisticsImportVo.java
new file mode 100644
index 0000000..f20f52e
--- /dev/null
+++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/vo/LogisticsImportVo.java
@@ -0,0 +1,16 @@
+package com.matrix.system.shopXcx.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+@ApiModel(value = "LogisticsImportVo", description = "信息返回类")
+public class LogisticsImportVo {
+ @ApiModelProperty(value = "单号")
+ private String waybillNo;
+ @ApiModelProperty(value = "备注")
+ private String remark;
+ @ApiModelProperty(value = "行数")
+ private int colNum;
+}
diff --git a/zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopOrderDao.xml b/zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopOrderDao.xml
index d2cd718..50e3463 100644
--- a/zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopOrderDao.xml
+++ b/zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopOrderDao.xml
@@ -756,6 +756,13 @@
group by order_status
</select>
+ <select id="selectShopOrderByOrderNo" resultType="com.matrix.system.shopXcx.bean.ShopOrder" >
+ select
+ a.*
+ from shop_order a
+ where a.order_no=#{orderNo}
+ </select>
+
<update id="batchUpdateOrderStatus">
<foreach collection="list" index="index" item="item" separator=";">
update shop_order set order_status=#{item.orderStatus}
diff --git a/zq-erp/src/main/resources/templates/views/admin/shop/logisticsImport-form.html b/zq-erp/src/main/resources/templates/views/admin/shop/logisticsImport-form.html
new file mode 100644
index 0000000..7ad2f92
--- /dev/null
+++ b/zq-erp/src/main/resources/templates/views/admin/shop/logisticsImport-form.html
@@ -0,0 +1,125 @@
+<!DOCTYPE HTML>
+<html xmlns:th="http://www.thymeleaf.org">
+<head>
+ <meta charset="utf-8">
+ <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
+ <meta name="renderer" content="webkit|ie-comp|ie-stand">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+ <meta name="viewport"
+ content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
+ <meta http-equiv="Cache-Control" content="no-siteapp" />
+ <!-- 本框架基本脚本和样式 -->
+ <script type="text/javascript"
+ th:src="@{/js/plugin/jquery-2.1.4.min.js}"></script>
+ <script type="text/javascript"
+ th:src="@{/js/systools/MBase.js}"></script>
+ <script src="https://cdn.jsdelivr.net/gh/jquery-form/form@4.2.2/dist/jquery.form.min.js" integrity="sha384-FzT3vTVGXqf7wRfy8k4BiyzvbNfeYjK+frTVqZeNDFl8woCbF0CYG6g2fMEFFo/i" crossorigin="anonymous"></script>
+</head>
+<body>
+<div class="ibox-content">
+ <form name="uploadExcel"
+ style="display: contents; margin-left: 20px;"
+ action="/admin/shopOrder/logisticsImport" method="post"
+ enctype="multipart/form-data" id="uploadForm">
+
+ <div class="form-group">
+ <input onclick="importChances()"
+ class="input-text upload-url radius form-control" type="text"
+ id="showFileName" readonly
+ style="width: 200px; display: inline; margin-left: 50px;">
+ <a onclick="importChances()" class="btn btn-primary radius">
+ <i class="fa fa-cloud-upload"></i> 浏览文件
+ </a>
+ <input type="file" name="file" accept=".xls,.xlsx"
+ id="chanceUploadId" style="display: none">
+ <button type="button" onclick="download()"
+ class="btn btn-success radius">下载模板</button></div>
+ <div class="form-group ">
+ <div class="col-sm-12 text-center">
+
+ <button type="submit" onclick="return submitFile()"
+ class="btn btn-success radius">导入快递单</button>
+ <a
+ class="btn btn-danger radius" href="javascript:;" onclick="MTools.closeForm()" ><i class="fa fa-close"></i> 关闭</a>
+ </div>
+ </div>
+ </form>
+</div>
+</body>
+<script type="text/javascript" th:src="@{/js/systools/MJsBase.js}"></script>
+<script th:inline="javascript">
+ MTools.autoFullSelect();
+ $(".select2").select2();
+
+ /*<![CDATA[*/
+ var obj=/*[[${obj}]]*/
+ /*]]>*/
+
+ var invokeUrl=basePath+"/admin/shopOrder/showList";
+ var myForm=MForm.initForm({
+ invokeUrl:invokeUrl,
+ afterSubmit:function(){
+ parent.myGrid.serchData();
+ },
+ });
+
+
+ //绑定文件的点击事件
+ function importChances() {
+ var file = $("#chanceUploadId").click();
+
+ //选中文件,文件名字显示在文本框中
+ $("#chanceUploadId").change(
+ function() {
+ $("#showFileName").val('');
+ var fileName = $(this).val();
+ fileName = fileName.substring(
+ fileName.lastIndexOf("\\") + 1, fileName
+ .lastIndexOf("."));
+ $("#showFileName").val(fileName);
+ })
+ }
+ //提交文件
+ function submitFile() {
+ if ($("#showFileName").val() == ''
+ || $("#showFileName").val().length < 1) {
+ layer.msg("请选择上传文件!", {
+ icon : 2
+ });
+ return false;
+ }
+
+ layer.load(2, {
+ time : 100 * 1000,
+ shade : [ 0.4, '#aeaeae' ]
+ });
+
+ $("#uploadForm").ajaxForm(function (data) {
+ layer.closeAll('loading');
+ console.log(data)
+ if (data.status == "200") {
+ layer.open({
+ title: '导入快递单',
+ content: data.info
+ });
+ } else {
+ layer.open({
+ title: '导入快递单',
+ content: data.info
+ });
+ }
+ $("#showFileName").val('');
+ var file = $("#chanceUploadId");
+ file.after(file.clone().val(''));
+ file.remove();
+ });
+ }
+
+
+ function download() {
+ //window.location.href= "https://xcshop.csxuncong.com/uploadefile/image/logisticsImport.xls";
+ window.location.href= "http://xcshop.csxuncong.com/uploadfile/image/logisticsImport.xls";
+ }
+</script>
+</body>
+</html>
\ No newline at end of file
diff --git a/zq-erp/src/main/resources/templates/views/admin/shop/shopOrder-list.html b/zq-erp/src/main/resources/templates/views/admin/shop/shopOrder-list.html
index 4dcba3f..7d02c7a 100644
--- a/zq-erp/src/main/resources/templates/views/admin/shop/shopOrder-list.html
+++ b/zq-erp/src/main/resources/templates/views/admin/shop/shopOrder-list.html
@@ -84,11 +84,11 @@
class="form-control datetimepicker" id="orderEndTime">
</div>
- <input type="hidden" value="" name="orderStatus" id="orderStatus"/>
+ <input type="hidden" value="2" name="orderStatus" id="orderStatus"/>
<div class="form-group mr-20">
- <button type="button" class="btn btn-my btn-sm active" id="btn0" value="">全部</button>
+ <button type="button" class="btn btn-my btn-sm" id="btn0" value="">全部</button>
<button type="button" class="btn btn-my btn-sm" id="btn1" value="1">待付款</button>
- <button type="button" class="btn btn-my btn-sm" id="btn2" value="2">待配送</button>
+ <button type="button" class="btn btn-my btn-sm active" id="btn2" value="2">待配送</button>
<button type="button" class="btn btn-my btn-sm" id="btn3" value="3">待收货</button>
<button type="button" class="btn btn-my btn-sm" id="btn4" value="4">待评价</button>
<button type="button" class="btn btn-my btn-sm" id="btn5" value="5">已评价</button>
@@ -106,6 +106,11 @@
class="btn btn-info"
matrix:btn="order-exportExcel">
<i class="fa fa-search "></i> 导出EXCEL
+ </button>
+ <button onclick="importLogisticsInfo()" type="button"
+ class="btn btn-info"
+ matrix:btn="order-exportExcel">
+ <i class="fa fa-search "></i> 导入快递单
</button>
<button type="reset" class="btn btn-info ">
<i class="fa fa-refresh "></i> 重置
@@ -170,6 +175,15 @@
$(this).addClass("active");
});
+ function importLogisticsInfo() {
+ layer.open({
+ type: 2,
+ title: "导入快递单",
+ area: [MUI.SIZE_L, '400px'],
+ content : [ basePath+'/admin/redirect/shop/logisticsImport-form']
+ });
+ }
+
function exportExcel() {
--
Gitblit v1.9.1