From 22c04c61f5b928e80f527fcbcaa8c69b211e9ebb Mon Sep 17 00:00:00 2001 From: GYJ <1157756119@qq.com> Date: Mon, 19 Aug 2024 15:30:14 +0800 Subject: [PATCH 01/21] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E5=BC=B9=E7=AA=97=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/TbShopAdController.java | 40 ++++++++++++ .../cashierservice/dao/TbShopAdDao.java | 23 +++++++ .../cashierservice/entity/TbShopAd.java | 63 +++++++++++++++++++ .../entity/dto/TbShopAdDto.java | 61 ++++++++++++++++++ .../service/TbShopAdService.java | 20 ++++++ .../service/impl/TbShopAdServiceImpl.java | 27 ++++++++ src/main/resources/mapper/TbShopAdDao.xml | 22 +++++++ 7 files changed, 256 insertions(+) create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/controller/TbShopAdController.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopAdDao.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopAd.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/TbShopAdDto.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopAdService.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopAdServiceImpl.java create mode 100644 src/main/resources/mapper/TbShopAdDao.xml diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbShopAdController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbShopAdController.java new file mode 100644 index 0000000..faabacf --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbShopAdController.java @@ -0,0 +1,40 @@ +package com.chaozhanggui.system.cashierservice.controller; + +import com.chaozhanggui.system.cashierservice.entity.TbShopAd; +import com.chaozhanggui.system.cashierservice.entity.dto.TbShopAdDto; +import com.chaozhanggui.system.cashierservice.service.TbShopAdService; +import com.chaozhanggui.system.cashierservice.sign.CodeEnum; +import com.chaozhanggui.system.cashierservice.sign.Result; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * (TbShopAd)表控制层 + * + * @author GYJ + * @since 2024-08-19 14:25:09 + */ +@RestController +@RequestMapping("tbShopAd") +public class TbShopAdController { + + private final TbShopAdService tbShopAdService; + + public TbShopAdController(@Qualifier("tbShopAdServiceImpl") TbShopAdService tbShopAdService) { + this.tbShopAdService = tbShopAdService; + } + + + @GetMapping("/list") + public Result list(@RequestParam(value = "shopId") Integer shopId) { + List tbShopAds = tbShopAdService.shopAdList(shopId); + return Result.success(CodeEnum.ENCRYPT, TbShopAdDto.convertShopAdDoToDtoList(tbShopAds)); + } + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopAdDao.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopAdDao.java new file mode 100644 index 0000000..3030d0f --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopAdDao.java @@ -0,0 +1,23 @@ +package com.chaozhanggui.system.cashierservice.dao; + +import com.chaozhanggui.system.cashierservice.entity.TbShopAd; +import org.apache.ibatis.annotations.Select; + +import java.util.List; + +/** + * (TbShopAd)表数据库访问层 + * + * @author GYJ + * @since 2024-08-19 14:25:09 + */ +public interface TbShopAdDao { + /** + * 查询指定行数据 + * + * @return 对象列表 + */ + @Select("select * from fycashier.tb_shop_ad where (shop_id = #{songId} or shop_id = 1) and status=1") + List shopAdList(Integer shopId); +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopAd.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopAd.java new file mode 100644 index 0000000..ffb7e8d --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopAd.java @@ -0,0 +1,63 @@ +package com.chaozhanggui.system.cashierservice.entity; + +import lombok.Data; + +import java.util.Date; +import java.io.Serializable; + +/** + * (TbShopAd)实体类 + * + * @author GYJ + * @since 2024-08-19 14:25:09 + */ +@Data +public class TbShopAd implements Serializable { + private static final long serialVersionUID = -34028307481923067L; +/** + * 自增id + */ + private Integer id; +/** + * 店铺id,如果是通用广告则为0 + */ + private Integer shopId; +/** + * 广告图片地址 + */ + private String imgUrl; +/** + * 跳转页面路径 + */ + private String linkPath; +/** + * 广告展示圆角 + */ + private Integer borderRadius; +/** + * 弹窗展示位置:home首页,make_order点餐页 + */ + private String showPosition; +/** + * 显示频率:only_one 仅首次展示, every_show 每次打开都展示,every_day 每天展示一次,three_day 每三天展示一次, seven_day 每七天展示一次, thirty_day 没30天展示一次 + */ + private String frequency; +/** + * 广告状态:0未启用,1已启用 + */ + private Integer status; +/** + * 排序 + */ + private Integer sort; +/** + * 创建时间 + */ + private Date createTime; +/** + * 更新时间 + */ + private Date updateTime; + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/TbShopAdDto.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/TbShopAdDto.java new file mode 100644 index 0000000..006ce6f --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/dto/TbShopAdDto.java @@ -0,0 +1,61 @@ +package com.chaozhanggui.system.cashierservice.entity.dto; + +import com.chaozhanggui.system.cashierservice.entity.TbShopAd; +import lombok.Data; + +import java.util.List; +import java.util.stream.Collectors; + +/** + * @author GYJ + */ +@Data +public class TbShopAdDto { + private Integer id; + /** + * 店铺id,如果是通用广告则为0 + */ + private Integer shopId; + /** + * 广告图片地址 + */ + private String imgUrl; + /** + * 跳转页面路径 + */ + private String linkPath; + /** + * 广告展示圆角 + */ + private Integer borderRadius; + /** + * 弹窗展示位置:home首页,make_order点餐页 + */ + private String showPosition; + /** + * 显示频率:only_one 仅首次展示, every_show 每次打开都展示,every_day 每天展示一次,three_day 每三天展示一次, seven_day 每七天展示一次, thirty_day 没30天展示一次 + */ + private String frequency; + + /** + * 更新时间 + */ + private Long updateTime; + + public static List convertShopAdDoToDtoList(List adList) { + return adList.stream().map(TbShopAdDto::convertShopAdDoToDto).collect(Collectors.toList()); + } + + public static TbShopAdDto convertShopAdDoToDto(TbShopAd ad) { + TbShopAdDto dto = new TbShopAdDto(); + dto.setId(ad.getId()); + dto.setShopId(ad.getShopId()); + dto.setImgUrl(ad.getImgUrl()); + dto.setLinkPath(ad.getLinkPath()); + dto.setBorderRadius(ad.getBorderRadius()); + dto.setShowPosition(ad.getShowPosition()); + dto.setFrequency(ad.getFrequency()); + dto.setUpdateTime(ad.getUpdateTime().getTime()); + return dto; + } +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopAdService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopAdService.java new file mode 100644 index 0000000..9cad181 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopAdService.java @@ -0,0 +1,20 @@ +package com.chaozhanggui.system.cashierservice.service; + +import com.chaozhanggui.system.cashierservice.entity.TbShopAd; + +import java.util.List; + +/** + * (TbShopAd)表服务接口 + * + * @author GYJ + * @since 2024-08-19 14:25:17 + */ +public interface TbShopAdService { + /** + * 分页查询 + * + * @return 查询结果 + */ + List shopAdList(Integer shopId); +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopAdServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopAdServiceImpl.java new file mode 100644 index 0000000..ad9ebb7 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopAdServiceImpl.java @@ -0,0 +1,27 @@ +package com.chaozhanggui.system.cashierservice.service.impl; + +import com.chaozhanggui.system.cashierservice.dao.TbShopAdDao; +import com.chaozhanggui.system.cashierservice.entity.TbShopAd; +import com.chaozhanggui.system.cashierservice.service.TbShopAdService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * (TbShopAd)表服务实现类 + * + * @author GYJ + * @since 2024-08-19 14:25:17 + */ +@Service +public class TbShopAdServiceImpl implements TbShopAdService { + @Autowired + private TbShopAdDao tbShopAdDao; + + @Override + public List shopAdList(Integer shopId) { + System.out.println("shopId = " + shopId); + return tbShopAdDao.shopAdList(shopId); + } +} diff --git a/src/main/resources/mapper/TbShopAdDao.xml b/src/main/resources/mapper/TbShopAdDao.xml new file mode 100644 index 0000000..799d46a --- /dev/null +++ b/src/main/resources/mapper/TbShopAdDao.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + From 2f1f8877fc27f9f237fed4b401dc323f8d26aed1 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 17:51:45 +0800 Subject: [PATCH 02/21] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E5=85=81=E8=AE=B8=E7=94=A8=E6=88=B7=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E5=85=85=E5=80=BC=E9=87=91=E9=A2=9D=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashierservice/controller/UserContoller.java | 1 + .../system/cashierservice/entity/TbShopUser.java | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/UserContoller.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/UserContoller.java index 02c6b7f..c13a247 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/UserContoller.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/UserContoller.java @@ -122,6 +122,7 @@ public class UserContoller { shopUser.setLng(tbShopInfo.getLng()); shopUser.setLat(tbShopInfo.getLat()); shopUser.setAddress(tbShopInfo.getAddress()); + shopUser.setIsUser(tbShopInfo.getIsCustom()); } return Result.success(CodeEnum.SUCCESS, shopUser); } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopUser.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopUser.java index 1621a49..a001c1d 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopUser.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopUser.java @@ -1,5 +1,7 @@ package com.chaozhanggui.system.cashierservice.entity; +import org.springframework.data.annotation.Transient; + import java.io.Serializable; import java.math.BigDecimal; @@ -68,6 +70,10 @@ public class TbShopUser implements Serializable { private String lng=""; private String address=""; + + @Transient + private String isUser; + private static final long serialVersionUID = 1L; public String getId() { @@ -311,6 +317,13 @@ public class TbShopUser implements Serializable { this.miniOpenId = miniOpenId == null ? null : miniOpenId.trim(); } + public String getIsUser() { + return isUser; + } + + public void setIsUser(String isUser) { + this.isUser = isUser; + } public String getLat() { return lat; From 878b21f7f6ebc560e42b87d4803bca1c67e108a2 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Tue, 20 Aug 2024 10:00:22 +0800 Subject: [PATCH 03/21] =?UTF-8?q?=E4=BC=9A=E5=91=98=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=8F=82=E6=95=B0=E6=A0=A1=E9=AA=8C=20?= =?UTF-8?q?=E6=97=A0=E6=89=8B=E6=9C=BA=E5=8F=B7=E4=BC=9A=E5=91=98=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=89=8B=E6=9C=BA=E5=8F=B7=E6=8E=A5=E5=8F=A3=20?= =?UTF-8?q?=E9=87=8D=E7=BD=AE=E8=B5=84=E9=87=91=E5=AF=86=E7=A0=81=20?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8F=82=E6=95=B0=20=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E6=89=8B=E6=9C=BA=E5=8F=B7=E6=98=AF=E4=BC=9A=E5=91=98=E8=BF=98?= =?UTF-8?q?=E6=98=AF=E7=94=A8=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/UserContoller.java | 11 ++++ .../entity/vo/OpenMemberVo.java | 6 +- .../cashierservice/service/LoginService.java | 21 +++---- .../cashierservice/service/UserService.java | 59 +++++++++++++------ 4 files changed, 62 insertions(+), 35 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/UserContoller.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/UserContoller.java index c13a247..319da29 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/UserContoller.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/UserContoller.java @@ -65,9 +65,20 @@ public class UserContoller { @PostMapping("/openMember") public Result openMember(@RequestBody OpenMemberVo memberVo){ + if(StringUtils.isBlank(memberVo.getTelephone())){ + return Result.fail("手机号不可为空"); + } return userService.openMember(memberVo); } + @PostMapping("/upVipPhont") + public Result upVipPhont(@RequestBody OpenMemberVo memberVo){ + if(StringUtils.isBlank(memberVo.getTelephone())){ + return Result.fail("手机号不可为空"); + } + return userService.upVipPhont(memberVo); + } + @GetMapping("/shopUserInfo") public Result shopUserInfo(@RequestParam("userId") String userId, @RequestHeader("openId") String openId, @RequestParam("shopId") String shopId) throws Exception { if(shopId.equals("undefined")){ diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/OpenMemberVo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/OpenMemberVo.java index b08c50e..28c9515 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/OpenMemberVo.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/OpenMemberVo.java @@ -6,10 +6,8 @@ import lombok.Data; public class OpenMemberVo { private Integer id; private Integer shopId; - private String headImg; - - private String nickName; - private String telephone; + private String nickName; private String birthDay; + private String headImg; } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java index c9194ed..bf59077 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/LoginService.java @@ -537,21 +537,23 @@ public class LoginService { ) { return Result.fail("参数错误"); } - TbUserInfo userInfo = tbUserInfoMapper.selectByPrimaryKey(Integer.valueOf(userId)); - boolean flag = validate(map.get("code").toString(), userInfo.getTelephone()); - if (!flag) { - return Result.fail("验证码错误"); + String phone = userInfo.getTelephone(); + if (map.containsKey("vipId")) { + TbShopUser tbShopUser = tbShopUserMapper.selectByPrimaryKey(map.get("vipId").toString()); + phone = tbShopUser.getTelephone(); } + if (StringUtils.isBlank(phone)) return Result.fail("设置密码失败,手机号获取为空"); + boolean flag = validate(map.get("code").toString(), phone); + + if (!flag) return Result.fail("验证码错误"); userInfo.setIsPwd("1"); userInfo.setPwd(MD5Utils.md5(map.get("pwd").toString())); userInfo.setUpdatedAt(System.currentTimeMillis()); tbUserInfoMapper.updateByPrimaryKey(userInfo); - return Result.success(CodeEnum.SUCCESS); - } @@ -581,11 +583,4 @@ public class LoginService { return Result.success(CodeEnum.SUCCESS); } - - - public static void main(String[] args) { - for (int i = 0; i < 10; i++) { - System.out.println(RandomUtil.randomNumbers(10)); - } - } } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/UserService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/UserService.java index 6c93e90..85f1220 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/UserService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/UserService.java @@ -1,5 +1,6 @@ package com.chaozhanggui.system.cashierservice.service; +import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.extra.qrcode.QrCodeUtil; import cn.hutool.extra.qrcode.QrConfig; @@ -21,6 +22,7 @@ import com.chaozhanggui.system.cashierservice.wxUtil.WxAccountUtil; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.core.io.Resource; @@ -271,25 +273,46 @@ public class UserService { } public Result openMember(OpenMemberVo memberVo) { - TbUserInfo userInfo = new TbUserInfo(); - userInfo.setId(memberVo.getId()); - userInfo.setHeadImg(memberVo.getHeadImg()); - userInfo.setNickName(memberVo.getNickName()); - userInfo.setTelephone(memberVo.getTelephone()); - userInfo.setBirthDay(memberVo.getBirthDay()); - userInfoMapper.updateByPrimaryKeySelective(userInfo); - List tbShopUsers = shopUserMapper.selectAllByUserId(memberVo.getId().toString()); - for (TbShopUser tbShopUser : tbShopUsers) { - tbShopUser.setTelephone(memberVo.getTelephone()); - shopUserMapper.updateByPrimaryKey(tbShopUser); - } TbShopUser tbShopUser = shopUserMapper.selectByUserIdAndShopId(memberVo.getId().toString(), memberVo.getShopId().toString()); - tbShopUser.setName(memberVo.getNickName()); - tbShopUser.setHeadImg(memberVo.getHeadImg()); - tbShopUser.setTelephone(memberVo.getTelephone()); - tbShopUser.setBirthDay(memberVo.getBirthDay()); - tbShopUser.setIsVip(Byte.parseByte("1")); - shopUserMapper.updateByPrimaryKey(tbShopUser); + if(tbShopUser!=null){ + tbShopUser.setName(StringUtils.isNotBlank(memberVo.getNickName())?memberVo.getNickName():null); + tbShopUser.setHeadImg(StringUtils.isNotBlank(memberVo.getHeadImg())?memberVo.getHeadImg():null); + tbShopUser.setTelephone(memberVo.getTelephone()); + tbShopUser.setBirthDay(StringUtils.isNotBlank(memberVo.getBirthDay())?memberVo.getBirthDay():null); + tbShopUser.setIsVip(Byte.parseByte("1")); + shopUserMapper.updateByPrimaryKeySelective(tbShopUser); + }else { + TbUserInfo tbUserInfo = userInfoMapper.selectByPrimaryKey(memberVo.getId()); + tbShopUser = new TbShopUser(); + tbShopUser.setName(StringUtils.isNotBlank(memberVo.getNickName())?memberVo.getNickName():null); + tbShopUser.setSex(Byte.parseByte("1")); + tbShopUser.setBirthDay(StringUtils.isNotBlank(memberVo.getBirthDay())?memberVo.getBirthDay():null); + tbShopUser.setLevel(Byte.parseByte("1")); + String dynamicCode = RandomUtil.randomNumbers(8); + tbShopUser.setCode(dynamicCode); + tbShopUser.setTelephone(memberVo.getTelephone()); + tbShopUser.setAmount(BigDecimal.ZERO); + tbShopUser.setIsVip(Byte.parseByte("0")); + tbShopUser.setCreditAmount(BigDecimal.ZERO); + tbShopUser.setConsumeAmount(BigDecimal.ZERO); + tbShopUser.setConsumeNumber(0); + tbShopUser.setLevelConsume(BigDecimal.ZERO); + tbShopUser.setStatus(Byte.parseByte("1")); + tbShopUser.setShopId(memberVo.getShopId().toString()); + tbShopUser.setUserId(tbUserInfo.getId().toString()); + tbShopUser.setMiniOpenId(tbUserInfo.getMiniAppOpenId()); + tbShopUser.setCreatedAt(System.currentTimeMillis()); + tbShopUser.setUpdatedAt(System.currentTimeMillis()); + shopUserMapper.insertSelective(tbShopUser); + } + return Result.success(CodeEnum.SUCCESS); + } + + public Result upVipPhont(OpenMemberVo memberVo) { + TbShopUser shopUser = new TbShopUser(); + shopUser.setId(memberVo.getId().toString()); + shopUser.setTelephone(memberVo.getTelephone()); + shopUserMapper.updateByPrimaryKeySelective(shopUser); return Result.success(CodeEnum.SUCCESS); } } From a316be436bf3624d73139f0119f9f9684394cd67 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Tue, 20 Aug 2024 11:10:26 +0800 Subject: [PATCH 04/21] =?UTF-8?q?=E5=BC=80=E9=80=9A=E4=BC=9A=E5=91=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chaozhanggui/system/cashierservice/service/UserService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/UserService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/UserService.java index 85f1220..fe9aa67 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/UserService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/UserService.java @@ -292,7 +292,7 @@ public class UserService { tbShopUser.setCode(dynamicCode); tbShopUser.setTelephone(memberVo.getTelephone()); tbShopUser.setAmount(BigDecimal.ZERO); - tbShopUser.setIsVip(Byte.parseByte("0")); + tbShopUser.setIsVip(Byte.parseByte("1")); tbShopUser.setCreditAmount(BigDecimal.ZERO); tbShopUser.setConsumeAmount(BigDecimal.ZERO); tbShopUser.setConsumeNumber(0); From b34eaa2894fe4f19c3e76ff759a6f047dce72a4f 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: Tue, 20 Aug 2024 15:53:09 +0800 Subject: [PATCH 05/21] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=80=97=E6=9D=90?= =?UTF-8?q?=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cashierservice/dao/TbConsInfoMapper.java | 27 +++ .../cashierservice/dao/TbProskuConMapper.java | 37 ++++ .../cashierservice/entity/TbConsInfo.java | 169 +++++++++++++++ .../cashierservice/entity/TbProskuCon.java | 89 ++++++++ .../cashierservice/service/CartService.java | 26 +++ .../resources/mapper/TbConsInfoMapper.xml | 194 ++++++++++++++++++ .../resources/mapper/TbProskuConMapper.xml | 155 ++++++++++++++ 7 files changed, 697 insertions(+) create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/dao/TbConsInfoMapper.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProskuConMapper.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/TbConsInfo.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProskuCon.java create mode 100644 src/main/resources/mapper/TbConsInfoMapper.xml create mode 100644 src/main/resources/mapper/TbProskuConMapper.xml diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbConsInfoMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbConsInfoMapper.java new file mode 100644 index 0000000..f37b6d3 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbConsInfoMapper.java @@ -0,0 +1,27 @@ +package com.chaozhanggui.system.cashierservice.dao; + +import com.chaozhanggui.system.cashierservice.entity.TbConsInfo; +import org.apache.ibatis.annotations.Mapper; +import org.springframework.stereotype.Component; + +import java.util.List; + +@Component +@Mapper +public interface TbConsInfoMapper { + int deleteByPrimaryKey(Integer id); + + int insert(TbConsInfo record); + + int insertSelective(TbConsInfo record); + + TbConsInfo selectByPrimaryKey(Integer id); + + int updateByPrimaryKeySelective(TbConsInfo record); + + int updateByPrimaryKey(TbConsInfo record); + + int countAll(); + + List selectAllInfo(); +} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProskuConMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProskuConMapper.java new file mode 100644 index 0000000..ceca300 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProskuConMapper.java @@ -0,0 +1,37 @@ +package com.chaozhanggui.system.cashierservice.dao; + +import com.chaozhanggui.system.cashierservice.entity.TbProskuCon; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Component; + +import java.util.List; + +@Component +@Mapper +public interface TbProskuConMapper { + int deleteByPrimaryKey(Integer id); + + int insert(TbProskuCon record); + + int insertSelective(TbProskuCon record); + + TbProskuCon selectByPrimaryKey(Integer id); + + int updateByPrimaryKeySelective(TbProskuCon record); + + int updateByPrimaryKey(TbProskuCon record); + + + List selectBySkuIdAndShopId(@Param("skuId") Integer skuId, @Param("shopId") Integer shopId); + List selectBySkuIdAndShopIdAngCheck(@Param("skuId") Integer skuId, @Param("shopId") Integer shopId); + + + List selectIdBySkuIdAndShopId(@Param("skuId") Integer skuId, @Param("shopId") Integer shopId); + + List selectByShopIdAndSkuIdAndProductId(@Param("skuId") Integer skuId, @Param("shopId") Integer shopId,@Param("productId") Integer productId); + List selectByShopIdAndSkuIdAndProductIdAndCheck(@Param("skuId") Integer skuId, @Param("shopId") Integer shopId,@Param("productId") Integer productId); + + + +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbConsInfo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbConsInfo.java new file mode 100644 index 0000000..f3b3d99 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbConsInfo.java @@ -0,0 +1,169 @@ +package com.chaozhanggui.system.cashierservice.entity; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +public class TbConsInfo implements Serializable { + private Integer id; + + private Integer shopId; + + private Integer conTypeId; + + private String conTypeName; + + private String conCode; + + private String conName; + + private BigDecimal stockNumber; + + private String conUnit; + + private BigDecimal lasterInStock; + + private BigDecimal conWarning; + + private BigDecimal stockConsume; + + private String status; + + private BigDecimal price; + + private Date createTime; + + private Date updateTime; + + private String isCheck; + + private static final long serialVersionUID = 1L; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getShopId() { + return shopId; + } + + public void setShopId(Integer shopId) { + this.shopId = shopId; + } + + public Integer getConTypeId() { + return conTypeId; + } + + public void setConTypeId(Integer conTypeId) { + this.conTypeId = conTypeId; + } + + public String getConTypeName() { + return conTypeName; + } + + public void setConTypeName(String conTypeName) { + this.conTypeName = conTypeName == null ? null : conTypeName.trim(); + } + + public String getConCode() { + return conCode; + } + + public void setConCode(String conCode) { + this.conCode = conCode == null ? null : conCode.trim(); + } + + public String getConName() { + return conName; + } + + public void setConName(String conName) { + this.conName = conName == null ? null : conName.trim(); + } + + public BigDecimal getStockNumber() { + return stockNumber; + } + + public void setStockNumber(BigDecimal stockNumber) { + this.stockNumber = stockNumber; + } + + public String getConUnit() { + return conUnit; + } + + public void setConUnit(String conUnit) { + this.conUnit = conUnit == null ? null : conUnit.trim(); + } + + public BigDecimal getLasterInStock() { + return lasterInStock; + } + + public void setLasterInStock(BigDecimal lasterInStock) { + this.lasterInStock = lasterInStock; + } + + public BigDecimal getConWarning() { + return conWarning; + } + + public void setConWarning(BigDecimal conWarning) { + this.conWarning = conWarning; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public BigDecimal getStockConsume() { + return stockConsume; + } + + public void setStockConsume(BigDecimal stockConsume) { + this.stockConsume = stockConsume; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public BigDecimal getPrice() { + return price; + } + + public void setPrice(BigDecimal price) { + this.price = price; + } + + public String getIsCheck() { + return isCheck; + } + + public void setIsCheck(String isCheck) { + this.isCheck = isCheck; + } +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProskuCon.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProskuCon.java new file mode 100644 index 0000000..e5912fa --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbProskuCon.java @@ -0,0 +1,89 @@ +package com.chaozhanggui.system.cashierservice.entity; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +public class TbProskuCon implements Serializable { + private Integer id; + + private Integer shopId; + + private Integer productId; + + private Integer productSkuId; + + private Integer conInfoId; + + private BigDecimal surplusStock; + + private String status; + + private Date createTime; + + private static final long serialVersionUID = 1L; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getShopId() { + return shopId; + } + + public void setShopId(Integer shopId) { + this.shopId = shopId; + } + + public Integer getProductId() { + return productId; + } + + public void setProductId(Integer productId) { + this.productId = productId; + } + + public Integer getProductSkuId() { + return productSkuId; + } + + public void setProductSkuId(Integer productSkuId) { + this.productSkuId = productSkuId; + } + + public Integer getConInfoId() { + return conInfoId; + } + + public void setConInfoId(Integer conInfoId) { + this.conInfoId = conInfoId; + } + + public BigDecimal getSurplusStock() { + return surplusStock; + } + + public void setSurplusStock(BigDecimal surplusStock) { + this.surplusStock = surplusStock; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status == null ? null : status.trim(); + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } +} \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java index 2bdda19..1985f1a 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java @@ -85,6 +85,13 @@ public class CartService { private final RedisTemplate redisTemplate; + + @Autowired + private TbProskuConMapper tbProskuConMapper; + + @Autowired + TbConsInfoMapper tbConsInfoMapper; + public CartService(TbUserShopMsgMapper tbUserShopMsgMapper, WechatUtil wechatUtil, WxAccountUtil wxAccountUtil, TbShopOpenIdMapper shopOpenIdMapper, ProductService productService, TbProductMapper tbProductMapper, RedisTemplate redisTemplate) { this.tbUserShopMsgMapper = tbUserShopMsgMapper; this.wechatUtil = wechatUtil; @@ -171,6 +178,25 @@ public class CartService { } } } + + + + List proskuConList= tbProskuConMapper.selectByShopIdAndSkuIdAndProductId(Integer.valueOf(skuId),Integer.valueOf(shopId),Integer.valueOf(productId)); + if(Objects.nonNull(proskuConList)&&proskuConList.size()>0){ + for (TbProskuCon proskuCon : proskuConList) { + if("1".equals(proskuCon.getStatus())){ + TbConsInfo consInfo= tbConsInfoMapper.selectByPrimaryKey(proskuCon.getConInfoId()); + if("1".equals(consInfo.getIsCheck())){ + if(N.gt(proskuCon.getSurplusStock(),consInfo.getStockNumber().abs().subtract(consInfo.getStockConsume().abs()))){ + return Result.fail("商品:".concat(tbProduct.getName()).concat("对应的:").concat(consInfo.getConName()).concat("耗材不足")); + } + } + } + } + } + + + JSONArray jsonArray = new JSONArray(); BigDecimal amount = BigDecimal.ZERO; try{ diff --git a/src/main/resources/mapper/TbConsInfoMapper.xml b/src/main/resources/mapper/TbConsInfoMapper.xml new file mode 100644 index 0000000..ccd5270 --- /dev/null +++ b/src/main/resources/mapper/TbConsInfoMapper.xml @@ -0,0 +1,194 @@ + + + + + + + + + + + + + + + + + + + + + + + + + id, shop_id, con_type_id, con_type_name, con_code, con_name, stock_number,price,stock_consume,status, con_unit, + laster_in_stock, con_warning, create_time, update_time,is_check + + + + delete from tb_cons_info + where id = #{id,jdbcType=INTEGER} + + + insert into tb_cons_info (id, shop_id, con_type_id, + con_type_name, con_code, con_name, + stock_number, con_unit, laster_in_stock, + con_warning, create_time, update_time + ) + values (#{id,jdbcType=INTEGER}, #{shopId,jdbcType=INTEGER}, #{conTypeId,jdbcType=INTEGER}, + #{conTypeName,jdbcType=VARCHAR}, #{conCode,jdbcType=VARCHAR}, #{conName,jdbcType=VARCHAR}, + #{stockNumber,jdbcType=DECIMAL}, #{conUnit,jdbcType=VARCHAR}, #{lasterInStock,jdbcType=DECIMAL}, + #{conWarning,jdbcType=DECIMAL}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP} + ) + + + insert into tb_cons_info + + + id, + + + shop_id, + + + con_type_id, + + + con_type_name, + + + con_code, + + + con_name, + + + stock_number, + + + con_unit, + + + laster_in_stock, + + + con_warning, + + + create_time, + + + update_time, + + + + + #{id,jdbcType=INTEGER}, + + + #{shopId,jdbcType=INTEGER}, + + + #{conTypeId,jdbcType=INTEGER}, + + + #{conTypeName,jdbcType=VARCHAR}, + + + #{conCode,jdbcType=VARCHAR}, + + + #{conName,jdbcType=VARCHAR}, + + + #{stockNumber,jdbcType=DECIMAL}, + + + #{conUnit,jdbcType=VARCHAR}, + + + #{lasterInStock,jdbcType=DECIMAL}, + + + #{conWarning,jdbcType=DECIMAL}, + + + #{createTime,jdbcType=TIMESTAMP}, + + + #{updateTime,jdbcType=TIMESTAMP}, + + + + + update tb_cons_info + + + shop_id = #{shopId,jdbcType=INTEGER}, + + + con_type_id = #{conTypeId,jdbcType=INTEGER}, + + + con_type_name = #{conTypeName,jdbcType=VARCHAR}, + + + con_code = #{conCode,jdbcType=VARCHAR}, + + + con_name = #{conName,jdbcType=VARCHAR}, + + + stock_number = #{stockNumber,jdbcType=DECIMAL}, + + + con_unit = #{conUnit,jdbcType=VARCHAR}, + + + laster_in_stock = #{lasterInStock,jdbcType=DECIMAL}, + + + con_warning = #{conWarning,jdbcType=DECIMAL}, + + + create_time = #{createTime,jdbcType=TIMESTAMP}, + + + update_time = #{updateTime,jdbcType=TIMESTAMP}, + + + where id = #{id,jdbcType=INTEGER} + + + update tb_cons_info + set shop_id = #{shopId,jdbcType=INTEGER}, + con_type_id = #{conTypeId,jdbcType=INTEGER}, + con_type_name = #{conTypeName,jdbcType=VARCHAR}, + con_code = #{conCode,jdbcType=VARCHAR}, + con_name = #{conName,jdbcType=VARCHAR}, + stock_number = #{stockNumber,jdbcType=DECIMAL}, + con_unit = #{conUnit,jdbcType=VARCHAR}, + laster_in_stock = #{lasterInStock,jdbcType=DECIMAL}, + con_warning = #{conWarning,jdbcType=DECIMAL}, + create_time = #{createTime,jdbcType=TIMESTAMP}, + update_time = #{updateTime,jdbcType=TIMESTAMP}, + stock_consume=#{stockConsume,jdbcType=DECIMAL} + where id = #{id,jdbcType=INTEGER} + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/TbProskuConMapper.xml b/src/main/resources/mapper/TbProskuConMapper.xml new file mode 100644 index 0000000..0c4f495 --- /dev/null +++ b/src/main/resources/mapper/TbProskuConMapper.xml @@ -0,0 +1,155 @@ + + + + + + + + + + + + + + + id, shop_id,product_id ,product_sku_id, con_info_id, surplus_stock, status, create_time + + + + delete from tb_prosku_con + where id = #{id,jdbcType=INTEGER} + + + insert into tb_prosku_con (id, shop_id, product_sku_id, + con_info_id, surplus_stock, status, + create_time) + values (#{id,jdbcType=INTEGER}, #{shopId,jdbcType=INTEGER}, #{productSkuId,jdbcType=INTEGER}, + #{conInfoId,jdbcType=INTEGER}, #{surplusStock,jdbcType=DECIMAL}, #{status,jdbcType=VARCHAR}, + #{createTime,jdbcType=TIMESTAMP}) + + + insert into tb_prosku_con + + + id, + + + shop_id, + + + product_sku_id, + + + con_info_id, + + + surplus_stock, + + + status, + + + create_time, + + + + + #{id,jdbcType=INTEGER}, + + + #{shopId,jdbcType=INTEGER}, + + + #{productSkuId,jdbcType=INTEGER}, + + + #{conInfoId,jdbcType=INTEGER}, + + + #{surplusStock,jdbcType=DECIMAL}, + + + #{status,jdbcType=VARCHAR}, + + + #{createTime,jdbcType=TIMESTAMP}, + + + + + update tb_prosku_con + + + shop_id = #{shopId,jdbcType=INTEGER}, + + + product_sku_id = #{productSkuId,jdbcType=INTEGER}, + + + con_info_id = #{conInfoId,jdbcType=INTEGER}, + + + surplus_stock = #{surplusStock,jdbcType=DECIMAL}, + + + status = #{status,jdbcType=VARCHAR}, + + + create_time = #{createTime,jdbcType=TIMESTAMP}, + + + where id = #{id,jdbcType=INTEGER} + + + update tb_prosku_con + set shop_id = #{shopId,jdbcType=INTEGER}, + product_sku_id = #{productSkuId,jdbcType=INTEGER}, + con_info_id = #{conInfoId,jdbcType=INTEGER}, + surplus_stock = #{surplusStock,jdbcType=DECIMAL}, + status = #{status,jdbcType=VARCHAR}, + create_time = #{createTime,jdbcType=TIMESTAMP} + where id = #{id,jdbcType=INTEGER} + + + + + + + + + + + + + + + From 9fcee207d53dbc89895e0fba90fd5112130ffb1d Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Wed, 21 Aug 2024 09:28:40 +0800 Subject: [PATCH 06/21] =?UTF-8?q?=E5=95=86=E5=93=81=E5=88=97=E8=A1=A8=20?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E5=BA=93=E5=AD=98=20=E4=BB=A5=E5=8F=8A=20?= =?UTF-8?q?=E8=80=97=E6=9D=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/ProductService.java | 82 +++++++++++-------- 1 file changed, 49 insertions(+), 33 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java index 8e844ad..83bd637 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java @@ -75,6 +75,12 @@ public class ProductService { @Autowired private TbUserInfoMapper tbUserInfoMapper; + @Autowired + private TbProskuConMapper tbProskuConMapper; + + @Autowired + private TbConsInfoMapper tbConsInfoMapper; + public Result queryShopIdByTableCode(String userId, String openId, String code, String lat, String lng) { if (StringUtils.isBlank(code)) return Result.fail("桌码信息为空"); if (StringUtils.isBlank(lat) || lat.equals("undefined")) { @@ -369,9 +375,9 @@ public class ProductService { it.setCartNumber("0"); List tbProductSkus = tbProductSkuMapper.selectGroundingByProId(it.getId()); TbProductSkuResult skuResult = tbProductSkuResultMapper.selectByPrimaryKey(it.getId()); + //判断库存及耗材 + checkPauseSale(it,tbProductSkus); - // 上下架对应的sku -// HashSet specSet = new HashSet<>(); AtomicDouble sum = new AtomicDouble(0.0); BigDecimal lowerPrice = null; for (TbProductSku item : tbProductSkus) { @@ -381,11 +387,6 @@ public class ProductService { if (lowerPrice == null || lowerPrice.compareTo(item.getSalePrice()) > 0) { lowerPrice = item.getSalePrice(); } - - String specSnap = item.getSpecSnap(); -// if (specSnap != null) { -// specSet.addAll(Arrays.asList(specSnap.split(","))); -// } } //销量 it.setStockNumber(sum.intValue()); @@ -394,32 +395,6 @@ public class ProductService { } //售价 it.setLowPrice(lowerPrice); -// String tagSnap = skuResult != null ? skuResult.getTagSnap() : null; -// if (tagSnap != null) { -// JSONArray tagSnaps = JSONObject.parseArray(tagSnap); -// JSONObject snapJSON; -// JSONArray finalSnap = new JSONArray(); -// for (Object snap : tagSnaps) { -// snapJSON = (JSONObject) snap; -// String values = snapJSON.getString("value"); -// String finalValues = ""; -// if (StrUtil.isNotBlank(values)) { -// String[] valueList = values.split(","); -// for (String value : valueList) { -// if (specSet.contains(value)) { -// finalValues = finalValues + (value) + ","; -// } -// } -// if (StrUtil.isNotBlank(finalValues)) { -// finalValues = StrUtil.removeSuffix(finalValues, ","); -// snapJSON.put("value", finalValues); -// finalSnap.add(snapJSON); -// } -// } -// } -// //sku Result -// skuResult.setTagSnap(finalSnap.toJSONString()); -// } it.setProductSkuResult(skuResult); }); return products; @@ -428,6 +403,47 @@ public class ProductService { } } + public void checkPauseSale(TbProduct tbProduct, List skus) { + if (tbProduct.getIsStock() == 1) {//库存开关 1开启 + if (Integer.valueOf(tbProduct.getIsDistribute()).equals(1)) {//共享库存 1开启 + if (tbProduct.getStockNumber() != null && tbProduct.getStockNumber() <= 0) { + tbProduct.setIsPauseSale(Byte.parseByte("1"));//售罄 1暂停 + } + } else { + if (!tbProduct.getTypeEnum().equals("sku")) { + if (skus.stream().anyMatch(sku -> sku.getStockNumber() != null && sku.getStockNumber() <= 0)) + tbProduct.setIsPauseSale(Byte.parseByte("1"));//售罄 1暂停 + } else { + skus.removeIf(sku -> sku.getStockNumber() != null && sku.getStockNumber() <= 0); + if (CollectionUtils.isEmpty(skus)) { + tbProduct.setIsPauseSale(Byte.parseByte("1"));//售罄 1暂停 + return; + } + Iterator iterator = skus.iterator(); + while (iterator.hasNext()) { + TbProductSku tbProductSku = iterator.next(); + List proskuConList = tbProskuConMapper.selectByShopIdAndSkuIdAndProductId(Integer.valueOf(tbProductSku.getId()), Integer.valueOf(tbProductSku.getShopId()), Integer.valueOf(tbProductSku.getProductId())); + if (Objects.nonNull(proskuConList) && proskuConList.size() > 0) { + for (TbProskuCon proskuCon : proskuConList) { + if ("1".equals(proskuCon.getStatus())) { + TbConsInfo consInfo = tbConsInfoMapper.selectByPrimaryKey(proskuCon.getConInfoId()); + if ("1".equals(consInfo.getIsCheck())) { + if (N.gt(proskuCon.getSurplusStock(), consInfo.getStockNumber().abs().subtract(consInfo.getStockConsume().abs()))) { + iterator.remove(); + } + } + } + } + } + } + if (CollectionUtils.isEmpty(skus)) { + tbProduct.setIsPauseSale(Byte.parseByte("1"));//售罄 1暂停 + } + } + } + } + } + public Result queryProductSku(String code, String shopId, String productId, String spec_tag) { if (ObjectUtil.isEmpty(shopId) || ObjectUtil.isEmpty(productId)) { From fbb69e60d95002442c35ad2704a80288040303c6 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Wed, 21 Aug 2024 09:29:50 +0800 Subject: [PATCH 07/21] =?UTF-8?q?=E4=BC=9A=E5=91=98=20=E5=85=85=E5=80=BC?= =?UTF-8?q?=E6=B4=BB=E5=8A=A8=20=E5=A5=96=E5=8A=B1=20=E8=B5=A0=E9=80=81?= =?UTF-8?q?=E5=95=86=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dao/TbActivateGiveRecordMapper.java | 66 +++++++++ .../cashierservice/dao/TbActivateMapper.java | 12 +- .../dao/TbActivateProductMapper.java | 67 ++++++++++ .../cashierservice/entity/TbActivate.java | 11 ++ .../entity/TbActivateGiveRecord.java | 126 ++++++++++++++++++ .../entity/TbActivateProduct.java | 83 ++++++++++++ .../cashierservice/service/PayService.java | 77 +++++------ .../service/TbActivateGiveRecordService.java | 45 +++++++ .../service/TbActivateProductService.java | 46 +++++++ .../impl/TbActivateGiveRecordServiceImpl.java | 67 ++++++++++ .../impl/TbActivateProductServiceImpl.java | 67 ++++++++++ .../mapper/TbActivateGiveRecordMapper.xml | 123 +++++++++++++++++ .../resources/mapper/TbActivateMapper.xml | 15 ++- .../mapper/TbActivateProductMapper.xml | 105 +++++++++++++++ .../resources/mapper/TbShopUserFlowMapper.xml | 2 +- 15 files changed, 856 insertions(+), 56 deletions(-) create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateGiveRecordMapper.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateProductMapper.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivateGiveRecord.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivateProduct.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/service/TbActivateGiveRecordService.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/service/TbActivateProductService.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbActivateGiveRecordServiceImpl.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbActivateProductServiceImpl.java create mode 100644 src/main/resources/mapper/TbActivateGiveRecordMapper.xml create mode 100644 src/main/resources/mapper/TbActivateProductMapper.xml diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateGiveRecordMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateGiveRecordMapper.java new file mode 100644 index 0000000..96709b7 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateGiveRecordMapper.java @@ -0,0 +1,66 @@ +package com.chaozhanggui.system.cashierservice.dao; + +import com.chaozhanggui.system.cashierservice.entity.TbActivateGiveRecord; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 活动商品赠送表(TbActivateGiveRecord)表数据库访问层 + * + * @author ww + * @since 2024-08-20 15:20:43 + */ +public interface TbActivateGiveRecordMapper { + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + TbActivateGiveRecord queryById(Integer id); + + /** + * 查询数据 + * + * @param tbActivateGiveRecord 查询条件 + * @return 对象列表 + */ + List queryAll(TbActivateGiveRecord tbActivateGiveRecord); + + + /** + * 新增数据 + * + * @param tbActivateGiveRecord 实例对象 + * @return 影响行数 + */ + int insert(TbActivateGiveRecord tbActivateGiveRecord); + + /** + * 批量新增数据(MyBatis原生foreach方法) + * + * @param entities List 实例对象列表 + * @return 影响行数 + */ + int insertBatch(@Param("entities") List entities); + + /** + * 修改数据 + * + * @param tbActivateGiveRecord 实例对象 + * @return 影响行数 + */ + int update(TbActivateGiveRecord tbActivateGiveRecord); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 影响行数 + */ + int deleteById(Integer id); + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateMapper.java index 2a458b2..34b3888 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateMapper.java @@ -11,19 +11,19 @@ import java.util.List; @Component @Mapper public interface TbActivateMapper { - int deleteByPrimaryKey(Integer id); +// int deleteByPrimaryKey(Integer id); - int insert(TbActivate record); +// int insert(TbActivate record); - int insertSelective(TbActivate record); +// int insertSelective(TbActivate record); TbActivate selectByPrimaryKey(Integer id); - int updateByPrimaryKeySelective(TbActivate record); +// int updateByPrimaryKeySelective(TbActivate record); - int updateByPrimaryKey(TbActivate record); +// int updateByPrimaryKey(TbActivate record); TbActivate selectByAmount(@Param("shopId") String shopId,@Param("amount") BigDecimal amount); - List selectByShpopId(String shopId); + List selectByShopId(String shopId); } \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateProductMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateProductMapper.java new file mode 100644 index 0000000..59077ab --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateProductMapper.java @@ -0,0 +1,67 @@ +package com.chaozhanggui.system.cashierservice.dao; + +import com.chaozhanggui.system.cashierservice.entity.TbActivateProduct; +import org.apache.ibatis.annotations.Param; +import java.util.List; + +/** + * 活动赠送商品表(TbActivateProduct)表数据库访问层 + * + * @author ww + * @since 2024-08-20 15:14:55 + */ +public interface TbActivateProductMapper { + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + TbActivateProduct queryById(Integer id); + + /** + * 查询数据 + * + * @param tbActivateProduct 查询条件 + * @return 对象列表 + */ + List queryAll(TbActivateProduct tbActivateProduct); + + List queryAllByActivateId(Integer activateId); + + + /** + * 新增数据 + * + * @param tbActivateProduct 实例对象 + * @return 影响行数 + */ + int insert(TbActivateProduct tbActivateProduct); + + /** + * 批量新增数据(MyBatis原生foreach方法) + * + * @param entities List 实例对象列表 + * @return 影响行数 + */ + int insertBatch(@Param("entities") List entities); + + /** + * 修改数据 + * + * @param tbActivateProduct 实例对象 + * @return 影响行数 + */ + int update(TbActivateProduct tbActivateProduct); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 影响行数 + */ + int deleteById(Integer id); + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivate.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivate.java index c223bfc..480d9b3 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivate.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivate.java @@ -18,6 +18,9 @@ public class TbActivate implements Serializable { private String isDel; + //是否赠送商品 0否 1是 + private Integer isGiftPro; + private static final long serialVersionUID = 1L; public Integer getId() { @@ -75,4 +78,12 @@ public class TbActivate implements Serializable { public void setIsDel(String isDel) { this.isDel = isDel == null ? null : isDel.trim(); } + + public Integer getIsGiftPro() { + return isGiftPro; + } + + public void setIsGiftPro(Integer isGiftPro) { + this.isGiftPro = isGiftPro; + } } \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivateGiveRecord.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivateGiveRecord.java new file mode 100644 index 0000000..e643810 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivateGiveRecord.java @@ -0,0 +1,126 @@ +package com.chaozhanggui.system.cashierservice.entity; + +import java.util.Date; +import java.io.Serializable; + +/** + * 活动商品赠送表(TbActivateGiveRecord)实体类 + * + * @author ww + * @since 2024-08-20 15:20:43 + */ +public class TbActivateGiveRecord implements Serializable { + private static final long serialVersionUID = -53463432636369401L; + + private Integer id; + /** + * 会员id + */ + private Integer vipUserId; + /** + * 商品id + */ + private Integer proId; + /** + * 赠送数量 + */ + private Integer num; + /** + * 店铺id + */ + private Integer shopId; + private Integer sourceFlowId; + /** + * 来源活动id + */ + private Integer sourceActId; + + private Date createTime; + + private Date updateTime; + + public TbActivateGiveRecord(Integer vipUserId, Integer proId, Integer num, Integer shopId, Integer sourceActId,Integer sourceFlowId) { + this.vipUserId = vipUserId; + this.proId = proId; + this.num = num; + this.shopId = shopId; + this.sourceActId = sourceActId; + this.sourceFlowId = sourceFlowId; + this.createTime=new Date(); + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getVipUserId() { + return vipUserId; + } + + public void setVipUserId(Integer vipUserId) { + this.vipUserId = vipUserId; + } + + public Integer getProId() { + return proId; + } + + public void setProId(Integer proId) { + this.proId = proId; + } + + public Integer getNum() { + return num; + } + + public void setNum(Integer num) { + this.num = num; + } + + public Integer getShopId() { + return shopId; + } + + public void setShopId(Integer shopId) { + this.shopId = shopId; + } + + + public Integer getSourceFlowId() { + return sourceFlowId; + } + + public void setSourceFlowId(Integer sourceFlowId) { + this.sourceFlowId = sourceFlowId; + } + + public Integer getSourceActId() { + return sourceActId; + } + + public void setSourceActId(Integer sourceActId) { + this.sourceActId = sourceActId; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivateProduct.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivateProduct.java new file mode 100644 index 0000000..d8383dd --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivateProduct.java @@ -0,0 +1,83 @@ +package com.chaozhanggui.system.cashierservice.entity; + +import java.util.Date; +import java.io.Serializable; + +/** + * 活动赠送商品表(TbActivateProduct)实体类 + * + * @author ww + * @since 2024-08-20 15:15:01 + */ +public class TbActivateProduct implements Serializable { + private static final long serialVersionUID = 592370528166603965L; + + private Integer id; +/** + * 活动Id + */ + private Integer activateId; +/** + * 商品id + */ + private Integer productId; +/** + * 数量 + */ + private Integer num; + + private Date createTime; + + private Date updateTime; + + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getActivateId() { + return activateId; + } + + public void setActivateId(Integer activateId) { + this.activateId = activateId; + } + + public Integer getProductId() { + return productId; + } + + public void setProductId(Integer productId) { + this.productId = productId; + } + + public Integer getNum() { + return num; + } + + public void setNum(Integer num) { + this.num = num; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java index cf77531..f765809 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java @@ -71,6 +71,10 @@ public class PayService { @Autowired TbShopPayTypeMapper tbShopPayTypeMapper; + @Autowired + private TbActivateProductMapper actProductMapper; + @Autowired + private TbActivateGiveRecordMapper actGiveRecordMapper; @Autowired private TbShopSongOrderMapper tbShopSongOrderMapper; @@ -982,7 +986,7 @@ public class PayService { public Result getActivate(String shopId, int page, int pageSize) { PageHelper.startPage(page, pageSize); - List list = tbActivateMapper.selectByShpopId(shopId); + List list = tbActivateMapper.selectByShopId(shopId); PageInfo pageInfo = new PageInfo(list); return Result.success(CodeEnum.SUCCESS, pageInfo); } @@ -1079,42 +1083,53 @@ public class PayService { flow.setBalance(tbShopUser.getAmount()); flow.setCreateTime(new Date()); tbShopUserFlowMapper.insert(flow); - TbActivate activate = tbActivateMapper.selectByAmount(tbShopUser.getShopId(), memberIn.getAmount()); + //会员活动 + giveActivate(tbShopUser,memberIn.getAmount(),flow.getId()); + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("shopId", memberIn.getShopId()); + jsonObject.put("type", "wxMemberIn"); + jsonObject.put("amount", memberIn.getAmount()); + producer.putOrderCollect(jsonObject.toJSONString()); + return "success"; + } + + public void giveActivate(TbShopUser tbShopUser, BigDecimal memAmount,Integer flowId){ + TbActivate activate = tbActivateMapper.selectByAmount(tbShopUser.getShopId(), memAmount); if (ObjectUtil.isNotEmpty(activate) && ObjectUtil.isNotNull(activate)) { + if (activate.getIsGiftPro() != null && activate.getIsGiftPro() == 1) { + List tbActivateProducts = actProductMapper.queryAllByActivateId(activate.getId()); + List actGiveRecords = new ArrayList<>(); + for (TbActivateProduct actPro : tbActivateProducts) { + TbActivateGiveRecord record = new TbActivateGiveRecord(Integer.valueOf(tbShopUser.getId()), actPro.getProductId(), actPro.getNum(), Integer.valueOf(tbShopUser.getShopId()), activate.getId(),flowId); + actGiveRecords.add(record); + } + actGiveRecordMapper.insertBatch(actGiveRecords); + } BigDecimal amount = BigDecimal.ZERO; switch (activate.getHandselType()) { case "GD": amount = activate.getHandselNum(); break; case "RATIO": - amount = memberIn.getAmount().multiply(activate.getHandselNum()); + amount = memAmount.multiply(activate.getHandselNum()); break; } - tbShopUser.setAmount(tbShopUser.getAmount().add(amount)); tbShopUser.setUpdatedAt(System.currentTimeMillis()); tbShopUserMapper.updateByPrimaryKeySelective(tbShopUser); - flow = new TbShopUserFlow(); + TbShopUserFlow flow = new TbShopUserFlow(); flow.setShopUserId(Integer.valueOf(tbShopUser.getId())); flow.setBizCode("scanMemberAwardIn"); - flow.setBizName("会员充值奖励"); + flow.setBizName("充值活动奖励"); flow.setType("+"); flow.setAmount(amount); flow.setBalance(tbShopUser.getAmount()); flow.setCreateTime(new Date()); tbShopUserFlowMapper.insert(flow); - - - JSONObject jsonObject = new JSONObject(); - jsonObject.put("shopId", memberIn.getShopId()); - jsonObject.put("type", "wxMemberIn"); - jsonObject.put("amount", memberIn.getAmount()); - producer.putOrderCollect(jsonObject.toJSONString()); - } - return "success"; } @@ -1161,36 +1176,8 @@ public class PayService { flow.setBalance(tbShopUser.getAmount()); flow.setCreateTime(new Date()); tbShopUserFlowMapper.insert(flow); - - TbActivate activate = tbActivateMapper.selectByAmount(tbShopUser.getShopId(), memberIn.getAmount()); - if (ObjectUtil.isNotEmpty(activate) && ObjectUtil.isNotNull(activate)) { - BigDecimal amount = BigDecimal.ZERO; - switch (activate.getHandselType()) { - case "GD": - amount = activate.getHandselNum(); - break; - case "RATIO": - amount = memberIn.getAmount().multiply(activate.getHandselNum()); - break; - } - - - tbShopUser.setAmount(tbShopUser.getAmount().add(amount)); - tbShopUser.setUpdatedAt(System.currentTimeMillis()); - tbShopUserMapper.updateByPrimaryKeySelective(tbShopUser); - - flow = new TbShopUserFlow(); - flow.setShopUserId(Integer.valueOf(tbShopUser.getId())); - flow.setBizCode("scanMemberAwardIn"); - flow.setType("+"); - flow.setBizName("充值活动奖励"); - flow.setAmount(amount); - flow.setBalance(tbShopUser.getAmount()); - flow.setCreateTime(new Date()); - tbShopUserFlowMapper.insert(flow); - } - - + //会员活动 + giveActivate(tbShopUser,memberIn.getAmount(),flow.getId()); JSONObject jsonObject = new JSONObject(); jsonObject.put("shopId", memberIn.getShopId()); jsonObject.put("type", "wxMemberIn"); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/TbActivateGiveRecordService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbActivateGiveRecordService.java new file mode 100644 index 0000000..d10894b --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbActivateGiveRecordService.java @@ -0,0 +1,45 @@ +package com.chaozhanggui.system.cashierservice.service; + +import com.chaozhanggui.system.cashierservice.entity.TbActivateGiveRecord; + +/** + * 活动商品赠送表(TbActivateGiveRecord)表服务接口 + * + * @author ww + * @since 2024-08-20 15:20:43 + */ +public interface TbActivateGiveRecordService { + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + TbActivateGiveRecord queryById(Integer id); + + /** + * 新增数据 + * + * @param tbActivateGiveRecord 实例对象 + * @return 实例对象 + */ + TbActivateGiveRecord insert(TbActivateGiveRecord tbActivateGiveRecord); + + /** + * 修改数据 + * + * @param tbActivateGiveRecord 实例对象 + * @return 实例对象 + */ + TbActivateGiveRecord update(TbActivateGiveRecord tbActivateGiveRecord); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 是否成功 + */ + boolean deleteById(Integer id); + +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/TbActivateProductService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbActivateProductService.java new file mode 100644 index 0000000..675e184 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbActivateProductService.java @@ -0,0 +1,46 @@ +package com.chaozhanggui.system.cashierservice.service; + + +import com.chaozhanggui.system.cashierservice.entity.TbActivateProduct; + +/** + * 活动赠送商品表(TbActivateProduct)表服务接口 + * + * @author ww + * @since 2024-08-20 15:15:01 + */ +public interface TbActivateProductService { + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + TbActivateProduct queryById(Integer id); + + /** + * 新增数据 + * + * @param tbActivateProduct 实例对象 + * @return 实例对象 + */ + TbActivateProduct insert(TbActivateProduct tbActivateProduct); + + /** + * 修改数据 + * + * @param tbActivateProduct 实例对象 + * @return 实例对象 + */ + TbActivateProduct update(TbActivateProduct tbActivateProduct); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 是否成功 + */ + boolean deleteById(Integer id); + +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbActivateGiveRecordServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbActivateGiveRecordServiceImpl.java new file mode 100644 index 0000000..1050428 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbActivateGiveRecordServiceImpl.java @@ -0,0 +1,67 @@ +package com.chaozhanggui.system.cashierservice.service.impl; + +import com.chaozhanggui.system.cashierservice.entity.TbActivateGiveRecord; +import com.chaozhanggui.system.cashierservice.dao.TbActivateGiveRecordMapper; +import com.chaozhanggui.system.cashierservice.service.TbActivateGiveRecordService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + +/** + * 活动商品赠送表(TbActivateGiveRecord)表服务实现类 + * + * @author ww + * @since 2024-08-20 15:20:43 + */ +@Service("tbActivateGiveRecordService") +public class TbActivateGiveRecordServiceImpl implements TbActivateGiveRecordService { + @Resource + private TbActivateGiveRecordMapper tbActivateGiveRecordMapper; + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + @Override + public TbActivateGiveRecord queryById(Integer id) { + return this.tbActivateGiveRecordMapper.queryById(id); + } + + + /** + * 新增数据 + * + * @param tbActivateGiveRecord 实例对象 + * @return 实例对象 + */ + @Override + public TbActivateGiveRecord insert(TbActivateGiveRecord tbActivateGiveRecord) { + this.tbActivateGiveRecordMapper.insert(tbActivateGiveRecord); + return tbActivateGiveRecord; + } + + /** + * 修改数据 + * + * @param tbActivateGiveRecord 实例对象 + * @return 实例对象 + */ + @Override + public TbActivateGiveRecord update(TbActivateGiveRecord tbActivateGiveRecord) { + this.tbActivateGiveRecordMapper.update(tbActivateGiveRecord); + return this.queryById(tbActivateGiveRecord.getId()); + } + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 是否成功 + */ + @Override + public boolean deleteById(Integer id) { + return this.tbActivateGiveRecordMapper.deleteById(id) > 0; + } +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbActivateProductServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbActivateProductServiceImpl.java new file mode 100644 index 0000000..c06040a --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbActivateProductServiceImpl.java @@ -0,0 +1,67 @@ +package com.chaozhanggui.system.cashierservice.service.impl; + + +import com.chaozhanggui.system.cashierservice.dao.TbActivateProductMapper; +import com.chaozhanggui.system.cashierservice.entity.TbActivateProduct; +import com.chaozhanggui.system.cashierservice.service.TbActivateProductService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + +/** + * 活动赠送商品表(TbActivateProduct)表服务实现类 + * + * @author ww + * @since 2024-08-20 15:15:02 + */ +@Service("tbActivateProductService") +public class TbActivateProductServiceImpl implements TbActivateProductService { + @Resource + private TbActivateProductMapper tbActivateProductMapper; + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + @Override + public TbActivateProduct queryById(Integer id) { + return this.tbActivateProductMapper.queryById(id); + } + + /** + * 新增数据 + * + * @param tbActivateProduct 实例对象 + * @return 实例对象 + */ + @Override + public TbActivateProduct insert(TbActivateProduct tbActivateProduct) { + this.tbActivateProductMapper.insert(tbActivateProduct); + return tbActivateProduct; + } + + /** + * 修改数据 + * + * @param tbActivateProduct 实例对象 + * @return 实例对象 + */ + @Override + public TbActivateProduct update(TbActivateProduct tbActivateProduct) { + this.tbActivateProductMapper.update(tbActivateProduct); + return this.queryById(tbActivateProduct.getId()); + } + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 是否成功 + */ + @Override + public boolean deleteById(Integer id) { + return this.tbActivateProductMapper.deleteById(id) > 0; + } +} diff --git a/src/main/resources/mapper/TbActivateGiveRecordMapper.xml b/src/main/resources/mapper/TbActivateGiveRecordMapper.xml new file mode 100644 index 0000000..63320d2 --- /dev/null +++ b/src/main/resources/mapper/TbActivateGiveRecordMapper.xml @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + id + , vip_user_id, pro_id, num, shop_id, source_flow_id,source_act_id, create_time, update_time + + + + + + + + + + + insert into tb_activate_give_record(vip_user_id, pro_id, num, shop_id, source_act_id, source_flow_id, create_time, update_time) + values (#{vipUserId}, #{proId}, #{num}, #{shopId}, #{sourceActId}, #{sourceFlowId}, #{createTime}, #{updateTime}) + + + + insert into tb_activate_give_record(vip_user_id, pro_id, num, shop_id, source_act_id, source_flow_id, create_time, update_time) + values + + (#{entity.vipUserId}, #{entity.proId}, #{entity.num}, #{entity.shopId}, #{entity.sourceActId}, + #{entity.sourceFlowId},#{entity.createTime}, #{entity.updateTime}) + + + + + + update tb_activate_give_record + + + vip_user_id = #{vipUserId}, + + + pro_id = #{proId}, + + + num = #{num}, + + + shop_id = #{shopId}, + + + source_act_id = #{sourceActId}, + + + source_flow_id = #{sourceFlowId}, + + + create_time = #{createTime}, + + + update_time = #{updateTime}, + + + where id = #{id} + + + + + delete + from tb_activate_give_record + where id = #{id} + + + + diff --git a/src/main/resources/mapper/TbActivateMapper.xml b/src/main/resources/mapper/TbActivateMapper.xml index 50d204a..8eb2307 100644 --- a/src/main/resources/mapper/TbActivateMapper.xml +++ b/src/main/resources/mapper/TbActivateMapper.xml @@ -9,9 +9,10 @@ + - id, shop_id, min_num, max_num, handsel_num, handsel_type, is_del + id, shop_id, min_num, max_num, handsel_num, handsel_type, is_del,is_gift_pro - select * from tb_activate where shop_id=#{shopId} and is_del=0 and min_num <= #{amount} and max_num >= #{amount} - + select * + from tb_activate + where shop_id = #{shopId} + and is_del = 0 + and min_num <= #{amount} + and max_num >= #{amount} + order by max_num desc limit 1 + - select * from tb_activate where shop_id=#{shopId} \ No newline at end of file diff --git a/src/main/resources/mapper/TbActivateProductMapper.xml b/src/main/resources/mapper/TbActivateProductMapper.xml new file mode 100644 index 0000000..56eefa7 --- /dev/null +++ b/src/main/resources/mapper/TbActivateProductMapper.xml @@ -0,0 +1,105 @@ + + + + + + + + + + + + + +id, activate_id, product_id, num, create_time, update_time + + + + + + + + + + + + + insert into tb_activate_product(activate_id, product_id, num, create_time, update_time) + values (#{activateId}, #{productId}, #{num}, #{createTime}, #{updateTime}) + + + + insert into tb_activate_product(activate_id, product_id, num, create_time, update_time) + values + + (#{entity.activateId}, #{entity.productId}, #{entity.num}, #{entity.createTime}, #{entity.updateTime}) + + + + + + update tb_activate_product + + + activate_id = #{activateId}, + + + product_id = #{productId}, + + + num = #{num}, + + + create_time = #{createTime}, + + + update_time = #{updateTime}, + + + where id = #{id} + + + + + delete from tb_activate_product where id = #{id} + + + + diff --git a/src/main/resources/mapper/TbShopUserFlowMapper.xml b/src/main/resources/mapper/TbShopUserFlowMapper.xml index 9d7b16f..013efcf 100644 --- a/src/main/resources/mapper/TbShopUserFlowMapper.xml +++ b/src/main/resources/mapper/TbShopUserFlowMapper.xml @@ -24,7 +24,7 @@ delete from tb_shop_user_flow where id = #{id,jdbcType=INTEGER} - + insert into tb_shop_user_flow (id, shop_user_id, amount, balance, biz_code, biz_name, create_time, type) From 3ae13b0b7e91b481e3e9101b8b187d058351b7d8 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Wed, 21 Aug 2024 10:07:48 +0800 Subject: [PATCH 08/21] =?UTF-8?q?=E5=BA=97=E9=93=BA=E6=89=A9=E5=B1=95?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CommonController.java | 11 ++ .../dao/TbShopExtendMapper.java | 33 +++++ .../cashierservice/entity/TbShopExtend.java | 113 ++++++++++++++++++ .../resources/mapper/TbShopExtendMapper.xml | 72 +++++++++++ 4 files changed, 229 insertions(+) create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopExtendMapper.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopExtend.java create mode 100644 src/main/resources/mapper/TbShopExtendMapper.xml diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/CommonController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/CommonController.java index 83211ee..ae9f246 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/CommonController.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/CommonController.java @@ -2,6 +2,7 @@ package com.chaozhanggui.system.cashierservice.controller; import cn.hutool.core.util.StrUtil; import com.chaozhanggui.system.cashierservice.dao.TbPlatformDictMapper; +import com.chaozhanggui.system.cashierservice.dao.TbShopExtendMapper; import com.chaozhanggui.system.cashierservice.entity.TbPlatformDict; import com.chaozhanggui.system.cashierservice.entity.dto.WxMsgSubDTO; import com.chaozhanggui.system.cashierservice.entity.vo.DistrictVo; @@ -24,12 +25,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Async; +import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import java.util.Collections; import java.util.List; +import java.util.Map; /** * 通用接口 @@ -50,6 +53,8 @@ public class CommonController { private TbPlatformDictMapper platformDictMapper; @Resource private FileService fileService; + @Resource + private TbShopExtendMapper extendMapper; private final LoginService loginService;; @@ -163,6 +168,12 @@ public class CommonController { return new Result(CodeEnum.SUCCESS, fileService.uploadFile(file)); } + @RequestMapping("common/shopExtend") + public Result getShopExtend(@RequestBody Map map) { + if (CollectionUtils.isEmpty(map) || !map.containsKey("shopId") || !map.containsKey("autokey")) return new Result(CodeEnum.SUCCESS); + return new Result(CodeEnum.SUCCESS, extendMapper.queryByShopIdAndAutoKey(Integer.valueOf(map.get("shopId").toString()),map.get("autokey"))); + } + // 检查手机号格式是否正确的方法 private boolean isValidPhoneNumber(String phone) { return phone.matches("^1[3-9]\\d{9}$"); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopExtendMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopExtendMapper.java new file mode 100644 index 0000000..0e80d49 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbShopExtendMapper.java @@ -0,0 +1,33 @@ +package com.chaozhanggui.system.cashierservice.dao; + +import com.chaozhanggui.system.cashierservice.entity.TbShopExtend; + +import java.util.List; + +/** + * 店铺扩展信息(TbShopExtend)表数据库访问层 + * + * @author ww + * @since 2024-08-21 09:40:25 + */ +public interface TbShopExtendMapper { + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + TbShopExtend queryById(Integer id); + + TbShopExtend queryByShopIdAndAutoKey(Integer shopId,String autokey); + + /** + * 查询数据 + * + * @param tbShopExtend 查询条件 + * @return 对象列表 + */ + List queryAll(TbShopExtend tbShopExtend); +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopExtend.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopExtend.java new file mode 100644 index 0000000..82867d6 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopExtend.java @@ -0,0 +1,113 @@ +package com.chaozhanggui.system.cashierservice.entity; + +import java.util.Date; +import java.io.Serializable; + +/** + * 店铺扩展信息(TbShopExtend)实体类 + * + * @author ww + * @since 2024-08-21 09:40:26 + */ +public class TbShopExtend implements Serializable { + private static final long serialVersionUID = -25782280496188600L; + /** + * 自增id + */ + private Integer id; + /** + * 商户Id + */ + private Integer shopId; + /** + * img:图片;text:文本; + */ + private String type; + /** + * 描述 + */ + private String name; + /** + * 自定义key + */ + private String autokey; + /** + * 值 + */ + private String value; + /** + * 更新时间 + */ + private Date updateTime; + /** + * 创建时间 + */ + private Date createTime; + + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getShopId() { + return shopId; + } + + public void setShopId(Integer shopId) { + this.shopId = shopId; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getAutokey() { + return autokey; + } + + public void setAutokey(String autokey) { + this.autokey = autokey; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + +} + diff --git a/src/main/resources/mapper/TbShopExtendMapper.xml b/src/main/resources/mapper/TbShopExtendMapper.xml new file mode 100644 index 0000000..817bd30 --- /dev/null +++ b/src/main/resources/mapper/TbShopExtendMapper.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + id + , shop_id, type, name, autoKey, value, update_time, create_time + + + + + + + + + + + From 58fa177785bfcf4b024064d7ffb2608dd8616855 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Wed, 21 Aug 2024 10:22:31 +0800 Subject: [PATCH 09/21] =?UTF-8?q?=E6=B3=A8=E8=A7=A3=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/TbActivateGiveRecordServiceImpl.java | 2 +- .../service/impl/TbActivateProductServiceImpl.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbActivateGiveRecordServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbActivateGiveRecordServiceImpl.java index 1050428..c690e62 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbActivateGiveRecordServiceImpl.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbActivateGiveRecordServiceImpl.java @@ -13,7 +13,7 @@ import javax.annotation.Resource; * @author ww * @since 2024-08-20 15:20:43 */ -@Service("tbActivateGiveRecordService") +@Service public class TbActivateGiveRecordServiceImpl implements TbActivateGiveRecordService { @Resource private TbActivateGiveRecordMapper tbActivateGiveRecordMapper; diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbActivateProductServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbActivateProductServiceImpl.java index c06040a..4803729 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbActivateProductServiceImpl.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbActivateProductServiceImpl.java @@ -14,7 +14,7 @@ import javax.annotation.Resource; * @author ww * @since 2024-08-20 15:15:02 */ -@Service("tbActivateProductService") +@Service public class TbActivateProductServiceImpl implements TbActivateProductService { @Resource private TbActivateProductMapper tbActivateProductMapper; From d264f79c9e1f3fbdc03a13bf7b8b768cbea034dd Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Wed, 21 Aug 2024 14:49:25 +0800 Subject: [PATCH 10/21] =?UTF-8?q?=E5=95=86=E5=93=81=E5=88=97=E8=A1=A8=20?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=20=E8=80=97=E6=9D=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/ProductService.java | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java index 83bd637..97c6826 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java @@ -408,39 +408,43 @@ public class ProductService { if (Integer.valueOf(tbProduct.getIsDistribute()).equals(1)) {//共享库存 1开启 if (tbProduct.getStockNumber() != null && tbProduct.getStockNumber() <= 0) { tbProduct.setIsPauseSale(Byte.parseByte("1"));//售罄 1暂停 + return; } } else { if (!tbProduct.getTypeEnum().equals("sku")) { - if (skus.stream().anyMatch(sku -> sku.getStockNumber() != null && sku.getStockNumber() <= 0)) + if (skus.stream().anyMatch(sku -> sku.getStockNumber() != null && sku.getStockNumber() <= 0)){ tbProduct.setIsPauseSale(Byte.parseByte("1"));//售罄 1暂停 + return; + } } else { skus.removeIf(sku -> sku.getStockNumber() != null && sku.getStockNumber() <= 0); if (CollectionUtils.isEmpty(skus)) { tbProduct.setIsPauseSale(Byte.parseByte("1"));//售罄 1暂停 return; } - Iterator iterator = skus.iterator(); - while (iterator.hasNext()) { - TbProductSku tbProductSku = iterator.next(); - List proskuConList = tbProskuConMapper.selectByShopIdAndSkuIdAndProductId(Integer.valueOf(tbProductSku.getId()), Integer.valueOf(tbProductSku.getShopId()), Integer.valueOf(tbProductSku.getProductId())); - if (Objects.nonNull(proskuConList) && proskuConList.size() > 0) { - for (TbProskuCon proskuCon : proskuConList) { - if ("1".equals(proskuCon.getStatus())) { - TbConsInfo consInfo = tbConsInfoMapper.selectByPrimaryKey(proskuCon.getConInfoId()); - if ("1".equals(consInfo.getIsCheck())) { - if (N.gt(proskuCon.getSurplusStock(), consInfo.getStockNumber().abs().subtract(consInfo.getStockConsume().abs()))) { - iterator.remove(); - } - } + } + } + Iterator iterator = skus.iterator(); + while (iterator.hasNext()) { + TbProductSku tbProductSku = iterator.next(); + List proskuConList = tbProskuConMapper.selectByShopIdAndSkuIdAndProductId(Integer.valueOf(tbProductSku.getId()), Integer.valueOf(tbProductSku.getShopId()), Integer.valueOf(tbProductSku.getProductId())); + if (Objects.nonNull(proskuConList) && proskuConList.size() > 0) { + for (TbProskuCon proskuCon : proskuConList) { + if ("1".equals(proskuCon.getStatus())) { + TbConsInfo consInfo = tbConsInfoMapper.selectByPrimaryKey(proskuCon.getConInfoId()); + if ("1".equals(consInfo.getIsCheck())) { + if (N.gt(proskuCon.getSurplusStock(), consInfo.getStockNumber().abs().subtract(consInfo.getStockConsume().abs()))) { + iterator.remove(); + break; } } } } - if (CollectionUtils.isEmpty(skus)) { - tbProduct.setIsPauseSale(Byte.parseByte("1"));//售罄 1暂停 - } } } + if (CollectionUtils.isEmpty(skus)) { + tbProduct.setIsPauseSale(Byte.parseByte("1"));//售罄 1暂停 + } } } From 7b71eced3694f918a758accfc586a164ab10b4dc Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Fri, 23 Aug 2024 09:57:34 +0800 Subject: [PATCH 11/21] =?UTF-8?q?=E4=BC=9A=E5=91=98=E5=95=86=E5=93=81=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=B4=AD=E7=89=A9=E8=BD=A6=20=E8=AE=B0?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ProductController.java | 8 +- .../dao/TbActivateGiveRecordMapper.java | 66 --------- .../dao/TbActivateInRecordMapper.java | 74 ++++++++++ .../dao/TbActivateOutRecordMapper.java | 74 ++++++++++ .../dao/TbActivateProductMapper.java | 1 + .../cashierservice/dao/TbProductMapper.java | 2 +- .../cashierservice/entity/TbActivate.java | 17 +++ ...iveRecord.java => TbActivateInRecord.java} | 42 ++++-- .../entity/TbActivateOutRecord.java | 125 +++++++++++++++++ .../cashierservice/entity/TbCashierCart.java | 1 + .../cashierservice/entity/TbOrderDetail.java | 2 + .../entity/vo/VipProductsLimits.java | 11 ++ .../cashierservice/service/CartService.java | 128 +++++++++++++---- .../cashierservice/service/PayService.java | 28 +++- .../service/ProductService.java | 33 +++-- .../service/TbActivateGiveRecordService.java | 45 ------ .../service/TbActivateInRecordService.java | 56 ++++++++ .../service/TbActivateOutRecordService.java | 45 ++++++ .../impl/TbActivateGiveRecordServiceImpl.java | 67 --------- .../impl/TbActivateInRecordServiceImpl.java | 96 +++++++++++++ .../impl/TbActivateOutRecordServiceImpl.java | 69 ++++++++++ .../impl/TbActivateProductServiceImpl.java | 2 + ...apper.xml => TbActivateInRecordMapper.xml} | 77 +++++++++-- .../mapper/TbActivateOutRecordMapper.xml | 130 ++++++++++++++++++ .../mapper/TbActivateProductMapper.xml | 9 ++ .../resources/mapper/TbCashierCartMapper.xml | 53 ++++--- .../resources/mapper/TbOrderDetailMapper.xml | 17 ++- src/main/resources/mapper/TbProductMapper.xml | 1 + 28 files changed, 1001 insertions(+), 278 deletions(-) delete mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateGiveRecordMapper.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateInRecordMapper.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateOutRecordMapper.java rename src/main/java/com/chaozhanggui/system/cashierservice/entity/{TbActivateGiveRecord.java => TbActivateInRecord.java} (78%) create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivateOutRecord.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/VipProductsLimits.java delete mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/service/TbActivateGiveRecordService.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/service/TbActivateInRecordService.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/service/TbActivateOutRecordService.java delete mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbActivateGiveRecordServiceImpl.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbActivateInRecordServiceImpl.java create mode 100644 src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbActivateOutRecordServiceImpl.java rename src/main/resources/mapper/{TbActivateGiveRecordMapper.xml => TbActivateInRecordMapper.xml} (57%) create mode 100644 src/main/resources/mapper/TbActivateOutRecordMapper.xml diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/ProductController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/ProductController.java index b36d7d9..a52d21c 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/ProductController.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/ProductController.java @@ -50,12 +50,13 @@ public class ProductController { * @return */ @RequestMapping("queryProduct") - public Result queryProduct(@RequestBody Map map) { + public Result queryProduct(@RequestHeader("id") String userId,@RequestBody Map map) { if (ObjectUtil.isEmpty(map) || map.size() <= 0 || !map.containsKey("shopId")) { return Result.fail("参数错误"); } return productService.queryProduct( + userId, map.get("shopId").toString(), (map.containsKey("productGroupId") && ObjectUtil.isNotEmpty(map.get("productGroupId"))) ? map.get("productGroupId").toString() : ""); } @@ -81,9 +82,10 @@ public class ProductController { @RequestParam(value = "code", required = false) String code, @RequestParam("shopId") String shopId, @RequestParam("productId") String productId, - @RequestParam("spec_tag") String spec_tag + @RequestParam("spec_tag") String spec_tag, + @RequestParam("isVip") Integer isVip ) { - return productService.queryProductSku(code,shopId, productId, spec_tag); + return productService.queryProductSku(code,shopId, productId, spec_tag,isVip); } @PostMapping("addCart") diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateGiveRecordMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateGiveRecordMapper.java deleted file mode 100644 index 96709b7..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateGiveRecordMapper.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.chaozhanggui.system.cashierservice.dao; - -import com.chaozhanggui.system.cashierservice.entity.TbActivateGiveRecord; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -/** - * 活动商品赠送表(TbActivateGiveRecord)表数据库访问层 - * - * @author ww - * @since 2024-08-20 15:20:43 - */ -public interface TbActivateGiveRecordMapper { - - /** - * 通过ID查询单条数据 - * - * @param id 主键 - * @return 实例对象 - */ - TbActivateGiveRecord queryById(Integer id); - - /** - * 查询数据 - * - * @param tbActivateGiveRecord 查询条件 - * @return 对象列表 - */ - List queryAll(TbActivateGiveRecord tbActivateGiveRecord); - - - /** - * 新增数据 - * - * @param tbActivateGiveRecord 实例对象 - * @return 影响行数 - */ - int insert(TbActivateGiveRecord tbActivateGiveRecord); - - /** - * 批量新增数据(MyBatis原生foreach方法) - * - * @param entities List 实例对象列表 - * @return 影响行数 - */ - int insertBatch(@Param("entities") List entities); - - /** - * 修改数据 - * - * @param tbActivateGiveRecord 实例对象 - * @return 影响行数 - */ - int update(TbActivateGiveRecord tbActivateGiveRecord); - - /** - * 通过主键删除数据 - * - * @param id 主键 - * @return 影响行数 - */ - int deleteById(Integer id); - -} - diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateInRecordMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateInRecordMapper.java new file mode 100644 index 0000000..3a0ba10 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateInRecordMapper.java @@ -0,0 +1,74 @@ +package com.chaozhanggui.system.cashierservice.dao; + +import com.chaozhanggui.system.cashierservice.entity.TbActivateInRecord; +import com.chaozhanggui.system.cashierservice.entity.TbProduct; +import com.chaozhanggui.system.cashierservice.entity.vo.VipProductsLimits; +import org.apache.ibatis.annotations.Param; +import org.springframework.data.domain.Pageable; + +import java.util.List; + +/** + * 活动商品赠送表(TbActivateInRecord)表数据库访问层 + * + * @author ww + * @since 2024-08-22 11:13:40 + */ +public interface TbActivateInRecordMapper { + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + TbActivateInRecord queryById(Integer id); + + /** + * 查询数据 + * + * @param tbActivateInRecord 查询条件 + * @return 对象列表 + */ + List queryAll(TbActivateInRecord tbActivateInRecord); + + List queryByVipIdAndShopId(@Param("vipUserId") Integer vipUserId, @Param("shopId") Integer shopId); + int queryByVipIdAndShopIdAndProId(@Param("vipUserId") Integer vipUserId, @Param("shopId") Integer shopId,@Param("productId") Integer productId); + List queryAllByVipIdAndShopIdAndProId(@Param("vipUserId") Integer vipUserId, @Param("shopId") Integer shopId,@Param("productId") Integer productId); + + /** + * 新增数据 + * + * @param tbActivateInRecord 实例对象 + * @return 影响行数 + */ + int insert(TbActivateInRecord tbActivateInRecord); + + /** + * 批量新增数据(MyBatis原生foreach方法) + * + * @param entities List 实例对象列表 + * @return 影响行数 + */ + int insertBatch(@Param("entities") List entities); + + /** + * 修改数据 + * + * @param tbActivateInRecord 实例对象 + * @return 影响行数 + */ + int update(TbActivateInRecord tbActivateInRecord); + + int updateOverNumById(@Param("id")Integer id,@Param("overNum")Integer overNum); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 影响行数 + */ + int deleteById(Integer id); + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateOutRecordMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateOutRecordMapper.java new file mode 100644 index 0000000..b2b9dcd --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateOutRecordMapper.java @@ -0,0 +1,74 @@ +package com.chaozhanggui.system.cashierservice.dao; + +import com.chaozhanggui.system.cashierservice.entity.TbActivateOutRecord; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 活动赠送商品使用记录表(TbActivateOutRecord)表数据库访问层 + * + * @author ww + * @since 2024-08-22 11:21:56 + */ +public interface TbActivateOutRecordMapper { + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + TbActivateOutRecord queryById(Integer id); + + /** + * 查询数据 + * + * @param tbActivateOutRecord 查询条件 + * @return 对象列表 + */ + List queryAll(TbActivateOutRecord tbActivateOutRecord); + + + /** + * 新增数据 + * + * @param tbActivateOutRecord 实例对象 + * @return 影响行数 + */ + int insert(TbActivateOutRecord tbActivateOutRecord); + + /** + * 批量新增数据(MyBatis原生foreach方法) + * + * @param entities List 实例对象列表 + * @return 影响行数 + */ + int insertBatch(@Param("entities") List entities); + + /** + * 修改数据 + * + * @param tbActivateOutRecord 实例对象 + * @return 影响行数 + */ + int update(TbActivateOutRecord tbActivateOutRecord); + + /** + * 根据订单id 将数据状态变为 + * @param orderId 订单Id + * @param status 状态 + * @return + */ + int updateByOrderIdAndStatus(@Param("orderId")Integer orderId,@Param("status")String status); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 影响行数 + */ + int deleteById(Integer id); + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateProductMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateProductMapper.java index 59077ab..6240a16 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateProductMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbActivateProductMapper.java @@ -29,6 +29,7 @@ public interface TbActivateProductMapper { List queryAll(TbActivateProduct tbActivateProduct); List queryAllByActivateId(Integer activateId); + List queryProsByActivateId(Integer activateId); /** diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProductMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProductMapper.java index 3968f0d..dc3920a 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProductMapper.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/dao/TbProductMapper.java @@ -26,7 +26,7 @@ public interface TbProductMapper { List selectByIds(@Param("list") List ids); Integer selectByQcode(@Param("code") String code,@Param("productId") Integer productId,@Param("shopId") String shopId); - Integer selectByCodeAndSkuId(@Param("code") String code,@Param("skuId") Integer skuId,@Param("shopId") String shopId); + Integer selectByCodeAndSkuId(@Param("code") String code,@Param("skuId") Integer skuId,@Param("shopId") String shopId,@Param("isVip") Integer isVip); Integer selectByNewQcode(@Param("code") String code,@Param("productId") Integer productId,@Param("shopId") String shopId,@Param("list") List list); List selGroups(@Param("proName") String proName,@Param("type") String type, diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivate.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivate.java index 480d9b3..a2d5246 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivate.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivate.java @@ -1,7 +1,11 @@ package com.chaozhanggui.system.cashierservice.entity; +import org.springframework.util.CollectionUtils; + import java.io.Serializable; import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; public class TbActivate implements Serializable { private Integer id; @@ -20,6 +24,7 @@ public class TbActivate implements Serializable { //是否赠送商品 0否 1是 private Integer isGiftPro; + private List gives; private static final long serialVersionUID = 1L; @@ -86,4 +91,16 @@ public class TbActivate implements Serializable { public void setIsGiftPro(Integer isGiftPro) { this.isGiftPro = isGiftPro; } + + public List getGives() { + return gives; + } + + public void setGives(List gives) { + if(CollectionUtils.isEmpty(gives)){ + this.gives = new ArrayList<>(); + }else { + this.gives = gives; + } + } } \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivateGiveRecord.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivateInRecord.java similarity index 78% rename from src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivateGiveRecord.java rename to src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivateInRecord.java index e643810..afc81af 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivateGiveRecord.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivateInRecord.java @@ -4,13 +4,13 @@ import java.util.Date; import java.io.Serializable; /** - * 活动商品赠送表(TbActivateGiveRecord)实体类 + * 活动商品赠送表(TbActivateInRecord)实体类 * * @author ww - * @since 2024-08-20 15:20:43 + * @since 2024-08-22 11:13:40 */ -public class TbActivateGiveRecord implements Serializable { - private static final long serialVersionUID = -53463432636369401L; +public class TbActivateInRecord implements Serializable { + private static final long serialVersionUID = -35515830201618782L; private Integer id; /** @@ -25,30 +25,37 @@ public class TbActivateGiveRecord implements Serializable { * 赠送数量 */ private Integer num; + /** + * 未使用数量 + */ + private Integer overNum; /** * 店铺id */ private Integer shopId; - private Integer sourceFlowId; /** * 来源活动id */ private Integer sourceActId; + private Integer sourceFlowId; + private Date createTime; private Date updateTime; - public TbActivateGiveRecord(Integer vipUserId, Integer proId, Integer num, Integer shopId, Integer sourceActId,Integer sourceFlowId) { + public TbActivateInRecord(Integer vipUserId, Integer proId, Integer num, Integer shopId, Integer sourceActId,Integer sourceFlowId) { this.vipUserId = vipUserId; this.proId = proId; this.num = num; + this.overNum = num; this.shopId = shopId; this.sourceActId = sourceActId; this.sourceFlowId = sourceFlowId; this.createTime=new Date(); } + public Integer getId() { return id; } @@ -81,6 +88,14 @@ public class TbActivateGiveRecord implements Serializable { this.num = num; } + public Integer getOverNum() { + return overNum; + } + + public void setOverNum(Integer overNum) { + this.overNum = overNum; + } + public Integer getShopId() { return shopId; } @@ -89,6 +104,13 @@ public class TbActivateGiveRecord implements Serializable { this.shopId = shopId; } + public Integer getSourceActId() { + return sourceActId; + } + + public void setSourceActId(Integer sourceActId) { + this.sourceActId = sourceActId; + } public Integer getSourceFlowId() { return sourceFlowId; @@ -98,14 +120,6 @@ public class TbActivateGiveRecord implements Serializable { this.sourceFlowId = sourceFlowId; } - public Integer getSourceActId() { - return sourceActId; - } - - public void setSourceActId(Integer sourceActId) { - this.sourceActId = sourceActId; - } - public Date getCreateTime() { return createTime; } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivateOutRecord.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivateOutRecord.java new file mode 100644 index 0000000..dd5d295 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbActivateOutRecord.java @@ -0,0 +1,125 @@ +package com.chaozhanggui.system.cashierservice.entity; + +import java.util.Date; +import java.io.Serializable; + +/** + * 活动赠送商品使用记录表(TbActivateOutRecord)实体类 + * + * @author ww + * @since 2024-08-22 11:21:56 + */ +public class TbActivateOutRecord implements Serializable { + private static final long serialVersionUID = -54399746948905097L; + + private Integer id; + /** + * 商品赠送Id + */ + private Integer giveId; + /** + * 商品id + */ + private Integer proId; + /** + * 使用数量 + */ + private Integer useNum; + /** + * 退单量 + */ + private Integer refNum; + /** + * 订单id + */ + private String orderId; + //新建: create, 完成: closed, 取消:cancel, + private String status; + + private Date createTime; + + private Date updateTime; + + public TbActivateOutRecord(Integer giveId, Integer proId, Integer useNum, String orderId, String status) { + this.giveId = giveId; + this.proId = proId; + this.useNum = useNum; + this.orderId = orderId; + this.status = status; + this.createTime = new Date(); + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getGiveId() { + return giveId; + } + + public void setGiveId(Integer giveId) { + this.giveId = giveId; + } + + public Integer getProId() { + return proId; + } + + public void setProId(Integer proId) { + this.proId = proId; + } + + public Integer getUseNum() { + return useNum; + } + + public void setUseNum(Integer useNum) { + this.useNum = useNum; + } + + public Integer getRefNum() { + return refNum; + } + + public void setRefNum(Integer refNum) { + this.refNum = refNum; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getOrderId() { + return orderId; + } + + public void setOrderId(String orderId) { + this.orderId = orderId; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + +} + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCashierCart.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCashierCart.java index 0c99e3a..b74eb9a 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCashierCart.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbCashierCart.java @@ -58,6 +58,7 @@ public class TbCashierCart implements Serializable { private Long updatedAt; private Integer userId; private String tableId; + private Byte isVip; private TbProductSpec tbProductSpec; private static final long serialVersionUID = 1L; diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbOrderDetail.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbOrderDetail.java index 3d97089..2b95fe1 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbOrderDetail.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbOrderDetail.java @@ -20,6 +20,8 @@ public class TbOrderDetail implements Serializable { private Integer num; + private Byte isVip; + private String productName; private String status; diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/VipProductsLimits.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/VipProductsLimits.java new file mode 100644 index 0000000..74f091b --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/VipProductsLimits.java @@ -0,0 +1,11 @@ +package com.chaozhanggui.system.cashierservice.entity.vo; + +import com.chaozhanggui.system.cashierservice.entity.TbProduct; +import lombok.Data; + +@Data +public class VipProductsLimits extends TbProduct { + + private Integer vipLimitNumber; + +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java index 1985f1a..44cfe6f 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java @@ -29,6 +29,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; +import javax.annotation.Resource; import java.io.IOException; import java.math.BigDecimal; import java.time.Instant; @@ -57,6 +58,9 @@ public class CartService { private TbMerchantAccountMapper merchantAccountMapper; @Autowired private TbUserInfoMapper userInfoMapper; + @Autowired + private TbShopUserMapper shopUserMapper; + @Autowired private TbOrderDetailMapper orderDetailMapper; @Autowired @@ -71,6 +75,10 @@ public class CartService { private final WxAccountUtil wxAccountUtil; private final TbShopOpenIdMapper shopOpenIdMapper; + @Resource + private TbActivateInRecordService activateInRecordService; + @Autowired + private TbActivateOutRecordMapper outRecordMapper; @Autowired private RabbitProducer producer; @@ -122,6 +130,7 @@ public class CartService { if (!CollectionUtils.isEmpty(tbCashierCarts)) { for (TbCashierCart cashierCart : tbCashierCarts) { array.add(cashierCart); + if(cashierCart.getIsVip().equals((byte) 1)) continue; amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee()))); } redisUtil.saveMessage(RedisCst.TABLE_CART.concat(key), array.toString()); @@ -148,8 +157,9 @@ public class CartService { String skuId = jsonObject.getString("skuId"); Integer type = jsonObject.getInteger("type"); Integer buyNum = jsonObject.getInteger("num"); + Integer isVip = jsonObject.getInteger("isVip"); if (StringUtils.isBlank(tableId) || StringUtils.isBlank(shopId) || StringUtils.isBlank(productId) - || StringUtils.isBlank(skuId) || type==null || buyNum == null) { + || StringUtils.isBlank(skuId) || type == null || buyNum == null) { return Result.fail("参数缺失"); } String key = tableId + "-" + shopId; @@ -160,42 +170,38 @@ public class CartService { } // 判断商品是否已下架 TbProductSkuWithBLOBs tbProductSkuWithBLOBs = productSkuMapper.selectByPrimaryKey(Integer.valueOf(skuId)); - if (tbProductSkuWithBLOBs ==null || tbProductSkuWithBLOBs.getIsGrounding().equals(0)) { - rmCart(jsonObject,skuId,key); + if (tbProductSkuWithBLOBs == null || tbProductSkuWithBLOBs.getIsGrounding().equals(0)) { + rmCart(jsonObject, skuId, key); return Result.fail("商品已下架"); } if (tbProduct.getIsStock() == 1) { // 1:共享库存 0:独立库存 if (Integer.valueOf(tbProduct.getIsDistribute()).equals(1)) { if (tbProduct.getIsPauseSale() == 1) {//是否售罄 - rmCart(jsonObject,skuId,key); + rmCart(jsonObject, skuId, key); return Result.fail("该商品已售罄"); } } else { if (tbProductSkuWithBLOBs.getIsPauseSale() == 1) {//是否售罄 - rmCart(jsonObject,skuId,key); + rmCart(jsonObject, skuId, key); return Result.fail("该商品已售罄"); } } } - - - List proskuConList= tbProskuConMapper.selectByShopIdAndSkuIdAndProductId(Integer.valueOf(skuId),Integer.valueOf(shopId),Integer.valueOf(productId)); - if(Objects.nonNull(proskuConList)&&proskuConList.size()>0){ - for (TbProskuCon proskuCon : proskuConList) { - if("1".equals(proskuCon.getStatus())){ - TbConsInfo consInfo= tbConsInfoMapper.selectByPrimaryKey(proskuCon.getConInfoId()); - if("1".equals(consInfo.getIsCheck())){ - if(N.gt(proskuCon.getSurplusStock(),consInfo.getStockNumber().abs().subtract(consInfo.getStockConsume().abs()))){ - return Result.fail("商品:".concat(tbProduct.getName()).concat("对应的:").concat(consInfo.getConName()).concat("耗材不足")); + List proskuConList = tbProskuConMapper.selectByShopIdAndSkuIdAndProductId(Integer.valueOf(skuId), Integer.valueOf(shopId), Integer.valueOf(productId)); + if (Objects.nonNull(proskuConList) && proskuConList.size() > 0) { + for (TbProskuCon proskuCon : proskuConList) { + if ("1".equals(proskuCon.getStatus())) { + TbConsInfo consInfo = tbConsInfoMapper.selectByPrimaryKey(proskuCon.getConInfoId()); + if ("1".equals(consInfo.getIsCheck())) { + if (N.gt(proskuCon.getSurplusStock(), consInfo.getStockNumber().abs().subtract(consInfo.getStockConsume().abs()))) { + return Result.fail("商品:".concat(tbProduct.getName()).concat("对应的:").concat(consInfo.getConName()).concat("耗材不足")); + } } } } } - } - - JSONArray jsonArray = new JSONArray(); BigDecimal amount = BigDecimal.ZERO; @@ -205,7 +211,7 @@ public class CartService { if (Objects.isNull(array) || array.isEmpty()) { if (type == 1) { TbCashierCart cashierCart = addCart(productId, skuId, - jsonObject.getInteger("userId"), buyNum, tableId, shopId); + jsonObject.getInteger("userId"), buyNum, tableId, shopId,isVip); jsonArray.add(cashierCart); amount = amount.add(new BigDecimal(cashierCart.getNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee()))); } @@ -214,7 +220,8 @@ public class CartService { for (int i = 0; i < array.size(); i++) { JSONObject object = array.getJSONObject(i); TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(object.toJSONString(), TbCashierCart.class); - if (cashierCart.getSkuId().equals(skuId)) { + + if (cashierCart.getSkuId().equals(skuId) && cashierCart.getIsVip().intValue() == isVip) { cashierCart.setTotalNumber(buyNum); cashierCart.setNumber(buyNum); if (type == 0 && tbProductSkuWithBLOBs.getSuit() != null && tbProductSkuWithBLOBs.getSuit() > 1 && cashierCart.getNumber() < tbProductSkuWithBLOBs.getSuit()) { @@ -222,7 +229,11 @@ public class CartService { continue; } if (cashierCart.getNumber() > 0) { - cashierCart.setTotalAmount(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee()))); + if (isVip == 1) { + cashierCart.setTotalAmount(BigDecimal.ZERO); + } else { + cashierCart.setTotalAmount(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee()))); + } cashierCart.setUpdatedAt(Instant.now().toEpochMilli()); cashierCartMapper.updateByPrimaryKeySelective(cashierCart); } else { @@ -236,7 +247,7 @@ public class CartService { } if (flag && type == 1) { TbCashierCart cashierCart = addCart(productId, skuId, - jsonObject.getInteger("userId"), buyNum, tableId, shopId); + jsonObject.getInteger("userId"), buyNum, tableId, shopId,isVip); jsonArray.add(cashierCart); amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee()))); } @@ -244,9 +255,11 @@ public class CartService { } else { if (type == 1) { TbCashierCart cashierCart = addCart(productId, skuId, - jsonObject.getInteger("userId"), buyNum, tableId, shopId); + jsonObject.getInteger("userId"), buyNum, tableId, shopId,isVip); jsonArray.add(cashierCart); - amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee()))); + if (isVip != 1) { + amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee()))); + } } } }catch (MsgException e){ @@ -264,7 +277,7 @@ public class CartService { jsonObject1.put("reqData", jsonObject); PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, "", false); } catch (Exception e) { - log.error("长链接错误 createCart{}", e.getMessage()); + log.error("长链接错误 createCart {}", e.getMessage()); } return Result.success(CodeEnum.SUCCESS); } @@ -379,7 +392,7 @@ public class CartService { } } - private TbCashierCart addCart(String productId, String skuId, Integer userId, Integer num, String tableId, String shopId) throws Exception{ + private TbCashierCart addCart(String productId, String skuId, Integer userId, Integer num, String tableId, String shopId,Integer isVip) throws Exception{ try { TbProduct product = productMapper.selectById(Integer.valueOf(productId)); String key = tableId + "-" + shopId; @@ -435,7 +448,14 @@ public class CartService { cashierCart.setUpdatedAt(Instant.now().toEpochMilli()); cashierCart.setPackFee(BigDecimal.ZERO); cashierCart.setRefundNumber(0); - cashierCart.setTotalAmount(new BigDecimal(cashierCart.getTotalNumber()).multiply(productSku.getSalePrice().add(cashierCart.getPackFee()))); + if(isVip==1){ + cashierCart.setIsVip(Byte.parseByte("1")); + cashierCart.setTotalAmount(BigDecimal.ZERO); + cashierCart.setSalePrice(BigDecimal.ZERO); + }else { + cashierCart.setIsVip(Byte.parseByte("0")); + cashierCart.setTotalAmount(new BigDecimal(cashierCart.getTotalNumber()).multiply(productSku.getSalePrice().add(cashierCart.getPackFee()))); + } cashierCartMapper.insert(cashierCart); @@ -448,7 +468,7 @@ public class CartService { return cashierCart; } catch (Exception e) { - log.error("长链接错误 addCart{}", e.getMessage()); + log.error("长链接错误 addCart {}", e.getMessage()); throw e; } } @@ -479,9 +499,36 @@ public class CartService { if (tbUserInfo == null) { MsgException.throwException("生成订单失败"); } + TbShopUser tbShopUser = shopUserMapper.selectByUserIdAndShopId(userId, shopId); + boolean isVip= false; + if (tbShopUser != null && tbShopUser.getIsVip().equals((byte) 1)) { + isVip=true; + } + //校验 库存 耗材 for (int i = 0; i < array.size(); i++) { JSONObject object = array.getJSONObject(i); TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(object.toJSONString(), TbCashierCart.class); + if (cashierCart.getIsVip().equals((byte) 1)) { + if (isVip) { + int i1 = activateInRecordService.queryByVipIdAndShopIdAndProId( + Integer.valueOf(tbShopUser.getId()), Integer.valueOf(shopId), Integer.valueOf(cashierCart.getProductId())); + if (i1 < cashierCart.getTotalNumber()) { + JSONObject jsonObject1 = new JSONObject(); + jsonObject1.put("status", "fail"); + jsonObject1.put("msg", "会员商品[" + cashierCart.getName() + "],可下单数量为" + i1); + jsonObject1.put("data", new ArrayList<>()); + PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true); + return; + } + } else { + JSONObject jsonObject1 = new JSONObject(); + jsonObject1.put("status", "fail"); + jsonObject1.put("msg", "非会员用户不可下单会员商品"); + jsonObject1.put("data", new ArrayList<>()); + PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, jsonObject.getString("userId"), true); + return; + } + } TbProductSkuWithBLOBs tbProduct = productSkuMapper.selectByPrimaryKey(Integer.valueOf(cashierCart.getSkuId())); TbProduct tbProduct1 = tbProductMapper.selectById(Integer.valueOf(tbProduct.getProductId())); @@ -540,6 +587,7 @@ public class CartService { orderDetail.setPackAmount(cashierCart.getPackFee()); orderDetail.setProductImg(cashierCart.getCoverImg()); orderDetail.setStatus("unpaid"); + orderDetail.setIsVip(cashierCart.getIsVip()); if (StringUtils.isNotEmpty(cashierCart.getOrderId())) { orderId = Integer.valueOf(cashierCart.getOrderId()); } @@ -553,6 +601,8 @@ public class CartService { TbShopTable shopTable = shopTableMapper.selectQRcode(jsonObject.getString("tableId")); //生成订单 TbOrderInfo orderInfo = orderInfoMapper.selectByPrimaryKey(orderId); + + //优惠卷 String isBuyYhq = "false"; String isuseYhq = "false"; if (jsonObject.containsKey("isYhq") && jsonObject.getString("isYhq").equals("1")) { @@ -697,9 +747,29 @@ public class CartService { orderDetail.setOrderId(orderId); orderDetailMapper.insert(orderDetail); } + List outRecords = new ArrayList<>(); for (int i = 0; i < array.size(); i++) { JSONObject object = array.getJSONObject(i); TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(object.toJSONString(), TbCashierCart.class); + if (cashierCart.getIsVip().equals((byte) 1)) { + List actInRecords = activateInRecordService.queryAllByVipIdAndShopIdAndProId( + Integer.valueOf(tbShopUser.getId()), Integer.valueOf(orderInfo.getShopId()), Integer.valueOf(cashierCart.getProductId())); + Integer totalNumber = cashierCart.getTotalNumber(); + for (TbActivateInRecord actInRecord : actInRecords) { + if (totalNumber > 0) { + if (actInRecord.getOverNum() > totalNumber) { + TbActivateOutRecord outRecord = new TbActivateOutRecord(actInRecord.getId(), actInRecord.getProId(), totalNumber, orderInfo.getId().toString(), "create"); + outRecords.add(outRecord); + activateInRecordService.updateOverNumById(actInRecord.getId(), actInRecord.getOverNum() - totalNumber); + } else { + TbActivateOutRecord outRecord = new TbActivateOutRecord(actInRecord.getId(), actInRecord.getProId(), actInRecord.getOverNum(), orderInfo.getId().toString(), "create"); + outRecords.add(outRecord); + activateInRecordService.updateOverNumById(actInRecord.getId(), 0); + totalNumber = totalNumber - actInRecord.getOverNum(); + } + } + } + } cashierCart.setUpdatedAt(System.currentTimeMillis()); cashierCart.setOrderId(orderId + ""); cashierCart.setStatus("closed"); @@ -709,7 +779,7 @@ public class CartService { } - + if(!CollectionUtils.isEmpty(outRecords)) outRecordMapper.insertBatch(outRecords); // 发送mq消息 JSONObject jsonObject2 = new JSONObject(); jsonObject2.put("orderId", orderInfo.getId()); diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java index f765809..2e54784 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java @@ -34,6 +34,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; import org.springframework.web.client.RestTemplate; import javax.annotation.Resource; @@ -73,8 +74,8 @@ public class PayService { TbShopPayTypeMapper tbShopPayTypeMapper; @Autowired private TbActivateProductMapper actProductMapper; - @Autowired - private TbActivateGiveRecordMapper actGiveRecordMapper; + @Resource + private TbActivateInRecordMapper activateInRecordMapper; @Autowired private TbShopSongOrderMapper tbShopSongOrderMapper; @@ -115,6 +116,10 @@ public class PayService { @Autowired TbShopUserFlowMapper tbShopUserFlowMapper; + @Resource + private TbActivateInRecordService activateInRecordService; + @Autowired + private TbActivateOutRecordMapper outRecordMapper; @Value("${thirdPay.payType}") private String thirdPayType; @@ -365,6 +370,10 @@ public class PayService { // return Result.failCode("会员卡余额不足","2"); return Result.success(CodeEnum.SUCCESS, "2"); } + List cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, null); + if (ObjectUtil.isEmpty(cashierCarts) || ObjectUtil.isNull(cashierCarts)) { + return Result.fail("购物车信息不存在"); + } user.setAmount(user.getAmount().subtract(orderInfo.getOrderAmount())); user.setConsumeAmount(user.getConsumeAmount().add(orderInfo.getPayAmount())); @@ -872,7 +881,7 @@ public class PayService { //更新子单状态 tbOrderDetailMapper.updateStatusByOrderIdAndStatus(orderInfo.getId(), "closed"); - + outRecordMapper.updateByOrderIdAndStatus(orderInfo.getId(),"closed"); //修改主单状态 orderInfo.setStatus("closed"); orderInfo.setPayType("wx_lite"); @@ -926,7 +935,7 @@ public class PayService { orderInfo.setPayOrderNo(payOrderNO); orderInfo.setPayAmount(orderInfo.getOrderAmount()); tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo); - + outRecordMapper.updateByOrderIdAndStatus(orderInfo.getId(),"closed"); JSONObject jsonObject = new JSONObject(); jsonObject.put("token", 0); @@ -987,6 +996,11 @@ public class PayService { public Result getActivate(String shopId, int page, int pageSize) { PageHelper.startPage(page, pageSize); List list = tbActivateMapper.selectByShopId(shopId); + for (TbActivate tbActivate : list) { + if (tbActivate.getIsGiftPro() == 1) { + tbActivate.setGives(actProductMapper.queryProsByActivateId(tbActivate.getId())); + } + } PageInfo pageInfo = new PageInfo(list); return Result.success(CodeEnum.SUCCESS, pageInfo); } @@ -1099,12 +1113,12 @@ public class PayService { if (ObjectUtil.isNotEmpty(activate) && ObjectUtil.isNotNull(activate)) { if (activate.getIsGiftPro() != null && activate.getIsGiftPro() == 1) { List tbActivateProducts = actProductMapper.queryAllByActivateId(activate.getId()); - List actGiveRecords = new ArrayList<>(); + List actGiveRecords = new ArrayList<>(); for (TbActivateProduct actPro : tbActivateProducts) { - TbActivateGiveRecord record = new TbActivateGiveRecord(Integer.valueOf(tbShopUser.getId()), actPro.getProductId(), actPro.getNum(), Integer.valueOf(tbShopUser.getShopId()), activate.getId(),flowId); + TbActivateInRecord record = new TbActivateInRecord(Integer.valueOf(tbShopUser.getId()), actPro.getProductId(), actPro.getNum(), Integer.valueOf(tbShopUser.getShopId()), activate.getId(),flowId); actGiveRecords.add(record); } - actGiveRecordMapper.insertBatch(actGiveRecords); + activateInRecordMapper.insertBatch(actGiveRecords); } BigDecimal amount = BigDecimal.ZERO; switch (activate.getHandselType()) { diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java index 97c6826..a1934bd 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java @@ -80,6 +80,8 @@ public class ProductService { @Autowired private TbConsInfoMapper tbConsInfoMapper; + @Resource + private TbActivateInRecordService activateInRecordService; public Result queryShopIdByTableCode(String userId, String openId, String code, String lat, String lng) { if (StringUtils.isBlank(code)) return Result.fail("桌码信息为空"); @@ -142,32 +144,41 @@ public class ProductService { return Result.success(CodeEnum.SUCCESS, concurrentMap); } - public Result queryProduct(String shopId, String productGroupId) { + public Result queryProduct(String userId,String shopId, String productGroupId) { ConcurrentMap concurrentMap = new ConcurrentHashMap<>(); Integer id = ObjectUtil.isNotEmpty(productGroupId) ? Integer.valueOf(productGroupId) : null; //招牌菜 List tbProducts = tbProductMapper.selectIsSpecialty(Integer.valueOf(shopId)); - concurrentMap.put("hots", handleDate(tbProducts,true,1)); + concurrentMap.put("hots", handleDate(tbProducts,true,1,false)); List groupList = tbProductGroupMapper.selectByShopId(shopId, id); if (ObjectUtil.isNotEmpty(groupList) && groupList.size() > 0) { //热销 TbProductGroup hot = new TbProductGroup(); hot.setName("热销"); List hots = tbProductMapper.selectHot(shopId); - hot.setProducts(handleDate(hots,true,1)); + hot.setProducts(handleDate(hots,true,1,false)); //商品 groupList.parallelStream().forEach(g -> { if (g.getUseTime()==1) g.setIsSale(getIsSale(g.getSaleStartTime(),g.getSaleEndTime())); String in = g.getProductIds().substring(1, g.getProductIds().length() - 1); if (ObjectUtil.isNotEmpty(in) && ObjectUtil.isNotNull(in)) { -// List products = tbProductMapper.selectByIdIn(in); List products = tbProductMapper.selectByIdInAndCheck(in); - g.setProducts(handleDate(products,false,g.getIsSale())); + g.setProducts(handleDate(products,false,g.getIsSale(),false)); } else { g.setProducts(new ArrayList<>()); } }); groupList.sort(Comparator.comparingInt(TbProductGroup::getIsSale).reversed()); + TbShopUser tbShopUser = tbShopUserMapper.selectByUserIdAndShopId(userId, shopId); + if (tbShopUser != null) { + TbProductGroup vipProGroup = new TbProductGroup(); + vipProGroup.setName("会员商品"); + List vipPros = activateInRecordService.queryByVipIdAndShopId(Integer.valueOf(tbShopUser.getId()), Integer.valueOf(shopId)); + if(!CollectionUtils.isEmpty(vipPros)){ + vipProGroup.setProducts(handleDate(vipPros, true, 1, true)); + groupList.add(0, vipProGroup); + } + } groupList.add(0, hot); concurrentMap.put("productInfo", groupList); } @@ -353,7 +364,7 @@ public class ProductService { * @param check 是否校验可售 * @return */ - public List handleDate(List products,boolean check,Integer isSale){ + public List handleDate(List products,boolean check,Integer isSale,boolean isVip){ if (!CollectionUtils.isEmpty(products)) { products.parallelStream().forEach(it -> { if(check){ @@ -396,6 +407,10 @@ public class ProductService { //售价 it.setLowPrice(lowerPrice); it.setProductSkuResult(skuResult); + if (isVip) { + it.setLowPrice(BigDecimal.ZERO); + it.setIsVip(Byte.parseByte("1")); + } }); return products; }else { @@ -449,8 +464,8 @@ public class ProductService { } - public Result queryProductSku(String code, String shopId, String productId, String spec_tag) { - if (ObjectUtil.isEmpty(shopId) || ObjectUtil.isEmpty(productId)) { + public Result queryProductSku(String code, String shopId, String productId, String spec_tag,Integer isVip) { + if (ObjectUtil.isEmpty(shopId) || ObjectUtil.isEmpty(productId) || ObjectUtil.isEmpty(isVip)) { return Result.fail("参数错误"); } TbProductSkuWithBLOBs tbProductSkuWithBLOBs = tbProductSkuMapper.selectByShopIdAndProductIdAndSpec(shopId, productId, spec_tag); @@ -463,7 +478,7 @@ public class ProductService { tbProductSkuWithBLOBs.setId(null); }else { if (StringUtils.isNotBlank(code)) { - Integer sum = tbProductMapper.selectByCodeAndSkuId(code, tbProductSkuWithBLOBs.getId(), shopId); + Integer sum = tbProductMapper.selectByCodeAndSkuId(code, tbProductSkuWithBLOBs.getId(), shopId,isVip); tbProductSkuWithBLOBs.setNumber(sum); } } diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/TbActivateGiveRecordService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbActivateGiveRecordService.java deleted file mode 100644 index d10894b..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/TbActivateGiveRecordService.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.chaozhanggui.system.cashierservice.service; - -import com.chaozhanggui.system.cashierservice.entity.TbActivateGiveRecord; - -/** - * 活动商品赠送表(TbActivateGiveRecord)表服务接口 - * - * @author ww - * @since 2024-08-20 15:20:43 - */ -public interface TbActivateGiveRecordService { - - /** - * 通过ID查询单条数据 - * - * @param id 主键 - * @return 实例对象 - */ - TbActivateGiveRecord queryById(Integer id); - - /** - * 新增数据 - * - * @param tbActivateGiveRecord 实例对象 - * @return 实例对象 - */ - TbActivateGiveRecord insert(TbActivateGiveRecord tbActivateGiveRecord); - - /** - * 修改数据 - * - * @param tbActivateGiveRecord 实例对象 - * @return 实例对象 - */ - TbActivateGiveRecord update(TbActivateGiveRecord tbActivateGiveRecord); - - /** - * 通过主键删除数据 - * - * @param id 主键 - * @return 是否成功 - */ - boolean deleteById(Integer id); - -} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/TbActivateInRecordService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbActivateInRecordService.java new file mode 100644 index 0000000..01c3a7d --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbActivateInRecordService.java @@ -0,0 +1,56 @@ +package com.chaozhanggui.system.cashierservice.service; + +import com.chaozhanggui.system.cashierservice.entity.TbActivateInRecord; +import com.chaozhanggui.system.cashierservice.entity.TbProduct; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; + +import java.util.List; + +/** + * 活动商品赠送表(TbActivateInRecord)表服务接口 + * + * @author ww + * @since 2024-08-22 11:13:40 + */ +public interface TbActivateInRecordService { + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + TbActivateInRecord queryById(Integer id); + + List queryByVipIdAndShopId(Integer vipUserId, Integer shopId); + int queryByVipIdAndShopIdAndProId(Integer vipUserId, Integer shopId,Integer productId); + List queryAllByVipIdAndShopIdAndProId(Integer vipUserId, Integer shopId,Integer productId); + + /** + * 新增数据 + * + * @param tbActivateInRecord 实例对象 + * @return 实例对象 + */ + TbActivateInRecord insert(TbActivateInRecord tbActivateInRecord); + + /** + * 修改数据 + * + * @param tbActivateInRecord 实例对象 + * @return 实例对象 + */ + TbActivateInRecord update(TbActivateInRecord tbActivateInRecord); + + int updateOverNumById(Integer id,Integer overNum); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 是否成功 + */ + boolean deleteById(Integer id); + +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/TbActivateOutRecordService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbActivateOutRecordService.java new file mode 100644 index 0000000..e8be3aa --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbActivateOutRecordService.java @@ -0,0 +1,45 @@ +package com.chaozhanggui.system.cashierservice.service; + +import com.chaozhanggui.system.cashierservice.entity.TbActivateOutRecord; + +/** + * 活动赠送商品使用记录表(TbActivateOutRecord)表服务接口 + * + * @author ww + * @since 2024-08-22 11:21:56 + */ +public interface TbActivateOutRecordService { + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + TbActivateOutRecord queryById(Integer id); + + /** + * 新增数据 + * + * @param tbActivateOutRecord 实例对象 + * @return 实例对象 + */ + TbActivateOutRecord insert(TbActivateOutRecord tbActivateOutRecord); + + /** + * 修改数据 + * + * @param tbActivateOutRecord 实例对象 + * @return 实例对象 + */ + TbActivateOutRecord update(TbActivateOutRecord tbActivateOutRecord); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 是否成功 + */ + boolean deleteById(Integer id); + +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbActivateGiveRecordServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbActivateGiveRecordServiceImpl.java deleted file mode 100644 index c690e62..0000000 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbActivateGiveRecordServiceImpl.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.chaozhanggui.system.cashierservice.service.impl; - -import com.chaozhanggui.system.cashierservice.entity.TbActivateGiveRecord; -import com.chaozhanggui.system.cashierservice.dao.TbActivateGiveRecordMapper; -import com.chaozhanggui.system.cashierservice.service.TbActivateGiveRecordService; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; - -/** - * 活动商品赠送表(TbActivateGiveRecord)表服务实现类 - * - * @author ww - * @since 2024-08-20 15:20:43 - */ -@Service -public class TbActivateGiveRecordServiceImpl implements TbActivateGiveRecordService { - @Resource - private TbActivateGiveRecordMapper tbActivateGiveRecordMapper; - - /** - * 通过ID查询单条数据 - * - * @param id 主键 - * @return 实例对象 - */ - @Override - public TbActivateGiveRecord queryById(Integer id) { - return this.tbActivateGiveRecordMapper.queryById(id); - } - - - /** - * 新增数据 - * - * @param tbActivateGiveRecord 实例对象 - * @return 实例对象 - */ - @Override - public TbActivateGiveRecord insert(TbActivateGiveRecord tbActivateGiveRecord) { - this.tbActivateGiveRecordMapper.insert(tbActivateGiveRecord); - return tbActivateGiveRecord; - } - - /** - * 修改数据 - * - * @param tbActivateGiveRecord 实例对象 - * @return 实例对象 - */ - @Override - public TbActivateGiveRecord update(TbActivateGiveRecord tbActivateGiveRecord) { - this.tbActivateGiveRecordMapper.update(tbActivateGiveRecord); - return this.queryById(tbActivateGiveRecord.getId()); - } - - /** - * 通过主键删除数据 - * - * @param id 主键 - * @return 是否成功 - */ - @Override - public boolean deleteById(Integer id) { - return this.tbActivateGiveRecordMapper.deleteById(id) > 0; - } -} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbActivateInRecordServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbActivateInRecordServiceImpl.java new file mode 100644 index 0000000..efcba84 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbActivateInRecordServiceImpl.java @@ -0,0 +1,96 @@ +package com.chaozhanggui.system.cashierservice.service.impl; + +import com.chaozhanggui.system.cashierservice.dao.TbActivateInRecordMapper; +import com.chaozhanggui.system.cashierservice.entity.TbActivateInRecord; +import com.chaozhanggui.system.cashierservice.entity.TbProduct; +import com.chaozhanggui.system.cashierservice.service.TbActivateInRecordService; +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; + +/** + * 活动商品赠送表(TbActivateInRecord)表服务实现类 + * + * @author ww + * @since 2024-08-22 11:13:40 + */ +@Service +@Primary +public class TbActivateInRecordServiceImpl implements TbActivateInRecordService { + @Resource + private TbActivateInRecordMapper tbActivateInRecordMapper; + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + @Override + public TbActivateInRecord queryById(Integer id) { + return this.tbActivateInRecordMapper.queryById(id); + } + + @Override + public List queryByVipIdAndShopId(Integer vipUserId, Integer shopId) { +// List tbProducts = tbActivateInRecordMapper.queryByVipIdAndShopId(vipUserId, shopId); +// for (TbProduct tbProduct : tbProducts) { +// tbProduct.setLimitNumber(tbActivateInRecordMapper.queryByVipIdAndShopIdAndProId(vipUserId, shopId,tbProduct.getId())); +// } +// return tbProducts; + return tbActivateInRecordMapper.queryByVipIdAndShopId(vipUserId, shopId); + } + + @Override + public int queryByVipIdAndShopIdAndProId(Integer vipUserId, Integer shopId,Integer productId){ + return tbActivateInRecordMapper.queryByVipIdAndShopIdAndProId(vipUserId,shopId,productId); + } + + @Override + public List queryAllByVipIdAndShopIdAndProId(Integer vipUserId, Integer shopId,Integer productId){ + return tbActivateInRecordMapper.queryAllByVipIdAndShopIdAndProId(vipUserId,shopId,productId); + } + + + /** + * 新增数据 + * + * @param tbActivateInRecord 实例对象 + * @return 实例对象 + */ + @Override + public TbActivateInRecord insert(TbActivateInRecord tbActivateInRecord) { + this.tbActivateInRecordMapper.insert(tbActivateInRecord); + return tbActivateInRecord; + } + + /** + * 修改数据 + * + * @param tbActivateInRecord 实例对象 + * @return 实例对象 + */ + @Override + public TbActivateInRecord update(TbActivateInRecord tbActivateInRecord) { + this.tbActivateInRecordMapper.update(tbActivateInRecord); + return this.queryById(tbActivateInRecord.getId()); + } + + @Override + public int updateOverNumById(Integer id,Integer overNum){ + return tbActivateInRecordMapper.updateOverNumById(id,overNum); + } + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 是否成功 + */ + @Override + public boolean deleteById(Integer id) { + return this.tbActivateInRecordMapper.deleteById(id) > 0; + } +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbActivateOutRecordServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbActivateOutRecordServiceImpl.java new file mode 100644 index 0000000..493603d --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbActivateOutRecordServiceImpl.java @@ -0,0 +1,69 @@ +package com.chaozhanggui.system.cashierservice.service.impl; + +import com.chaozhanggui.system.cashierservice.entity.TbActivateOutRecord; +import com.chaozhanggui.system.cashierservice.dao.TbActivateOutRecordMapper; +import com.chaozhanggui.system.cashierservice.service.TbActivateOutRecordService; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + +/** + * 活动赠送商品使用记录表(TbActivateOutRecord)表服务实现类 + * + * @author ww + * @since 2024-08-22 11:21:56 + */ +@Service +@Primary +public class TbActivateOutRecordServiceImpl implements TbActivateOutRecordService { + @Resource + private TbActivateOutRecordMapper tbActivateOutRecordMapper; + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + @Override + public TbActivateOutRecord queryById(Integer id) { + return this.tbActivateOutRecordMapper.queryById(id); + } + + /** + * 新增数据 + * + * @param tbActivateOutRecord 实例对象 + * @return 实例对象 + */ + @Override + public TbActivateOutRecord insert(TbActivateOutRecord tbActivateOutRecord) { + this.tbActivateOutRecordMapper.insert(tbActivateOutRecord); + return tbActivateOutRecord; + } + + /** + * 修改数据 + * + * @param tbActivateOutRecord 实例对象 + * @return 实例对象 + */ + @Override + public TbActivateOutRecord update(TbActivateOutRecord tbActivateOutRecord) { + this.tbActivateOutRecordMapper.update(tbActivateOutRecord); + return this.queryById(tbActivateOutRecord.getId()); + } + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 是否成功 + */ + @Override + public boolean deleteById(Integer id) { + return this.tbActivateOutRecordMapper.deleteById(id) > 0; + } +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbActivateProductServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbActivateProductServiceImpl.java index 4803729..66e033e 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbActivateProductServiceImpl.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbActivateProductServiceImpl.java @@ -4,6 +4,7 @@ package com.chaozhanggui.system.cashierservice.service.impl; import com.chaozhanggui.system.cashierservice.dao.TbActivateProductMapper; import com.chaozhanggui.system.cashierservice.entity.TbActivateProduct; import com.chaozhanggui.system.cashierservice.service.TbActivateProductService; +import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -15,6 +16,7 @@ import javax.annotation.Resource; * @since 2024-08-20 15:15:02 */ @Service +@Primary public class TbActivateProductServiceImpl implements TbActivateProductService { @Resource private TbActivateProductMapper tbActivateProductMapper; diff --git a/src/main/resources/mapper/TbActivateGiveRecordMapper.xml b/src/main/resources/mapper/TbActivateInRecordMapper.xml similarity index 57% rename from src/main/resources/mapper/TbActivateGiveRecordMapper.xml rename to src/main/resources/mapper/TbActivateInRecordMapper.xml index 63320d2..27c4cb5 100644 --- a/src/main/resources/mapper/TbActivateGiveRecordMapper.xml +++ b/src/main/resources/mapper/TbActivateInRecordMapper.xml @@ -1,12 +1,13 @@ - + - + + @@ -16,23 +17,55 @@ id - , vip_user_id, pro_id, num, shop_id, source_flow_id,source_act_id, create_time, update_time + , vip_user_id, pro_id, num, over_num, shop_id, source_act_id, source_flow_id, create_time, update_time - select - from tb_activate_give_record + from tb_activate_in_record where id = #{id} + + + + + + - select - from tb_activate_give_record + from tb_activate_in_record and id = #{id} @@ -46,6 +79,9 @@ and num = #{num} + + and over_num = #{overNum} + and shop_id = #{shopId} @@ -67,22 +103,25 @@ - insert into tb_activate_give_record(vip_user_id, pro_id, num, shop_id, source_act_id, source_flow_id, create_time, update_time) - values (#{vipUserId}, #{proId}, #{num}, #{shopId}, #{sourceActId}, #{sourceFlowId}, #{createTime}, #{updateTime}) + insert into tb_activate_in_record(vip_user_id, pro_id, num, over_num, shop_id, source_act_id, source_flow_id, + create_time, update_time) + values (#{vipUserId}, #{proId}, #{num}, #{overNum}, #{shopId}, #{sourceActId}, #{sourceFlowId}, #{createTime}, + #{updateTime}) - insert into tb_activate_give_record(vip_user_id, pro_id, num, shop_id, source_act_id, source_flow_id, create_time, update_time) + insert into tb_activate_in_record(vip_user_id, pro_id, num, over_num, shop_id, source_act_id, source_flow_id, + create_time, update_time) values - (#{entity.vipUserId}, #{entity.proId}, #{entity.num}, #{entity.shopId}, #{entity.sourceActId}, - #{entity.sourceFlowId},#{entity.createTime}, #{entity.updateTime}) + (#{entity.vipUserId}, #{entity.proId}, #{entity.num}, #{entity.overNum}, #{entity.shopId}, + #{entity.sourceActId}, #{entity.sourceFlowId}, #{entity.createTime}, #{entity.updateTime}) - update tb_activate_give_record + update tb_activate_in_record vip_user_id = #{vipUserId}, @@ -93,6 +132,9 @@ num = #{num}, + + over_num = #{overNum}, + shop_id = #{shopId}, @@ -111,11 +153,18 @@ where id = #{id} + + update tb_activate_in_record + set + over_num = #{overNum} + where id = #{id}; + + delete - from tb_activate_give_record + from tb_activate_in_record where id = #{id} diff --git a/src/main/resources/mapper/TbActivateOutRecordMapper.xml b/src/main/resources/mapper/TbActivateOutRecordMapper.xml new file mode 100644 index 0000000..ba0d537 --- /dev/null +++ b/src/main/resources/mapper/TbActivateOutRecordMapper.xml @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + id + , give_id, pro_id, use_num, ref_num, order_id,status, create_time, update_time + + + + + + + + + + + insert into tb_activate_out_record(give_id, pro_id, use_num, ref_num, order_id, status, create_time, update_time) + values (#{giveId}, #{proId}, #{useNum}, #{refNum}, #{orderId}, #{status} #{createTime}, #{updateTime}) + + + + insert into tb_activate_out_record(give_id, pro_id, use_num, ref_num, order_id, status, create_time, update_time) + values + + (#{entity.giveId}, #{entity.proId}, #{entity.useNum}, #{entity.refNum}, #{entity.orderId}, + #{entity.status}, #{entity.createTime}, #{entity.updateTime}) + + + + + + update tb_activate_out_record + + + give_id = #{giveId}, + + + pro_id = #{proId}, + + + use_num = #{useNum}, + + + ref_num = #{refNum}, + + + order_id = #{orderId}, + + + status = #{status}, + + + create_time = #{createTime}, + + + update_time = #{updateTime}, + + + where id = #{id} + + + update tb_activate_out_record + set + status = 'closed' + where order_id = #{orderId} + + + + + + delete + from tb_activate_out_record + where id = #{id} + + + + diff --git a/src/main/resources/mapper/TbActivateProductMapper.xml b/src/main/resources/mapper/TbActivateProductMapper.xml index 56eefa7..ac6356a 100644 --- a/src/main/resources/mapper/TbActivateProductMapper.xml +++ b/src/main/resources/mapper/TbActivateProductMapper.xml @@ -58,6 +58,15 @@ id, activate_id, product_id, num, create_time, update_time activate_id = #{activateId} + + diff --git a/src/main/resources/mapper/TbCashierCartMapper.xml b/src/main/resources/mapper/TbCashierCartMapper.xml index 0674893..50c4e1a 100644 --- a/src/main/resources/mapper/TbCashierCartMapper.xml +++ b/src/main/resources/mapper/TbCashierCartMapper.xml @@ -33,11 +33,12 @@ + id, master_id, order_id, ref_order_id, total_amount, product_id, cover_img, is_sku,pack_fee,is_pack,is_gift,pending_at, sku_id, name, sale_price, number, total_number, refund_number, category_id, status, - type, merchant_id, shop_id, created_at, updated_at, user_id, table_id,pack_fee,trade_day,uuid,sku_name + type, merchant_id, shop_id, created_at, updated_at, user_id, table_id,pack_fee,trade_day,uuid,sku_name,is_vip select @@ -43,12 +44,12 @@ product_id, product_sku_id, num, product_name, product_sku_name, product_img, create_time, update_time, price, - price_amount,pack_amount,status) + price_amount,pack_amount,status,is_vip) values (#{id,jdbcType=INTEGER}, #{orderId,jdbcType=INTEGER}, #{shopId,jdbcType=INTEGER}, #{productId,jdbcType=INTEGER}, #{productSkuId,jdbcType=INTEGER}, #{num,jdbcType=INTEGER}, #{productName,jdbcType=VARCHAR}, #{productSkuName,jdbcType=VARCHAR}, #{productImg,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{price,jdbcType=DECIMAL}, - #{priceAmount,jdbcType=DECIMAL},#{packAmount,jdbcType=DECIMAL},#{status,jdbcType=VARCHAR}) + #{priceAmount,jdbcType=DECIMAL},#{packAmount,jdbcType=DECIMAL},#{status,jdbcType=VARCHAR},#{isVip,jdbcType=TINYINT}) insert into tb_order_detail @@ -92,6 +93,9 @@ price_amount, + + is_vip, + @@ -133,6 +137,9 @@ #{priceAmount,jdbcType=DECIMAL}, + + #{isVip,jdbcType=TINYINT}, + num = #{num,jdbcType=INTEGER}, + + is_vip = #{isVip,jdbcType=TINYINT}, + product_name = #{productName,jdbcType=VARCHAR}, @@ -197,6 +207,7 @@ create_time = #{createTime,jdbcType=TIMESTAMP}, update_time = #{updateTime,jdbcType=TIMESTAMP}, price = #{price,jdbcType=DECIMAL}, + is_vip= #{isVip,jdbcType=TINYINT}, price_amount = #{priceAmount,jdbcType=DECIMAL} where id = #{id,jdbcType=INTEGER} diff --git a/src/main/resources/mapper/TbProductMapper.xml b/src/main/resources/mapper/TbProductMapper.xml index 66fee1f..4946725 100644 --- a/src/main/resources/mapper/TbProductMapper.xml +++ b/src/main/resources/mapper/TbProductMapper.xml @@ -1009,6 +1009,7 @@ AND t.sku_id = #{skuId} AND t.`status` = 'create' AND t.table_id = #{code} + AND t.is_vip = #{isVip} + + + + + + + - select - from tb_activate_give_record + from tb_activate_in_record and id = #{id} @@ -46,6 +79,9 @@ and num = #{num} + + and over_num = #{overNum} + and shop_id = #{shopId} @@ -67,22 +103,25 @@ - insert into tb_activate_give_record(vip_user_id, pro_id, num, shop_id, source_act_id, source_flow_id, create_time, update_time) - values (#{vipUserId}, #{proId}, #{num}, #{shopId}, #{sourceActId}, #{sourceFlowId}, #{createTime}, #{updateTime}) + insert into tb_activate_in_record(vip_user_id, pro_id, num, over_num, shop_id, source_act_id, source_flow_id, + create_time, update_time) + values (#{vipUserId}, #{proId}, #{num}, #{overNum}, #{shopId}, #{sourceActId}, #{sourceFlowId}, #{createTime}, + #{updateTime}) - insert into tb_activate_give_record(vip_user_id, pro_id, num, shop_id, source_act_id, source_flow_id, create_time, update_time) + insert into tb_activate_in_record(vip_user_id, pro_id, num, over_num, shop_id, source_act_id, source_flow_id, + create_time, update_time) values - (#{entity.vipUserId}, #{entity.proId}, #{entity.num}, #{entity.shopId}, #{entity.sourceActId}, - #{entity.sourceFlowId},#{entity.createTime}, #{entity.updateTime}) + (#{entity.vipUserId}, #{entity.proId}, #{entity.num}, #{entity.overNum}, #{entity.shopId}, + #{entity.sourceActId}, #{entity.sourceFlowId}, #{entity.createTime}, #{entity.updateTime}) - update tb_activate_give_record + update tb_activate_in_record vip_user_id = #{vipUserId}, @@ -93,6 +132,9 @@ num = #{num}, + + over_num = #{overNum}, + shop_id = #{shopId}, @@ -111,11 +153,18 @@ where id = #{id} + + update tb_activate_in_record + set + over_num = #{overNum} + where id = #{id}; + + delete - from tb_activate_give_record + from tb_activate_in_record where id = #{id} diff --git a/src/main/resources/mapper/TbActivateOutRecordMapper.xml b/src/main/resources/mapper/TbActivateOutRecordMapper.xml new file mode 100644 index 0000000..ba0d537 --- /dev/null +++ b/src/main/resources/mapper/TbActivateOutRecordMapper.xml @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + id + , give_id, pro_id, use_num, ref_num, order_id,status, create_time, update_time + + + + + + + + + + + insert into tb_activate_out_record(give_id, pro_id, use_num, ref_num, order_id, status, create_time, update_time) + values (#{giveId}, #{proId}, #{useNum}, #{refNum}, #{orderId}, #{status} #{createTime}, #{updateTime}) + + + + insert into tb_activate_out_record(give_id, pro_id, use_num, ref_num, order_id, status, create_time, update_time) + values + + (#{entity.giveId}, #{entity.proId}, #{entity.useNum}, #{entity.refNum}, #{entity.orderId}, + #{entity.status}, #{entity.createTime}, #{entity.updateTime}) + + + + + + update tb_activate_out_record + + + give_id = #{giveId}, + + + pro_id = #{proId}, + + + use_num = #{useNum}, + + + ref_num = #{refNum}, + + + order_id = #{orderId}, + + + status = #{status}, + + + create_time = #{createTime}, + + + update_time = #{updateTime}, + + + where id = #{id} + + + update tb_activate_out_record + set + status = 'closed' + where order_id = #{orderId} + + + + + + delete + from tb_activate_out_record + where id = #{id} + + + + diff --git a/src/main/resources/mapper/TbActivateProductMapper.xml b/src/main/resources/mapper/TbActivateProductMapper.xml index 56eefa7..ac6356a 100644 --- a/src/main/resources/mapper/TbActivateProductMapper.xml +++ b/src/main/resources/mapper/TbActivateProductMapper.xml @@ -58,6 +58,15 @@ id, activate_id, product_id, num, create_time, update_time activate_id = #{activateId} + + diff --git a/src/main/resources/mapper/TbCashierCartMapper.xml b/src/main/resources/mapper/TbCashierCartMapper.xml index 0674893..50c4e1a 100644 --- a/src/main/resources/mapper/TbCashierCartMapper.xml +++ b/src/main/resources/mapper/TbCashierCartMapper.xml @@ -33,11 +33,12 @@ + id, master_id, order_id, ref_order_id, total_amount, product_id, cover_img, is_sku,pack_fee,is_pack,is_gift,pending_at, sku_id, name, sale_price, number, total_number, refund_number, category_id, status, - type, merchant_id, shop_id, created_at, updated_at, user_id, table_id,pack_fee,trade_day,uuid,sku_name + type, merchant_id, shop_id, created_at, updated_at, user_id, table_id,pack_fee,trade_day,uuid,sku_name,is_vip select @@ -43,12 +44,12 @@ product_id, product_sku_id, num, product_name, product_sku_name, product_img, create_time, update_time, price, - price_amount,pack_amount,status) + price_amount,pack_amount,status,is_vip) values (#{id,jdbcType=INTEGER}, #{orderId,jdbcType=INTEGER}, #{shopId,jdbcType=INTEGER}, #{productId,jdbcType=INTEGER}, #{productSkuId,jdbcType=INTEGER}, #{num,jdbcType=INTEGER}, #{productName,jdbcType=VARCHAR}, #{productSkuName,jdbcType=VARCHAR}, #{productImg,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{price,jdbcType=DECIMAL}, - #{priceAmount,jdbcType=DECIMAL},#{packAmount,jdbcType=DECIMAL},#{status,jdbcType=VARCHAR}) + #{priceAmount,jdbcType=DECIMAL},#{packAmount,jdbcType=DECIMAL},#{status,jdbcType=VARCHAR},#{isVip,jdbcType=TINYINT}) insert into tb_order_detail @@ -92,6 +93,9 @@ price_amount, + + is_vip, + @@ -133,6 +137,9 @@ #{priceAmount,jdbcType=DECIMAL}, + + #{isVip,jdbcType=TINYINT}, + num = #{num,jdbcType=INTEGER}, + + is_vip = #{isVip,jdbcType=TINYINT}, + product_name = #{productName,jdbcType=VARCHAR}, @@ -197,6 +207,7 @@ create_time = #{createTime,jdbcType=TIMESTAMP}, update_time = #{updateTime,jdbcType=TIMESTAMP}, price = #{price,jdbcType=DECIMAL}, + is_vip= #{isVip,jdbcType=TINYINT}, price_amount = #{priceAmount,jdbcType=DECIMAL} where id = #{id,jdbcType=INTEGER} diff --git a/src/main/resources/mapper/TbProductMapper.xml b/src/main/resources/mapper/TbProductMapper.xml index 66fee1f..4946725 100644 --- a/src/main/resources/mapper/TbProductMapper.xml +++ b/src/main/resources/mapper/TbProductMapper.xml @@ -1009,6 +1009,7 @@ AND t.sku_id = #{skuId} AND t.`status` = 'create' AND t.table_id = #{code} + AND t.is_vip = #{isVip} From a8fff70798423e24282deca2652fa161d713ded7 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Fri, 23 Aug 2024 11:08:30 +0800 Subject: [PATCH 17/21] =?UTF-8?q?=E4=BC=9A=E5=91=98=E5=95=86=E5=93=81=20?= =?UTF-8?q?=E4=B8=8D=E5=81=9A=E8=B5=B7=E5=94=AE=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/cashierservice/service/CartService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java index 1487dfd..833db96 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/CartService.java @@ -224,7 +224,7 @@ public class CartService { if (cashierCart.getSkuId().equals(skuId) && cashierCart.getIsVip().intValue() == isVip) { cashierCart.setTotalNumber(buyNum); cashierCart.setNumber(buyNum); - if (type == 0 && tbProductSkuWithBLOBs.getSuit() != null && tbProductSkuWithBLOBs.getSuit() > 1 && cashierCart.getNumber() < tbProductSkuWithBLOBs.getSuit()) { + if (type == 0 && isVip == 0 && tbProductSkuWithBLOBs.getSuit() != null && tbProductSkuWithBLOBs.getSuit() > 1 && cashierCart.getNumber() < tbProductSkuWithBLOBs.getSuit()) { cashierCartMapper.deleteByPrimaryKey(cashierCart.getId()); continue; } @@ -398,7 +398,7 @@ public class CartService { String key = tableId + "-" + shopId; TbProductSkuWithBLOBs productSku = productSkuMapper.selectByPrimaryKey(Integer.valueOf(skuId)); TbCashierCart cashierCart = new TbCashierCart(); - if (productSku.getSuit() != null && productSku.getSuit() > 1) { + if (productSku.getSuit() != null && productSku.getSuit() > 1 && isVip != 1) { if (product.getIsStock() == 1) { boolean isSale = false; // 1:共享库存 0:独立库存 From 870ed00e1c4f8a6d4ae40f773e0faf0885b66ccc Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Fri, 23 Aug 2024 11:18:43 +0800 Subject: [PATCH 18/21] =?UTF-8?q?=E6=94=AF=E4=BB=98=E5=AE=8C=E6=88=90=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B5=A0=E9=80=81=E5=95=86=E5=93=81=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/cashierservice/service/PayService.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java index 2e54784..721c520 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java @@ -370,10 +370,6 @@ public class PayService { // return Result.failCode("会员卡余额不足","2"); return Result.success(CodeEnum.SUCCESS, "2"); } - List cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, null); - if (ObjectUtil.isEmpty(cashierCarts) || ObjectUtil.isNull(cashierCarts)) { - return Result.fail("购物车信息不存在"); - } user.setAmount(user.getAmount().subtract(orderInfo.getOrderAmount())); user.setConsumeAmount(user.getConsumeAmount().add(orderInfo.getPayAmount())); @@ -406,7 +402,7 @@ public class PayService { tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed"); tbOrderDetailMapper.updateStatusByOrderIdAndStatus(Integer.valueOf(orderId), "closed"); - + outRecordMapper.updateByOrderIdAndStatus(orderInfo.getId(),"closed"); log.info("更新购物车:{}", cartCount); JSONObject jsonObject = new JSONObject(); From 7232fb317320d8dba0e742ad021aae46697f6695 Mon Sep 17 00:00:00 2001 From: SongZhang <2064194730@qq.com> Date: Fri, 23 Aug 2024 16:54:30 +0800 Subject: [PATCH 19/21] =?UTF-8?q?1.=E6=9F=A5=E8=AF=A2=E8=A7=84=E6=A0=BC?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=90=8C=E6=AD=A5=E8=BF=94=E5=9B=9E=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E5=94=AE=E7=BD=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/ProductService.java | 44 ++++++++++++++++--- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java index 9ef636d..9c6f777 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java @@ -233,7 +233,8 @@ public class ProductService { // 重组有效规格数据 String tagSnap = skuResult != null ? skuResult.getTagSnap() : null; - List tbProductSkus = tbProductSkuMapper.selectGroundingByProId(querySpecDTO.getProductId()); +// List tbProductSkus = tbProductSkuMapper.selectGroundingByProId(querySpecDTO.getProductId()); + List tbProductSkus = tbProductSkuMapper.selectSku(String.valueOf(querySpecDTO.getProductId())); JSONArray finalSnap = new JSONArray(); // if (tagSnap != null) { @@ -315,11 +316,17 @@ public class ProductService { } ArrayList> specList = new ArrayList<>(); + HashMap unGroundingMap = new HashMap<>(); tbProductSkus.forEach(item -> { - HashMap itemMap = new HashMap<>(); - itemMap.put("specSnap", item.getSpecSnap()); - itemMap.put("skuId", item.getId()); - specList.add(itemMap); + if (item.getIsGrounding() == 1) { + HashMap itemMap = new HashMap<>(); + itemMap.put("specSnap", item.getSpecSnap()); + itemMap.put("skuId", item.getId()); + itemMap.put("info", item); + specList.add(itemMap); + }else { + unGroundingMap.put(item.getSpecSnap(), item); + } }); @@ -329,6 +336,13 @@ public class ProductService { for (HashMap spec : specList) { if (res.equals(spec.get("specSnap").toString())) { spec.put("isGrounding", true); + TbProductSku sku = (TbProductSku) spec.get("info"); + if (sku != null) { + checkPauseSale(tbProduct, new ArrayList<>(Collections.singletonList(sku)), true); + spec.put("isPauseSale", tbProduct.getIsPauseSale()); + }else { + spec.put("isPauseSale", 1); + } found = true; break; } @@ -338,6 +352,13 @@ public class ProductService { itemMap.put("specSnap", res); itemMap.put("skuId", null); itemMap.put("isGrounding", false); + TbProductSku sku = unGroundingMap.get("specSnap"); + if (sku != null) { + checkPauseSale(tbProduct, Collections.singletonList(sku), true); + itemMap.put("isPauseSale", tbProduct.getIsPauseSale()); + }else { + itemMap.put("isPauseSale", 1); + } otherVal.add(itemMap); } } @@ -387,7 +408,7 @@ public class ProductService { List tbProductSkus = tbProductSkuMapper.selectGroundingByProId(it.getId()); TbProductSkuResult skuResult = tbProductSkuResultMapper.selectByPrimaryKey(it.getId()); //判断库存及耗材 - checkPauseSale(it,tbProductSkus); + checkPauseSale(it,tbProductSkus, false); AtomicDouble sum = new AtomicDouble(0.0); BigDecimal lowerPrice = null; @@ -418,14 +439,23 @@ public class ProductService { } } - public void checkPauseSale(TbProduct tbProduct, List skus) { + public void checkPauseSale(TbProduct tbProduct, List skus, boolean isSingle) { if (tbProduct.getIsStock() == 1) {//库存开关 1开启 if (Integer.valueOf(tbProduct.getIsDistribute()).equals(1)) {//共享库存 1开启 if (tbProduct.getStockNumber() != null && tbProduct.getStockNumber() <= 0) { tbProduct.setIsPauseSale(Byte.parseByte("1"));//售罄 1暂停 return; } + + if (isSingle && tbProduct.getIsPauseSale() == 1) { + return; + } } else { + if (isSingle && !skus.stream().filter(res -> res.getIsPauseSale().equals(1)).collect(Collectors.toList()).isEmpty()) { + tbProduct.setIsPauseSale(Byte.parseByte("1"));//售罄 1暂停 + return; + } + if (!tbProduct.getTypeEnum().equals("sku")) { if (skus.stream().anyMatch(sku -> sku.getStockNumber() != null && sku.getStockNumber() <= 0)){ tbProduct.setIsPauseSale(Byte.parseByte("1"));//售罄 1暂停 From f16090f04ed2e8d9a85328fef95fcf0a423e543f Mon Sep 17 00:00:00 2001 From: SongZhang <2064194730@qq.com> Date: Fri, 23 Aug 2024 17:17:35 +0800 Subject: [PATCH 20/21] =?UTF-8?q?1.=E6=9F=A5=E8=AF=A2=E8=A7=84=E6=A0=BC?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=90=8C=E6=AD=A5=E8=BF=94=E5=9B=9E=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E5=94=AE=E7=BD=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/cashierservice/service/ProductService.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java index 9c6f777..9e2c781 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/ProductService.java @@ -338,6 +338,7 @@ public class ProductService { spec.put("isGrounding", true); TbProductSku sku = (TbProductSku) spec.get("info"); if (sku != null) { + tbProduct.setIsPauseSale(tbProduct.getIsDistribute() == 1 ? tbProduct.getIsPauseSale() : sku.getIsPauseSale().byteValue()); checkPauseSale(tbProduct, new ArrayList<>(Collections.singletonList(sku)), true); spec.put("isPauseSale", tbProduct.getIsPauseSale()); }else { @@ -354,6 +355,7 @@ public class ProductService { itemMap.put("isGrounding", false); TbProductSku sku = unGroundingMap.get("specSnap"); if (sku != null) { + tbProduct.setIsPauseSale(tbProduct.getIsDistribute() == 1 ? tbProduct.getIsPauseSale() : sku.getIsPauseSale().byteValue()); checkPauseSale(tbProduct, Collections.singletonList(sku), true); itemMap.put("isPauseSale", tbProduct.getIsPauseSale()); }else { From 1b1fe068449cac5f4959040a0410bae12f8b9088 Mon Sep 17 00:00:00 2001 From: SongZhang <2064194730@qq.com> Date: Fri, 23 Aug 2024 17:39:12 +0800 Subject: [PATCH 21/21] =?UTF-8?q?1.=E6=9F=A5=E8=AF=A2=E8=A7=84=E6=A0=BC?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=90=8C=E6=AD=A5=E8=BF=94=E5=9B=9E=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E5=94=AE=E7=BD=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/mapper/TbProductSkuMapper.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/mapper/TbProductSkuMapper.xml b/src/main/resources/mapper/TbProductSkuMapper.xml index 65a401f..d02c9b6 100644 --- a/src/main/resources/mapper/TbProductSkuMapper.xml +++ b/src/main/resources/mapper/TbProductSkuMapper.xml @@ -403,7 +403,7 @@ FROM tb_product_sku WHERE - product_id = #{productId} + product_id = #{productId} and is_del=0