记得上下班打卡 | git大法好,push需谨慎

Commit 54beec84 authored by 胡佳晨's avatar 胡佳晨

快递发货。

parent 3a5ad738
...@@ -23,10 +23,9 @@ ...@@ -23,10 +23,9 @@
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.liquidnet</groupId> <groupId>com.alibaba</groupId>
<artifactId>liquidnet-client-admin-common</artifactId> <artifactId>easyexcel</artifactId>
<version>4.6.1</version> <version>3.0.5</version>
<scope>compile</scope>
</dependency> </dependency>
</dependencies> </dependencies>
......
package com.liquidnet.service.goblin.dto.vo; package com.liquidnet.service.goblin.dto.vo;
import com.liquidnet.client.admin.common.annotation.Excel; import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
import lombok.Data; import lombok.Data;
@Data @Data
@HeadRowHeight(value = 20)//设置表头行高
@ColumnWidth(value = 15)//设置表头行宽
public class OrderMallOrderVo { public class OrderMallOrderVo {
@Excel(name = "订单编号",cellType = Excel.ColumnType.STRING) @ExcelProperty(value = "订单编号",index = 0)
private String orderCode; private String orderCode;
@Excel(name = "购买人手机号",cellType = Excel.ColumnType.STRING) @ExcelProperty(value = "购买人手机号",index = 1)
private String userMobile; private String userMobile;
@Excel(name = "快递费",cellType = Excel.ColumnType.STRING) @ExcelProperty(value = "快递费",index = 2)
private String priceExpress; private String priceExpress;
@Excel(name = "平台券优惠金额",cellType = Excel.ColumnType.STRING) @ExcelProperty(value = "平台券优惠金额",index = 3)
private String priceCoupon; private String priceCoupon;
@Excel(name = "店铺券优惠金额",cellType = Excel.ColumnType.STRING) @ExcelProperty(value = "店铺券优惠金额",index = 4)
private String storePriceCoupon; private String storePriceCoupon;
@Excel(name = "收货人",cellType = Excel.ColumnType.STRING) @ExcelProperty(value = "收货人",index = 5)
private String expressContacts; private String expressContacts;
@Excel(name = "收货人电话",cellType = Excel.ColumnType.STRING) @ExcelProperty(value = "收货人电话",index = 6)
private String expressPhone; private String expressPhone;
@Excel(name = "快递地址",cellType = Excel.ColumnType.STRING) @ExcelProperty(value = "快递地址",index = 7)
private String expressDetailAddress; private String expressDetailAddress;
@Excel(name = "支付方式",cellType = Excel.ColumnType.STRING) @ExcelProperty(value = "支付方式",index = 8)
private String payType; private String payType;
@Excel(name = "支付时间",cellType = Excel.ColumnType.STRING) @ExcelProperty(value = "支付时间",index = 9)
private String payTime; private String payTime;
@Excel(name = "下单时间",cellType = Excel.ColumnType.STRING) @ExcelProperty(value = "下单时间",index = 10)
private String createdAt; private String createdAt;
@Excel(name = "快递公司",cellType = Excel.ColumnType.STRING) @ExcelProperty(value = "快递公司",index = 11)
private String logisticsCompany; private String logisticsCompany;
@Excel(name = "物流单号",cellType = Excel.ColumnType.STRING) @ExcelProperty(value = "物流单号",index = 12)
private String mailNo; private String mailNo;
@Excel(name = "商品id1",cellType = Excel.ColumnType.STRING) @ExcelProperty(value = "商品id1",index = 13)
private String spuId; private String spuId;
@Excel(name = "商品名1",cellType = Excel.ColumnType.STRING) @ExcelProperty(value = "商品名1",index = 14)
private String name; private String name;
@Excel(name = "一级分类1",cellType = Excel.ColumnType.STRING) @ExcelProperty(value = "一级分类1",index = 15)
private String cate1Name; private String cate1Name;
@Excel(name = "二级分类1",cellType = Excel.ColumnType.STRING) @ExcelProperty(value = "二级分类1",index = 16)
private String cate2Name; private String cate2Name;
@Excel(name = "款式1",cellType = Excel.ColumnType.STRING) @ExcelProperty(value = "款式1",index = 17)
private String skuName; private String skuName;
@Excel(name = "数量1",cellType = Excel.ColumnType.STRING) @ExcelProperty(value = "数量1",index = 18)
private String num; private String num;
@Excel(name = "单价1",cellType = Excel.ColumnType.STRING) @ExcelProperty(value = "单价1",index = 19)
private String skuPrice; private String skuPrice;
@Excel(name = "价格1",cellType = Excel.ColumnType.STRING) @ExcelProperty(value = "价格1",index = 20)
private String skuPriceActual; private String skuPriceActual;
@Excel(name = "订单skuId1",cellType = Excel.ColumnType.STRING) @ExcelProperty(value = "订单skuId1",index = 21)
private String orderSkuId; private String orderSkuId;
} }
...@@ -6,6 +6,6 @@ import javax.servlet.http.HttpServletResponse; ...@@ -6,6 +6,6 @@ import javax.servlet.http.HttpServletResponse;
public interface IGoblinExportService { public interface IGoblinExportService {
//导出商城订单信息 //导出商城订单信息
ResponseDto<Boolean> exportMallOrder(HttpServletResponse response, String beginTime, String endTime, String state, Integer mailType); ResponseDto<Boolean> exportMallOrder(HttpServletResponse response, String beginTime, String endTime, String state, Integer mailType,String storeId);
} }
package com.liquidnet.service.goblin.service; package com.liquidnet.service.goblin.service;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.goblin.dto.vo.OrderMallOrderVo; import com.liquidnet.service.goblin.dto.vo.OrderMallOrderVo;
import org.springframework.web.multipart.MultipartFile;
import java.util.List; import java.util.List;
public interface IGoblinImportService { public interface IGoblinImportService {
//导入对订单发货 //导入对订单发货
String importExpress(List<OrderMallOrderVo> orderOutLineVoList); ResponseDto<String> importExpress(MultipartFile file);
} }
...@@ -32,7 +32,7 @@ public interface IGoblinStoreOrderService { ...@@ -32,7 +32,7 @@ public interface IGoblinStoreOrderService {
ResponseDto<Boolean> refundOrderSku(String orderId, String orderSkuId, BigDecimal price); ResponseDto<Boolean> refundOrderSku(String orderId, String orderSkuId, BigDecimal price);
ResponseDto<Boolean> express(String orderId, String orderSkuIds,String mailNo); ResponseDto<Boolean> express(String orderId, String orderSkuIds,String mailNo,String uid);
ResponseDto<Boolean> changeExpressMailNo(String orderId, String mailId,String mailNo); ResponseDto<Boolean> changeExpressMailNo(String orderId, String mailId,String mailNo);
......
...@@ -4,6 +4,8 @@ import lombok.Data; ...@@ -4,6 +4,8 @@ import lombok.Data;
@Data @Data
public class MallOrdertDao { public class MallOrdertDao {
//订单id
private String orderId;
//订单编号 //订单编号
private String orderCode; private String orderCode;
//购买人手机号 //购买人手机号
......
...@@ -19,6 +19,6 @@ import java.util.List; ...@@ -19,6 +19,6 @@ import java.util.List;
public interface GoblinStoreOrderMapper extends BaseMapper<GoblinStoreOrder> { public interface GoblinStoreOrderMapper extends BaseMapper<GoblinStoreOrder> {
List<MallOrdertDao> exportMallOrder(@Param("beginTime") Date beginTime, @Param("endTime") Date endTime, @Param("states") List<String> List<MallOrdertDao> exportMallOrder(@Param("beginTime") Date beginTime, @Param("endTime") Date endTime, @Param("states") List<String>
states, @Param("mailType") Integer mailType); states, @Param("mailType") Integer mailType, @Param("storeId") String storeId);
} }
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
<mapper namespace="com.liquidnet.service.goblin.mapper.GoblinStoreOrderMapper"> <mapper namespace="com.liquidnet.service.goblin.mapper.GoblinStoreOrderMapper">
<resultMap id="exportMallOrderDaoResult" type="com.liquidnet.service.goblin.dto.MallOrdertDao"> <resultMap id="exportMallOrderDaoResult" type="com.liquidnet.service.goblin.dto.MallOrdertDao">
<result column="order_id" property="orderId"/>
<result column="order_code" property="orderCode"/> <result column="order_code" property="orderCode"/>
<result column="user_mobile" property="userMobile"/> <result column="user_mobile" property="userMobile"/>
<result column="price_express" property="priceExpress"/> <result column="price_express" property="priceExpress"/>
...@@ -28,7 +29,9 @@ ...@@ -28,7 +29,9 @@
</resultMap> </resultMap>
<select id="exportMallOrder" resultMap="exportMallOrderDaoResult"> <select id="exportMallOrder" resultMap="exportMallOrderDaoResult">
select gso.order_code as order_code, select
gso.order_id as order_id,
gso.order_code as order_code,
gso.user_mobile as user_mobile, gso.user_mobile as user_mobile,
gso.price_express as price_express, gso.price_express as price_express,
gso.price_coupon as price_coupon, gso.price_coupon as price_coupon,
...@@ -60,6 +63,7 @@ ...@@ -60,6 +63,7 @@
inner join goblin_order_attr as goa on goa.order_id = gso.order_id inner join goblin_order_attr as goa on goa.order_id = gso.order_id
left join goblin_mail as gm on gm.order_id = gso.order_id left join goblin_mail as gm on gm.order_id = gso.order_id
<where> <where>
and gso.store_id = #{storeId}
<if test="beginTime != null and endTime != null"> <if test="beginTime != null and endTime != null">
and gso.created_at between #{beginTime} and #{endTime} and gso.created_at between #{beginTime} and #{endTime}
</if> </if>
......
...@@ -84,12 +84,6 @@ ...@@ -84,12 +84,6 @@
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId> <artifactId>easyexcel</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.liquidnet</groupId>
<artifactId>liquidnet-client-admin-common</artifactId>
<version>4.6.1</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
package com.liquidnet.service.goblin.controller; package com.liquidnet.service.goblin.controller;
import com.liquidnet.client.admin.common.core.domain.AjaxResult; import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.client.admin.common.utils.poi.ExcelUtil;
import com.liquidnet.service.goblin.dto.vo.OrderMallOrderVo;
import com.liquidnet.service.goblin.service.IGoblinImportService; import com.liquidnet.service.goblin.service.IGoblinImportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.validation.constraints.Null;
import java.util.List; import java.util.List;
@Controller @Controller
@Api(tags = "订单导入")
@RequestMapping("/import") @RequestMapping("/import")
public class GoblinImportController { public class GoblinImportController {
private String prefix = "zhengzai/kylin/performances/orderImport"; private String prefix = "zhengzai/kylin/performances/orderImport";
...@@ -26,11 +29,11 @@ public class GoblinImportController { ...@@ -26,11 +29,11 @@ public class GoblinImportController {
* 导入对订单发货 * 导入对订单发货
*/ */
@PostMapping("/OrderExpress") @PostMapping("/OrderExpress")
@ApiOperation("快递发货")
@ResponseBody @ResponseBody
public AjaxResult importOrderExpress(MultipartFile file) throws Exception { public ResponseDto<String> importOrderExpress(MultipartFile file) throws Exception {
ExcelUtil<OrderMallOrderVo> util = new ExcelUtil(OrderMallOrderVo.class); // ExcelUtil<OrderMallOrderVo> util = new ExcelUtil(OrderMallOrderVo.class);
List<OrderMallOrderVo> MallOrdertVoList = util.importExcel(file.getInputStream()); // List<OrderMallOrderVo> MallOrdertVoList = util.importExcel(file.getInputStream());
String message = iGoblinImportService.importExpress(MallOrdertVoList); return iGoblinImportService.importExpress(file);
return AjaxResult.success(message);
} }
} }
...@@ -2,6 +2,7 @@ package com.liquidnet.service.goblin.controller.manage; ...@@ -2,6 +2,7 @@ package com.liquidnet.service.goblin.controller.manage;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.github.xiaoymin.knife4j.annotations.ApiSupport; import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.liquidnet.commons.lang.util.CurrentUtil;
import com.liquidnet.service.base.ResponseDto; import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.goblin.dto.vo.GoblinMailVo; import com.liquidnet.service.goblin.dto.vo.GoblinMailVo;
import com.liquidnet.service.goblin.dto.vo.GoblinStoreOrderListVo; import com.liquidnet.service.goblin.dto.vo.GoblinStoreOrderListVo;
...@@ -134,7 +135,7 @@ public class GoblinStoreOrderController { ...@@ -134,7 +135,7 @@ public class GoblinStoreOrderController {
public ResponseDto<Boolean> express(@RequestParam(value = "orderId", required = true) @Valid String orderId, public ResponseDto<Boolean> express(@RequestParam(value = "orderId", required = true) @Valid String orderId,
@RequestParam(value = "orderSkuIds", required = false) @Valid String orderSkuIds, @RequestParam(value = "orderSkuIds", required = false) @Valid String orderSkuIds,
@RequestParam(value = "mailNo", required = true) @Valid String mailNo) { @RequestParam(value = "mailNo", required = true) @Valid String mailNo) {
return goblinStoreOrderService.express(orderId, orderSkuIds, mailNo); return goblinStoreOrderService.express(orderId, orderSkuIds, mailNo, CurrentUtil.getCurrentUid());
} }
@ApiOperation(value = "修改快递单号") @ApiOperation(value = "修改快递单号")
......
package com.liquidnet.service.goblin.service.impl; package com.liquidnet.service.goblin.service.impl;
import com.liquidnet.client.admin.common.exception.BusinessException; import com.alibaba.excel.EasyExcel;
import com.liquidnet.client.admin.common.utils.StringUtils; import com.alibaba.excel.read.listener.PageReadListener;
import com.liquidnet.commons.lang.util.CurrentUtil;
import com.liquidnet.service.base.ResponseDto; import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.goblin.dto.vo.OrderMallOrderVo;
import com.liquidnet.service.goblin.service.IGoblinImportService; import com.liquidnet.service.goblin.service.IGoblinImportService;
import com.liquidnet.service.goblin.service.manage.IGoblinStoreOrderService; import com.liquidnet.service.goblin.service.manage.IGoblinStoreOrderService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
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 java.util.List; import java.util.HashMap;
@Service @Service
@Slf4j @Slf4j
...@@ -20,31 +21,71 @@ public class GoblinImportServiceImpl implements IGoblinImportService { ...@@ -20,31 +21,71 @@ public class GoblinImportServiceImpl implements IGoblinImportService {
private IGoblinStoreOrderService iGoblinStoreOrderService; private IGoblinStoreOrderService iGoblinStoreOrderService;
@Override @Override
public String importExpress(List<OrderMallOrderVo> mallOrdertVoList) { public ResponseDto<String> importExpress(MultipartFile file) {
if (StringUtils.isNull(mallOrdertVoList) || mallOrdertVoList.size() == 0) { if (file == null) {
throw new BusinessException("导入数据不能为空!"); return ResponseDto.failure();
} }
int successNum = 0; try {
int failureNum = 0; EasyExcel.read(file.getInputStream(), new PageReadListener<HashMap<String, String>>(dataList -> {
StringBuilder successMsg = new StringBuilder(); for (HashMap<String, String> item : dataList) {
StringBuilder failureMsg = new StringBuilder(); String skuIds = "";
for (OrderMallOrderVo mallOrderVo : mallOrdertVoList) { int init = 22;
ResponseDto<Boolean> express = iGoblinStoreOrderService.express(mallOrderVo.getOrderCode(), null, mallOrderVo.getMailNo()); int skip = 9;
if (express.getCode().equals("0")) { int count = (item.size() - init) / skip;
successNum++; String orderId = item.get(0);
successMsg.append("<br/>" + successNum + "、订单编号 " + mallOrderVo.getOrderCode() + " 导入发货成功"); String mailNo = item.get(13);
} else { for (int i = 0; i < count; i++) {
failureNum++; String skuId = item.get(init + (i * skip));
String msg = "<br/>" + failureNum + "、订单编号 " + mallOrderVo.getOrderCode() + " 失败原因:"; if (skuId != null && !skuId.equals("null")) {
failureMsg.append(msg + express.getMessage()); skuIds = skuIds.concat(skuId).concat(",");
} }
}
if (skuIds.trim().length() > 0) {
skuIds = skuIds.substring(0, skuIds.trim().length() - 1);
}
log.debug("orderId = " + orderId);
log.debug("skuIds = " + skuIds);
log.debug("mailNo = " + mailNo);
if (mailNo == null || mailNo.equals("")) {
log.error("发货失败 orderId = " + orderId + "skuIds = " + skuIds + " 快递单号空");
}
ResponseDto<Boolean> express = iGoblinStoreOrderService.express(orderId, skuIds, mailNo, "d0920ca469129c3950f70371b36c1ce2");
if (express.getCode().equals("0")) {
} else {
log.error("发货失败 orderId = " + orderId + "skuIds = " + skuIds + " mailNo = " + mailNo);
}
}
})).sheet().doRead();
// if (StringUtils.isNull(mallOrdertVoList) || mallOrdertVoList.size() == 0) {
// throw new BusinessException("导入数据不能为空!");
// }
// int successNum = 0;
// int failureNum = 0;
// StringBuilder successMsg = new StringBuilder();
// StringBuilder failureMsg = new StringBuilder();
// for (OrderMallOrderVo mallOrderVo : mallOrdertVoList) {
// log.debug("data = " + mallOrderVo.toString());
//// ResponseDto<Boolean> express = iGoblinStoreOrderService.express(mallOrderVo.getOrderCode(), null, mallOrderVo.getMailNo());
// if (express.getCode().equals("0")) {
// successNum++;
// successMsg.append("<br/>" + successNum + "、订单编号 " + mallOrderVo.getOrderCode() + " 导入发货成功");
// } else {
// failureNum++;
// String msg = "<br/>" + failureNum + "、订单编号 " + mallOrderVo.getOrderCode() + " 失败原因:";
// failureMsg.append(msg + express.getMessage());
// }
// }
// if (failureNum > 0) {
// failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
// throw new BusinessException(failureMsg.toString());
// } else {
// successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
// }
// return successMsg.toString();
} catch (Exception e) {
e.printStackTrace();
return ResponseDto.failure();
} }
if (failureNum > 0) { return ResponseDto.success("订单导入成功");
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
throw new BusinessException(failureMsg.toString());
} else {
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
}
return successMsg.toString();
} }
} }
...@@ -538,8 +538,7 @@ public class GoblinStoreOrderServiceImpl implements IGoblinStoreOrderService { ...@@ -538,8 +538,7 @@ public class GoblinStoreOrderServiceImpl implements IGoblinStoreOrderService {
} }
@Override @Override
public ResponseDto<Boolean> express(String orderId, String orderSkuIds, String mailNo) { public ResponseDto<Boolean> express(String orderId, String orderSkuIds, String mailNo,String uid) {
String uid = CurrentUtil.getCurrentUid();
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
String nowStr = DateUtil.getNowTime(); String nowStr = DateUtil.getNowTime();
LinkedList<String> sqls = CollectionUtil.linkedListString(); LinkedList<String> sqls = CollectionUtil.linkedListString();
......
...@@ -2,6 +2,8 @@ package com.liquidnet.service.platform.controller.goblin; ...@@ -2,6 +2,8 @@ package com.liquidnet.service.platform.controller.goblin;
import com.liquidnet.service.goblin.service.IGoblinExportService; import com.liquidnet.service.goblin.service.IGoblinExportService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
...@@ -30,9 +32,16 @@ public class GoblinExportDataController { ...@@ -30,9 +32,16 @@ public class GoblinExportDataController {
*/ */
@GetMapping("/exportMallOrder") @GetMapping("/exportMallOrder")
@ApiOperation(value = "excel订单信息导出") @ApiOperation(value = "excel订单信息导出")
public void exportMallOrder(HttpServletResponse response, @RequestParam("beginTime") String beginTime, @RequestParam("endTime")String endTime, @ApiImplicitParams({
@RequestParam("state")String state, @RequestParam("mailType")Integer mailType) { @ApiImplicitParam(type = "form", required = true, dataType = "String", name = "beginTime", value = "开始时间"),
iGoblinExportService.exportMallOrder(response, beginTime, endTime, state, mailType); @ApiImplicitParam(type = "form", required = true, dataType = "String", name = "storeId", value = "店铺id"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "endTime", value = "结束时间"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "state", value = "状态逗号隔开字符串[0-待付款(用户刚下单)|2-代发货(用户付完款 等待商城发货)|3-代收货(商城已经发货 等待用户确认收货)|4-已完成(用户已经确认收货 订单结束)|5-取消订单(用户未付款前取消订单)|6-退款通过(用户已经付款但是商城还未发货,用户发出退款申请,商城同意退款)|7-退货通过(用户已经确认收货后用户发出退货申请,商城同意所有退货申请 ,一个订单可能有多个单品)|61-6的发起状态|71-7的发起状态】"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "mailType", value = "快递状态[0-全部|1-未发货|2-已发货]"),
})
public void exportMallOrder(HttpServletResponse response, @RequestParam("beginTime") String beginTime, @RequestParam("endTime") String endTime,
@RequestParam("state") String state, @RequestParam("mailType") Integer mailType, @RequestParam("storeId") String storeId) {
iGoblinExportService.exportMallOrder(response, beginTime, endTime, state, mailType, storeId);
} }
} }
...@@ -22,6 +22,7 @@ import java.net.URLEncoder; ...@@ -22,6 +22,7 @@ import java.net.URLEncoder;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.*; import java.util.*;
@Service @Service
@Slf4j @Slf4j
public class GoblinExportServiceImpl implements IGoblinExportService { public class GoblinExportServiceImpl implements IGoblinExportService {
...@@ -30,8 +31,8 @@ public class GoblinExportServiceImpl implements IGoblinExportService { ...@@ -30,8 +31,8 @@ public class GoblinExportServiceImpl implements IGoblinExportService {
GoblinStoreOrderMapper goblinStoreOrderMapper; GoblinStoreOrderMapper goblinStoreOrderMapper;
@Override @Override
public ResponseDto<Boolean> exportMallOrder(HttpServletResponse response, String beginTime, String endTime, String state, Integer mailType) { public ResponseDto<Boolean> exportMallOrder(HttpServletResponse response, String beginTime, String endTime, String state, Integer mailType, String storeId) {
if (!timeIsNotNull(beginTime,endTime)) { if (!timeIsNotNull(beginTime, endTime)) {
return ResponseDto.failure("起始和结束时间不能为空!"); return ResponseDto.failure("起始和结束时间不能为空!");
} }
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
...@@ -42,7 +43,7 @@ public class GoblinExportServiceImpl implements IGoblinExportService { ...@@ -42,7 +43,7 @@ public class GoblinExportServiceImpl implements IGoblinExportService {
if (StringUtils.isNotBlank(state)) { if (StringUtils.isNotBlank(state)) {
states = Arrays.asList(state.split(",")); states = Arrays.asList(state.split(","));
} }
List<MallOrdertDao> voList = goblinStoreOrderMapper.exportMallOrder(beginDate, endDate, states ,mailType); List<MallOrdertDao> voList = goblinStoreOrderMapper.exportMallOrder(beginDate, endDate, states, mailType, storeId);
Map<String, List<String>> map = CollectionUtil.mapStringList(); Map<String, List<String>> map = CollectionUtil.mapStringList();
int max = 0; int max = 0;
//将数据保存到list中 //将数据保存到list中
...@@ -51,6 +52,7 @@ public class GoblinExportServiceImpl implements IGoblinExportService { ...@@ -51,6 +52,7 @@ public class GoblinExportServiceImpl implements IGoblinExportService {
String orderCode = te.getOrderCode(); String orderCode = te.getOrderCode();
if (map.get(orderCode) == null) { if (map.get(orderCode) == null) {
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
list.add(te.getOrderId());
list.add(te.getOrderCode()); list.add(te.getOrderCode());
list.add(te.getUserMobile()); list.add(te.getUserMobile());
list.add(te.getPriceExpress()); list.add(te.getPriceExpress());
...@@ -93,6 +95,7 @@ public class GoblinExportServiceImpl implements IGoblinExportService { ...@@ -93,6 +95,7 @@ public class GoblinExportServiceImpl implements IGoblinExportService {
} }
} }
List<String> cells = new ArrayList<>(); List<String> cells = new ArrayList<>();
cells.add("订单id");
cells.add("订单编号"); cells.add("订单编号");
cells.add("购买人手机号"); cells.add("购买人手机号");
cells.add("快递费"); cells.add("快递费");
...@@ -106,17 +109,17 @@ public class GoblinExportServiceImpl implements IGoblinExportService { ...@@ -106,17 +109,17 @@ public class GoblinExportServiceImpl implements IGoblinExportService {
cells.add("下单时间"); cells.add("下单时间");
cells.add("快递公司"); cells.add("快递公司");
cells.add("物流单号"); cells.add("物流单号");
int j = (max-13)/9; int j = (max - 13) / 9;
for (int i = 1; i <= j; i++) { for (int i = 1; i <= j; i++) {
cells.add("商品id"+i); cells.add("商品id" + i);
cells.add("商品名"+i); cells.add("商品名" + i);
cells.add("一级分类"+i); cells.add("一级分类" + i);
cells.add("二级分类"+i); cells.add("二级分类" + i);
cells.add("款式"+i); cells.add("款式" + i);
cells.add("数量"+i); cells.add("数量" + i);
cells.add("单价"+i); cells.add("单价" + i);
cells.add("价格"+i); cells.add("价格" + i);
cells.add("订单skuId"+i); cells.add("订单skuId" + i);
} }
String[] header = cells.toArray(new String[cells.size()]); String[] header = cells.toArray(new String[cells.size()]);
...@@ -130,7 +133,7 @@ public class GoblinExportServiceImpl implements IGoblinExportService { ...@@ -130,7 +133,7 @@ public class GoblinExportServiceImpl implements IGoblinExportService {
// 这个策略是 头是头的样式 内容是内容的样式 其他的策略可以自己实现 // 这个策略是 头是头的样式 内容是内容的样式 其他的策略可以自己实现
HorizontalCellStyleStrategy horizontalCellStyleStrategy = HorizontalCellStyleStrategy horizontalCellStyleStrategy =
new HorizontalCellStyleStrategy(headWriteCellStyle, new WriteCellStyle()); new HorizontalCellStyleStrategy(headWriteCellStyle, new WriteCellStyle());
EasyExcel.write(getOutputStream(fileName,response)) EasyExcel.write(getOutputStream(fileName, response))
//设置默认样式及写入头信息开始的行数 //设置默认样式及写入头信息开始的行数
// .useDefaultStyle(true).relativeHeadRowIndex(0) // .useDefaultStyle(true).relativeHeadRowIndex(0)
// 表头、内容样式设置 // 表头、内容样式设置
...@@ -167,7 +170,7 @@ public class GoblinExportServiceImpl implements IGoblinExportService { ...@@ -167,7 +170,7 @@ public class GoblinExportServiceImpl implements IGoblinExportService {
return list; return list;
} }
private static WriteCellStyle getHeadStyle(){ private static WriteCellStyle getHeadStyle() {
// 头的策略 // 头的策略
WriteCellStyle headWriteCellStyle = new WriteCellStyle(); WriteCellStyle headWriteCellStyle = new WriteCellStyle();
// 背景颜色 // 背景颜色
...@@ -176,7 +179,7 @@ public class GoblinExportServiceImpl implements IGoblinExportService { ...@@ -176,7 +179,7 @@ public class GoblinExportServiceImpl implements IGoblinExportService {
// 字体 // 字体
WriteFont headWriteFont = new WriteFont(); WriteFont headWriteFont = new WriteFont();
headWriteFont.setFontName("黑体");//设置字体名字 headWriteFont.setFontName("黑体");//设置字体名字
headWriteFont.setFontHeightInPoints((short)15);//设置字体大小 headWriteFont.setFontHeightInPoints((short) 15);//设置字体大小
headWriteFont.setBold(true);//字体加粗 headWriteFont.setBold(true);//字体加粗
headWriteCellStyle.setWriteFont(headWriteFont); //在样式用应用设置的字体; headWriteCellStyle.setWriteFont(headWriteFont); //在样式用应用设置的字体;
// 样式 // 样式
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment