优惠券 出入
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.ShopActivateInRecord;
|
||||
|
||||
/**
|
||||
* 活动商品赠送记录表 映射层。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-02-17
|
||||
*/
|
||||
public interface ShopActivateInRecordMapper extends BaseMapper<ShopActivateInRecord> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.czg.service.account.mapper;
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.account.entity.ShopActivate;
|
||||
|
||||
/**
|
||||
* 活动 映射层。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-02-17
|
||||
*/
|
||||
public interface ShopActivateMapper extends BaseMapper<ShopActivate> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
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> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.czg.service.account.mapper;
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.account.entity.ShopCoupon;
|
||||
|
||||
/**
|
||||
* 优惠券 映射层。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-02-17
|
||||
*/
|
||||
public interface ShopCouponMapper extends BaseMapper<ShopCoupon> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
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{
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
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{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.czg.service.account.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.czg.account.dto.ShopActivateDTO;
|
||||
import com.czg.account.entity.ShopActivate;
|
||||
import com.czg.account.service.ShopActivateService;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.service.account.mapper.ShopActivateMapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 活动 服务层实现。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-02-17
|
||||
*/
|
||||
@DubboService
|
||||
public class ShopActivateServiceImpl extends ServiceImpl<ShopActivateMapper, ShopActivate> implements ShopActivateService {
|
||||
|
||||
@Override
|
||||
public List<ShopActivateDTO> getList() {
|
||||
return queryChain().select().eq(ShopActivate::getShopId, StpKit.USER.getShopId())
|
||||
.orderBy(ShopActivate::getAmount, true).listAs(ShopActivateDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean add(ShopActivateDTO activateDTO) {
|
||||
ShopActivate shopActivate = new ShopActivate();
|
||||
BeanUtil.copyProperties(activateDTO, shopActivate);
|
||||
return save(shopActivate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean edit(ShopActivateDTO activateDTO) {
|
||||
ShopActivate shopActivate = new ShopActivate();
|
||||
BeanUtil.copyProperties(activateDTO, shopActivate);
|
||||
return updateById(shopActivate);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.czg.service.account.service.impl;
|
||||
|
||||
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.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.account.entity.ShopCoupon;
|
||||
import com.czg.account.service.ShopCouponService;
|
||||
import com.czg.service.account.mapper.ShopCouponMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 优惠券 服务层实现。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-02-17
|
||||
*/
|
||||
@Service
|
||||
public class ShopCouponServiceImpl extends ServiceImpl<ShopCouponMapper, ShopCoupon> implements ShopCouponService {
|
||||
|
||||
@Resource
|
||||
private ShopActivateInRecordService inService;
|
||||
@Resource
|
||||
private ShopActivateOutRecordService outService;
|
||||
|
||||
@Override
|
||||
public List<ShopCouponDTO> getList(ShopCouponDTO couponDTO) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ShopCouponDTO getCouponById(ShopCouponDTO couponDTO) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean add(ShopCouponDTO couponDTO) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean edit(ShopCouponDTO couponDTO) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean delete(Long id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean find(Long id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean use(Integer shopId, Integer orderId, Integer vipUserId, List<ShopActivateOutRecord> param) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 退还券
|
||||
*
|
||||
* @param param giveId和 refNum 必传
|
||||
*/
|
||||
@Override
|
||||
public Boolean refund(List<ShopActivateOutRecord> param) {
|
||||
// for (ShopActivateOutRecord outRecord : param) {
|
||||
// outService.updateChain()
|
||||
// .set(ShopActivateOutRecord::getRefNum, outRecord.getRefNum())
|
||||
// .eq(ShopActivateOutRecord::getId, outRecord.getId())
|
||||
// .update();
|
||||
// ShopActivateInRecord inRecord = inService.getById(outRecord.getGiveId());
|
||||
// inRecord.setOverNum(inRecord.getOverNum() + outRecord.getRefNum());
|
||||
// inService.updateOverNum(inRecord.getId(), inRecord.getOverNum());
|
||||
// }
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ import com.czg.exception.ApiNotPrintException;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.service.RedisService;
|
||||
import com.czg.service.account.mapper.ShopUserMapper;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import com.czg.utils.PageUtil;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
@@ -131,13 +132,9 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
|
||||
@Override
|
||||
public String getCode(long userInfoId, long shopId) {
|
||||
ShopUser shopUser = queryChain().eq(ShopUser::getShopId, shopId).eq(ShopUser::getUserId, userInfoId).one();
|
||||
if (shopUser == null) {
|
||||
throw new ApiNotPrintException("会员信息不存在");
|
||||
}
|
||||
AssertUtil.isNull(shopUser, "会员信息不存在");
|
||||
String dynamicCode = generatePaymentCode(String.valueOf(shopId), String.valueOf(userInfoId));
|
||||
redisService.set(RedisCst.SHOP_USER_DYNAMIC_CODE + shopUser.getId(), dynamicCode, 300);
|
||||
shopUser.setDynamicCode(dynamicCode);
|
||||
updateById(shopUser);
|
||||
redisService.set(RedisCst.SHOP_USER_DYNAMIC_CODE + shopUser.getId() + ":" + dynamicCode, 1, 180);
|
||||
return dynamicCode;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<?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,7 @@
|
||||
<?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.ShopActivateMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,7 @@
|
||||
<?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.ShopActivateOutRecordMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,7 @@
|
||||
<?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.ShopCouponMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.czg.service.order.dto;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 创建订单
|
||||
* @author ww
|
||||
*/
|
||||
@Data
|
||||
public class CreateOrderDTO {
|
||||
@NotBlank(message = "桌号不能为空")
|
||||
private String tableCode;
|
||||
@NotBlank(message = "用餐模式 堂食 dine-in 外带 take-out 外卖 take-away")
|
||||
private String dineMode;
|
||||
/**
|
||||
* 平台类型
|
||||
* 微信小程序 WX
|
||||
* 支付宝小程序 ALI
|
||||
* 收银机客户端 PC
|
||||
* PC管理端 APC
|
||||
* APP管理端 APP
|
||||
*/
|
||||
@NotBlank(message = "平台类型不能为空")
|
||||
private String platformType;
|
||||
|
||||
/**
|
||||
* 是否使用了霸王餐
|
||||
*/
|
||||
private boolean isFreeDine = false;
|
||||
|
||||
private String remark;
|
||||
|
||||
// 使用的积分抵扣数量
|
||||
private Integer pointsNum;
|
||||
|
||||
// 使用的优惠券
|
||||
@Valid
|
||||
private List<UserCouponInfoDTO> userCouponInfos = new ArrayList<>();
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.czg.service.order.dto;
|
||||
|
||||
import jakarta.validation.constraints.Min;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class UserCouponInfoDTO {
|
||||
private Long userCouponId;
|
||||
@Min(1)
|
||||
private Integer num;
|
||||
}
|
||||
@@ -57,10 +57,12 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
|
||||
queryWrapper.eq(OrderInfo::getShopId, param.getShopId())
|
||||
.eq(OrderInfo::getStatus, param.getStatus())
|
||||
.eq(OrderInfo::getOrderNo, param.getOrderNo())
|
||||
.eq(OrderInfo::getPayType, param.getPayType())
|
||||
.eq(OrderInfo::getTableCode, param.getTableCode())
|
||||
.eq(OrderInfo::getUserId, param.getUserId())
|
||||
.eq(OrderInfo::getTableCode, param.getTableCode())
|
||||
.eq(OrderInfo::getOrderNo, param.getOrderNo())
|
||||
.gt(OrderInfo::getCreateTime, param.getStartTime())
|
||||
.le(OrderInfo::getCreateTime, param.getEndTime())
|
||||
.in(OrderInfo::getId, like);
|
||||
Page<OrderInfoVo> orderInfoVoPage = pageAs(PageUtil.buildPage(), queryWrapper, OrderInfoVo.class);
|
||||
orderInfoVoPage.getRecords().parallelStream().forEach(s -> {
|
||||
@@ -83,8 +85,8 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
.where(OrderPayment::getId).eq(payment.getId())
|
||||
.update();
|
||||
|
||||
if ("TRADE_SUCCESS" .equals(czgCallBackDto.getState())) {
|
||||
if ("order" .equals(payment.getPayType())) {
|
||||
if ("TRADE_SUCCESS".equals(czgCallBackDto.getState())) {
|
||||
if ("order".equals(payment.getPayType())) {
|
||||
updateChain().of(OrderInfo.class)
|
||||
.set(OrderInfo::getPayAmount, new BigDecimal(czgCallBackDto.getAmount() / 100L))
|
||||
.set(OrderInfo::getStatus, OrderStatusEnums.DONE.getCode())
|
||||
|
||||
Reference in New Issue
Block a user