| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | 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()+";"; |
| | | } |
| | | ajaxResult = AjaxResult.buildSuccessInstance(infoRemind); |
| | | ajaxResult.setStatus(AjaxResult.STATUS_FAIL); |
| | | }else{ |
| | | ajaxResult = AjaxResult.buildSuccessInstance("导入成功"); |
| | | ajaxResult.setStatus(AjaxResult.STATUS_SUCCESS); |
| | | } |
| | | 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 |