|
|
@ -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(); |
|
|
|
} |
|
|
|
} |
|
|
|