From 5643faab221aad18af98e8c770ca1094aff5acf7 Mon Sep 17 00:00:00 2001 From: GYJ <1157756119@qq.com> Date: Mon, 19 Aug 2024 11:16:47 +0800 Subject: [PATCH 01/18] =?UTF-8?q?=E5=BC=B9=E7=AA=97=E5=B9=BF=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/TbMiniAppPagesController.java | 46 +++++++ .../controller/shop/TbShopAdController.java | 39 ++++++ .../cn/ysk/cashier/dto/TbMiniAppPagesDto.java | 22 ++++ .../cn/ysk/cashier/dto/shop/TbShopAdDto.java | 40 ++++++ .../mybatis/entity/TbMiniAppPages.java | 26 ++++ .../ysk/cashier/mybatis/entity/TbShopAd.java | 28 +++++ .../mybatis/mapper/TbMiniAppPagesMapper.java | 10 ++ .../mybatis/mapper/TbShopAdMapper.java | 10 ++ .../service/TbMiniAppPagesService.java | 22 ++++ .../mybatis/service/TbShopAdService.java | 22 ++++ .../impl/TbMiniAppPagesServiceImpl.java | 118 ++++++++++++++++++ .../service/impl/TbShopAdServiceImpl.java | 115 +++++++++++++++++ 12 files changed, 498 insertions(+) create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/controller/TbMiniAppPagesController.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopAdController.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/dto/TbMiniAppPagesDto.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopAdDto.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbMiniAppPages.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopAd.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbMiniAppPagesMapper.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbShopAdMapper.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbMiniAppPagesService.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopAdService.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbMiniAppPagesServiceImpl.java create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopAdServiceImpl.java diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/TbMiniAppPagesController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/TbMiniAppPagesController.java new file mode 100644 index 00000000..a7f6599e --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/TbMiniAppPagesController.java @@ -0,0 +1,46 @@ +package cn.ysk.cashier.controller; + +import cn.ysk.cashier.dto.TbMiniAppPagesDto; +import cn.ysk.cashier.mybatis.service.TbMiniAppPagesService; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + +/** + * @author GYJ + */ +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/miniAppPages") +public class TbMiniAppPagesController { + + final private TbMiniAppPagesService tbMiniAppPagesService; + + @PostMapping + @ApiOperation("新增/system/miniAppPages") + public ResponseEntity createTbMiniAppPages(@Validated @RequestBody TbMiniAppPagesDto pagesDto) { + return tbMiniAppPagesService.createTbMiniAppPages(pagesDto); + } + + @PutMapping + @ApiOperation("修改/system/miniAppPages") + public ResponseEntity updateTbMiniAppPages(@Validated @RequestBody TbMiniAppPagesDto pagesDto) { + return tbMiniAppPagesService.updateTbMiniAppPages(pagesDto); + } + + @DeleteMapping("/{pagesId}") + @ApiOperation("删除/system/miniAppPages") + public ResponseEntity deleteTbMiniAppPages(@PathVariable Integer pagesId) { + return tbMiniAppPagesService.deleteTbMiniAppPages(pagesId); + } + + @GetMapping + @ApiOperation("查询/system/miniAppPages") + public ResponseEntity getTbMiniAppPages(@RequestParam Map params) { + return tbMiniAppPagesService.getTbMiniAppPages(params); + } +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopAdController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopAdController.java new file mode 100644 index 00000000..e1396888 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopAdController.java @@ -0,0 +1,39 @@ +package cn.ysk.cashier.controller.shop; + +import cn.ysk.cashier.dto.shop.TbShopAdDto; +import cn.ysk.cashier.mybatis.service.TbShopAdService; +import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + +/** + * @author GYJ + */ +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/ad") +public class TbShopAdController { + final private TbShopAdService tbShopAdService; + + @PostMapping + public ResponseEntity createTbShopAd(@RequestBody TbShopAdDto adDto) { + return tbShopAdService.createTbShopAd(adDto); + } + + @PutMapping + public ResponseEntity updateTbShopAd(@RequestBody TbShopAdDto adDto) { + return tbShopAdService.updateTbShopAd(adDto); + } + + @DeleteMapping("/{adId}") + public ResponseEntity deleteTbShopAd(@PathVariable Integer adId) { + return tbShopAdService.deleteTbShopAd(adId); + } + + @GetMapping + public ResponseEntity getTbShopAd(@RequestParam Map params) { + return tbShopAdService.getTbShopAd(params); + } +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/TbMiniAppPagesDto.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/TbMiniAppPagesDto.java new file mode 100644 index 00000000..e90ba071 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/TbMiniAppPagesDto.java @@ -0,0 +1,22 @@ +package cn.ysk.cashier.dto; + +import lombok.Data; + +import java.util.Date; + +/** + * @author GYJ + */ +@Data +public class TbMiniAppPagesDto { + private Integer id; + private Integer shopId; + private String name; + private String path; + private String icon; + private String description; + private Integer sort; + private Integer status; + private Date createTime; + private Date updateTime; +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopAdDto.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopAdDto.java new file mode 100644 index 00000000..59411fea --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopAdDto.java @@ -0,0 +1,40 @@ +package cn.ysk.cashier.dto.shop; + +import cn.ysk.cashier.mybatis.entity.TbShopAd; +import lombok.Data; + +import java.util.Date; + +/** + * @author GYJ + */ +@Data +public class TbShopAdDto { + private Integer id; + private Integer shopId; + private String imgUrl; + private String linkPath; + private Integer borderRadius; + private String showPosition; + private String frequency; + private Integer status; + private Integer sort; + private Date createTime; + private Date updateTime; + + public TbShopAd convertToTbShopAd() { + TbShopAd tbShopAd = new TbShopAd(); + tbShopAd.setId(this.id); + tbShopAd.setShopId(this.shopId); + tbShopAd.setImgUrl(this.imgUrl); + tbShopAd.setLinkPath(this.linkPath); + tbShopAd.setBorderRadius(this.borderRadius); + tbShopAd.setShowPosition(this.showPosition); + tbShopAd.setFrequency(this.frequency); + tbShopAd.setStatus(this.status); + tbShopAd.setSort(this.sort); + tbShopAd.setCreateTime(this.createTime); + tbShopAd.setUpdateTime(this.updateTime); + return tbShopAd; + } +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbMiniAppPages.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbMiniAppPages.java new file mode 100644 index 00000000..70c1042e --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbMiniAppPages.java @@ -0,0 +1,26 @@ +package cn.ysk.cashier.mybatis.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * @author GYJ + */ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("tb_mini_app_pages") +public class TbMiniAppPages extends Model { + private Integer id; + private String icon; + private String name; + private String path; + private String description; + private Integer status; + private Integer sort; + private Date createTime; + private Date updateTime; +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopAd.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopAd.java new file mode 100644 index 00000000..31fb11db --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopAd.java @@ -0,0 +1,28 @@ +package cn.ysk.cashier.mybatis.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.extension.activerecord.Model; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * @author GYJ + */ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("tb_shop_ad") +public class TbShopAd extends Model { + private Integer id; + private Integer shopId; + private String imgUrl; + private String linkPath; + private Integer borderRadius; + private String showPosition; + private String frequency; + private Integer status; + private Integer sort; + private Date createTime; + private Date updateTime; +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbMiniAppPagesMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbMiniAppPagesMapper.java new file mode 100644 index 00000000..e4803dce --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbMiniAppPagesMapper.java @@ -0,0 +1,10 @@ +package cn.ysk.cashier.mybatis.mapper; + +import cn.ysk.cashier.mybatis.entity.TbMiniAppPages; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + * @author GYJ + */ +public interface TbMiniAppPagesMapper extends BaseMapper { +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbShopAdMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbShopAdMapper.java new file mode 100644 index 00000000..6ea4b44c --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbShopAdMapper.java @@ -0,0 +1,10 @@ +package cn.ysk.cashier.mybatis.mapper; + +import cn.ysk.cashier.mybatis.entity.TbShopAd; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + * @author GYJ + */ +public interface TbShopAdMapper extends BaseMapper { +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbMiniAppPagesService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbMiniAppPagesService.java new file mode 100644 index 00000000..005efedd --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbMiniAppPagesService.java @@ -0,0 +1,22 @@ +package cn.ysk.cashier.mybatis.service; + +import cn.ysk.cashier.dto.TbMiniAppPagesDto; +import cn.ysk.cashier.mybatis.entity.TbMiniAppPages; +import com.baomidou.mybatisplus.extension.service.IService; +import org.springframework.http.ResponseEntity; + +import java.util.Map; + +/** + * @author GYJ + */ +public interface TbMiniAppPagesService extends IService { + + ResponseEntity createTbMiniAppPages(TbMiniAppPagesDto pagesDto); + + ResponseEntity updateTbMiniAppPages(TbMiniAppPagesDto pagesDto); + + ResponseEntity deleteTbMiniAppPages(Integer pagesId); + + ResponseEntity getTbMiniAppPages(Map params); +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopAdService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopAdService.java new file mode 100644 index 00000000..3c5503eb --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopAdService.java @@ -0,0 +1,22 @@ +package cn.ysk.cashier.mybatis.service; + +import cn.ysk.cashier.dto.shop.TbShopAdDto; +import cn.ysk.cashier.mybatis.entity.TbShopAd; +import com.baomidou.mybatisplus.extension.service.IService; +import org.springframework.http.ResponseEntity; + +import java.util.Map; + +/** + * @author GYJ + */ +public interface TbShopAdService extends IService { + + ResponseEntity createTbShopAd(TbShopAdDto adDto); + + ResponseEntity updateTbShopAd(TbShopAdDto adDto); + + ResponseEntity deleteTbShopAd(Integer adId); + + ResponseEntity getTbShopAd(Map params); +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbMiniAppPagesServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbMiniAppPagesServiceImpl.java new file mode 100644 index 00000000..caf356bc --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbMiniAppPagesServiceImpl.java @@ -0,0 +1,118 @@ +package cn.ysk.cashier.mybatis.service.impl; + +import cn.ysk.cashier.dto.TbMiniAppPagesDto; +import cn.ysk.cashier.mybatis.entity.TbMiniAppPages; +import cn.ysk.cashier.mybatis.mapper.TbMiniAppPagesMapper; +import cn.ysk.cashier.mybatis.service.TbMiniAppPagesService; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; + +import java.util.Date; +import java.util.Map; + +/** + * @author GYJ + */ +@Service +@RequiredArgsConstructor +public class TbMiniAppPagesServiceImpl extends ServiceImpl implements TbMiniAppPagesService { + @Override + public ResponseEntity createTbMiniAppPages(TbMiniAppPagesDto pagesDto) { + if (pagesDto == null) { + return ResponseEntity.badRequest().body("参数不能为空"); + } + if (pagesDto.getName() == null || pagesDto.getPath() == null) { + return ResponseEntity.badRequest().body("页面名称和路径不能为空"); + } + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("name", pagesDto.getName()); + TbMiniAppPages tbMiniAppPages = baseMapper.selectOne(wrapper); + if (tbMiniAppPages != null) { + return ResponseEntity.badRequest().body("页面已存在"); + } + + tbMiniAppPages = new TbMiniAppPages(); + tbMiniAppPages.setName(pagesDto.getName()); + tbMiniAppPages.setPath(pagesDto.getPath()); + tbMiniAppPages.setIcon(pagesDto.getIcon()); + tbMiniAppPages.setSort(pagesDto.getSort()); + tbMiniAppPages.setDescription(pagesDto.getDescription()); + tbMiniAppPages.setStatus(pagesDto.getStatus()); + tbMiniAppPages.setCreateTime(new Date()); + tbMiniAppPages.setUpdateTime(new Date()); + + baseMapper.insert(tbMiniAppPages); + + return ResponseEntity.ok().body("新增成功"); + } + + @Override + public ResponseEntity updateTbMiniAppPages(TbMiniAppPagesDto pagesDto) { + TbMiniAppPages appPages = baseMapper.selectById(pagesDto.getId()); + if (appPages == null) { + return ResponseEntity.badRequest().body("页面不存在"); + } + + if (pagesDto.getName() == null || pagesDto.getPath() == null) { + return ResponseEntity.badRequest().body("页面名称和路径不能为空"); + } + + if (!appPages.getName().equals(pagesDto.getName())) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("name", pagesDto.getName()); + TbMiniAppPages tbMiniAppPages = baseMapper.selectOne(wrapper); + if (tbMiniAppPages != null) { + return ResponseEntity.badRequest().body("页面已存在"); + } + } + + if (pagesDto.getName() != null) { + appPages.setName(pagesDto.getName()); + } + if (pagesDto.getPath() != null) { + appPages.setPath(pagesDto.getPath()); + } + if (pagesDto.getIcon() != null) { + appPages.setIcon(pagesDto.getIcon()); + } + if (pagesDto.getSort() != null) { + appPages.setSort(pagesDto.getSort()); + } + if (pagesDto.getDescription() != null) { + appPages.setDescription(pagesDto.getDescription()); + } + if (pagesDto.getStatus() != null) { + appPages.setStatus(pagesDto.getStatus()); + } + appPages.setUpdateTime(new Date()); + + baseMapper.updateById(appPages); + + return ResponseEntity.ok().body("更新成功"); + } + + @Override + public ResponseEntity deleteTbMiniAppPages(Integer pagesId) { + TbMiniAppPages appPages = baseMapper.selectById(pagesId); + if (appPages == null) { + return ResponseEntity.badRequest().body("页面不存在"); + } + + baseMapper.deleteById(pagesId); + + return ResponseEntity.ok().body("删除成功"); + } + + @Override + public ResponseEntity getTbMiniAppPages(Map params) { + QueryWrapper wrapper = new QueryWrapper<>(); + if (params.get("status") != null) { + wrapper.eq("status", params.get("status")); + } + wrapper.orderByDesc("sort"); + return ResponseEntity.ok().body(baseMapper.selectList(wrapper)); + } +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopAdServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopAdServiceImpl.java new file mode 100644 index 00000000..c1d0c3d4 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopAdServiceImpl.java @@ -0,0 +1,115 @@ +package cn.ysk.cashier.mybatis.service.impl; + +import cn.hutool.core.util.StrUtil; +import cn.ysk.cashier.dto.shop.TbShopAdDto; +import cn.ysk.cashier.mybatis.entity.TbShopAd; +import cn.ysk.cashier.mybatis.mapper.TbShopAdMapper; +import cn.ysk.cashier.mybatis.service.TbShopAdService; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; + +import java.util.Date; +import java.util.Map; + +/** + * @author GYJ + */ +@Service +@RequiredArgsConstructor +public class TbShopAdServiceImpl extends ServiceImpl implements TbShopAdService { + @Override + public ResponseEntity createTbShopAd(TbShopAdDto adDto) { + if (adDto.getShopId() == null || adDto.getShopId() == 0) { + return ResponseEntity.badRequest().body("店铺ID不能为空"); + } + if (StrUtil.isBlank(adDto.getImgUrl())) { + return ResponseEntity.badRequest().body("图片地址不能为空"); + } + TbShopAd shopAd = adDto.convertToTbShopAd(); + shopAd.setCreateTime(new Date()); + shopAd.setUpdateTime(new Date()); + baseMapper.insert(shopAd); + return ResponseEntity.ok().body("新增成功"); + } + + @Override + public ResponseEntity updateTbShopAd(TbShopAdDto adDto) { + if (adDto.getShopId() == null || adDto.getShopId() == 0) { + return ResponseEntity.badRequest().body("店铺ID不能为空"); + } + if (StrUtil.isBlank(adDto.getImgUrl())) { + return ResponseEntity.badRequest().body("图片地址不能为空"); + } + TbShopAd shopAd = baseMapper.selectById(adDto.getId()); + if (shopAd == null) { + return ResponseEntity.badRequest().body("广告不存在"); + } + + if (StrUtil.isNotBlank(adDto.getImgUrl())) { + shopAd.setImgUrl(adDto.getImgUrl()); + } + if (StrUtil.isNotBlank(adDto.getLinkPath())) { + shopAd.setLinkPath(adDto.getLinkPath()); + } + if (adDto.getBorderRadius() != null) { + shopAd.setBorderRadius(adDto.getBorderRadius()); + } + if (StrUtil.isNotBlank(adDto.getShowPosition())) { + shopAd.setShowPosition(adDto.getShowPosition()); + } + if (StrUtil.isNotBlank(adDto.getFrequency())) { + shopAd.setFrequency(adDto.getFrequency()); + } + if (adDto.getStatus() != null) { + shopAd.setStatus(adDto.getStatus()); + } + if (adDto.getSort() != null) { + shopAd.setSort(adDto.getSort()); + } + shopAd.setUpdateTime(new Date()); + + baseMapper.updateById(shopAd); + + return ResponseEntity.ok().body("修改成功"); + } + + @Override + public ResponseEntity deleteTbShopAd(Integer adId) { + TbShopAd shopAd = baseMapper.selectById(adId); + if (shopAd == null) { + return ResponseEntity.badRequest().body("广告不存在"); + } + + baseMapper.deleteById(adId); + + return ResponseEntity.ok().body("删除成功"); + } + + @Override + public ResponseEntity getTbShopAd(Map params) { + QueryWrapper wrapper = new QueryWrapper<>(); + + if (StrUtil.isBlank((String) params.get("shopId"))) { + return ResponseEntity.badRequest().body("店铺ID不能为空"); + } + + if (StrUtil.isNotBlank((String) params.get("status"))) { + wrapper.eq("status", params.get("status")); + } + + if (StrUtil.isNotBlank((String) params.get("showPosition"))) { + wrapper.eq("show_position", params.get("showPosition")); + } + + if (StrUtil.isNotBlank((String) params.get("frequency"))) { + wrapper.eq("frequency", params.get("frequency")); + } + + wrapper.orderByDesc("sort"); + + return ResponseEntity.ok().body(baseMapper.selectList(wrapper)); + } +} From 89810ae9b92657d8f1211c994a6d731d76375108 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=89=9B=E5=8F=89=E9=97=AA=E9=97=AA?= <18322780655@163.com> Date: Mon, 19 Aug 2024 11:20:58 +0800 Subject: [PATCH 02/18] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=87=8F=E5=B0=91=E4=BC=9A=E5=91=98=E4=BD=99=E9=A2=9D=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/shop/TbShopUserController.java | 8 +++ .../impl/shopimpl/TbShopUserServiceImpl.java | 70 +++++++++++++++++++ .../service/shop/TbShopUserService.java | 2 + 3 files changed, 80 insertions(+) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopUserController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopUserController.java index 0dbe5f8b..e5df29ca 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopUserController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopUserController.java @@ -21,6 +21,7 @@ import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; import java.io.IOException; +import java.util.Map; /** * @author lyf @@ -96,4 +97,11 @@ public class TbShopUserController { public void rechargeListDownload(HttpServletResponse response, @RequestBody TbShopRechargeListDto criteria) throws IOException { tbShopUserService.rechargeListDownload(response, criteria); } + + + @PostMapping("midfiyAccount") + @ApiOperation("增加扣减会员余额") + public ResponseEntity midfiyAccount(Map map){ + return null; + } } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopUserServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopUserServiceImpl.java index c1c1d916..f0dfc99a 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopUserServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopUserServiceImpl.java @@ -1,12 +1,15 @@ package cn.ysk.cashier.service.impl.shopimpl; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.ysk.cashier.dto.shop.TbShopRechargeListDto; import cn.ysk.cashier.dto.shop.TbShopRechargeRespDto; import cn.ysk.cashier.dto.shop.TbShopUserDto; import cn.ysk.cashier.dto.shop.TbShopUserQueryCriteria; +import cn.ysk.cashier.exception.BadRequestException; import cn.ysk.cashier.mapper.shop.TbShopUserMapper; +import cn.ysk.cashier.mybatis.entity.TbShopUserFlow; import cn.ysk.cashier.mybatis.mapper.ShopUserMapper; import cn.ysk.cashier.mybatis.mapper.TbShopUserFlowMapper; import cn.ysk.cashier.pojo.shop.TbShopUser; @@ -31,6 +34,7 @@ import java.io.IOException; import java.math.BigDecimal; import java.time.Instant; import java.util.*; +import java.util.regex.Pattern; /** * @author lyf @@ -50,6 +54,10 @@ public class TbShopUserServiceImpl implements TbShopUserService { @Autowired private ShopUserMapper shopUserMapper; + @Autowired + private TbShopUserFlowMapper tbShopUserFlowMapper; + + @Override public Map queryShopUser(TbShopUserQueryCriteria criteria) { IPage iPage = shopUserMapper.queryUser(criteria, criteria.getIsVip(), @@ -183,4 +191,66 @@ public class TbShopUserServiceImpl implements TbShopUserService { } FileUtil.downloadExcel(list, response); } + + @Override + public void modfiyAccount(Map map) { + if(ObjectUtil.isNull(map)||ObjectUtil.isEmpty(map)||!map.containsKey("id")||!map.containsKey("type")||!map.containsKey("amount") + ||ObjectUtil.isEmpty(map.get("id"))||ObjectUtil.isNull(map.get("id"))||ObjectUtil.isNull(map.get("type"))||ObjectUtil.isEmpty(map.get("type")) + ||ObjectUtil.isEmpty(map.get("amount"))||ObjectUtil.isNull(map.get("amount")) + + ){ + throw new BadRequestException("参数错误"); + + } + + String regex = "^(([1-9][0-9]*)|(([0]\\.\\d{1,2}|[1-9][0-9]*\\.\\d{1,2})))$"; + if(!map.get("amount").toString().matches(regex)){ + throw new BadRequestException("请输入正确的数字"); + } + + + + TbShopUser tbShopUser= tbShopUserRepository.getById(Integer.valueOf(map.get("id")+"")); + if(ObjectUtil.isNull(tbShopUser)){ + throw new BadRequestException("不存在的会员信息"); + } + + BigDecimal amount=new BigDecimal(map.get("amount").toString()); + if(amount.compareTo(tbShopUser.getAmount())>0){ + throw new BadRequestException("账户余额不足,请输入正确的金额"); + } + + String type=map.get("type").toString(); + TbShopUserFlow flow=new TbShopUserFlow(); + + if("in".equals(type)){ + flow.setType("+"); + flow.setBizName("充值退款"); + flow.setBizCode("manualIn"); + tbShopUser.setAmount(tbShopUser.getAmount().add(amount)); + }else if("out".equals(type)){ + flow.setBizCode("manualOut"); + flow.setBizName("消费"); + flow.setType("-"); + tbShopUser.setAmount(tbShopUser.getAmount().subtract(amount)); + }else { + throw new BadRequestException("错误的请求类型"); + } + + tbShopUser.setUpdatedAt(System.currentTimeMillis()); + tbShopUserRepository.save(tbShopUser); + + + flow.setShopUserId(tbShopUser.getId()); + flow.setAmount(amount); + flow.setBalance(tbShopUser.getAmount()); + flow.setCreateTime(new Date()); + + tbShopUserFlowMapper.insert(flow); + + + + + } + } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopUserService.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopUserService.java index ad4c884b..608242c3 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopUserService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopUserService.java @@ -89,4 +89,6 @@ public interface TbShopUserService { void rechargeListDownload(HttpServletResponse response, TbShopRechargeListDto criteria) throws IOException; + void modfiyAccount(Map map); + } From 2ad3ca3ef88fbc235713b094c410fcde76412d39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=89=9B=E5=8F=89=E9=97=AA=E9=97=AA?= <18322780655@163.com> Date: Mon, 19 Aug 2024 11:23:32 +0800 Subject: [PATCH 03/18] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=87=8F=E5=B0=91=E4=BC=9A=E5=91=98=E4=BD=99=E9=A2=9D=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/ysk/cashier/controller/shop/TbShopUserController.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopUserController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopUserController.java index e5df29ca..60ef62cf 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopUserController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopUserController.java @@ -102,6 +102,7 @@ public class TbShopUserController { @PostMapping("midfiyAccount") @ApiOperation("增加扣减会员余额") public ResponseEntity midfiyAccount(Map map){ - return null; + tbShopUserService.modfiyAccount(map); + return new ResponseEntity<>(HttpStatus.NO_CONTENT) ; } } From 8d73b216efe28991523811335e4f18d10db7c2db Mon Sep 17 00:00:00 2001 From: SongZhang <2064194730@qq.com> Date: Sat, 17 Aug 2024 10:03:11 +0800 Subject: [PATCH 04/18] =?UTF-8?q?1.=E4=BB=A3=E5=AE=A2=E4=B8=8B=E5=8D=95=20?= =?UTF-8?q?=E6=8C=82=E8=B5=B7=E8=AE=A2=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/product/TbPlaceController.java | 5 ++-- .../mybatis/mapper/TbCashierCartMapper.java | 5 ++++ .../impl/shopimpl/TbShopTableServiceImpl.java | 26 ++++++++++++++++--- .../service/shop/TbShopTableService.java | 2 +- .../cn/ysk/cashier/vo/PendingCountVO.java | 14 ++++++++++ 5 files changed, 46 insertions(+), 6 deletions(-) create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/vo/PendingCountVO.java diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java index 118f6870..154dd508 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java @@ -96,9 +96,10 @@ public class TbPlaceController { @RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer size, @RequestParam Integer shopId, - @RequestParam(required = false) Integer vipUserId + @RequestParam(required = false) Integer vipUserId, + @RequestParam String masterId ) { - return ResponseEntity.ok(tbShopTableService.getCart(tableId, page, size, shopId, vipUserId)); + return ResponseEntity.ok(tbShopTableService.getCart(tableId, page, size, shopId, vipUserId, masterId)); } @AnonymousAccess diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCashierCartMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCashierCartMapper.java index b0056e9f..236e460d 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCashierCartMapper.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCashierCartMapper.java @@ -3,6 +3,7 @@ package cn.ysk.cashier.mybatis.mapper; import cn.ysk.cashier.mybatis.entity.Activate; import cn.ysk.cashier.pojo.order.TbCashierCart; import cn.ysk.cashier.vo.CarVO; +import cn.ysk.cashier.vo.PendingCountVO; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; @@ -18,4 +19,8 @@ public interface TbCashierCartMapper extends BaseMapper { " ifnull(sum(total_amount),0) as totalAmount\n" + " from tb_cashier_cart where table_id is not null and shop_id = #{shopId} and status = 'refund' group by shop_Id, master_id order by trade_day desc") List selectCar(@Param("shopId") Integer shopId); + + @Select(" SELECT order_id orderId, pending_at, sum(total_amount) toalAmount, count(id) totalCount from tb_cashier_cart where status = 'refund' and shop_id=#{shopId} " + + " GROUP BY order_id ORDER BY trade_day") + List countPending(@Param("shopId") Integer shopId); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 19344eab..1938bec8 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -41,6 +41,7 @@ import cn.ysk.cashier.repository.product.TbProductRepository; import cn.ysk.cashier.repository.product.TbProductSkuRepository; import cn.ysk.cashier.repository.shop.TbShopInfoRepository; import cn.ysk.cashier.utils.*; +import cn.ysk.cashier.vo.PendingCountVO; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; @@ -395,7 +396,8 @@ public class TbShopTableServiceImpl implements TbShopTableService { } @Override - public com.baomidou.mybatisplus.extension.plugins.pagination.Page getCart(Long tableId, Integer page, Integer size, Integer shopId, Integer vipUserId) { + public com.baomidou.mybatisplus.extension.plugins.pagination.Page getCart(Long tableId, Integer page, + Integer size, Integer shopId, Integer vipUserId, String masterId) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() .eq(TbCashierCart::getTableId, tableId) .eq(TbCashierCart::getStatus, "create") @@ -404,6 +406,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { if (vipUserId != null) { queryWrapper.eq(TbCashierCart::getUserId, vipUserId); }else { + queryWrapper.eq(TbCashierCart::getMasterId, masterId); queryWrapper.isNull(TbCashierCart::getUserId); } @@ -643,7 +646,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { } else { orderCode = String.valueOf(Integer.parseInt(code.replace("#", "")) + 1); } - redisTemplate.opsForValue().set("SHOP:CODE:" + clientType + ":" + shopId + ":" + day, "#" + Integer.parseInt(code.replace("#", "")) + 2); + redisTemplate.opsForValue().set("SHOP:CODE:" + clientType + ":" + shopId + ":" + day, String.valueOf(Integer.parseInt(orderCode) + 1)); boolean flag = Boolean.TRUE.equals(redisTemplate.opsForValue().setIfAbsent("SHOP:CODE:SET" + clientType + ":" + shopId + ":" + day, orderCode)); if (flag) { return generateOrderCode(day, clientType, shopId); @@ -872,7 +875,24 @@ public class TbShopTableServiceImpl implements TbShopTableService { @Override public Object getCar(Integer shopId) { - return cashierCartMapper.selectCar(shopId); + ArrayList> data = new ArrayList<>(); + + List pendingCountVOS = cashierCartMapper.countPending(shopId); + List tbCashierCarts = cashierCartMapper.selectList(new LambdaQueryWrapper() + .eq(TbCashierCart::getShopId, shopId) + .eq(TbCashierCart::getStatus, "refund")); + + HashMap> cashierMap = new HashMap<>(); + for (TbCashierCart tbCashierCart : tbCashierCarts) { + List list = cashierMap.computeIfAbsent(tbCashierCart.getOrderId().toString(), k -> new ArrayList<>()); + list.add(tbCashierCart); + } + + pendingCountVOS.forEach(item -> { + Map map = BeanUtil.beanToMap(item, false, false); + map.put("carList", cashierMap.get(item.getOrderId().toString())); + }); + return data; } @Override diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopTableService.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopTableService.java index 00e4c62c..23ce9f60 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopTableService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopTableService.java @@ -102,7 +102,7 @@ public interface TbShopTableService { void clearCart(ClearCartDTO clearCartDTO); - Page getCart(Long tableId, Integer page, Integer size, Integer shopId, Integer vipUserId); + Page getCart(Long tableId, Integer page, Integer size, Integer shopId, Integer vipUserId, String masterId); TbCashierCart updateCart(UpdateCartDTO updateCartDTO); diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/vo/PendingCountVO.java b/eladmin-system/src/main/java/cn/ysk/cashier/vo/PendingCountVO.java new file mode 100644 index 00000000..47c673e3 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/vo/PendingCountVO.java @@ -0,0 +1,14 @@ +package cn.ysk.cashier.vo; + +import lombok.Data; + +import java.math.BigDecimal; +import java.sql.Timestamp; + +@Data +public class PendingCountVO { + private Long pendingAt; + private BigDecimal totalAmount; + private Integer totalCount; + private Integer orderId; +} From 0ec21c31e944397ce3fc10c5fa16d5460f4ceaa0 Mon Sep 17 00:00:00 2001 From: SongZhang <2064194730@qq.com> Date: Sat, 17 Aug 2024 15:21:45 +0800 Subject: [PATCH 05/18] =?UTF-8?q?1.=E4=BB=A3=E5=AE=A2=E4=B8=8B=E5=8D=95=20?= =?UTF-8?q?=E6=8C=82=E8=B5=B7=E8=AE=A2=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ysk/cashier/dto/shoptable/PendingDTO.java | 1 + .../mybatis/mapper/TbCashierCartMapper.java | 6 +++- .../impl/shopimpl/TbShopTableServiceImpl.java | 28 +++++++++++++------ .../cn/ysk/cashier/vo/PendingCountVO.java | 1 + .../cn/ysk/cashier/vo/TbCashierCartVO.java | 11 ++++++++ 5 files changed, 38 insertions(+), 9 deletions(-) create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/vo/TbCashierCartVO.java diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/PendingDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/PendingDTO.java index 773e3af5..7bfbedf3 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/PendingDTO.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/PendingDTO.java @@ -17,4 +17,5 @@ public class PendingDTO { private Integer vipUserId; @NotNull private Boolean isPending; + private Integer orderId; } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCashierCartMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCashierCartMapper.java index 236e460d..cda17036 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCashierCartMapper.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCashierCartMapper.java @@ -4,6 +4,7 @@ import cn.ysk.cashier.mybatis.entity.Activate; import cn.ysk.cashier.pojo.order.TbCashierCart; import cn.ysk.cashier.vo.CarVO; import cn.ysk.cashier.vo.PendingCountVO; +import cn.ysk.cashier.vo.TbCashierCartVO; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; @@ -20,7 +21,10 @@ public interface TbCashierCartMapper extends BaseMapper { " from tb_cashier_cart where table_id is not null and shop_id = #{shopId} and status = 'refund' group by shop_Id, master_id order by trade_day desc") List selectCar(@Param("shopId") Integer shopId); - @Select(" SELECT order_id orderId, pending_at, sum(total_amount) toalAmount, count(id) totalCount from tb_cashier_cart where status = 'refund' and shop_id=#{shopId} " + + @Select(" SELECT order_id orderId, pending_at, sum(total_amount) totalAmount, count(id) totalCount, count(total_number) totalNumber from tb_cashier_cart where status = 'refund' and shop_id=#{shopId} " + " GROUP BY order_id ORDER BY trade_day") List countPending(@Param("shopId") Integer shopId); + + @Select("select a.*, b.spec_snap from tb_cashier_cart as a left join tb_product_sku as b on a.sku_id=b.id where a.shop_id=#{shopId} and a.status='refund';") + List selectPending(Integer shopId); } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 1938bec8..67d93221 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -822,14 +822,23 @@ public class TbShopTableServiceImpl implements TbShopTableService { @Override public Object pending(PendingDTO pendingDTO) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() - .eq(TbCashierCart::getShopId, pendingDTO.getShopId()) - .eq(TbCashierCart::getTableId, pendingDTO.getTableId()) - .eq(TbCashierCart::getStatus, "create"); - if (pendingDTO.getVipUserId() != null) { - queryWrapper.eq(TbCashierCart::getUserId, pendingDTO.getVipUserId()); + .eq(TbCashierCart::getShopId, pendingDTO.getShopId()); + + if (!pendingDTO.getIsPending()) { + if (pendingDTO.getOrderId() == null) { + throw new BadRequestException("取消挂起订单id不为空"); + } + queryWrapper.eq(TbCashierCart::getOrderId, pendingDTO.getOrderId()); }else { - queryWrapper.eq(TbCashierCart::getMasterId, pendingDTO.getMasterId()) - .isNull(TbCashierCart::getUserId); + queryWrapper.eq(TbCashierCart::getTableId, pendingDTO.getTableId()) + .eq(TbCashierCart::getStatus, "create"); + if (pendingDTO.getVipUserId() != null) { + queryWrapper.eq(TbCashierCart::getUserId, pendingDTO.getVipUserId()); + }else { + queryWrapper.eq(TbCashierCart::getMasterId, pendingDTO.getMasterId()) + .isNull(TbCashierCart::getUserId); + } + } List cashierCarts = cashierCartMapper .selectList(queryWrapper); @@ -875,13 +884,15 @@ public class TbShopTableServiceImpl implements TbShopTableService { @Override public Object getCar(Integer shopId) { - ArrayList> data = new ArrayList<>(); + ArrayList> data = new ArrayList<>(); List pendingCountVOS = cashierCartMapper.countPending(shopId); List tbCashierCarts = cashierCartMapper.selectList(new LambdaQueryWrapper() .eq(TbCashierCart::getShopId, shopId) .eq(TbCashierCart::getStatus, "refund")); + cashierCartMapper.selectPending(shopId); + HashMap> cashierMap = new HashMap<>(); for (TbCashierCart tbCashierCart : tbCashierCarts) { List list = cashierMap.computeIfAbsent(tbCashierCart.getOrderId().toString(), k -> new ArrayList<>()); @@ -891,6 +902,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { pendingCountVOS.forEach(item -> { Map map = BeanUtil.beanToMap(item, false, false); map.put("carList", cashierMap.get(item.getOrderId().toString())); + data.add(map); }); return data; } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/vo/PendingCountVO.java b/eladmin-system/src/main/java/cn/ysk/cashier/vo/PendingCountVO.java index 47c673e3..43bcf404 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/vo/PendingCountVO.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/vo/PendingCountVO.java @@ -10,5 +10,6 @@ public class PendingCountVO { private Long pendingAt; private BigDecimal totalAmount; private Integer totalCount; + private Integer totalNumber; private Integer orderId; } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbCashierCartVO.java b/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbCashierCartVO.java new file mode 100644 index 00000000..5268c775 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbCashierCartVO.java @@ -0,0 +1,11 @@ +package cn.ysk.cashier.vo; + +import cn.ysk.cashier.pojo.order.TbCashierCart; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@EqualsAndHashCode(callSuper = true) +@Data +public class TbCashierCartVO extends TbCashierCart { + private String specSnap; +} From ff07ab528e305cf79cb922c704562ae3336fe5ca Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Sat, 17 Aug 2024 11:49:01 +0800 Subject: [PATCH 06/18] =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E7=AE=A1=E7=90=86=20?= =?UTF-8?q?=E8=B5=A0=E9=80=81=E5=95=86=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ysk/cashier/mybatis/entity/Activate.java | 25 ++++++++++++++++ .../mybatis/mapper/ActivateMapper.java | 1 - .../mybatis/mapper/TbCashierCartMapper.java | 1 - .../mybatis/rest/StorageController.java | 12 ++++++-- .../cashier/mybatis/service/ShopService.java | 20 ++++--------- .../mybatis/service/impl/ShopServiceImpl.java | 29 +++++++++---------- 6 files changed, 53 insertions(+), 35 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/Activate.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/Activate.java index 47efc722..8252f2fa 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/Activate.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/Activate.java @@ -1,13 +1,19 @@ package cn.ysk.cashier.mybatis.entity; +import cn.ysk.cashier.utils.ListUtil; import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.extension.activerecord.Model; import lombok.Data; import lombok.EqualsAndHashCode; +import org.apache.commons.lang3.StringUtils; +import org.springframework.util.CollectionUtils; import java.math.BigDecimal; +import java.util.List; +import java.util.stream.Collectors; @Data @EqualsAndHashCode(callSuper = true) @@ -23,6 +29,25 @@ public class Activate extends Model { private String handselType; private String isDel; private String isUser; + //是否赠送商品 0否 1是 + private Integer isGiftPro; + private String productIds; + @TableField(exist = false) + private List prodIds; + public void setProductIds(String productIds) { + this.productIds = productIds; + if(StringUtils.isNotBlank(productIds)){ + prodIds=ListUtil.stringChangeIntegerList(productIds); + } + } + public void setProdIds(List prodIds) { + this.prodIds = prodIds; + if(!CollectionUtils.isEmpty(prodIds)){ + productIds="["+prodIds.stream() + .map(String::valueOf) + .collect(Collectors.joining(","))+"]"; + } + } } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/ActivateMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/ActivateMapper.java index 813f54a0..cadddeab 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/ActivateMapper.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/ActivateMapper.java @@ -1,7 +1,6 @@ package cn.ysk.cashier.mybatis.mapper; import cn.ysk.cashier.mybatis.entity.Activate; -import cn.ysk.cashier.mybatis.entity.TbUserStorage; import com.baomidou.mybatisplus.core.mapper.BaseMapper; public interface ActivateMapper extends BaseMapper { diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCashierCartMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCashierCartMapper.java index cda17036..68b0f273 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCashierCartMapper.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbCashierCartMapper.java @@ -1,6 +1,5 @@ package cn.ysk.cashier.mybatis.mapper; -import cn.ysk.cashier.mybatis.entity.Activate; import cn.ysk.cashier.pojo.order.TbCashierCart; import cn.ysk.cashier.vo.CarVO; import cn.ysk.cashier.vo.PendingCountVO; diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/rest/StorageController.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/rest/StorageController.java index c91459eb..a9fefcc7 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/rest/StorageController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/rest/StorageController.java @@ -2,7 +2,6 @@ package cn.ysk.cashier.mybatis.rest; import cn.hutool.core.io.IoUtil; import cn.hutool.http.HttpUtil; -import cn.ysk.cashier.annotation.rest.AnonymousPostMapping; import cn.ysk.cashier.domain.QiniuContent; import cn.ysk.cashier.exception.BadRequestException; import cn.ysk.cashier.mybatis.entity.Activate; @@ -14,6 +13,7 @@ import cn.ysk.cashier.utils.SecurityUtils; import com.alibaba.fastjson.JSONObject; import com.google.gson.JsonObject; import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -23,9 +23,7 @@ import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.*; import java.io.InputStream; -import java.util.HashMap; import java.util.Map; -import java.util.concurrent.TimeUnit; @Slf4j @RestController @@ -50,11 +48,19 @@ public class StorageController { } @PostMapping("/modityActivate") public ResponseEntity modityActivate(@RequestBody Activate activate){ + if (activate.getIsGiftPro() != null && activate.getIsGiftPro() == 1 && CollectionUtils.isEmpty(activate.getProdIds())) + throw new BadRequestException("赠送商品不可为空"); String userName = SecurityUtils.getCurrentUsername(); shopService.modityActivate(activate); return new ResponseEntity<>(HttpStatus.OK); } + @GetMapping("/activate/{activateId}") + @ApiOperation("查询活动赠送商品") + public ResponseEntity queryActivatePros(@PathVariable("activateId") Integer activateId){ + return new ResponseEntity<>(shopService.findActivatePros(activateId),HttpStatus.OK); + } + /** * @param params * shopId 必填 diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/ShopService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/ShopService.java index ccd5c489..93a8462d 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/ShopService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/ShopService.java @@ -1,24 +1,12 @@ -/* -* Copyright 2019-2020 Zheng Jie -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ package cn.ysk.cashier.mybatis.service; import cn.ysk.cashier.mybatis.entity.Activate; import cn.ysk.cashier.mybatis.entity.StorageVo; +import cn.ysk.cashier.pojo.product.TbProduct; import org.springframework.data.domain.Pageable; +import java.util.List; + /** * @website https://eladmin.vip * @description 服务接口 @@ -36,4 +24,6 @@ public interface ShopService { Object findActivate(String shopId); void modityActivate(Activate activate); + + List findActivatePros(Integer activate); } \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/ShopServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/ShopServiceImpl.java index 704ca82b..485d762c 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/ShopServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/ShopServiceImpl.java @@ -1,23 +1,10 @@ -/* - * Copyright 2019-2020 Zheng Jie - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ package cn.ysk.cashier.mybatis.service.impl; import cn.ysk.cashier.mybatis.entity.Activate; import cn.ysk.cashier.mybatis.mapper.*; +import cn.ysk.cashier.pojo.product.TbProduct; import cn.ysk.cashier.pojo.shop.TbMerchantAccount; +import cn.ysk.cashier.repository.product.TbProductRepository; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -30,6 +17,7 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; import java.util.*; @@ -50,6 +38,8 @@ public class ShopServiceImpl implements ShopService { private TbProducSkutMapper producSkutMapper; @Autowired private ActivateMapper activateMapper; + @Autowired + private TbProductRepository tbProductRepository; @Override public Object findStorage(Integer shopId, String account, Pageable pageable) { QueryWrapper queryWrapper = new QueryWrapper<>(); @@ -139,4 +129,13 @@ public class ShopServiceImpl implements ShopService { activateMapper.insert(activate); } } + + @Override + public List findActivatePros(Integer activateId) { + Activate activate = activateMapper.selectById(activateId); + if (!CollectionUtils.isEmpty(activate.getProdIds())){ + return tbProductRepository.findByIds(activate.getProdIds()); + } + return new ArrayList<>(); + } } \ No newline at end of file From e3f68dc486ef5819d20b1b81ab67ddf70fe6475e Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Sat, 17 Aug 2024 14:15:12 +0800 Subject: [PATCH 07/18] =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=AE=A1=E7=90=86=20?= =?UTF-8?q?=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/ysk/cashier/mybatis/mapper/ShopUserMapper.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/ShopUserMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/ShopUserMapper.java index 0d6fa038..7aeff932 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/ShopUserMapper.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/ShopUserMapper.java @@ -27,9 +27,10 @@ public interface ShopUserMapper extends BaseMapper { " or u.telephone like concat('%', #{param.name}, '%') or su.telephone like concat('%', #{param.name}, '%'))" + "" + "" + - "AND su.is_vip=#{isVip}" + + "AND su.is_vip=#{isVip} " + "" + "" + + "order by su.created_at" + "") IPage queryUser(TbShopUserQueryCriteria param, Integer isVip, Page pageInfo); From 2250bda5c17ac787235e35e6264161146769bc0c Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Sat, 17 Aug 2024 14:38:00 +0800 Subject: [PATCH 08/18] =?UTF-8?q?=E5=88=86=E7=BB=84=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E7=AE=A1=E6=8E=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/ysk/cashier/dto/product/TbProductGroupDto.java | 11 ----------- .../impl/productimpl/TbProductGroupServiceImpl.java | 6 +----- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/product/TbProductGroupDto.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/product/TbProductGroupDto.java index 3c6d5e75..5bb4eeba 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/product/TbProductGroupDto.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/product/TbProductGroupDto.java @@ -54,15 +54,4 @@ public class TbProductGroupDto implements Serializable { private String saleStartTime; private String saleEndTime; - - public void upSaleEndTime() { - if (useTime != null && useTime == 1) { - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm"); - LocalTime startTime = LocalTime.parse(saleStartTime, formatter); - LocalTime endTime = LocalTime.parse(saleEndTime, formatter); - if (endTime.isBefore(startTime)) { - saleEndTime = "次日 " + saleEndTime; - } - } - } } \ No newline at end of file diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductGroupServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductGroupServiceImpl.java index 0b4215bd..93efc746 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductGroupServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductGroupServiceImpl.java @@ -58,11 +58,7 @@ public class TbProductGroupServiceImpl implements TbProductGroupService { PageRequest sort = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), Sort.by("sort")); Page page = tbProductGroupRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),sort); - Page map = page.map(tbProductGroupMapper::toDto); - map.getContent().forEach(s->{ - s.upSaleEndTime(); - }); - return PageUtil.toPage(map); + return PageUtil.toPage(page.map(tbProductGroupMapper::toDto)); } @Override From 8da97add53ed71bcc9002844d5fc775712099a50 Mon Sep 17 00:00:00 2001 From: SongZhang <2064194730@qq.com> Date: Sat, 17 Aug 2024 16:49:18 +0800 Subject: [PATCH 09/18] =?UTF-8?q?1.=E5=95=86=E5=93=81=E4=B8=8D=E6=8E=A8?= =?UTF-8?q?=E9=80=81=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ysk/cashier/service/impl/productimpl/StockServiceImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/StockServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/StockServiceImpl.java index 3f49b4c4..f4fe27b4 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/StockServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/StockServiceImpl.java @@ -365,7 +365,8 @@ public class StockServiceImpl implements StockService { break; case "pauseSale": sqlQuery.append(" set is_pause_sale = ").append(updateValueVO.getUpdateValue()); - TbProduct product1 = tbProductRepository.selectBySkuId(Integer.valueOf(updateValueVO.getTargetId())); + TbProduct product1 = tbProductRepository.getById(Integer.valueOf(updateValueVO.getTargetId())); + // 推送微信操作消息 if (product1 != null) { wxMsgUtils.aboardOperationMsg(("0".equals(updateValueVO.getUpdateValue()) ? "关闭售罄: " : "开启售罄: ") + product1.getName(), Integer.valueOf(updateValueVO.getShopId())); From 5f2950ab728f7bce9cb5716052ae69b33acef077 Mon Sep 17 00:00:00 2001 From: SongZhang <2064194730@qq.com> Date: Sat, 17 Aug 2024 17:37:06 +0800 Subject: [PATCH 10/18] =?UTF-8?q?1.=E4=BB=A3=E5=AE=A2=E4=B8=8B=E5=8D=95?= =?UTF-8?q?=E6=8C=82=E5=8D=95=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/cn/ysk/cashier/dto/shoptable/PendingDTO.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/PendingDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/PendingDTO.java index 7bfbedf3..f6720c7f 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/PendingDTO.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/PendingDTO.java @@ -8,11 +8,9 @@ import javax.validation.constraints.NotNull; @Data public class PendingDTO { - @NotEmpty private String masterId; @NotNull private Integer shopId; - @NotNull private Long tableId; private Integer vipUserId; @NotNull From fa868cce3163fb41d54a39fd41d9ca7bb3a938bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=89=9B=E5=8F=89=E9=97=AA=E9=97=AA?= <18322780655@163.com> Date: Sat, 17 Aug 2024 15:28:21 +0800 Subject: [PATCH 11/18] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=80=97=E6=9D=90?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E5=8D=95=E4=BB=B7=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/cn/ysk/cashier/cons/domain/ViewConInfoFlow.java | 4 ++++ .../cn/ysk/cashier/cons/service/dto/ViewConInfoFlowDto.java | 2 ++ 2 files changed, 6 insertions(+) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/domain/ViewConInfoFlow.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/domain/ViewConInfoFlow.java index 97967dc0..d15646af 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/domain/ViewConInfoFlow.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/domain/ViewConInfoFlow.java @@ -123,6 +123,10 @@ public class ViewConInfoFlow implements Serializable { @ApiModelProperty(value = "更新时间") private Date updateTime; + @Column(name = "price") + @ApiModelProperty(value = "单价") + private BigDecimal price; + public void copy(ViewConInfoFlow source){ diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/dto/ViewConInfoFlowDto.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/dto/ViewConInfoFlowDto.java index 00fc202f..3b35c877 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/dto/ViewConInfoFlowDto.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/dto/ViewConInfoFlowDto.java @@ -68,4 +68,6 @@ public class ViewConInfoFlowDto implements Serializable { private String isCheck; private Date createTime; private Date updateTime; + + private BigDecimal price; } \ No newline at end of file From 4909ebe8072ac70f8ea5b121544f262c1dfc90a9 Mon Sep 17 00:00:00 2001 From: SongZhang <2064194730@qq.com> Date: Mon, 19 Aug 2024 10:11:51 +0800 Subject: [PATCH 12/18] =?UTF-8?q?1.=E4=BB=A3=E5=AE=A2=E4=B8=8B=E5=8D=95=20?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E8=AE=A2=E5=8D=95=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/product/TbPlaceController.java | 23 +++++++++---------- .../cashier/dto/shoptable/DeleteOrderDTO.java | 9 ++++++++ .../impl/shopimpl/TbShopTableServiceImpl.java | 20 ++++++++++++++-- .../service/shop/TbShopTableService.java | 2 ++ 4 files changed, 40 insertions(+), 14 deletions(-) create mode 100644 eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/DeleteOrderDTO.java diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java index 154dd508..0bc3f355 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/product/TbPlaceController.java @@ -92,9 +92,9 @@ public class TbPlaceController { @Log("代客下单 查询购物车") @ApiOperation("代客下单 查询购物车 /shop/table") public ResponseEntity getCart( - @RequestParam Long tableId, @RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer size, + @RequestParam Long tableId, @RequestParam Integer shopId, @RequestParam(required = false) Integer vipUserId, @RequestParam String masterId @@ -139,17 +139,6 @@ public class TbPlaceController { @AnonymousAccess - @GetMapping("/car") - @Log("代客下单 查询购物车") - @ApiOperation("代客下单 查询购物车 /shop/table") - public ResponseEntity getCar( - @RequestParam Integer shopId - ) { - return ResponseEntity.ok(tbShopTableService.getCar(shopId)); - } - - @AnonymousAccess - @GetMapping("/payType") @Log("代客下单 查询购物车") @ApiOperation("代客下单 查询购物车 /shop/table") @@ -170,5 +159,15 @@ public class TbPlaceController { ) { return ResponseEntity.ok(tbShopTableService.pay(payDTO)); } + @AnonymousAccess + + @DeleteMapping("/order") + @Log("代客下单 删除订单") + @ApiOperation("代客下单 查询购物车 /shop/table") + public ResponseEntity delete( + @Validated @RequestBody DeleteOrderDTO deleteOrderDTO + ) { + return ResponseEntity.ok(tbShopTableService.deleteOrder(deleteOrderDTO)); + } } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/DeleteOrderDTO.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/DeleteOrderDTO.java new file mode 100644 index 00000000..4b4626fc --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shoptable/DeleteOrderDTO.java @@ -0,0 +1,9 @@ +package cn.ysk.cashier.dto.shoptable; + +import lombok.Data; + +@Data +public class DeleteOrderDTO { + private Integer shopId; + private Integer orderId; +} diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java index 67d93221..fba59ba1 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopTableServiceImpl.java @@ -648,7 +648,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { } redisTemplate.opsForValue().set("SHOP:CODE:" + clientType + ":" + shopId + ":" + day, String.valueOf(Integer.parseInt(orderCode) + 1)); boolean flag = Boolean.TRUE.equals(redisTemplate.opsForValue().setIfAbsent("SHOP:CODE:SET" + clientType + ":" + shopId + ":" + day, orderCode)); - if (flag) { + if (!flag) { return generateOrderCode(day, clientType, shopId); } // 增加计数器 @@ -879,7 +879,7 @@ public class TbShopTableServiceImpl implements TbShopTableService { cashierCart.setStatus(pendingDTO.getIsPending() ? "refund" : "create"); cashierCartMapper.update(cashierCart, new LambdaUpdateWrapper() .eq(TbCashierCart::getOrderId, orderId)); - return orderInfo; + return orderInfoMapper.selectById(orderId); } @Override @@ -965,4 +965,20 @@ public class TbShopTableServiceImpl implements TbShopTableService { rabbitTemplate.convertAndSend(RabbitConstants.EXCHANGE_STOCK_RECORD, RabbitConstants.ROUTING_STOCK_RECORD_SALE, mqData.toJSONString(), new CorrelationData(UUID.randomUUID().toString())); return null; } + + @Override + public Object deleteOrder(DeleteOrderDTO deleteOrderDTO) { + int count1 = orderInfoMapper.delete(new LambdaQueryWrapper() + .eq(TbOrderInfo::getShopId, deleteOrderDTO.getShopId()) + .eq(TbOrderInfo::getId, deleteOrderDTO.getOrderId())); + + int count2 = orderDetailMapper.delete(new LambdaQueryWrapper() + .eq(TbOrderDetail::getShopId, deleteOrderDTO.getShopId()) + .eq(TbOrderDetail::getOrderId, deleteOrderDTO.getOrderId())); + + int count3 = cashierCartMapper.delete(new LambdaQueryWrapper() + .eq(TbCashierCart::getShopId, deleteOrderDTO.getShopId()) + .eq(TbCashierCart::getOrderId, deleteOrderDTO.getOrderId())); + return count1 > 0 && count2 > 0 && count3 > 0; + } } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopTableService.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopTableService.java index 23ce9f60..b73ef0e0 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopTableService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopTableService.java @@ -119,4 +119,6 @@ public interface TbShopTableService { Object getPayType(Integer shopId); Object pay(PayDTO payDTO); + + Object deleteOrder(DeleteOrderDTO deleteOrderDTO); } From 58eb528047a6658cf5306d1f81ad4b2574c2de9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=89=9B=E5=8F=89=E9=97=AA=E9=97=AA?= <18322780655@163.com> Date: Sat, 17 Aug 2024 18:25:03 +0800 Subject: [PATCH 13/18] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=80=97=E6=9D=90?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E5=8D=95=E4=BB=B7=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/ysk/cashier/cons/domain/ViewConInfoFlow.java | 5 +++++ .../cn/ysk/cashier/cons/service/dto/ViewConInfoFlowDto.java | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/domain/ViewConInfoFlow.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/domain/ViewConInfoFlow.java index d15646af..a9167784 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/domain/ViewConInfoFlow.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/domain/ViewConInfoFlow.java @@ -75,6 +75,11 @@ public class ViewConInfoFlow implements Serializable { private BigDecimal balance; + @Column(name = "`status`",nullable = false) + @ApiModelProperty(value = "status") + private String status; + + @Column(name = "`product_id`") @ApiModelProperty(value = "商品id") diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/dto/ViewConInfoFlowDto.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/dto/ViewConInfoFlowDto.java index 3b35c877..6e5e19ed 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/dto/ViewConInfoFlowDto.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/dto/ViewConInfoFlowDto.java @@ -50,7 +50,7 @@ public class ViewConInfoFlowDto implements Serializable { private String productId; private String productName; - + private String status; private String conCode; From cf62b77128c6fb8e90168292efed8d0d281e066d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=89=9B=E5=8F=89=E9=97=AA=E9=97=AA?= <18322780655@163.com> Date: Sat, 17 Aug 2024 18:33:35 +0800 Subject: [PATCH 14/18] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=80=97=E6=9D=90?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E5=8D=95=E4=BB=B7=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/cn/ysk/cashier/cons/domain/ViewConInfoFlow.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/domain/ViewConInfoFlow.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/domain/ViewConInfoFlow.java index a9167784..a5848254 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/domain/ViewConInfoFlow.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/domain/ViewConInfoFlow.java @@ -75,7 +75,7 @@ public class ViewConInfoFlow implements Serializable { private BigDecimal balance; - @Column(name = "`status`",nullable = false) + @Column(name = "`status`") @ApiModelProperty(value = "status") private String status; From 53fd7e24c03e084175f5eb7a8c495d1ba974adb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=89=9B=E5=8F=89=E9=97=AA=E9=97=AA?= <18322780655@163.com> Date: Mon, 19 Aug 2024 09:45:48 +0800 Subject: [PATCH 15/18] =?UTF-8?q?=E5=88=A4=E6=96=AD=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E8=80=97=E6=9D=90=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cons/service/impl/TbConsInfoServiceImpl.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConsInfoServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConsInfoServiceImpl.java index c40a90fc..d78df579 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConsInfoServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConsInfoServiceImpl.java @@ -155,12 +155,12 @@ public class TbConsInfoServiceImpl implements TbConsInfoService { throw new Exception("耗材信息不存在"); } - tbConsInfo.setConName(resource.getConName()); - tbConsInfo.setPrice(resource.getPrice()); - tbConsInfo.setConUnit(resource.getConUnit()); - tbConsInfo.setConWarning(resource.getConWarning()); - tbConsInfo.setStatus(resource.getStatus()); - tbConsInfo.setIsCheck(resource.getIsCheck()); + tbConsInfo.setConName(ObjectUtil.isEmpty(resource.getConName())||ObjectUtil.isNull(resource.getConName())?tbConsInfo.getConName():resource.getConName()); + tbConsInfo.setPrice(ObjectUtil.isEmpty(resource.getPrice())||ObjectUtil.isNull(resource.getPrice())?tbConsInfo.getPrice():resource.getPrice()); + tbConsInfo.setConUnit(ObjectUtil.isEmpty(resource.getConUnit())||ObjectUtil.isNull(resource.getConUnit())?tbConsInfo.getConUnit(): resource.getConUnit()); + tbConsInfo.setConWarning(ObjectUtil.isEmpty(resource.getConWarning())||ObjectUtil.isNull(resource.getConWarning())?tbConsInfo.getConWarning():resource.getConWarning()); + tbConsInfo.setStatus(ObjectUtil.isEmpty(resource.getStatus())||ObjectUtil.isNull(resource.getStatus())?tbConsInfo.getStatus():resource.getStatus()); + tbConsInfo.setIsCheck(ObjectUtil.isEmpty(resource.getIsCheck())||ObjectUtil.isNull(resource.getIsCheck())?tbConsInfo.getIsCheck():resource.getIsCheck()); tbConsInfo.setUpdateTime(new Timestamp(System.currentTimeMillis())); tbConsInfoRepository.save(tbConsInfo); From 635625842ac5b3c67d422e0106c2adeaaf5697ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=89=9B=E5=8F=89=E9=97=AA=E9=97=AA?= <18322780655@163.com> Date: Mon, 19 Aug 2024 11:20:58 +0800 Subject: [PATCH 16/18] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=87=8F=E5=B0=91=E4=BC=9A=E5=91=98=E4=BD=99=E9=A2=9D=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/shop/TbShopUserController.java | 8 +++ .../impl/shopimpl/TbShopUserServiceImpl.java | 70 +++++++++++++++++++ .../service/shop/TbShopUserService.java | 2 + 3 files changed, 80 insertions(+) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopUserController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopUserController.java index 0dbe5f8b..e5df29ca 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopUserController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopUserController.java @@ -21,6 +21,7 @@ import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; import java.io.IOException; +import java.util.Map; /** * @author lyf @@ -96,4 +97,11 @@ public class TbShopUserController { public void rechargeListDownload(HttpServletResponse response, @RequestBody TbShopRechargeListDto criteria) throws IOException { tbShopUserService.rechargeListDownload(response, criteria); } + + + @PostMapping("midfiyAccount") + @ApiOperation("增加扣减会员余额") + public ResponseEntity midfiyAccount(Map map){ + return null; + } } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopUserServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopUserServiceImpl.java index c1c1d916..f0dfc99a 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopUserServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/shopimpl/TbShopUserServiceImpl.java @@ -1,12 +1,15 @@ package cn.ysk.cashier.service.impl.shopimpl; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.ysk.cashier.dto.shop.TbShopRechargeListDto; import cn.ysk.cashier.dto.shop.TbShopRechargeRespDto; import cn.ysk.cashier.dto.shop.TbShopUserDto; import cn.ysk.cashier.dto.shop.TbShopUserQueryCriteria; +import cn.ysk.cashier.exception.BadRequestException; import cn.ysk.cashier.mapper.shop.TbShopUserMapper; +import cn.ysk.cashier.mybatis.entity.TbShopUserFlow; import cn.ysk.cashier.mybatis.mapper.ShopUserMapper; import cn.ysk.cashier.mybatis.mapper.TbShopUserFlowMapper; import cn.ysk.cashier.pojo.shop.TbShopUser; @@ -31,6 +34,7 @@ import java.io.IOException; import java.math.BigDecimal; import java.time.Instant; import java.util.*; +import java.util.regex.Pattern; /** * @author lyf @@ -50,6 +54,10 @@ public class TbShopUserServiceImpl implements TbShopUserService { @Autowired private ShopUserMapper shopUserMapper; + @Autowired + private TbShopUserFlowMapper tbShopUserFlowMapper; + + @Override public Map queryShopUser(TbShopUserQueryCriteria criteria) { IPage iPage = shopUserMapper.queryUser(criteria, criteria.getIsVip(), @@ -183,4 +191,66 @@ public class TbShopUserServiceImpl implements TbShopUserService { } FileUtil.downloadExcel(list, response); } + + @Override + public void modfiyAccount(Map map) { + if(ObjectUtil.isNull(map)||ObjectUtil.isEmpty(map)||!map.containsKey("id")||!map.containsKey("type")||!map.containsKey("amount") + ||ObjectUtil.isEmpty(map.get("id"))||ObjectUtil.isNull(map.get("id"))||ObjectUtil.isNull(map.get("type"))||ObjectUtil.isEmpty(map.get("type")) + ||ObjectUtil.isEmpty(map.get("amount"))||ObjectUtil.isNull(map.get("amount")) + + ){ + throw new BadRequestException("参数错误"); + + } + + String regex = "^(([1-9][0-9]*)|(([0]\\.\\d{1,2}|[1-9][0-9]*\\.\\d{1,2})))$"; + if(!map.get("amount").toString().matches(regex)){ + throw new BadRequestException("请输入正确的数字"); + } + + + + TbShopUser tbShopUser= tbShopUserRepository.getById(Integer.valueOf(map.get("id")+"")); + if(ObjectUtil.isNull(tbShopUser)){ + throw new BadRequestException("不存在的会员信息"); + } + + BigDecimal amount=new BigDecimal(map.get("amount").toString()); + if(amount.compareTo(tbShopUser.getAmount())>0){ + throw new BadRequestException("账户余额不足,请输入正确的金额"); + } + + String type=map.get("type").toString(); + TbShopUserFlow flow=new TbShopUserFlow(); + + if("in".equals(type)){ + flow.setType("+"); + flow.setBizName("充值退款"); + flow.setBizCode("manualIn"); + tbShopUser.setAmount(tbShopUser.getAmount().add(amount)); + }else if("out".equals(type)){ + flow.setBizCode("manualOut"); + flow.setBizName("消费"); + flow.setType("-"); + tbShopUser.setAmount(tbShopUser.getAmount().subtract(amount)); + }else { + throw new BadRequestException("错误的请求类型"); + } + + tbShopUser.setUpdatedAt(System.currentTimeMillis()); + tbShopUserRepository.save(tbShopUser); + + + flow.setShopUserId(tbShopUser.getId()); + flow.setAmount(amount); + flow.setBalance(tbShopUser.getAmount()); + flow.setCreateTime(new Date()); + + tbShopUserFlowMapper.insert(flow); + + + + + } + } diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopUserService.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopUserService.java index ad4c884b..608242c3 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopUserService.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/shop/TbShopUserService.java @@ -89,4 +89,6 @@ public interface TbShopUserService { void rechargeListDownload(HttpServletResponse response, TbShopRechargeListDto criteria) throws IOException; + void modfiyAccount(Map map); + } From 95e37c20487399102a9f7716825ee518bd7ec5c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=89=9B=E5=8F=89=E9=97=AA=E9=97=AA?= <18322780655@163.com> Date: Mon, 19 Aug 2024 11:25:01 +0800 Subject: [PATCH 17/18] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=87=8F=E5=B0=91=E4=BC=9A=E5=91=98=E4=BD=99=E9=A2=9D=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/ysk/cashier/controller/shop/TbShopUserController.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopUserController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopUserController.java index e5df29ca..c45c7de8 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopUserController.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopUserController.java @@ -102,6 +102,7 @@ public class TbShopUserController { @PostMapping("midfiyAccount") @ApiOperation("增加扣减会员余额") public ResponseEntity midfiyAccount(Map map){ - return null; + tbShopUserService.modfiyAccount(map); + return new ResponseEntity<>(HttpStatus.OK); } } From 53275cd5de0841edf994a51308ece58362fc02d9 Mon Sep 17 00:00:00 2001 From: GYJ <1157756119@qq.com> Date: Mon, 19 Aug 2024 16:09:44 +0800 Subject: [PATCH 18/18] =?UTF-8?q?=E9=9B=86=E6=88=90model=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/cn/ysk/cashier/mybatis/entity/TbShopAd.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopAd.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopAd.java index 31fb11db..ef625f97 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopAd.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopAd.java @@ -13,7 +13,7 @@ import java.util.Date; @Data @EqualsAndHashCode(callSuper = true) @TableName("tb_shop_ad") -public class TbShopAd extends Model { +public class TbShopAd extends Model { private Integer id; private Integer shopId; private String imgUrl;