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