优惠券重构
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
package com.czg.service.account.mapper;
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.account.entity.PointsBasicSetting;
|
||||
|
||||
/**
|
||||
* 积分基本设置 映射层。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-02-20
|
||||
*/
|
||||
public interface PointsBasicSettingMapper extends BaseMapper<PointsBasicSetting> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.czg.service.account.mapper;
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.account.entity.ShopActivateCouponRecord;
|
||||
|
||||
/**
|
||||
* 活动商品赠送记录表 映射层。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-02-20
|
||||
*/
|
||||
public interface ShopActivateCouponRecordMapper extends BaseMapper<ShopActivateCouponRecord> {
|
||||
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.czg.service.account.mapper;
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.account.entity.ShopActivateInRecord;
|
||||
|
||||
/**
|
||||
* 活动商品赠送记录表 映射层。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-02-17
|
||||
*/
|
||||
public interface ShopActivateInRecordMapper extends BaseMapper<ShopActivateInRecord> {
|
||||
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.czg.service.account.mapper;
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.account.entity.ShopActivateOutRecord;
|
||||
|
||||
/**
|
||||
* 活动赠送商品使用记录表 映射层。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-02-17
|
||||
*/
|
||||
public interface ShopActivateOutRecordMapper extends BaseMapper<ShopActivateOutRecord> {
|
||||
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.czg.service.account.mapper;
|
||||
|
||||
import com.czg.account.entity.ShopCouponProduct;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
|
||||
/**
|
||||
* 活动赠送商品表 映射层。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-02-18
|
||||
*/
|
||||
public interface ShopCouponProductMapper extends BaseMapper<ShopCouponProduct> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.czg.service.account.service.impl;
|
||||
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.account.entity.PointsBasicSetting;
|
||||
import com.czg.account.service.PointsBasicSettingService;
|
||||
import com.czg.service.account.mapper.PointsBasicSettingMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 积分基本设置 服务层实现。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-02-20
|
||||
*/
|
||||
@Service
|
||||
public class PointsBasicSettingServiceImpl extends ServiceImpl<PointsBasicSettingMapper, PointsBasicSetting> implements PointsBasicSettingService{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.czg.service.account.service.impl;
|
||||
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.account.entity.ShopActivateCouponRecord;
|
||||
import com.czg.account.service.ShopActivateCouponRecordService;
|
||||
import com.czg.service.account.mapper.ShopActivateCouponRecordMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 活动商品赠送记录表 服务层实现。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-02-20
|
||||
*/
|
||||
@Service
|
||||
public class ShopActivateCouponRecordServiceImpl extends ServiceImpl<ShopActivateCouponRecordMapper, ShopActivateCouponRecord> implements ShopActivateCouponRecordService{
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.czg.service.account.service.impl;
|
||||
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.account.entity.ShopActivateInRecord;
|
||||
import com.czg.account.service.ShopActivateInRecordService;
|
||||
import com.czg.service.account.mapper.ShopActivateInRecordMapper;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
|
||||
|
||||
/**
|
||||
* 活动商品赠送记录表 服务层实现。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-02-17
|
||||
*/
|
||||
@DubboService
|
||||
public class ShopActivateInRecordServiceImpl extends ServiceImpl<ShopActivateInRecordMapper, ShopActivateInRecord> implements ShopActivateInRecordService{
|
||||
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.czg.service.account.service.impl;
|
||||
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.account.entity.ShopActivateOutRecord;
|
||||
import com.czg.account.service.ShopActivateOutRecordService;
|
||||
import com.czg.service.account.mapper.ShopActivateOutRecordMapper;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 活动赠送商品使用记录表 服务层实现。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-02-17
|
||||
*/
|
||||
@DubboService
|
||||
public class ShopActivateOutRecordServiceImpl extends ServiceImpl<ShopActivateOutRecordMapper, ShopActivateOutRecord> implements ShopActivateOutRecordService{
|
||||
|
||||
}
|
||||
@@ -1,17 +1,22 @@
|
||||
package com.czg.service.account.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.account.dto.ShopActivateCouponDTO;
|
||||
import com.czg.account.dto.ShopActivateDTO;
|
||||
import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO;
|
||||
import com.czg.account.entity.ShopActivate;
|
||||
import com.czg.account.entity.ShopActivateInRecord;
|
||||
import com.czg.account.entity.ShopActivateCouponRecord;
|
||||
import com.czg.account.entity.ShopCoupon;
|
||||
import com.czg.account.entity.ShopCouponProduct;
|
||||
import com.czg.account.service.*;
|
||||
import com.czg.account.vo.CouponProductVo;
|
||||
import com.czg.account.service.ShopActivateCouponRecordService;
|
||||
import com.czg.account.service.ShopActivateService;
|
||||
import com.czg.account.service.ShopCouponService;
|
||||
import com.czg.account.service.ShopUserService;
|
||||
import com.czg.enums.ShopUserFlowBizEnum;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.service.account.mapper.ShopActivateMapper;
|
||||
@@ -24,7 +29,9 @@ import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 活动 服务层实现。
|
||||
@@ -38,24 +45,31 @@ public class ShopActivateServiceImpl extends ServiceImpl<ShopActivateMapper, Sho
|
||||
@Resource
|
||||
private ShopCouponService couponService;
|
||||
@Resource
|
||||
private ShopActivateInRecordService inRecordService;
|
||||
@Resource
|
||||
private ShopCouponProductService couProductService;
|
||||
private ShopActivateCouponRecordService inRecordService;
|
||||
@Resource
|
||||
private ShopUserService shopUserService;
|
||||
|
||||
@Override
|
||||
public List<ShopActivateDTO> getList() {
|
||||
return queryChain().select()
|
||||
List<ShopActivateDTO> activateDtoS = queryChain().select()
|
||||
.eq(ShopActivate::getShopId, StpKit.USER.getShopId())
|
||||
.orderBy(ShopActivate::getAmount, true)
|
||||
.listAs(ShopActivateDTO.class);
|
||||
for (ShopActivateDTO activateDTO : activateDtoS) {
|
||||
if (StrUtil.isNotBlank(activateDTO.getCoupons())) {
|
||||
activateDTO.setCouponList(JSON.parseArray(activateDTO.getCoupons(), ShopActivateCouponDTO.class));
|
||||
}
|
||||
}
|
||||
return activateDtoS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean add(ShopActivateDTO activateDTO) {
|
||||
ShopActivate shopActivate = new ShopActivate();
|
||||
BeanUtil.copyProperties(activateDTO, shopActivate);
|
||||
if (CollUtil.isNotEmpty(activateDTO.getCouponList())) {
|
||||
shopActivate.setCoupons(JSONObject.toJSONString(activateDTO.getCouponList()));
|
||||
}
|
||||
return save(shopActivate);
|
||||
}
|
||||
|
||||
@@ -63,6 +77,9 @@ public class ShopActivateServiceImpl extends ServiceImpl<ShopActivateMapper, Sho
|
||||
public Boolean edit(ShopActivateDTO activateDTO) {
|
||||
ShopActivate shopActivate = new ShopActivate();
|
||||
BeanUtil.copyProperties(activateDTO, shopActivate);
|
||||
if (CollUtil.isNotEmpty(activateDTO.getCouponList())) {
|
||||
shopActivate.setCoupons(JSONObject.toJSONString(activateDTO.getCouponList()));
|
||||
}
|
||||
return updateById(shopActivate);
|
||||
}
|
||||
|
||||
@@ -77,70 +94,58 @@ public class ShopActivateServiceImpl extends ServiceImpl<ShopActivateMapper, Sho
|
||||
}
|
||||
//赠送优惠券
|
||||
if (activate.getIsGiftCoupon() == 1) {
|
||||
ShopCoupon shopCoupon = couponService.getById(activate.getCouponId());
|
||||
if (shopCoupon != null && shopCoupon.getStatus().equals(1) && shopCoupon.getLeftNumber() > activate.getNum()) {
|
||||
LocalDateTime start = LocalDateTime.now().with(LocalTime.MIN);
|
||||
LocalDateTime end = null;
|
||||
if ("fixed".equals(shopCoupon.getValidityType())) {
|
||||
//固定时间
|
||||
end = LocalDateTimeUtil.offset(start, shopCoupon.getValidDays(), ChronoUnit.DAYS).with(LocalTime.MAX);
|
||||
} else if ("custom".equals(shopCoupon.getValidityType())) {
|
||||
//自定义时间
|
||||
start = shopCoupon.getValidStartTime();
|
||||
end = shopCoupon.getValidEndTime();
|
||||
List<ShopActivateCouponDTO> activateCoupons = JSON.parseArray(activate.getCoupons(), ShopActivateCouponDTO.class);
|
||||
Map<Long, ShopCoupon> couponMap = new HashMap<>();
|
||||
activateCoupons.forEach(coupon -> {
|
||||
ShopCoupon shopCoupon = new ShopCoupon();
|
||||
if (couponMap.containsKey(coupon.getId())) {
|
||||
shopCoupon = couponMap.get(coupon.getId());
|
||||
} else {
|
||||
shopCoupon = couponService.queryChain().select().eq(ShopCoupon::getId, coupon.getId()).one();
|
||||
couponMap.put(coupon.getId(), shopCoupon);
|
||||
}
|
||||
List<ShopActivateInRecord> actGiveRecords = new ArrayList<>();
|
||||
if (shopCoupon.getType() == 1) {
|
||||
//满减
|
||||
ShopActivateInRecord record = new ShopActivateInRecord();
|
||||
if (shopCoupon != null && shopCoupon.getStatus().equals(1) && shopCoupon.getLeftNumber() > coupon.getNum()) {
|
||||
LocalDateTime start = LocalDateTime.now().with(LocalTime.MIN);
|
||||
LocalDateTime end = null;
|
||||
if ("fixed".equals(shopCoupon.getValidityType())) {
|
||||
//固定时间
|
||||
end = LocalDateTimeUtil.offset(start, shopCoupon.getValidDays(), ChronoUnit.DAYS).with(LocalTime.MAX);
|
||||
} else if ("custom".equals(shopCoupon.getValidityType())) {
|
||||
//自定义时间
|
||||
start = shopCoupon.getValidStartTime();
|
||||
end = shopCoupon.getValidEndTime();
|
||||
}
|
||||
List<ShopActivateCouponRecord> actGiveRecords = new ArrayList<>();
|
||||
ShopActivateCouponRecord record = new ShopActivateCouponRecord();
|
||||
record.setVipUserId(vipId);
|
||||
record.setCouponId(shopCoupon.getId());
|
||||
record.setName("满" + shopCoupon.getFullAmount() + "减" + shopCoupon.getDiscountAmount());
|
||||
record.setFullAmount(shopCoupon.getFullAmount());
|
||||
record.setDiscountAmount(shopCoupon.getDiscountAmount());
|
||||
record.setType(1);
|
||||
record.setNum(activate.getNum());
|
||||
record.setOverNum(activate.getNum());
|
||||
record.setShopId(shopId);
|
||||
record.setSourceActId(activate.getId());
|
||||
record.setSourceFlowId(relationId);
|
||||
record.setUseStartTime(start);
|
||||
record.setUseEndTime(end);
|
||||
record.setSource("activate");
|
||||
record.setCouponJson(getCouponJson(activate, shopCoupon, null));
|
||||
actGiveRecords.add(record);
|
||||
} else if (shopCoupon.getType() == 2) {
|
||||
List<CouponProductVo> couponProducts = couProductService.queryChain()
|
||||
.select(ShopCouponProduct::getProductId, ShopCouponProduct::getNum)
|
||||
.eq(ShopCouponProduct::getCouponId, shopCoupon.getId())
|
||||
.listAs(CouponProductVo.class);
|
||||
//商品券
|
||||
for (CouponProductVo actPro : couponProducts) {
|
||||
ShopActivateInRecord record = new ShopActivateInRecord();
|
||||
record.setVipUserId(vipId);
|
||||
record.setCouponId(shopCoupon.getId());
|
||||
record.setName("商品券");
|
||||
record.setCouponJson(getCouponJson(activate, shopCoupon));
|
||||
if (shopCoupon.getType() == 1) {
|
||||
record.setType(1);
|
||||
record.setName("满" + shopCoupon.getFullAmount() + "减" + shopCoupon.getDiscountAmount());
|
||||
record.setFullAmount(shopCoupon.getFullAmount());
|
||||
record.setDiscountAmount(shopCoupon.getDiscountAmount());
|
||||
} else if (shopCoupon.getType() == 2) {
|
||||
record.setType(2);
|
||||
record.setProId(actPro.getProductId());
|
||||
record.setNum(actPro.getNum() * activate.getNum());
|
||||
record.setOverNum(actPro.getNum() * activate.getNum());
|
||||
record.setShopId(shopId);
|
||||
record.setSourceActId(activate.getId());
|
||||
record.setSourceFlowId(relationId);
|
||||
record.setUseStartTime(start);
|
||||
record.setUseEndTime(end);
|
||||
record.setSource("activate");
|
||||
record.setCouponJson(getCouponJson(activate, shopCoupon, actPro));
|
||||
record.setName("商品券");
|
||||
record.setProId(shopCoupon.getProId());
|
||||
}
|
||||
for (int i = 0; i < coupon.getNum(); i++) {
|
||||
actGiveRecords.add(record);
|
||||
}
|
||||
inRecordService.saveBatch(actGiveRecords);
|
||||
couponService.updateChain()
|
||||
.set(ShopCoupon::getLeftNumber, shopCoupon.getLeftNumber() - coupon.getNum())
|
||||
.eq(ShopCoupon::getId, shopCoupon.getId())
|
||||
.update();
|
||||
}
|
||||
inRecordService.saveBatch(actGiveRecords);
|
||||
shopCoupon.setLeftNumber(shopCoupon.getLeftNumber() - activate.getNum());
|
||||
couponService.updateChain()
|
||||
.set(ShopCoupon::getLeftNumber, shopCoupon.getLeftNumber() - activate.getNum())
|
||||
.eq(ShopCoupon::getId, shopCoupon.getId())
|
||||
.update();
|
||||
}
|
||||
});
|
||||
}
|
||||
//赠送金额
|
||||
if (activate.getGiftAmount() != null && activate.getGiftAmount().compareTo(BigDecimal.ZERO) > 0) {
|
||||
@@ -158,13 +163,10 @@ public class ShopActivateServiceImpl extends ServiceImpl<ShopActivateMapper, Sho
|
||||
}
|
||||
|
||||
|
||||
private String getCouponJson(ShopActivate activate, ShopCoupon tbShopCoupon, CouponProductVo couProduct) {
|
||||
private String getCouponJson(ShopActivate activate, ShopCoupon tbShopCoupon) {
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("activate", JSONObject.toJSONString(activate));
|
||||
result.put("coupon", JSONObject.toJSONString(tbShopCoupon));
|
||||
if (couProduct != null) {
|
||||
result.put("couProduct", JSONObject.toJSONString(couProduct));
|
||||
}
|
||||
return result.toJSONString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.czg.service.account.service.impl;
|
||||
|
||||
import com.czg.account.entity.ShopCouponProduct;
|
||||
import com.czg.account.service.ShopCouponProductService;
|
||||
import com.czg.service.account.mapper.ShopCouponProductMapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 活动赠送商品表 服务层实现。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-02-18
|
||||
*/
|
||||
@Service
|
||||
public class ShopCouponProductServiceImpl extends ServiceImpl<ShopCouponProductMapper, ShopCouponProduct> implements ShopCouponProductService {
|
||||
|
||||
}
|
||||
@@ -2,10 +2,8 @@ package com.czg.service.account.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.czg.account.dto.ShopCouponDTO;
|
||||
import com.czg.account.entity.ShopActivateInRecord;
|
||||
import com.czg.account.entity.ShopActivateOutRecord;
|
||||
import com.czg.account.service.ShopActivateInRecordService;
|
||||
import com.czg.account.service.ShopActivateOutRecordService;
|
||||
import com.czg.account.entity.ShopActivateCouponRecord;
|
||||
import com.czg.account.service.ShopActivateCouponRecordService;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.account.entity.ShopCoupon;
|
||||
@@ -26,23 +24,21 @@ import java.util.List;
|
||||
public class ShopCouponServiceImpl extends ServiceImpl<ShopCouponMapper, ShopCoupon> implements ShopCouponService {
|
||||
|
||||
@Resource
|
||||
private ShopActivateInRecordService inService;
|
||||
@Resource
|
||||
private ShopActivateOutRecordService outService;
|
||||
private ShopActivateCouponRecordService inService;
|
||||
|
||||
@Override
|
||||
public List<ShopCoupon> getList(Long shopId, Integer status) {
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
if (shopId != null) {
|
||||
if (status == 1) {
|
||||
queryWrapper.eq(ShopActivateOutRecord::getShopId, shopId);
|
||||
queryWrapper.eq(ShopActivateCouponRecord::getShopId, shopId);
|
||||
}else {
|
||||
queryWrapper.eq(ShopActivateInRecord::getShopId, shopId);
|
||||
queryWrapper.eq(ShopActivateCouponRecord::getShopId, shopId);
|
||||
}
|
||||
}
|
||||
return switch (status) {
|
||||
case -1 -> {
|
||||
queryWrapper.ge(ShopActivateInRecord::getUseEndTime, DateUtil.date());
|
||||
queryWrapper.ge(ShopActivateCouponRecord::getUseEndTime, DateUtil.date());
|
||||
yield list(queryWrapper);
|
||||
}
|
||||
case 0 -> {
|
||||
@@ -84,17 +80,16 @@ public class ShopCouponServiceImpl extends ServiceImpl<ShopCouponMapper, ShopCou
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean use(Integer shopId, Integer orderId, Integer vipUserId, List<ShopActivateOutRecord> param) {
|
||||
public Boolean use(Integer shopId, Integer orderId, Integer vipUserId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 退还券
|
||||
*
|
||||
* @param param giveId和 refNum 必传
|
||||
*/
|
||||
@Override
|
||||
public Boolean refund(List<ShopActivateOutRecord> param) {
|
||||
public Boolean refund() {
|
||||
// for (ShopActivateOutRecord outRecord : param) {
|
||||
// outService.updateChain()
|
||||
// .set(ShopActivateOutRecord::getRefNum, outRecord.getRefNum())
|
||||
|
||||
@@ -7,21 +7,21 @@ import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.qrcode.QrCodeUtil;
|
||||
import com.czg.account.dto.table.ShopTableAddDTO;
|
||||
import com.czg.account.dto.table.ShopTableBindDTO;
|
||||
import com.czg.account.entity.ShopTable;
|
||||
import com.czg.account.entity.ShopTableArea;
|
||||
import com.czg.account.entity.ShopTableCode;
|
||||
import com.czg.account.service.ShopTableAreaService;
|
||||
import com.czg.account.service.ShopTableCodeService;
|
||||
import com.czg.account.service.ShopTableService;
|
||||
import com.czg.enums.ShopTableStatusEnum;
|
||||
import com.czg.exception.ApiNotPrintException;
|
||||
import com.czg.service.account.mapper.ShopTableMapper;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.account.entity.ShopTable;
|
||||
import com.czg.account.service.ShopTableService;
|
||||
import com.czg.service.account.mapper.ShopTableMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@@ -39,8 +39,8 @@ import java.util.zip.ZipOutputStream;
|
||||
* @author zs
|
||||
* @since 2025-02-13
|
||||
*/
|
||||
@Service
|
||||
public class ShopTableServiceImpl extends ServiceImpl<ShopTableMapper, ShopTable> implements ShopTableService{
|
||||
@DubboService
|
||||
public class ShopTableServiceImpl extends ServiceImpl<ShopTableMapper, ShopTable> implements ShopTableService {
|
||||
@Resource
|
||||
private ShopTableAreaService shopAreaService;
|
||||
@Resource
|
||||
@@ -80,6 +80,11 @@ public class ShopTableServiceImpl extends ServiceImpl<ShopTableMapper, ShopTable
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ShopTable getOneByTableCode(Long shopId, String tableCode) {
|
||||
return queryChain().eq(ShopTable::getShopId, shopId).eq(ShopTable::getTableCode, tableCode).one();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createQrCode(Long shopId, Integer num, HttpServletResponse response) throws IOException {
|
||||
// 查询 shop 下面有多少台桌
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.czg.service.account.mapper.ShopCouponProductMapper">
|
||||
<mapper namespace="com.czg.service.account.mapper.PointsBasicSettingMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -2,6 +2,6 @@
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.czg.service.account.mapper.ShopActivateOutRecordMapper">
|
||||
<mapper namespace="com.czg.service.account.mapper.ShopActivateCouponRecordMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.czg.service.account.mapper.ShopActivateInRecordMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.czg.service.order.mapper;
|
||||
|
||||
import com.czg.order.entity.OrderDetail;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.order.entity.CashierCart;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 购物车 映射层。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-02-20
|
||||
*/
|
||||
public interface CashierCartMapper extends BaseMapper<CashierCart> {
|
||||
|
||||
|
||||
List<OrderDetail> getCartByTableCode(String tableCode);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.czg.service.order.service.impl;
|
||||
|
||||
import com.czg.order.entity.OrderDetail;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.order.entity.CashierCart;
|
||||
import com.czg.order.service.CashierCartService;
|
||||
import com.czg.service.order.mapper.CashierCartMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 购物车 服务层实现。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-02-20
|
||||
*/
|
||||
@Service
|
||||
public class CashierCartServiceImpl extends ServiceImpl<CashierCartMapper, CashierCart> implements CashierCartService{
|
||||
|
||||
@Override
|
||||
public List<OrderDetail> getCartByTableCode(String tableCode) {
|
||||
return getMapper().getCartByTableCode(tableCode);
|
||||
}
|
||||
}
|
||||
@@ -1,29 +1,33 @@
|
||||
package com.czg.service.order.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.exceptions.ValidateException;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO;
|
||||
import com.czg.account.entity.ShopUser;
|
||||
import com.czg.account.service.ShopActivateService;
|
||||
import com.czg.account.service.ShopUserService;
|
||||
import com.czg.account.entity.*;
|
||||
import com.czg.account.service.*;
|
||||
import com.czg.config.RabbitPublisher;
|
||||
import com.czg.entity.notify.CzgPayNotifyDTO;
|
||||
import com.czg.entity.notify.CzgRefundNotifyDTO;
|
||||
import com.czg.enums.ShopUserFlowBizEnum;
|
||||
import com.czg.order.dto.OrderInfoAddDTO;
|
||||
import com.czg.order.dto.OrderInfoQueryDTO;
|
||||
import com.czg.order.entity.OrderDetail;
|
||||
import com.czg.order.entity.OrderInfo;
|
||||
import com.czg.order.entity.OrderPayment;
|
||||
import com.czg.order.enums.PayEnums;
|
||||
import com.czg.order.service.CashierCartService;
|
||||
import com.czg.order.service.OrderDetailService;
|
||||
import com.czg.order.service.OrderInfoService;
|
||||
import com.czg.order.service.OrderPaymentService;
|
||||
import com.czg.order.vo.OrderDetailSmallVO;
|
||||
import com.czg.order.vo.OrderInfoCreateVo;
|
||||
import com.czg.order.vo.OrderInfoVo;
|
||||
import com.czg.service.order.enums.OrderStatusEnums;
|
||||
import com.czg.service.order.mapper.OrderInfoMapper;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import com.czg.utils.CzgStrUtils;
|
||||
import com.czg.utils.PageUtil;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
@@ -59,9 +63,21 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
private OrderPaymentService paymentService;
|
||||
@Resource
|
||||
private RabbitPublisher rabbitPublisher;
|
||||
@Resource
|
||||
private CashierCartService cartService;
|
||||
@Resource
|
||||
private OrderDetailService detailService;
|
||||
@DubboReference
|
||||
private ShopTableService shopTableService;
|
||||
@DubboReference
|
||||
private ShopInfoService shopInfoService;
|
||||
@DubboReference
|
||||
private PointsBasicSettingService pointsBasicService;
|
||||
@DubboReference
|
||||
private ShopUserService shopUserService;
|
||||
@DubboReference
|
||||
private UserInfoService userInfoService;
|
||||
@DubboReference
|
||||
private ShopActivateService activateService;
|
||||
|
||||
@Override
|
||||
@@ -97,6 +113,41 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
return orderInfoVoPage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrderInfoCreateVo createOrder(OrderInfoAddDTO param) {
|
||||
ShopInfo shopInfo = shopInfoService.getById(param.getShopId());
|
||||
AssertUtil.isNull(shopInfo, "生成订单失败,店铺信息不存在");
|
||||
if (shopInfo.getIsTableFee().equals(0) && param.getSeatNum() == 0) {
|
||||
throw new ValidateException("生成订单失败,请选择用餐人数后下单");
|
||||
}
|
||||
if (!shopInfo.getEatModel().contains(param.getEatModel())) {
|
||||
throw new ValidateException("生成订单失败,店铺不支持该用餐模式");
|
||||
}
|
||||
if ("afterPay".equals(param.getPayMode()) && !"restaurant".equals(shopInfo.getRegisterType())) {
|
||||
throw new ValidateException("生成订单失败,该店铺不支持后付费");
|
||||
}
|
||||
if (param.isVipPrice() && !shopInfo.getIsMemberPrice().equals(1)) {
|
||||
throw new ValidateException("生成订单失败,该店铺不支持使用会员价");
|
||||
}
|
||||
PointsBasicSetting pointSetting = pointsBasicService.getById(shopInfo.getId());
|
||||
if (param.getPointsNum().compareTo(BigDecimal.ZERO) > 0 && !pointSetting.getEnableDeduction().equals(1)) {
|
||||
throw new ValidateException("生成订单失败,该店铺未开启积分抵扣");
|
||||
}
|
||||
UserInfo userInfo = userInfoService.getById(param.getUserId());
|
||||
AssertUtil.isNull(userInfo, "生成订单失败,用户信息不存在");
|
||||
ShopUser shopUser = shopUserService.getShopUserInfo(param.getShopId(), param.getUserId());
|
||||
if (!shopUser.getIsVip().equals(1) && pointSetting.getDeductionGroup().contains("vip")) {
|
||||
throw new ValidateException("生成订单失败,该店铺仅会员可使用积分抵扣");
|
||||
}
|
||||
ShopTable table = shopTableService.getOneByTableCode(param.getShopId(), param.getTableCode());
|
||||
AssertUtil.isNull(table, "生成订单失败,桌台信息不存在");
|
||||
|
||||
// List<CashierCart> cashierCarts = cartService.
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void payCallBackOrder(@NotBlank String orderNo, @NotNull JSONObject resultJson) {
|
||||
|
||||
@@ -63,7 +63,7 @@ public class PayServiceImpl implements PayService {
|
||||
@DubboReference
|
||||
private ShopUserFlowService userFlowService;
|
||||
@DubboReference
|
||||
private ShopActivateInRecordService inRecordService;
|
||||
private ShopActivateCouponRecordService inRecordService;
|
||||
@Resource
|
||||
private RabbitPublisher rabbitPublisher;
|
||||
@Resource
|
||||
@@ -309,7 +309,7 @@ public class PayServiceImpl implements PayService {
|
||||
.eq(ShopUserFlow::getBizCode, ShopUserFlowBizEnum.AWARD_IN.getCode())
|
||||
.one();
|
||||
resultMap.put("amount", shopUser.getAmount());
|
||||
resultMap.put("inAmount", inFlow.getAmount( ));
|
||||
resultMap.put("inAmount", inFlow.getAmount());
|
||||
resultMap.put("inRefundAmount", inFlow.getRefundAmount());
|
||||
resultMap.put("giftAmount", giftFlow == null ? BigDecimal.ZERO : giftFlow.getAmount());
|
||||
resultMap.put("giftRefundAmount", giftFlow == null ? BigDecimal.ZERO : giftFlow.getRefundAmount());
|
||||
@@ -356,34 +356,34 @@ public class PayServiceImpl implements PayService {
|
||||
if (res.getCode() != 200 || res.getData() == null) {
|
||||
return CzgResult.failure(res.getMsg());
|
||||
}
|
||||
} else {
|
||||
ShopUserMoneyEditDTO shopUserMoneyEditDTO = ShopUserMoneyEditDTO.builder()
|
||||
.id(shopUser.getId())
|
||||
.money(refPayParam.getRefAmount())
|
||||
.type(0)
|
||||
.remark("退款")
|
||||
.bizEnum(ShopUserFlowBizEnum.RECHARGE_REFUND)
|
||||
.relationId(refPaymentId)
|
||||
.rechargeId(inFlow.getId())
|
||||
.build();
|
||||
//更新会员余额 并生成流水
|
||||
shopUserService.updateMoney(shopUser.getShopId(), shopUserMoneyEditDTO);
|
||||
}
|
||||
ShopUserMoneyEditDTO shopUserMoneyEditDTO = ShopUserMoneyEditDTO.builder()
|
||||
.id(shopUser.getId())
|
||||
.money(refPayParam.getRefAmount())
|
||||
.type(0)
|
||||
.remark("退款")
|
||||
.bizEnum(ShopUserFlowBizEnum.RECHARGE_REFUND)
|
||||
.relationId(refPaymentId)
|
||||
.rechargeId(inFlow.getId())
|
||||
.build();
|
||||
//更新会员余额 并生成流水
|
||||
shopUserService.updateMoney(shopUser.getShopId(), shopUserMoneyEditDTO);
|
||||
|
||||
userFlowService.updateChain()
|
||||
.setRaw(ShopUserFlow::getRefundAmount, "refund_amount" + refPayParam.getRefAmount())
|
||||
.eq(ShopUserFlow::getId, inFlow.getId())
|
||||
.update();
|
||||
if (giftFlow != null) {
|
||||
userFlowService.updateChain()
|
||||
.setRaw(ShopUserFlow::getRefundAmount, "refund_amount" + refPayParam.getRefAmount())
|
||||
.eq(ShopUserFlow::getId, inFlow.getId())
|
||||
.update();
|
||||
if (giftFlow != null) {
|
||||
userFlowService.updateChain()
|
||||
.setRaw(ShopUserFlow::getRefundAmount, "refund_amount" + giftFlow.getAmount())
|
||||
.eq(ShopUserFlow::getId, giftFlow.getId())
|
||||
.update();
|
||||
}
|
||||
inRecordService.updateChain()
|
||||
.set(ShopActivateInRecord::getOverNum, 0)
|
||||
.eq(ShopActivateInRecord::getId, inFlow.getId())
|
||||
.setRaw(ShopUserFlow::getRefundAmount, "refund_amount" + giftFlow.getAmount())
|
||||
.eq(ShopUserFlow::getId, giftFlow.getId())
|
||||
.update();
|
||||
}
|
||||
inRecordService.updateChain()
|
||||
.set(ShopActivateCouponRecord::getStatus, "not_used")
|
||||
.eq(ShopActivateCouponRecord::getSourceFlowId, inFlow.getId())
|
||||
.update();
|
||||
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.czg.service.order.mapper.CashierCartMapper">
|
||||
|
||||
<select id="getCartByTableCode" resultType="com.czg.order.entity.OrderDetail">
|
||||
select cart.shop_id as shopId,
|
||||
cart.product_id as productId,
|
||||
pros.product_name as productName,
|
||||
cart.sku_id as skuId,
|
||||
skus.spec_info as skuName,
|
||||
cart.number as number,
|
||||
from tb_cashier_cart cart
|
||||
left join tb_product pros on cart.product_id = pros.id
|
||||
left join tb_prod_sku skus on cart.sku_id = skus.id
|
||||
where table_code = #{tableCode}
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user