Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
@@ -43,10 +43,10 @@ public interface ShopUserMapper extends BaseMapper<ShopUser> {
|
||||
* @param shopId 店铺ID
|
||||
* @return 分页结果
|
||||
*/
|
||||
Page<ShopUser> selectPushEventUser(
|
||||
List<ShopUser> selectPushEventUser(
|
||||
@Param("mainShopId") Long mainShopId,
|
||||
@Param("shopId") Long shopId,
|
||||
SmsPushEventUser smsPushEventUser
|
||||
@Param("param") SmsPushEventUser smsPushEventUser
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@@ -29,15 +29,13 @@ import com.github.pagehelper.PageInfo;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
@@ -46,6 +44,7 @@ import java.util.stream.Collectors;
|
||||
* @author Administrator
|
||||
* @since 2025-02-08
|
||||
*/
|
||||
@Slf4j
|
||||
@DubboService
|
||||
public class AShopUserServiceImpl implements AShopUserService {
|
||||
@Resource
|
||||
@@ -95,14 +94,18 @@ public class AShopUserServiceImpl implements AShopUserService {
|
||||
|
||||
@Override
|
||||
public Page<ShopUser> getPushEventUser(SmsPushEventUser smsPushEventUser) {
|
||||
PageHelper.startPage(new Page<>(smsPushEventUser.getPage(), smsPushEventUser.getSize()));
|
||||
Long mainShopId = shopInfoService.getMainIdByShopId(smsPushEventUser.getShopId());
|
||||
// 调用Mapper层查询
|
||||
return shopUserMapper.selectPushEventUser(
|
||||
mainShopId,
|
||||
smsPushEventUser.getShopId(),
|
||||
smsPushEventUser
|
||||
);
|
||||
try {
|
||||
Long mainShopId = shopInfoService.getMainIdByShopId(smsPushEventUser.getShopId());
|
||||
PageHelper.startPage(smsPushEventUser.getPage(), smsPushEventUser.getSize());
|
||||
smsPushEventUser.checkIsAll();
|
||||
// 调用Mapper层查询
|
||||
List<ShopUser> shopUsers = shopUserMapper.selectPushEventUser(mainShopId,
|
||||
smsPushEventUser.getShopId(), smsPushEventUser);
|
||||
return PageUtil.convert(new PageInfo<>(shopUsers));
|
||||
}catch (Exception e){
|
||||
log.info("获取营销推送任务用户列表失败{},{}", smsPushEventUser, e.getMessage());
|
||||
return PageUtil.convert(new PageInfo<>());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -51,7 +51,6 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public ShopUser getShopUserInfo(Long shopId, long userId) {
|
||||
Long mainShopId = shopInfoService.getMainIdByShopId(shopId);
|
||||
@@ -117,6 +116,11 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
|
||||
shopUser.setConsumeCount(userInfo.getConsumeCount() + 1);
|
||||
shopUser.setConsumeAmount(userInfo.getConsumeAmount().add(shopUserEditDTO.getMoney()));
|
||||
updateById(shopUser);
|
||||
} else if (shopUserEditDTO.getType() == 1 && shopUserEditDTO.getBizEnum().getCode().contains("In")) {
|
||||
ShopUser shopUser = new ShopUser();
|
||||
shopUser.setId(userInfo.getId());
|
||||
shopUser.setRechargeCount(userInfo.getRechargeCount() + 1);
|
||||
updateById(shopUser);
|
||||
}
|
||||
return userFlow.getId();
|
||||
}
|
||||
|
||||
@@ -122,9 +122,9 @@
|
||||
u.id, u.head_img, u.nick_name, u.amount, u.account_points, u.phone,
|
||||
<choose>
|
||||
<!-- 当有筛选条件时才计算订单相关字段 -->
|
||||
<when test="orderTimeToday == 1 or orderTimeYesterday == 1 or
|
||||
orderTimeTwoWeeks == 1 or orderTimeMoreThanTwoWeeks == 1 or
|
||||
noOrder == 1 or oneOrder == 1 or fiveOrder == 1">
|
||||
<when test="param.orderTimeToday == 1 or param.orderTimeYesterday == 1 or
|
||||
param.orderTimeTwoWeeks == 1 or param.orderTimeMoreThanTwoWeeks == 1 or
|
||||
param.noOrder == 1 or param.oneOrder == 1 or param.fiveOrder == 1">
|
||||
COUNT(o.id) AS order_count,
|
||||
SUM(CASE WHEN o.trade_day = CURDATE() THEN 1 ELSE 0 END) AS today_orders,
|
||||
SUM(CASE WHEN o.trade_day = CURDATE() - INTERVAL 1 DAY THEN 1 ELSE 0 END) AS yesterday_orders,
|
||||
@@ -141,54 +141,48 @@
|
||||
0 AS earlier_orders
|
||||
</otherwise>
|
||||
</choose>
|
||||
FROM shop_user u
|
||||
FROM tb_shop_user u
|
||||
<!-- 只有当有筛选条件时才关联order表 -->
|
||||
<if test="orderTimeToday == 1 or orderTimeYesterday == 1 or
|
||||
orderTimeTwoWeeks == 1 or orderTimeMoreThanTwoWeeks == 1 or
|
||||
noOrder == 1 or oneOrder == 1 or fiveOrder == 1">
|
||||
LEFT JOIN `order` o ON u.user_id = o.user_id and o.user_id is not null AND o.shop_id = #{shopId} AND o.status = 'done'
|
||||
<if test="param.orderTimeToday == 1 or param.orderTimeYesterday == 1 or
|
||||
param.orderTimeTwoWeeks == 1 or param.orderTimeMoreThanTwoWeeks == 1 or
|
||||
param.noOrder == 1 or param.oneOrder == 1 or param.fiveOrder == 1">
|
||||
LEFT JOIN `tb_order_info` o ON u.user_id = o.user_id and o.user_id is not null AND o.shop_id = #{shopId} AND o.status = 'done'
|
||||
</if>
|
||||
WHERE u.main_shop_id = #{mainShopId} and u.phone is not null
|
||||
<!-- 性别筛选条件 -->
|
||||
<if test="(sexMan == 1 or sexWoman == 1 or sexUnknown == 1)">
|
||||
<if test="!(param.sexMan == 1 and param.sexWoman == 1 and param.sexUnknown == 1)
|
||||
and (param.sexMan == 1 or param.sexWoman == 1 or param.sexUnknown == 1)">
|
||||
AND
|
||||
<trim prefix="(" suffix=")" prefixOverrides="OR">
|
||||
<if test="sexMan == 1">OR u.sex = 1</if>
|
||||
<if test="sexWoman == 1">OR u.sex = 0</if>
|
||||
<if test="sexUnknown == 1">OR u.sex IS NULL</if>
|
||||
<if test="param.sexMan == 1">OR u.sex = 1</if>
|
||||
<if test="param.sexWoman == 1">OR u.sex = 0</if>
|
||||
<if test="param.sexUnknown == 1">OR u.sex IS NULL</if>
|
||||
</trim>
|
||||
</if>
|
||||
|
||||
<!-- 会员状态筛选 -->
|
||||
<if test="isVip != null">
|
||||
AND u.is_vip = #{isVip}
|
||||
<if test="param.isVip != null">
|
||||
AND u.is_vip = #{param.isVip}
|
||||
</if>
|
||||
|
||||
<!-- 充值状态筛选 -->
|
||||
<if test="isRecharge != null">
|
||||
AND
|
||||
<if test="isRecharge == 0">
|
||||
u.recharge_count = 0
|
||||
</if>
|
||||
<if test="isRecharge != 0">
|
||||
u.recharge_count > 0
|
||||
</if>
|
||||
</if>
|
||||
<if test="param.isRecharge != null">
|
||||
AND u.recharge_count <![CDATA[ ${param.isRecharge == 0 ? '=' : '>'} ]]> 0
|
||||
</if>
|
||||
<!-- 只有当有筛选条件时才需要HAVING子句 -->
|
||||
<if test="orderTimeToday == 1 or orderTimeYesterday == 1 or
|
||||
orderTimeTwoWeeks == 1 or orderTimeMoreThanTwoWeeks == 1 or
|
||||
noOrder == 1 or oneOrder == 1 or fiveOrder == 1">
|
||||
<if test="param.orderTimeToday == 1 or param.orderTimeYesterday == 1 or
|
||||
param.orderTimeTwoWeeks == 1 or param.orderTimeMoreThanTwoWeeks == 1 or
|
||||
param.noOrder == 1 or param.oneOrder == 1 or param.fiveOrder == 1">
|
||||
GROUP BY u.id
|
||||
HAVING
|
||||
<trim prefix="(" suffix=")" prefixOverrides="OR">
|
||||
<if test="orderTimeToday == 1">OR today_orders > 0</if>
|
||||
<if test="orderTimeYesterday == 1">OR yesterday_orders > 0</if>
|
||||
<if test="orderTimeTwoWeeks == 1">OR two_weeks_orders > 0</if>
|
||||
<if test="orderTimeMoreThanTwoWeeks == 1">OR earlier_orders > 0</if>
|
||||
<if test="param.orderTimeToday == 1">OR today_orders > 0</if>
|
||||
<if test="param.orderTimeYesterday == 1">OR yesterday_orders > 0</if>
|
||||
<if test="param.orderTimeTwoWeeks == 1">OR two_weeks_orders > 0</if>
|
||||
<if test="param.orderTimeMoreThanTwoWeeks == 1">OR earlier_orders > 0</if>
|
||||
|
||||
<if test="noOrder == 1">OR order_count = 0</if>
|
||||
<if test="oneOrder == 1">OR order_count = 1</if>
|
||||
<if test="fiveOrder == 1">OR order_count >= 5</if>
|
||||
<if test="param.noOrder == 1">OR order_count = 0</if>
|
||||
<if test="param.oneOrder == 1">OR order_count = 1</if>
|
||||
<if test="param.fiveOrder == 1">OR order_count >= 5</if>
|
||||
</trim>
|
||||
</if>
|
||||
order by u.create_time desc
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.czg.service.market.mapper;
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.market.entity.SmsShopMoneyDetail;
|
||||
|
||||
/**
|
||||
* 短信余额明细 映射层。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-10-16
|
||||
*/
|
||||
public interface SmsShopMoneyDetailMapper extends BaseMapper<SmsShopMoneyDetail> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.czg.service.market.mapper;
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.market.entity.SmsShopMoney;
|
||||
|
||||
/**
|
||||
* 店铺短信余额 映射层。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-10-16
|
||||
*/
|
||||
public interface SmsShopMoneyMapper extends BaseMapper<SmsShopMoney> {
|
||||
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import com.czg.TimeQueryParam;
|
||||
import com.czg.account.entity.ShopInfo;
|
||||
import com.czg.account.service.ShopInfoService;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.market.dto.MkDiscountActivityDTO;
|
||||
import com.czg.market.entity.MkDiscountActivity;
|
||||
import com.czg.market.entity.MkDiscountThreshold;
|
||||
@@ -21,7 +22,11 @@ import jakarta.annotation.Resource;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
|
||||
/**
|
||||
* 商家满减活动表 服务层实现。
|
||||
@@ -62,11 +67,17 @@ public class MkDiscountActivityServiceImpl extends ServiceImpl<MkDiscountActivit
|
||||
MkDiscountActivityDTO activityDTO = getActivityByShopId(shopId);
|
||||
AssertUtil.isNull(activityDTO, "店铺未配置满减活动");
|
||||
//检查是否开启了优惠券抵扣
|
||||
AssertUtil.isNotEqual(activityDTO.getCouponShare() == 1, couponShare, "满减活动与优惠券不可共用");
|
||||
if (couponShare && activityDTO.getCouponShare() == 0) {
|
||||
throw new CzgException("满减活动与优惠券不可共用");
|
||||
}
|
||||
//检查是否开启了会员抵扣
|
||||
AssertUtil.isNotEqual(activityDTO.getVipPriceShare() == 1, vipShare, "满减活动与会员价不可共用");
|
||||
if (vipShare && activityDTO.getVipPriceShare() == 0) {
|
||||
throw new CzgException("满减活动与会员价不可共用");
|
||||
}
|
||||
//检查是否开启了积分抵扣
|
||||
AssertUtil.isNotEqual(activityDTO.getPointsShare() == 1, pointsShare, "满减活动与积分抵扣不可共用");
|
||||
if (pointsShare && activityDTO.getPointsShare() == 0) {
|
||||
throw new CzgException("满减活动与积分抵扣不可共用");
|
||||
}
|
||||
return activityDTO;
|
||||
}
|
||||
|
||||
@@ -95,6 +106,7 @@ public class MkDiscountActivityServiceImpl extends ServiceImpl<MkDiscountActivit
|
||||
if (CollUtil.isEmpty(param.getThresholds())) {
|
||||
throw new IllegalArgumentException("活动必须配置满减阈值");
|
||||
}
|
||||
validateAndInitStatus(param);
|
||||
MkDiscountActivity activity = BeanUtil.toBean(param, MkDiscountActivity.class);
|
||||
save(activity);
|
||||
for (MkDiscountThreshold threshold : param.getThresholds()) {
|
||||
@@ -108,6 +120,7 @@ public class MkDiscountActivityServiceImpl extends ServiceImpl<MkDiscountActivit
|
||||
if (CollUtil.isEmpty(param.getThresholds())) {
|
||||
throw new IllegalArgumentException("活动必须配置满减阈值");
|
||||
}
|
||||
validateAndInitStatus(param);
|
||||
MkDiscountActivity activity = BeanUtil.toBean(param, MkDiscountActivity.class);
|
||||
updateById(activity, true);
|
||||
thresholdMapper.deleteByQuery(
|
||||
@@ -123,4 +136,38 @@ public class MkDiscountActivityServiceImpl extends ServiceImpl<MkDiscountActivit
|
||||
public void deleteActivity(Long id) {
|
||||
updateById(new MkDiscountActivity().setIsDel(true).setUpdateTime(LocalDateTime.now()).setId(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验时间有效性并初始化状态
|
||||
*/
|
||||
private void validateAndInitStatus(MkDiscountActivityDTO param) {
|
||||
LocalDate startDate;
|
||||
LocalDate endDate;
|
||||
LocalDate currentDate = LocalDate.now();
|
||||
|
||||
try {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
startDate = LocalDate.parse(param.getValidStartTime(), formatter);
|
||||
endDate = LocalDate.parse(param.getValidEndTime(), formatter);
|
||||
} catch (DateTimeParseException e) {
|
||||
throw new IllegalArgumentException("时间格式不正确,请使用yyyy-MM-dd格式");
|
||||
}
|
||||
// 校验开始时间不能晚于结束时间
|
||||
if (currentDate.isAfter(endDate)) {
|
||||
throw new CzgException("有效期结束时间不能早于当前时间");
|
||||
}
|
||||
// 校验开始时间不能晚于结束时间
|
||||
if (startDate.isAfter(endDate)) {
|
||||
throw new CzgException("有效期开始时间不能晚于结束时间");
|
||||
}
|
||||
|
||||
// 根据时间初始化状态
|
||||
if (currentDate.isBefore(startDate)) {
|
||||
// 当前日期在开始日期之前-未开始
|
||||
param.setStatus(1);
|
||||
} else {
|
||||
// 这里先默认设置为进行中,具体由定时任务根据时段更新
|
||||
param.setStatus(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,14 +38,14 @@ public class SmsPushEventServiceImpl extends ServiceImpl<SmsPushEventMapper, Sms
|
||||
private RabbitPublisher rabbitPublisher;
|
||||
|
||||
@Override
|
||||
public Page<SmsPushEventDTO> getPushEventPage(BaseQueryParam param, Long shopId, Long id) {
|
||||
public Page<SmsPushEventDTO> getPushEventPage(Integer page, Integer size, Long shopId, Long id) {
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
queryWrapper.eq(SmsPushEvent::getShopId, shopId)
|
||||
.eq(SmsPushEvent::getId, id)
|
||||
.eq(SmsPushEvent::getIsDel, 0)
|
||||
.orderBy(SmsPushEvent::getCreateTime).desc();
|
||||
Page<SmsPushEventDTO> page = pageAs(new Page<>(param.getPage(), param.getSize()), queryWrapper, SmsPushEventDTO.class);
|
||||
for (SmsPushEventDTO record : page.getRecords()) {
|
||||
Page<SmsPushEventDTO> page1 = pageAs(new Page<>(page, size), queryWrapper, SmsPushEventDTO.class);
|
||||
for (SmsPushEventDTO record : page1.getRecords()) {
|
||||
if (record.getUserType() != 2) {
|
||||
continue;
|
||||
}
|
||||
@@ -54,7 +54,7 @@ public class SmsPushEventServiceImpl extends ServiceImpl<SmsPushEventMapper, Sms
|
||||
);
|
||||
record.setSmsPushEventUser(eventUser);
|
||||
}
|
||||
return page;
|
||||
return page1;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.czg.service.market.service.impl;
|
||||
|
||||
import com.czg.market.dto.SmsShopMoneyDetailDTO;
|
||||
import com.czg.market.entity.SmsShopMoneyDetail;
|
||||
import com.czg.market.service.SmsShopMoneyDetailService;
|
||||
import com.czg.service.market.mapper.SmsShopMoneyDetailMapper;
|
||||
import com.czg.utils.PageUtil;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
|
||||
/**
|
||||
* 短信余额明细 服务层实现。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-10-16
|
||||
*/
|
||||
@Service
|
||||
public class SmsShopMoneyDetailServiceImpl extends ServiceImpl<SmsShopMoneyDetailMapper, SmsShopMoneyDetail> implements SmsShopMoneyDetailService {
|
||||
|
||||
@Override
|
||||
public Page<SmsShopMoneyDetailDTO> getSmsMoneyDetailPage(Long shopId) {
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
queryWrapper.eq(SmsShopMoneyDetail::getShopId, shopId)
|
||||
.eq(SmsShopMoneyDetail::getIsDel, 0)
|
||||
.orderBy(SmsShopMoneyDetail::getCreateTime).desc();
|
||||
return pageAs(PageUtil.buildPage(), queryWrapper, SmsShopMoneyDetailDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countSendTotal(Long shopId) {
|
||||
QueryWrapper queryWrapper = new QueryWrapper()
|
||||
.eq(SmsShopMoneyDetail::getShopId, shopId)
|
||||
.gt(SmsShopMoneyDetail::getSendRows, 0)
|
||||
.eq(SmsShopMoneyDetail::getType, 2)
|
||||
.eq(SmsShopMoneyDetail::getIsDel, 0);
|
||||
return count(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal countSendAmountTotal(Long shopId) {
|
||||
QueryWrapper queryWrapper = new QueryWrapper()
|
||||
.select("sum(expense)")
|
||||
.eq(SmsShopMoneyDetail::getShopId, shopId)
|
||||
.gt(SmsShopMoneyDetail::getSendRows, 0)
|
||||
.eq(SmsShopMoneyDetail::getType, 2)
|
||||
.eq(SmsShopMoneyDetail::getIsDel, 0);
|
||||
return getOneAs(queryWrapper, BigDecimal.class);
|
||||
}
|
||||
}
|
||||
@@ -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.market.mapper.SmsShopMoneyDetailMapper">
|
||||
|
||||
</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.market.mapper.SmsShopMoneyMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -338,7 +338,8 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
||||
if (param.getDiscountActAmount().compareTo(BigDecimal.ZERO) > 0) {
|
||||
//检查满减活动是否开启
|
||||
discountAct = discountActService.checkDiscountAct(orderInfo.getShopId(),
|
||||
CollUtil.isNotEmpty(param.getCouponList()), param.isVipPrice(), param.getPointsDiscountAmount().compareTo(BigDecimal.ZERO) > 0);
|
||||
CollUtil.isNotEmpty(param.getCouponList()), param.isVipPrice(),
|
||||
param.getPointsDiscountAmount().compareTo(BigDecimal.ZERO) > 0);
|
||||
}
|
||||
orderInfo.setSeatNum(param.getSeatNum());
|
||||
if (shopInfo.getIsTableFee() != 1 && shopInfo.getTableFee().compareTo(BigDecimal.ZERO) != 0) {
|
||||
|
||||
Reference in New Issue
Block a user