企业卡预约提货、获取周六日、详情添加字段
This commit is contained in:
@@ -48,6 +48,7 @@ public class EmpAppletVo {
|
||||
private String giftCode;
|
||||
private String giftCodeKey;
|
||||
private String qrCode;
|
||||
private List<LpkReserveOrderCardVo> orderCardVoList;
|
||||
|
||||
public String getStart() {
|
||||
SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd");
|
||||
|
||||
@@ -31,5 +31,6 @@ public class EmpCard {
|
||||
private String customerSid;
|
||||
private String customerMobile;
|
||||
private Date bindDate;
|
||||
private String isReservation ;//是否超过预约时间 0 否 1是
|
||||
|
||||
}
|
||||
|
||||
@@ -34,4 +34,19 @@ public interface EmpCardMapper extends BaseMapper<EmpCard> {
|
||||
|
||||
IPage<EmpCardVo> cardStatisticsList(IPage<EmpCardQuery> page, @Param(Constants.WRAPPER) QueryWrapper<EmpCardQuery> qw);
|
||||
List<EmpCardStatisticsExportVo> cardStatisticsListExport(@Param(Constants.WRAPPER) QueryWrapper<EmpCardQuery> qw);
|
||||
@Select(" SELECT\n" +
|
||||
" card.*,\n" +
|
||||
" case card.state\n" +
|
||||
" WHEN 3 then '未提货'\n" +
|
||||
" WHEN 4 then '已经预约提货(预约部分提货)'\n" +
|
||||
" WHEN 5 then '已经提取完成'\n" +
|
||||
" end stateValue,\n" +
|
||||
" bag.dateStart as dateStart\n" +
|
||||
" ,bag.dateEnd as dateEnd\n" +
|
||||
" ,bag.name as pname,card.state as states,card.serialNumber as serialNumber\n" +
|
||||
" FROM\n" +
|
||||
" emp_card card\n" +
|
||||
" LEFT JOIN lpk_giftbag bag on card.giftbagSid=bag.sid" +
|
||||
" where card.sid=#{sid}")
|
||||
AppletVo getCardBySid(String cardSid);
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.yxt.yyth.api.lpkgiftcard.LpkGiftCardListQuery;
|
||||
import com.yxt.yyth.api.lpkgiftcard.LpkGiftCardListVo;
|
||||
import com.yxt.yyth.api.lpkgiftcard.LpkGiftCardQuery;
|
||||
import com.yxt.yyth.api.lpkreserveorder.LpkReserveOrderQuery;
|
||||
import com.yxt.yyth.biz.empcardgift.EmpCardGiftService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -82,4 +83,13 @@ public class EmpCardRest {
|
||||
public void cardStatisticsListExport(@RequestBody EmpCardQuery pq) {
|
||||
empCardService.cardStatisticsListExport(pq);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/isSaturAndSun/{cardSid}")
|
||||
@ApiOperation(value = "获取时间段的周六日")
|
||||
public ResultBean isSaturAndSun(@PathVariable("cardSid") String cardSid) {
|
||||
return empCardService.isSaturAndSun(cardSid);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2,11 +2,13 @@ package com.yxt.yyth.biz.empcard;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.write.metadata.style.WriteCellStyle;
|
||||
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.yxt.common.base.service.MybatisBaseService;
|
||||
import com.yxt.common.base.utils.ExportExcelUtils;
|
||||
import com.yxt.common.base.utils.PagerUtil;
|
||||
@@ -20,15 +22,26 @@ import com.yxt.yyth.api.empcardgift.EmpCardGift;
|
||||
import com.yxt.yyth.api.empcardgift.EmpCardGiftVo;
|
||||
import com.yxt.yyth.api.empcardgiftgoods.EmpCardGiftGoodsVo;
|
||||
import com.yxt.yyth.api.empcardgrantlog.EmpCardGrantLogVo;
|
||||
import com.yxt.yyth.api.empreserveorder.EmpReserveOrder;
|
||||
import com.yxt.yyth.api.lpkgiftbaggoods.LpkGiftBagGoodsVo;
|
||||
import com.yxt.yyth.api.lpkgiftcard.*;
|
||||
import com.yxt.yyth.api.lpkgoods.LpkGoods;
|
||||
import com.yxt.yyth.api.lpkreserveorder.LpkReserveOrderCardVo;
|
||||
import com.yxt.yyth.api.lpkreserveorder.LpkReserveOrderQuery;
|
||||
import com.yxt.yyth.api.lpkreserveorder.LpkReserveOrderVo;
|
||||
import com.yxt.yyth.api.lpkreserveordergoods.LpkReserveOrderGoods;
|
||||
import com.yxt.yyth.api.lpkstore.LpkStoreDetailsVo;
|
||||
import com.yxt.yyth.biz.empcardbuildrecord.EmpCardBuildRecordService;
|
||||
import com.yxt.yyth.biz.empcardgift.EmpCardGiftService;
|
||||
import com.yxt.yyth.biz.empcardgiftgoods.EmpCardGiftGoodsService;
|
||||
import com.yxt.yyth.biz.empcardgrantlog.EmpCardGrantLogService;
|
||||
import com.yxt.yyth.biz.lpkgiftbaggoods.LpkGiftBagGoodsService;
|
||||
import com.yxt.yyth.biz.lpkgiftcard.LpkGiftCardMapper;
|
||||
import com.yxt.yyth.biz.lpkgiftcard.generateRule.UniqueIdGenerator;
|
||||
import com.yxt.yyth.biz.lpkgoods.LpkGoodsService;
|
||||
import com.yxt.yyth.biz.lpkreserveorder.LpkReserveOrderService;
|
||||
import com.yxt.yyth.biz.lpkreserveordergoods.LpkReserveOrderGoodsService;
|
||||
import com.yxt.yyth.biz.lpkstore.LpkStoreService;
|
||||
import com.yxt.yyth.utils.StyleUtils;
|
||||
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -41,6 +54,9 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.DayOfWeek;
|
||||
import java.time.LocalDate;
|
||||
import java.time.Period;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -64,6 +80,16 @@ public class EmpCardService extends MybatisBaseService<EmpCardMapper, EmpCard> {
|
||||
@Autowired
|
||||
EmpCardGiftGoodsService empCardGiftGoodsService;
|
||||
@Autowired
|
||||
private LpkGiftCardMapper lpkGiftCardMapper;
|
||||
@Autowired
|
||||
private LpkReserveOrderService lpkReserveOrderService;
|
||||
@Autowired
|
||||
private LpkGoodsService lpkGoodsService;
|
||||
@Autowired
|
||||
private LpkStoreService lpkStoreService;
|
||||
@Autowired
|
||||
private LpkReserveOrderGoodsService lpkReserveOrderGoodsService;
|
||||
@Autowired
|
||||
private HttpServletResponse response;
|
||||
@Value("${image.url.prefix:http://127.0.0.1:8080/upload/}")
|
||||
private String urlPrefix;
|
||||
@@ -285,6 +311,7 @@ public class EmpCardService extends MybatisBaseService<EmpCardMapper, EmpCard> {
|
||||
|
||||
list.forEach(s -> {
|
||||
EmpCardGiftVo goods = empCardGiftService.getEmpCardGoods(vo.getSid(), s.getGoodsSid()).getData();
|
||||
LpkReserveOrderGoods goods1 = lpkReserveOrderGoodsService.getReserveByCardSid(vo.getSid(), s.getGoodsSid()).getData();
|
||||
GoodsVo goodsVo = new GoodsVo();
|
||||
goodsVo.setGoods(s.getGoodsName());
|
||||
goodsVo.setNum(s.getGoodsNumber());
|
||||
@@ -301,7 +328,7 @@ public class EmpCardService extends MybatisBaseService<EmpCardMapper, EmpCard> {
|
||||
} else {
|
||||
if (null != goods) {
|
||||
if (goods.getGoodsNumber() != s.getGoodsNumber()) {
|
||||
goodsVo.setLNum(s.getGoodsNumber() - goods.getGoodsNumber());
|
||||
goodsVo.setLNum(s.getGoodsNumber() - goods.getGoodsNumber()- goods1.getGoodsNumber());
|
||||
// goodsVo.setSelect(s.getGoodsNumber() - goods.getGoodsNumber());
|
||||
goodsVo.setSelect(0);
|
||||
}
|
||||
@@ -342,13 +369,35 @@ public class EmpCardService extends MybatisBaseService<EmpCardMapper, EmpCard> {
|
||||
vo.setGiftCodeKey(String.valueOf(randomNumber));
|
||||
vo.setGiftCode("99"+uuid.substring(2));
|
||||
vo.setQrCode(qrUrl+vo.getGiftCode());
|
||||
List<LpkReserveOrderCardVo> empReserveOrderCardVos = lpkReserveOrderService.selOrderByCardSid(sid).getData();
|
||||
for (LpkReserveOrderCardVo vo2 : empReserveOrderCardVos) {
|
||||
List<LpkReserveOrderGoods> goods = lpkReserveOrderGoodsService.selByOrderSids(vo2.getSid());
|
||||
for (LpkReserveOrderGoods goods1 : goods) {
|
||||
LpkGoods lpkGoods = lpkGoodsService.getOne(new QueryWrapper<LpkGoods>().eq("sid", goods1.getGoodsSid()));
|
||||
if (StringUtils.isBlank(vo2.getGoods())) {
|
||||
vo2.setGoods(lpkGoods.getName() + ":" + goods1.getNum() + lpkGoods.getUnitName());
|
||||
} else {
|
||||
vo2.setGoods(vo2.getGoods() + " " + lpkGoods.getName() + ":" + goods1.getNum() + lpkGoods.getUnitName());
|
||||
}
|
||||
}
|
||||
}
|
||||
//上次取货点
|
||||
LpkReserveOrderVo vo1 = lpkReserveOrderService.getStoreByCustomerSid(vo.getCustomerSid()).getData();
|
||||
if (null != vo1) {
|
||||
LpkStoreDetailsVo vo2 = lpkStoreService.storeInit(vo1.getStoreSid()).getData();
|
||||
if (null != vo2) {
|
||||
vo.setAddressName(vo2.getName());
|
||||
vo.setValue(vo2.getSid());
|
||||
}
|
||||
}
|
||||
vo.setOrderCardVoList(empReserveOrderCardVos);
|
||||
return rb.success().setData(vo);
|
||||
}
|
||||
public ResultBean changState(String cardSid, String state) {
|
||||
ResultBean rb = new ResultBean().fail();
|
||||
EmpCard card = baseMapper.selectOne(new QueryWrapper<EmpCard>().eq("sid", cardSid));
|
||||
card.setState(state);
|
||||
// card.setIsReservation("0");
|
||||
card.setIsReservation("0");
|
||||
baseMapper.updateById(card);
|
||||
return rb.success().setData("成功");
|
||||
}
|
||||
@@ -424,4 +473,41 @@ public class EmpCardService extends MybatisBaseService<EmpCardMapper, EmpCard> {
|
||||
return rb.success().setData(pagging);
|
||||
}
|
||||
|
||||
public ResultBean isSaturAndSun(String cardSid) {
|
||||
ResultBean rb = new ResultBean().fail();
|
||||
AppletVo appletVo = baseMapper.getCardBySid(cardSid);
|
||||
Date date =new Date();
|
||||
SimpleDateFormat sdf1 =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String nowDate =sdf1.format(date);
|
||||
LocalDate now = DateUtil.parse(nowDate).toSqlDate().toLocalDate();
|
||||
LocalDate endD = DateUtil.parse(appletVo.getDateEnd()).toSqlDate().toLocalDate();
|
||||
List<String> weekMap = new ArrayList<>();
|
||||
// 第一个星期六
|
||||
LocalDate saturday = now.with(DayOfWeek.SATURDAY);
|
||||
do {
|
||||
if (CollectionUtils.isEmpty(weekMap)) {
|
||||
weekMap.add(saturday.toString());
|
||||
} else {
|
||||
weekMap.add(saturday.toString());
|
||||
}
|
||||
// 迭代一个星期
|
||||
saturday = saturday.plus(Period.ofDays(7));
|
||||
} while (saturday.compareTo(endD) < 1);
|
||||
// 第一个星期天
|
||||
LocalDate sunday = now.with(DayOfWeek.SUNDAY);
|
||||
do {
|
||||
if (CollectionUtils.isEmpty(weekMap)) {
|
||||
weekMap.add(saturday.toString());
|
||||
} else {
|
||||
weekMap.add(sunday.toString());
|
||||
}
|
||||
// 迭代一个星期
|
||||
sunday = sunday.plus(Period.ofDays(7));
|
||||
} while (sunday.compareTo(endD) < 1);
|
||||
String nextYear = DateUtil.offsetMonth(new Date(), 12).toString();
|
||||
int y = DateUtil.year(DateUtil.parse(nextYear));
|
||||
weekMap.add(String.valueOf(y) + "-01-01");
|
||||
Object[] array = weekMap.stream().sorted().toArray();
|
||||
return rb.success().setData(array);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,11 @@ public class EmpReserveOrderRest {
|
||||
return empReserveOrderService.submission(dto);
|
||||
}
|
||||
|
||||
@ApiOperation("企业卡预约提交")
|
||||
@PostMapping("/submissionEmp")
|
||||
public ResultBean submissionEmp(@RequestBody LpkReserveOrderDto dto) {
|
||||
return empReserveOrderService.submissionEmp(dto);
|
||||
}
|
||||
@ApiOperation("订单列表")
|
||||
@PostMapping("/orderList")
|
||||
public ResultBean<PagerVo<EmpReserveOrderVo>> orderList(@RequestBody PagerQuery<EmpReserveOrderQuery> pq) {
|
||||
|
||||
@@ -33,6 +33,7 @@ import com.yxt.yyth.biz.lpkstore.LpkStoreService;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.text.ParseException;
|
||||
@@ -66,6 +67,7 @@ public class EmpReserveOrderService extends MybatisBaseService<EmpReserveOrderMa
|
||||
@Autowired
|
||||
LpkReserveOrderGoodsService lpkReserveOrderGoodsService;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResultBean submission(LpkReserveOrderDto dto) {
|
||||
ResultBean rb = new ResultBean().fail();
|
||||
boolean b=isSatAndSun(dto.getReserveDate());
|
||||
@@ -83,6 +85,24 @@ public class EmpReserveOrderService extends MybatisBaseService<EmpReserveOrderMa
|
||||
empReserveOrderGoodsService.submissionDetail(dto);
|
||||
return rb.success().setData("预约成功");
|
||||
}
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResultBean submissionEmp(LpkReserveOrderDto dto) {
|
||||
ResultBean rb = new ResultBean().fail();
|
||||
boolean b=isSatAndSun(dto.getReserveDate());
|
||||
if(!b){
|
||||
return rb.setMsg("周六、周日不能预约提货");
|
||||
}
|
||||
LpkReserveOrder order = new LpkReserveOrder();
|
||||
BeanUtil.copyProperties(dto, order, "id", "sid");
|
||||
order.setStoreSid(dto.getValue());
|
||||
order.setCardSid(dto.getSid());
|
||||
order.setCreateTime(new DateTime());
|
||||
order.setCardType("3");
|
||||
lpkReserveOrderMapper.insert(order);
|
||||
dto.setOrderSid(order.getSid());
|
||||
empReserveOrderGoodsService.submissionDetailEmp(dto);
|
||||
return rb.success().setData("预约成功");
|
||||
}
|
||||
// public ResultBean submission(EmpReserveOrderDto dto) {
|
||||
// ResultBean rb = new ResultBean().fail();
|
||||
// boolean b=isSatAndSun(dto.getReserveDate());
|
||||
|
||||
@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import com.yxt.common.base.service.MybatisBaseService;
|
||||
import com.yxt.common.core.result.ResultBean;
|
||||
import com.yxt.yyth.api.empcard.EmpAppletVo;
|
||||
import com.yxt.yyth.api.empcardgift.EmpGiftAppletVo;
|
||||
import com.yxt.yyth.api.empreserveorder.EmpReserveOrderDto;
|
||||
import com.yxt.yyth.api.empreserveordergoods.EmpReserveOrderGoods;
|
||||
@@ -11,6 +12,7 @@ import com.yxt.yyth.api.lpkgiftcard.AppletVo;
|
||||
import com.yxt.yyth.api.empcardgift.GoodsVo;
|
||||
import com.yxt.yyth.api.lpkreserveorder.LpkReserveOrderDto;
|
||||
import com.yxt.yyth.api.lpkreserveordergoods.LpkReserveOrderGoods;
|
||||
import com.yxt.yyth.biz.empcard.EmpCardService;
|
||||
import com.yxt.yyth.biz.empcardgift.EmpCardGiftService;
|
||||
import com.yxt.yyth.biz.lpkgiftcard.LpkGiftCardService;
|
||||
import com.yxt.yyth.biz.lpkreserveordergoods.LpkReserveOrderGoodsMapper;
|
||||
@@ -30,6 +32,8 @@ public class EmpReserveOrderGoodsService extends MybatisBaseService<EmpReserveOr
|
||||
EmpCardGiftService empCardGiftService;
|
||||
@Autowired
|
||||
LpkReserveOrderGoodsMapper lpkReserveOrderGoodsMapper;
|
||||
@Autowired
|
||||
private EmpCardService empCardService;
|
||||
public ResultBean<EmpReserveOrderGoods> getReserveByCardSid(String carSid, String goodsSid) {
|
||||
ResultBean rb = new ResultBean();
|
||||
EmpReserveOrderGoods goods = baseMapper.getReserveByCardSid(carSid, goodsSid);
|
||||
@@ -66,6 +70,38 @@ public class EmpReserveOrderGoodsService extends MybatisBaseService<EmpReserveOr
|
||||
}
|
||||
return rb.success().setData("预约成功");
|
||||
}
|
||||
|
||||
public ResultBean submissionDetailEmp(LpkReserveOrderDto dto) {
|
||||
ResultBean rb = new ResultBean();
|
||||
LpkReserveOrderGoods goods = new LpkReserveOrderGoods();
|
||||
BeanUtil.copyProperties(dto, goods, "id", "sid");
|
||||
goods.setCardSid(dto.getSid());
|
||||
for (com.yxt.yyth.api.lpkgiftcard.GoodsVo goods1 : dto.getGoodsVos()) {
|
||||
if (goods1.getSelect() != 0) {
|
||||
goods.setCardSid(dto.getSid());
|
||||
goods.setGoodsSid(goods1.getGoodsSid());
|
||||
goods.setGoodsNumber(goods1.getSelect());
|
||||
goods.setCreateTime(new DateTime());
|
||||
lpkReserveOrderGoodsMapper.insert(goods);
|
||||
}
|
||||
}
|
||||
EmpAppletVo vo =empCardService.getEmpCardBySid(dto.getSid()).getData();
|
||||
int i = 0;
|
||||
for (com.yxt.yyth.api.lpkgiftcard.GoodsVo vo1 : vo.getGoodsVos()) {
|
||||
LpkReserveOrderGoods goods1 = lpkReserveOrderGoodsMapper.getReserveByCardSid(dto.getSid(), vo1.getGoodsSid());
|
||||
if (null != goods1) {
|
||||
if (vo1.getNum() <= goods1.getGoodsNumber()) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (vo.getGoodsVos().size() == i) {
|
||||
empCardService.changState(dto.getSid(), "5");
|
||||
} else {
|
||||
empCardService.changState(dto.getSid(), "4");
|
||||
}
|
||||
}
|
||||
return rb.success().setData("预约成功");
|
||||
}
|
||||
//
|
||||
// public ResultBean submissionDetail(EmpReserveOrderDto dto) {
|
||||
// ResultBean rb = new ResultBean();
|
||||
|
||||
@@ -217,6 +217,24 @@
|
||||
<where>
|
||||
o.customerSid=#{userSid} and o.cardType='2'
|
||||
</where>
|
||||
union
|
||||
SELECT date_format(o.reserveDate, '%Y-%m-%d') as reserveDate,
|
||||
c.`code`,
|
||||
o.cardType as type,
|
||||
s.`name` as store,
|
||||
b.`name` as bagName,
|
||||
o.cardSid as cardSid,
|
||||
o.sid as orderSid,
|
||||
o.userName,
|
||||
o.userPhone,c.serialNumber as serialNumber,
|
||||
o.sid
|
||||
FROM lpk_reserve_order AS o
|
||||
LEFT JOIN lpk_store AS s ON o.storeSid = s.sid
|
||||
LEFT JOIN emp_card AS c ON o.cardSid = c.sid
|
||||
LEFT JOIN lpk_giftbag AS b ON c.giftbagSid = b.sid
|
||||
<where>
|
||||
o.customerSid=#{userSid} and o.cardType='3'
|
||||
</where>
|
||||
ORDER BY reserveDate DESC
|
||||
</select>
|
||||
<select id="exportExcel" resultType="com.yxt.yyth.api.lpkreserveorder.ReserveOrderExport">
|
||||
|
||||
@@ -29,9 +29,11 @@ public class SaTokenConfigure implements WebMvcConfigurer {
|
||||
.excludePathPatterns("/empcard/getEmpCardBySid/**")
|
||||
.excludePathPatterns("/lpkgiftcard/isSaturAndSun/**")
|
||||
.excludePathPatterns("/empcardgift/isSaturAndSun/**")
|
||||
.excludePathPatterns("/empcard/isSaturAndSun/**")
|
||||
.excludePathPatterns("/lpkgiftcard/getReservationBySid/**")
|
||||
.excludePathPatterns("/lpksreservoorder/submission")
|
||||
.excludePathPatterns("/empsreservoorder/submission")
|
||||
.excludePathPatterns("/empsreservoorder/submissionEmp")
|
||||
.excludePathPatterns("/empcardgift/generateCard")
|
||||
.excludePathPatterns("/lpkgiftcard/bindCard")
|
||||
.excludePathPatterns("/empcard/bindCard")
|
||||
|
||||
Reference in New Issue
Block a user