预约订单列表加导出功能
This commit is contained in:
@@ -16,4 +16,5 @@ public class LpkReserveOrderCardVo implements Vo {
|
||||
private String bagName; //礼包
|
||||
private String cardSid; // 提货卡sid
|
||||
private String orderSid; //预约订单sid
|
||||
|
||||
}
|
||||
|
||||
@@ -9,9 +9,9 @@ import lombok.Data;
|
||||
*/
|
||||
@Data
|
||||
public class LpkReserveOrderQuery implements Query {
|
||||
private String userName;
|
||||
private String store;
|
||||
private String startDate;
|
||||
private String endDate;
|
||||
private String userName; //用户名
|
||||
private String store; // 门店
|
||||
private String startDate; //预约开始日期
|
||||
// private String endDate; // 预约结束日期
|
||||
private String userSid;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@ package com.yxt.yyth.api.lpkreserveorder;
|
||||
import com.yxt.common.core.vo.Vo;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Fan
|
||||
* @description
|
||||
@@ -10,9 +13,12 @@ import lombok.Data;
|
||||
*/
|
||||
@Data
|
||||
public class LpkReserveOrderVo implements Vo {
|
||||
private String sid;
|
||||
private String userName;
|
||||
private String userPhone;
|
||||
private String store;
|
||||
private String reserveDate;
|
||||
private String sid; //预约订单sid
|
||||
private String userName; //用户名
|
||||
private String userPhone; //用户电话
|
||||
private String store; //门店
|
||||
private String reserveDate; //预约时间
|
||||
private String bagName; //礼包
|
||||
private String code; //卡号
|
||||
private List<OrderGoodsVo> goodsVo = new ArrayList<>();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.yxt.yyth.api.lpkreserveorder;
|
||||
|
||||
import com.yxt.common.core.vo.Vo;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author Fan
|
||||
* @description
|
||||
* @date 2023/11/28 10:11
|
||||
*/
|
||||
@Data
|
||||
public class OrderGoodsVo implements Vo {
|
||||
private int num;
|
||||
private String goodName;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.yxt.yyth.api.lpkreserveorder;
|
||||
|
||||
import com.yxt.common.core.utils.ExportEntityMap;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author Fan
|
||||
* @description
|
||||
* @date 2023/11/28 10:26
|
||||
*/
|
||||
@Data
|
||||
public class ReserveOrderExport {
|
||||
@ExportEntityMap(CnName = "预约时间", EnName = "reserveDate")
|
||||
private String reserveDate;
|
||||
@ExportEntityMap(CnName = "提货门店", EnName = "store")
|
||||
private String store;
|
||||
@ExportEntityMap(CnName = "姓名", EnName = "userName")
|
||||
private String userName;
|
||||
@ExportEntityMap(CnName = "联系方式", EnName = "userPhone")
|
||||
private String userPhone;
|
||||
@ExportEntityMap(CnName = "提货卡号", EnName = "code")
|
||||
private String code;
|
||||
@ExportEntityMap(CnName = "礼包名称", EnName = "bagName")
|
||||
private String bagName;
|
||||
@ExportEntityMap(CnName = "商品明细", EnName = "goodsInfo")
|
||||
private String goodsInfo;
|
||||
private String sid;
|
||||
}
|
||||
@@ -78,7 +78,7 @@ public class LpkGiftCardRest {
|
||||
@PostMapping("/exportExcel")
|
||||
public ResultBean exportExcel(@RequestBody LpkGiftCardListQuery query) {
|
||||
return lpkGiftCardService.exportExcel(query);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -4,9 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.yxt.yyth.api.lpkreserveorder.LpkReserveOrder;
|
||||
import com.yxt.yyth.api.lpkreserveorder.LpkReserveOrderCardVo;
|
||||
import com.yxt.yyth.api.lpkreserveorder.LpkReserveOrderVo;
|
||||
import com.yxt.yyth.api.lpkreserveorder.*;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@@ -23,4 +21,6 @@ public interface LpkReserveOrderMapper extends BaseMapper<LpkReserveOrder> {
|
||||
List<LpkReserveOrderCardVo> orderByCardSid(String sid);
|
||||
|
||||
IPage<LpkReserveOrderCardVo> orderListByUserSid(IPage<LpkReserveOrder> page, @Param(Constants.WRAPPER) QueryWrapper<LpkReserveOrder> qw);
|
||||
|
||||
List<ReserveOrderExport> exportExcel(@Param(Constants.WRAPPER) QueryWrapper<LpkReserveOrderQuery> qw);
|
||||
}
|
||||
|
||||
@@ -24,9 +24,13 @@
|
||||
date_format(o.reserveDate, '%Y-%m-%d') as reserveDate,
|
||||
o.userName,
|
||||
o.userPhone,
|
||||
s.name as store
|
||||
s.`name` as store,
|
||||
b.`name` as bagName,
|
||||
c.`code`
|
||||
from lpk_reserve_order as o
|
||||
left join lpk_store as s on o.storeSid = s.sid
|
||||
LEFT JOIN lpk_giftcard AS c ON o.cardSid = c.sid
|
||||
LEFT JOIN lpk_giftbag AS b ON c.giftbagSid = b.sid
|
||||
<where>
|
||||
${ew.sqlSegment}
|
||||
</where>
|
||||
@@ -58,4 +62,21 @@
|
||||
${ew.sqlSegment}
|
||||
</where>
|
||||
</select>
|
||||
<select id="exportExcel" resultType="com.yxt.yyth.api.lpkreserveorder.ReserveOrderExport">
|
||||
select
|
||||
o.sid,
|
||||
date_format(o.reserveDate, '%Y-%m-%d') as reserveDate,
|
||||
o.userName,
|
||||
o.userPhone,
|
||||
s.`name` as store,
|
||||
b.`name` as bagName,
|
||||
c.`code`
|
||||
from lpk_reserve_order as o
|
||||
left join lpk_store as s on o.storeSid = s.sid
|
||||
LEFT JOIN lpk_giftcard AS c ON o.cardSid = c.sid
|
||||
LEFT JOIN lpk_giftbag AS b ON c.giftbagSid = b.sid
|
||||
<where>
|
||||
${ew.sqlSegment}
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -5,6 +5,7 @@ import com.yxt.common.core.result.ResultBean;
|
||||
import com.yxt.common.core.vo.PagerVo;
|
||||
import com.yxt.yyth.api.lpkcustomer.LpkCustomerQuery;
|
||||
import com.yxt.yyth.api.lpkcustomer.LpkCustomerVo;
|
||||
import com.yxt.yyth.api.lpkgiftcard.LpkGiftCardListQuery;
|
||||
import com.yxt.yyth.api.lpkreserveorder.LpkReserveOrderCardVo;
|
||||
import com.yxt.yyth.api.lpkreserveorder.LpkReserveOrderDto;
|
||||
import com.yxt.yyth.api.lpkreserveorder.LpkReserveOrderQuery;
|
||||
@@ -57,4 +58,10 @@ public class LpkReserveOrderRest {
|
||||
public ResultBean orderDetails(@PathVariable("orderSid") String orderSid) {
|
||||
return lpkReserveOrderService.orderDetails(orderSid);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "预约订单信息列表导出")
|
||||
@PostMapping("/exportExcel")
|
||||
public ResultBean exportExcel(@RequestBody LpkReserveOrderQuery query) {
|
||||
return lpkReserveOrderService.exportExcel(query);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -6,37 +6,35 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.yxt.common.base.config.component.FileUploadComponent;
|
||||
import com.yxt.common.base.service.MybatisBaseService;
|
||||
import com.yxt.common.base.utils.ExportExcelUtils;
|
||||
import com.yxt.common.base.utils.PagerUtil;
|
||||
import com.yxt.common.base.utils.StringUtils;
|
||||
import com.yxt.common.core.query.PagerQuery;
|
||||
import com.yxt.common.core.result.ResultBean;
|
||||
import com.yxt.common.core.vo.PagerVo;
|
||||
import com.yxt.yyth.api.lpkcustomer.LpkCustomer;
|
||||
import com.yxt.yyth.api.lpkcustomer.LpkCustomerQuery;
|
||||
import com.yxt.yyth.api.lpkcustomer.LpkCustomerVo;
|
||||
import com.yxt.yyth.api.lpkgiftbaggoods.LpkGiftBagGoodsVo;
|
||||
import com.yxt.yyth.api.lpkgiftcard.AppletVo;
|
||||
import com.yxt.yyth.api.lpkgiftcard.GoodsVo;
|
||||
import com.yxt.yyth.api.lpkgiftcard.LpkGiftCard;
|
||||
import com.yxt.yyth.api.lpkgiftcard.LpkGiftCardExport;
|
||||
import com.yxt.yyth.api.lpkgoods.LpkGoods;
|
||||
import com.yxt.yyth.api.lpkreserveorder.*;
|
||||
import com.yxt.yyth.api.lpkreserveordergoods.LpkReserveOrderGoods;
|
||||
import com.yxt.yyth.api.lpkreserveordergoods.LpkReserveOrderGoodsDto;
|
||||
import com.yxt.yyth.api.lpkstore.LpkStore;
|
||||
import com.yxt.yyth.api.lpkstore.StoreSelect;
|
||||
import com.yxt.yyth.biz.lpkgiftbaggoods.LpkGiftBagGoodsService;
|
||||
import com.yxt.yyth.biz.lpkgiftcard.LpkGiftCardMapper;
|
||||
import com.yxt.yyth.biz.lpkgiftcard.LpkGiftCardService;
|
||||
import com.yxt.yyth.biz.lpkgoods.LpkGoodsService;
|
||||
import com.yxt.yyth.biz.lpkreserveordergoods.LpkReserveOrderGoodsService;
|
||||
import com.yxt.yyth.biz.lpkstore.LpkStoreService;
|
||||
import org.apache.commons.collections.list.AbstractLinkedList;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -56,6 +54,10 @@ public class LpkReserveOrderService extends MybatisBaseService<LpkReserveOrderMa
|
||||
LpkStoreService lpkStoreService;
|
||||
@Autowired
|
||||
private FileUploadComponent fileUploadComponent;
|
||||
@Autowired
|
||||
private LpkGoodsService lpkGoodsService;
|
||||
@Autowired
|
||||
private HttpServletResponse response;
|
||||
|
||||
public ResultBean submission(LpkReserveOrderDto dto) {
|
||||
ResultBean rb = new ResultBean();
|
||||
@@ -82,13 +84,36 @@ public class LpkReserveOrderService extends MybatisBaseService<LpkReserveOrderMa
|
||||
qw.like("o.userName", query.getUserName());
|
||||
}
|
||||
String startDate = query.getStartDate();
|
||||
String endDate = query.getEndDate();
|
||||
// String endDate = query.getEndDate();
|
||||
qw.apply(org.apache.commons.lang3.StringUtils.isNotEmpty(startDate), "date_format (o.reserveDate,'%Y-%m-%d') >= date_format('" + startDate + "','%Y-%m-%d')").
|
||||
apply(org.apache.commons.lang3.StringUtils.isNotEmpty(endDate), "date_format (o.reserveDate,'%Y-%m-%d') <= date_format('" + endDate + "','%Y-%m-%d')"
|
||||
apply(org.apache.commons.lang3.StringUtils.isNotEmpty(startDate), "date_format (o.reserveDate,'%Y-%m-%d') <= date_format('" + startDate + "','%Y-%m-%d')"
|
||||
);
|
||||
qw.orderByDesc("o.createTime");
|
||||
IPage<LpkReserveOrder> page = PagerUtil.queryToPage(pq);
|
||||
IPage<LpkReserveOrderVo> pagging = baseMapper.orderList(page, qw);
|
||||
List<LpkReserveOrderVo> records = pagging.getRecords();
|
||||
if (!records.isEmpty()) {
|
||||
records.forEach(s -> {
|
||||
List<LpkReserveOrderGoods> orderGoods = lpkReserveOrderGoodsService.selByOrderSid(s.getSid());
|
||||
List<OrderGoodsVo> goodsVoList = new ArrayList<>();
|
||||
if (!orderGoods.isEmpty()) {
|
||||
for (LpkReserveOrderGoods orderGood : orderGoods) {
|
||||
OrderGoodsVo goodsVo = new OrderGoodsVo();
|
||||
if (StringUtils.isNotBlank(orderGood.getGoodsSid())) {
|
||||
LpkGoods lpkGoods = lpkGoodsService.fetchBySid(orderGood.getGoodsSid());
|
||||
if (null != lpkGoods) {
|
||||
goodsVo.setGoodName(lpkGoods.getName());
|
||||
}
|
||||
}
|
||||
if (orderGood.getGoodsNumber() != 0) {
|
||||
goodsVo.setNum((int) orderGood.getGoodsNumber());
|
||||
}
|
||||
goodsVoList.add(goodsVo);
|
||||
}
|
||||
}
|
||||
s.setGoodsVo(goodsVoList);
|
||||
});
|
||||
}
|
||||
PagerVo<LpkReserveOrderVo> p = PagerUtil.pageToVo(pagging, null);
|
||||
return rb.success().setData(p);
|
||||
}
|
||||
@@ -165,4 +190,72 @@ public class LpkReserveOrderService extends MybatisBaseService<LpkReserveOrderMa
|
||||
}
|
||||
return rb.success();
|
||||
}
|
||||
|
||||
public ResultBean exportExcel(LpkReserveOrderQuery query) {
|
||||
ResultBean rb = ResultBean.fireFail();
|
||||
QueryWrapper<LpkReserveOrderQuery> qw = new QueryWrapper<>();
|
||||
qw.eq("1", "1");
|
||||
if (StringUtils.isNotBlank(query.getStore())) {
|
||||
qw.like("s.name", query.getStore());
|
||||
}
|
||||
if (StringUtils.isNotBlank(query.getUserName())) {
|
||||
qw.like("o.userName", query.getUserName());
|
||||
}
|
||||
String startDate = query.getStartDate();
|
||||
// String endDate = query.getEndDate();
|
||||
qw.apply(org.apache.commons.lang3.StringUtils.isNotEmpty(startDate), "date_format (o.reserveDate,'%Y-%m-%d') >= date_format('" + startDate + "','%Y-%m-%d')").
|
||||
apply(org.apache.commons.lang3.StringUtils.isNotEmpty(startDate), "date_format (o.reserveDate,'%Y-%m-%d') <= date_format('" + startDate + "','%Y-%m-%d')"
|
||||
);
|
||||
qw.orderByDesc("o.createTime");
|
||||
//得到所有要导出的数据
|
||||
List<ReserveOrderExport> exportList = baseMapper.exportExcel(qw);
|
||||
if (!exportList.isEmpty()) {
|
||||
exportList.forEach(s -> {
|
||||
if (StringUtils.isNotBlank(s.getUserPhone())) {
|
||||
String phone = s.getUserPhone().substring(0, 3) + "****" + s.getUserPhone().substring(7);
|
||||
s.setUserPhone(phone);
|
||||
}
|
||||
List<LpkReserveOrderGoods> orderGoods = lpkReserveOrderGoodsService.selByOrderSid(s.getSid());
|
||||
if (!orderGoods.isEmpty()) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (LpkReserveOrderGoods orderGood : orderGoods) {
|
||||
String num = "";
|
||||
String goodsName = "";
|
||||
String finWord = "";
|
||||
String unitName = "";
|
||||
if (StringUtils.isNotBlank(orderGood.getGoodsSid())) {
|
||||
LpkGoods lpkGoods = lpkGoodsService.fetchBySid(orderGood.getGoodsSid());
|
||||
if (null != lpkGoods) {
|
||||
goodsName = lpkGoods.getName();
|
||||
if (StringUtils.isNotBlank(lpkGoods.getUnitName())) {
|
||||
unitName = lpkGoods.getUnitName();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (orderGood.getGoodsNumber() != 0) {
|
||||
num = String.valueOf((int) orderGood.getGoodsNumber());
|
||||
}
|
||||
finWord = num + unitName + goodsName;
|
||||
sb.append(finWord).append("、");
|
||||
}
|
||||
if (sb.length() > 0) {
|
||||
sb.delete(sb.length() - 1, sb.length());
|
||||
s.setGoodsInfo(sb.toString());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
//定义导出的excel名字
|
||||
String excelName = "1";
|
||||
String fileNameURL = "1";
|
||||
// try {
|
||||
// fileNameURL = URLEncoder.encode(excelName, "UTF-8");
|
||||
// fileNameURL = URLEncoder.encode(excelName, "UTF-8");
|
||||
// } catch (UnsupportedEncodingException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//导出预约订单信息列表
|
||||
ExportExcelUtils.export(fileNameURL, exportList, ReserveOrderExport.class, response);
|
||||
return rb.success();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wangpengfei
|
||||
* @date 2023/11/23 10:36
|
||||
@@ -13,7 +15,10 @@ import org.apache.ibatis.annotations.Select;
|
||||
@Mapper
|
||||
public interface LpkReserveOrderGoodsMapper extends BaseMapper<LpkReserveOrderGoods> {
|
||||
@Select("select sum(goodsNumber) as goodsNumber , goodsSid as goodsSid from lpk_reserve_order_goods where cardSid=#{cardSid} and goodsSid=#{goodsSid}")
|
||||
LpkReserveOrderGoods getReserveByCardSid (@Param("cardSid")String cardSid,@Param("goodsSid") String goodsSid);
|
||||
LpkReserveOrderGoods getReserveByCardSid(@Param("cardSid") String cardSid, @Param("goodsSid") String goodsSid);
|
||||
|
||||
LpkReserveOrderGoods selByOrderSidAndGoodSid(@Param("orderSid")String orderSid,@Param("goodsSid") String goodsSid);
|
||||
LpkReserveOrderGoods selByOrderSidAndGoodSid(@Param("orderSid") String orderSid, @Param("goodsSid") String goodsSid);
|
||||
|
||||
@Select("select * from lpk_reserve_order_goods where orderSid=#{orderSid}")
|
||||
List<LpkReserveOrderGoods> selByOrderSid(String orderSid);
|
||||
}
|
||||
|
||||
@@ -68,4 +68,7 @@ public class LpkReserveOrderGoodsService extends MybatisBaseService<LpkReserveOr
|
||||
public LpkReserveOrderGoods selByOrderSidAndGoodSid(String orderSid, String goodsSid) {
|
||||
return baseMapper.selByOrderSidAndGoodSid(orderSid,goodsSid);
|
||||
}
|
||||
public List<LpkReserveOrderGoods> selByOrderSid(String orderSid) {
|
||||
return baseMapper.selByOrderSid(orderSid);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user