diff --git a/docs/databases/将卡中数据导入到账户中20240123.sql b/docs/databases/将卡中数据导入到账户中20240123.sql new file mode 100644 index 0000000..7b1d48f --- /dev/null +++ b/docs/databases/将卡中数据导入到账户中20240123.sql @@ -0,0 +1,158 @@ + + + + +-- 个人卡 +CREATE TABLE tmp_cust_goods( + SELECT + r.wxMpOpenid, + d.customerSid, + d.bindDate, + d.giftbagSid, + d.serialNumber, + d.code, + s.goodsSid, + s.goodsNumber, + e.NAME AS goodsName, + '个人卡' cardtype + FROM lpk_giftcard d + LEFT JOIN lpk_customer r ON r.sid = d.customerSid + LEFT JOIN lpk_giftbag_goods s ON s.giftbagSid=d.giftbagSid + LEFT JOIN lpk_goods e ON e.sid = s.goodsSid + WHERE d.customerSid IS NOT NULL AND d.customerSid <> '' + ORDER BY r.wxMpOpenid +); + +select count(1) from tmp_cust_goods; -- 5080 + +-- 企业卡 +INSERT INTO tmp_cust_goods + SELECT + r.wxMpOpenid, + d.customerSid, + d.bindDate, + d.giftbagSid, + d.serialNumber, + d.code, + s.goodsSid, + s.goodsNumber, + e.NAME AS goodsName, + '企业卡' cardtype + FROM emp_card d + LEFT JOIN lpk_customer r ON r.sid = d.customerSid + LEFT JOIN lpk_giftbag_goods s ON s.giftbagSid=d.giftbagSid + LEFT JOIN lpk_goods e ON e.sid = s.goodsSid + WHERE d.customerSid IS NOT NULL AND d.customerSid <> '' + ORDER BY r.wxMpOpenid; + +select count(1) from tmp_cust_goods; -- 5256 + +-- 购买卡 +INSERT INTO tmp_cust_goods + SELECT + r.wxMpOpenid, + d.customerSid, + d.bindDate, + d.sid, + d.serialNumber, + d.code, + s.goodsSid, + s.goodsNumber, + e.NAME AS goodsName, + '购买卡' cardtype + FROM emp_card_gift d + LEFT JOIN lpk_customer r ON r.sid = d.customerSid + LEFT JOIN emp_card_gift_goods s ON s.empCardGiftSid=d.sid + LEFT JOIN lpk_goods e ON e.sid = s.goodsSid + WHERE d.customerSid IS NOT NULL AND d.customerSid <> '' AND d.isSenior = '1' + ORDER BY r.wxMpOpenid; + +select count(1) from tmp_cust_goods; -- 5325 + +-- 转赠卡 +INSERT INTO tmp_cust_goods + SELECT + r.wxMpOpenid, + d.customerSid, + d.bindDate, + d.sid, + d.serialNumber, + d.code, + s.goodsSid, + s.goodsNumber, + e.NAME AS goodsName, + '转赠卡' cardtype + FROM emp_card_gift d + LEFT JOIN lpk_customer r ON r.sid = d.customerSid + LEFT JOIN emp_card_gift_goods s ON s.empCardGiftSid=d.sid + LEFT JOIN lpk_goods e ON e.sid = s.goodsSid + WHERE d.customerSid IS NOT NULL AND d.customerSid <> '' AND d.isSenior = '2' + ORDER BY r.wxMpOpenid; + +select count(1) from tmp_cust_goods; -- 5652 + + + -- 预约提货,数量为负值 + INSERT INTO tmp_cust_goods + SELECT + r.wxMpOpenid, + d.customerSid, + d.reserveDate, + d.sid, + d.storeSid, + d.cardCode, + s.goodsSid, + -s.goodsNumber AS goodsNumber, + e.NAME AS goodsName, + d.cardType cardtype + FROM lpk_reserve_order d + LEFT JOIN lpk_customer r ON r.sid = d.customerSid + LEFT JOIN lpk_reserve_order_goods s ON s.orderSid=d.sid + LEFT JOIN lpk_goods e ON e.sid = s.goodsSid + WHERE 1=1 + ORDER BY r.wxMpOpenid; + +select count(1) from tmp_cust_goods; -- 10917 + + + -- 赠出的卡,数量为负值 + INSERT INTO tmp_cust_goods + SELECT + r.wxMpOpenid, + d.empCardCustomerSid, + d.grantDate, + d.sid, + d.serialNumber, + d.code, + s.goodsSid, + -s.goodsNumber AS goodsNumber, + e.NAME AS goodsName, + '赠出' cardtype + FROM emp_card_gift d + LEFT JOIN lpk_customer r ON r.sid = d.empCardCustomerSid + LEFT JOIN emp_card_gift_goods s ON s.empCardGiftSid=d.sid + LEFT JOIN lpk_goods e ON e.sid = s.goodsSid + WHERE d.empCardCustomerSid IS NOT NULL AND d.empCardCustomerSid <> '' AND d.isSenior = '2' + ORDER BY r.wxMpOpenid; + +select count(1) from tmp_cust_goods; -- 11292 + +select * from tmp_cust_goods; + +delete from vegetable_cellar where 1=1; + +-- 统计 + INSERT INTO vegetable_cellar(sid,customerSid,goodsSid,goodsNumber) + SELECT + UUID(), + customerSid, + goodsSid, + SUM(goodsNumber) AS goodsNumber + FROM tmp_cust_goods + GROUP BY customerSid,goodsSid + HAVING goodsNumber>0 + + + + update vegetable_cellar vc set affiliation=(select brandId from lpk_goods lg where vc.goodsSid=lg.sid) where 1=1 + diff --git a/src/main/java/com/yxt/yythmall/adminapi/AdminReserveRest.java b/src/main/java/com/yxt/yythmall/adminapi/AdminReserveRest.java index 6794a06..843cf89 100644 --- a/src/main/java/com/yxt/yythmall/adminapi/AdminReserveRest.java +++ b/src/main/java/com/yxt/yythmall/adminapi/AdminReserveRest.java @@ -1,33 +1,28 @@ package com.yxt.yythmall.adminapi; +import com.yxt.common.core.query.PagerQuery; import com.yxt.common.core.result.ResultBean; -import com.yxt.yythmall.adminapi.vo.PmsBrandVo; -import com.yxt.yythmall.adminapi.vo.PmsProductCategoryVo; -import com.yxt.yythmall.adminservice.AdminMallService; +import com.yxt.common.core.vo.PagerVo; +import com.yxt.yythmall.api.lpkreserveorder.LpkReserveOrderQuery; +import com.yxt.yythmall.biz.vegecallerreserveorder.ReserveOrderVo; +import com.yxt.yythmall.biz.vegecallerreserveorder.VegeCellarReserveOrderService; +import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import java.util.List; - @RestController("com.yxt.yythmall.adminapi.AdminReserveRest") @RequestMapping("/adminapi/reserve") public class AdminReserveRest { @Autowired - private AdminMallService adminMallService; + private VegeCellarReserveOrderService vegeCellarReserveOrderService; - @GetMapping(value = "/listAllBrand") - public ResultBean> listAllBrand() { - ResultBean rb = ResultBean.fireFail(); - List list = adminMallService.listBrand(); - return rb.success().setData(list); - } - @GetMapping(value = "/listAllCategory") - public ResultBean> listAllCategory() { - ResultBean rb = ResultBean.fireFail(); - List list = adminMallService.listAllCategory(); - return rb.success().setData(list); + @ApiOperation("精确到客户的预约单列表") + @PostMapping("/pageOfCustomer") + public ResultBean> orderList(@RequestBody PagerQuery pq) { + return vegeCellarReserveOrderService.pageOfCustomer(pq); } } diff --git a/src/main/java/com/yxt/yythmall/biz/smscoupon/SmsCouponController.java b/src/main/java/com/yxt/yythmall/biz/smscoupon/SmsCouponController.java index f50884a..8e6139d 100644 --- a/src/main/java/com/yxt/yythmall/biz/smscoupon/SmsCouponController.java +++ b/src/main/java/com/yxt/yythmall/biz/smscoupon/SmsCouponController.java @@ -39,7 +39,9 @@ public class SmsCouponController { @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize ) { try { - return new CommonResult().success(ISmsCouponService.page(new Page(pageNum, pageSize), new QueryWrapper<>(entity))); + return new CommonResult().success( + ISmsCouponService.page(new Page(pageNum, pageSize), new QueryWrapper<>(entity).orderByDesc("id")) + ); } catch (Exception e) { log.error("根据条件查询所有优惠卷表列表:%s", e.getMessage(), e); } diff --git a/src/main/java/com/yxt/yythmall/biz/vegecallerreserveorder/ReserveOrderVo.java b/src/main/java/com/yxt/yythmall/biz/vegecallerreserveorder/ReserveOrderVo.java new file mode 100644 index 0000000..c571a81 --- /dev/null +++ b/src/main/java/com/yxt/yythmall/biz/vegecallerreserveorder/ReserveOrderVo.java @@ -0,0 +1,37 @@ +package com.yxt.yythmall.biz.vegecallerreserveorder; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.yxt.common.core.vo.Vo; +import com.yxt.yythmall.api.lpkreserveorder.OrderGoodsVo; +import lombok.Data; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * @author Fan + * @description + * @date 2023/11/27 15:11 + */ +@Data +public class ReserveOrderVo implements Vo { + private String reserveDate; + private String customerSid; + private String storeSid; + private String storeName; + private String storeLinker; + private String storePhone; + private String storeAddress; + private String affiliation; + private String userName; + private String userPhone; + private String bankSid; + private String bankName; + private String bankLinker; + private String bankPhone; + private String bankAddress; + private String goodsSid; + private String goodsName; + private String goodsNumber; +} diff --git a/src/main/java/com/yxt/yythmall/biz/vegecallerreserveorder/VegeCellarReserveOrderMapper.java b/src/main/java/com/yxt/yythmall/biz/vegecallerreserveorder/VegeCellarReserveOrderMapper.java index b259e5d..9954334 100644 --- a/src/main/java/com/yxt/yythmall/biz/vegecallerreserveorder/VegeCellarReserveOrderMapper.java +++ b/src/main/java/com/yxt/yythmall/biz/vegecallerreserveorder/VegeCellarReserveOrderMapper.java @@ -3,16 +3,13 @@ package com.yxt.yythmall.biz.vegecallerreserveorder; 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.common.core.vo.PagerVo; import com.yxt.yythmall.api.vegecallerreserveorder.VegeCellarReserveOrder; import com.yxt.yythmall.api.vegecallerreserveorder.VegeCellarReserveOrderQuery; import com.yxt.yythmall.api.vegecallerreserveorder.VegeCellarReserveOrderVo; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; -import org.apache.ibatis.annotations.Select; - -import java.util.List; /** * @author wangpengfei @@ -28,6 +25,8 @@ public interface VegeCellarReserveOrderMapper extends BaseMapper orderListByUserSid(IPage page, @Param(Constants.WRAPPER) QueryWrapper qw); IPage orderListByUserSid(IPage page, @Param("query") VegeCellarReserveOrderQuery query); + + PagerVo pageOfCustomer(IPage page,QueryWrapper qw); // // List exportExcel(@Param("qw") VegeCellarReserveOrderQuery qw); // List exportExcelByStore(@Param(Constants.WRAPPER) QueryWrapper qw); diff --git a/src/main/java/com/yxt/yythmall/biz/vegecallerreserveorder/VegeCellarReserveOrderMapper.xml b/src/main/java/com/yxt/yythmall/biz/vegecallerreserveorder/VegeCellarReserveOrderMapper.xml index 5e08ff6..d86e9ef 100644 --- a/src/main/java/com/yxt/yythmall/biz/vegecallerreserveorder/VegeCellarReserveOrderMapper.xml +++ b/src/main/java/com/yxt/yythmall/biz/vegecallerreserveorder/VegeCellarReserveOrderMapper.xml @@ -447,4 +447,35 @@ ${ew.sqlSegment} + + \ No newline at end of file diff --git a/src/main/java/com/yxt/yythmall/biz/vegecallerreserveorder/VegeCellarReserveOrderService.java b/src/main/java/com/yxt/yythmall/biz/vegecallerreserveorder/VegeCellarReserveOrderService.java index b43294c..8ec866c 100644 --- a/src/main/java/com/yxt/yythmall/biz/vegecallerreserveorder/VegeCellarReserveOrderService.java +++ b/src/main/java/com/yxt/yythmall/biz/vegecallerreserveorder/VegeCellarReserveOrderService.java @@ -3,47 +3,29 @@ package com.yxt.yythmall.biz.vegecallerreserveorder; 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 cn.hutool.core.util.StrUtil; 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.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.yythmall.api.lpkgiftbaggoods.LpkGiftBagGoodsVo; -import com.yxt.yythmall.api.lpkgiftcard.AppletVo; -import com.yxt.yythmall.api.lpkgiftcard.GoodsVo; import com.yxt.yythmall.api.lpkgoods.LpkGoods; +import com.yxt.yythmall.api.lpkreserveorder.LpkReserveOrderQuery; import com.yxt.yythmall.api.lpkstore.LpkStore; -import com.yxt.yythmall.api.lpkstore.StoreSelect; import com.yxt.yythmall.api.vegecallerreservedetails.VegeCellarReserveDetails; import com.yxt.yythmall.api.vegecallerreserveorder.*; -import com.yxt.yythmall.biz.lpkgiftbaggoods.LpkGiftBagGoodsService; -import com.yxt.yythmall.biz.lpkgiftcard.LpkGiftCardMapper; import com.yxt.yythmall.biz.lpkgiftcard.generateRule.UniqueIdGenerator; import com.yxt.yythmall.biz.lpkgoods.LpkGoodsService; import com.yxt.yythmall.biz.lpkstore.LpkStoreService; import com.yxt.yythmall.biz.vegecallerreservedetail.VegeCellarReserveDetailsService; -import com.yxt.yythmall.utils.StyleUtils; -import org.apache.poi.ss.usermodel.HorizontalAlignment; -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.ServletOutputStream; -import javax.servlet.http.HttpServletResponse; -import java.io.BufferedOutputStream; -import java.io.IOException; -import java.text.ParseException; -import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Date; import java.util.List; /** @@ -54,28 +36,29 @@ import java.util.List; public class VegeCellarReserveOrderService extends MybatisBaseService { @Autowired VegeCellarReserveDetailsService vegeCellarReserveDetailsService; -// @Autowired + // @Autowired // LpkGiftCardMapper lpkGiftCardMapper; // @Autowired // LpkGiftBagGoodsService lpkGiftBagGoodsService; @Autowired LpkStoreService lpkStoreService; -// @Autowired + // @Autowired // private FileUploadComponent fileUploadComponent; @Autowired private LpkGoodsService lpkGoodsService; -// @Autowired + + // @Autowired // private HttpServletResponse response; // @Transactional(rollbackFor = Exception.class) public ResultBean submission(VegeCellarReserveOrderDto dto) { ResultBean rb = new ResultBean().fail(); - boolean b=isSatAndSun(dto.getReserveDate()); - if(!b){ + boolean b = isSatAndSun(dto.getReserveDate()); + if (!b) { return rb.setMsg("周六、周日不能预约提货"); } VegeCellarReserveOrder order = new VegeCellarReserveOrder(); - LpkStore lpkStore= lpkStoreService.getOne(new QueryWrapper().eq("sid",dto.getStoreSid())); + LpkStore lpkStore = lpkStoreService.getOne(new QueryWrapper().eq("sid", dto.getStoreSid())); BeanUtil.copyProperties(dto, order, "id", "sid"); order.setStoreSid(dto.getStoreSid()); // order.setCardSid(dto.getSid()); @@ -85,19 +68,20 @@ public class VegeCellarReserveOrderService extends MybatisBaseService().eq("customerSid",dto.getCustomerSid()) - .eq("affiliation",dto.getAffiliation()).eq("state","0")).get(0); - if(order==null){ + order = baseMapper.selectList(new QueryWrapper().eq("customerSid", dto.getCustomerSid()) + .eq("affiliation", dto.getAffiliation()).eq("state", "0")).get(0); + if (order == null) { BeanUtil.copyProperties(dto, order, "id", "sid"); order.setStoreSid(dto.getStoreSid()); // order.setCardSid(dto.getSid()); @@ -108,16 +92,17 @@ public class VegeCellarReserveOrderService extends MybatisBaseService().eq("customerSid",dto.getCustomerSid()) - .eq("affiliation",dto.getAffiliation()).eq("state","0")).get(0); - if(order==null){ + order = baseMapper.selectList(new QueryWrapper().eq("customerSid", dto.getCustomerSid()) + .eq("affiliation", dto.getAffiliation()).eq("state", "0")).get(0); + if (order == null) { BeanUtil.copyProperties(dto, order, "id", "sid"); order.setStoreSid(dto.getStoreSid()); // order.setCardSid(dto.getSid()); @@ -130,9 +115,9 @@ public class VegeCellarReserveOrderService extends MybatisBaseService qw = new QueryWrapper<>(); - if(StringUtils.isBlank(query.getCustomerSid())){ + if (StringUtils.isBlank(query.getCustomerSid())) { return rb.setMsg("参数不全"); } qw.eq("o.customerSid", query.getUserSid()); - qw.eq("o.state",query.getState()); + qw.eq("o.state", query.getState()); qw.orderByDesc("reserveDate"); IPage page = PagerUtil.queryToPage(pq); IPage pagging = baseMapper.orderListByUserSid(page, query); - List goodsVo = new ArrayList<>(); - for(VegeCellarReserveOrderVo vo:pagging.getRecords()){ - List goods =vegeCellarReserveDetailsService.selByOrderSids(vo.getSid()); - for(VegeCellarReserveDetails goods1:goods){ - LpkGoods lpkGoods=lpkGoodsService.getOne(new QueryWrapper().eq("sid",goods1.getGoodsSid())); + List goodsVo = new ArrayList<>(); + for (VegeCellarReserveOrderVo vo : pagging.getRecords()) { + List goods = vegeCellarReserveDetailsService.selByOrderSids(vo.getSid()); + for (VegeCellarReserveDetails goods1 : goods) { + LpkGoods lpkGoods = lpkGoodsService.getOne(new QueryWrapper().eq("sid", goods1.getGoodsSid())); // OrderGoodsVo orderGoodsVo=new OrderGoodsVo(); // orderGoodsVo.setGoodName(lpkGoods.getName()); // orderGoodsVo.setNum(Integer.parseInt(goods1.getNum())); // orderGoodsVo.setUnitName(lpkGoods.getUnitName()); // goodsVo.add(orderGoodsVo); - if(StringUtils.isBlank(vo.getGoodss())){ - vo.setGoodss(lpkGoods.getName()+":"+goods1.getNum()+lpkGoods.getUnitName()); - }else{ - vo.setGoodss(vo.getGoodss()+" "+lpkGoods.getName()+":"+goods1.getNum()+lpkGoods.getUnitName()); + if (StringUtils.isBlank(vo.getGoodss())) { + vo.setGoodss(lpkGoods.getName() + ":" + goods1.getNum() + lpkGoods.getUnitName()); + } else { + vo.setGoodss(vo.getGoodss() + " " + lpkGoods.getName() + ":" + goods1.getNum() + lpkGoods.getUnitName()); } } vo.setGoodsVo(goodsVo); @@ -722,4 +708,36 @@ public class VegeCellarReserveOrderService extends MybatisBaseService buildQuery(LpkReserveOrderQuery query) { + QueryWrapper qw = new QueryWrapper<>(); + if (StrUtil.isNotBlank(query.getStartDate())) { + qw.ge("date_format(vo.reserveDate,'%Y-%m-%d')", query.getStartDate()); + } + if (StrUtil.isNotBlank(query.getEndDate())) { + qw.le("date_format(vo.reserveDate,'%Y-%m-%d')", query.getEndDate()); + } + if (StrUtil.isNotBlank(query.getBankSid())) { + qw.eq("lb.sid", query.getBankSid()); + } + if (StrUtil.isNotBlank(query.getStore())) { + qw.eq("vo.storeSid", query.getStore()); + } + if (StrUtil.isNotBlank(query.getCardType())) { + qw.eq("vo.affiliation", query.getCardType()); + } + + qw.orderByAsc("vo.reserveDate"); + return qw; + } + + public ResultBean> pageOfCustomer(PagerQuery pq) { + ResultBean rb = ResultBean.fireFail(); + LpkReserveOrderQuery query = pq.getParams(); + QueryWrapper qw = buildQuery(query); + + IPage page = PagerUtil.queryToPage(pq); + PagerVo pagerVo = baseMapper.pageOfCustomer(page,qw); + return rb.success().setData(pagerVo); + } }