Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
commit
be6ce13888
|
|
@ -1,6 +1,5 @@
|
|||
package com.czg.controller.admin;
|
||||
|
||||
import com.czg.BaseQueryParam;
|
||||
import com.czg.market.dto.SmsPushEventDTO;
|
||||
import com.czg.market.service.SmsPushEventService;
|
||||
import com.czg.resp.CzgResult;
|
||||
|
|
@ -29,8 +28,10 @@ public class SmsPushEventController {
|
|||
* 列表
|
||||
*/
|
||||
@GetMapping
|
||||
public CzgResult<Page<SmsPushEventDTO>> getPushEventPage(@RequestParam BaseQueryParam param, @RequestParam(required = false) Long id) {
|
||||
Page<SmsPushEventDTO> data = pushEventService.getPushEventPage(param, StpKit.USER.getShopId(), id);
|
||||
public CzgResult<Page<SmsPushEventDTO>> getPushEventPage(@RequestParam(required = false, defaultValue = "1") Integer page,
|
||||
@RequestParam(required = false, defaultValue = "10") Integer size,
|
||||
@RequestParam(required = false) Long id) {
|
||||
Page<SmsPushEventDTO> data = pushEventService.getPushEventPage(page, size, StpKit.USER.getShopId(), id);
|
||||
return CzgResult.success(data);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,42 +1,58 @@
|
|||
|
||||
package com.czg.controller.admin;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.market.dto.SmsShopMoneyDetailDTO;
|
||||
import com.czg.market.dto.SmsShopTemplateDTO;
|
||||
import com.czg.market.entity.SmsShopMoney;
|
||||
import com.czg.market.service.SmsShopMoneyDetailService;
|
||||
import com.czg.market.service.SmsShopTemplateService;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.service.market.mapper.SmsShopMoneyMapper;
|
||||
import com.czg.validator.group.InsertGroup;
|
||||
import com.czg.validator.group.UpdateGroup;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 短信模板
|
||||
*
|
||||
* @author ww
|
||||
* @description
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/admin/smsTemplate")
|
||||
@RequestMapping("/admin")
|
||||
public class SmsShopTemplateController {
|
||||
@Resource
|
||||
private SmsShopTemplateService templateService;
|
||||
@Resource
|
||||
private SmsShopMoneyDetailService smsMoneyDetailService;
|
||||
@Resource
|
||||
private SmsShopMoneyMapper shopMoneyMapper;
|
||||
|
||||
/**
|
||||
* 列表
|
||||
*/
|
||||
@GetMapping
|
||||
@GetMapping("/smsTemplate")
|
||||
public CzgResult<List<SmsShopTemplateDTO>> getTemplateList(@RequestParam(required = false) String title) {
|
||||
List<SmsShopTemplateDTO> data = templateService.getTemplateList(title, StpKit.USER.getShopId());
|
||||
return CzgResult.success(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@PostMapping
|
||||
@PostMapping("/smsTemplate")
|
||||
public CzgResult<Void> addTemplate(@RequestBody @Validated(InsertGroup.class) SmsShopTemplateDTO param) {
|
||||
param.setShopId(StpKit.USER.getShopId());
|
||||
templateService.addTemplate(param);
|
||||
|
|
@ -47,10 +63,41 @@ public class SmsShopTemplateController {
|
|||
* 重新提交
|
||||
* 状态为 -1 失败的 可以修改模板重新提交
|
||||
*/
|
||||
@PostMapping("/resubmit")
|
||||
@PostMapping("/smsTemplate/resubmit")
|
||||
public CzgResult<Void> resubmit(@RequestBody @Validated(UpdateGroup.class) SmsShopTemplateDTO param) {
|
||||
param.setShopId(StpKit.USER.getShopId());
|
||||
templateService.resubmit(param);
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取店铺短信余额
|
||||
*/
|
||||
@GetMapping("/smsMoney")
|
||||
public CzgResult<SmsShopMoney> getShopSmsMoney() {
|
||||
SmsShopMoney shopMoney = shopMoneyMapper.selectOneByQuery(
|
||||
new QueryWrapper()
|
||||
.eq(SmsShopMoney::getShopId, StpKit.USER.getShopId())
|
||||
);
|
||||
if (shopMoney == null) {
|
||||
shopMoney = new SmsShopMoney();
|
||||
shopMoney.setShopId(StpKit.USER.getShopId());
|
||||
shopMoney.setMoney(BigDecimal.ZERO);
|
||||
shopMoneyMapper.insert(shopMoney);
|
||||
}
|
||||
return CzgResult.success(shopMoney);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取店铺短信余额明细
|
||||
*/
|
||||
@GetMapping("/smsMoneyDetail")
|
||||
public CzgResult<JSONObject> getSmsMoneyDetailPage(@RequestParam(required = false) Integer page,
|
||||
@RequestParam(required = false) Integer size) {
|
||||
Page<SmsShopMoneyDetailDTO> data = smsMoneyDetailService.getSmsMoneyDetailPage(StpKit.USER.getShopId());
|
||||
JSONObject from = JSONObject.from(data);
|
||||
from.put("sendTotal", smsMoneyDetailService.countSendTotal(StpKit.USER.getShopId()));
|
||||
from.put("sendAmountTotal", smsMoneyDetailService.countSendAmountTotal(StpKit.USER.getShopId()));
|
||||
return CzgResult.success(from);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,46 @@
|
|||
package com.czg.task;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
|
||||
/**
|
||||
* market服务 任务总调度
|
||||
* @author ww
|
||||
* @description
|
||||
*/
|
||||
public class AAMarketTasks {
|
||||
//生日有礼奖励发放
|
||||
@Resource
|
||||
private BirthdayGiftTask birthdayGiftTask;
|
||||
@Scheduled(cron = "0 0 12 * * ?")
|
||||
public void birthdayGiftTask() {
|
||||
birthdayGiftTask.deliver();
|
||||
}
|
||||
|
||||
|
||||
//优惠券 过期
|
||||
@Resource
|
||||
private CouponTask couponTask;
|
||||
@Scheduled(cron = "0 30 * * * ? ")
|
||||
public void couponTask() {
|
||||
couponTask.task();
|
||||
}
|
||||
|
||||
//会员奖励发放
|
||||
@Resource
|
||||
private MemberTask memberTask;
|
||||
@Scheduled(cron = "0 0 1 * * ? ")
|
||||
public void memberTask() {
|
||||
memberTask.task();
|
||||
}
|
||||
|
||||
//满减活动定时任务
|
||||
@Resource
|
||||
private DiscountActivityTask discountActivityTask;
|
||||
@Scheduled(cron = "1 0 0 * * ? ")
|
||||
public void discountActivityTask() {
|
||||
discountActivityTask.task();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -31,7 +31,7 @@ public class BirthdayGiftTask {
|
|||
/**
|
||||
* 生日有礼奖励发放
|
||||
*/
|
||||
@Scheduled(cron = "0 0 12 * * ?")
|
||||
// @Scheduled(cron = "0 0 12 * * ?")
|
||||
public void deliver() {
|
||||
birthdayGiftService.deliver();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ public class CouponTask {
|
|||
/**
|
||||
* 优惠券 过期
|
||||
*/
|
||||
@Scheduled(cron = "0 30 * * * ? ")
|
||||
public void deliver() {
|
||||
// @Scheduled(cron = "0 30 * * * ? ")
|
||||
public void task() {
|
||||
try {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
mkShopCouponRecordService.update(new MkShopCouponRecord().setStatus(2), new QueryWrapper()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
package com.czg.task;
|
||||
|
||||
import com.czg.market.entity.MkDiscountActivity;
|
||||
import com.czg.market.service.MkDiscountActivityService;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 满减活动定时任务
|
||||
*
|
||||
* @author ww
|
||||
* @description
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DiscountActivityTask {
|
||||
@Resource
|
||||
private MkDiscountActivityService discountActivityService;
|
||||
|
||||
/**
|
||||
* 满减活动 过期
|
||||
*/
|
||||
public void task() {
|
||||
discountActivityService.update(new MkDiscountActivity().setStatus(2),
|
||||
new QueryWrapper()
|
||||
.eq(MkDiscountActivity::getStatus, 1)
|
||||
.le(MkDiscountActivity::getValidStartTime, LocalDateTime.now())
|
||||
.gt(MkDiscountActivity::getValidEndTime, LocalDateTime.now())
|
||||
);
|
||||
discountActivityService.update(new MkDiscountActivity().setStatus(3),
|
||||
new QueryWrapper().le(MkDiscountActivity::getValidEndTime, LocalDateTime.now())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -37,8 +37,8 @@ public class MemberTask {
|
|||
/**
|
||||
* 奖励发放
|
||||
*/
|
||||
@Scheduled(cron = "0 0 1 * * ? ")
|
||||
public void deliver() {
|
||||
// @Scheduled(cron = "0 0 1 * * ? ")
|
||||
public void task() {
|
||||
shopUserService.list(new QueryWrapper().eq(ShopUser::getIsVip, 1).lt(ShopUser::getNextDeliverTime, DateUtil.date().toLocalDateTime())).forEach(item -> {
|
||||
memberConfigService.deliver(item.getSourceShopId(), item.getUserId(), TableValueConstant.MemberExpFlow.Type.MEMBER_TASK, null, null, null);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,61 @@
|
|||
|
||||
package com.czg.market.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import lombok.experimental.Accessors;
|
||||
import java.io.Serial;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 短信余额明细 实体类。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-10-16
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class SmsShopMoneyDetailDTO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long id;
|
||||
|
||||
private Long shopId;
|
||||
|
||||
/**
|
||||
* 变动原因
|
||||
*/
|
||||
private String reason;
|
||||
|
||||
/**
|
||||
* 1+ 2-
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 发送条数
|
||||
*/
|
||||
private Long sendRows;
|
||||
|
||||
/**
|
||||
* 消费值
|
||||
*/
|
||||
private BigDecimal expense;
|
||||
|
||||
/**
|
||||
* 余额
|
||||
*/
|
||||
private BigDecimal balance;
|
||||
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
|
|
@ -107,6 +107,28 @@ public class SmsPushEventUser implements Serializable {
|
|||
private Integer page;
|
||||
@Column(ignore = true)
|
||||
private Integer size;
|
||||
@Column(ignore = true)
|
||||
private Integer isAll;
|
||||
|
||||
/**
|
||||
* 是否查询所有用户 1查询所有用户 其余不查
|
||||
*/
|
||||
public void checkIsAll() {
|
||||
if (isAll != null && isAll == 1) {
|
||||
sexMan = 0;
|
||||
sexWoman = 0;
|
||||
sexUnknown = 0;
|
||||
isVip = null;
|
||||
isRecharge = null;
|
||||
noOrder = 0;
|
||||
oneOrder = 0;
|
||||
fiveOrder = 0;
|
||||
orderTimeToday = 0;
|
||||
orderTimeYesterday = 0;
|
||||
orderTimeTwoWeeks = 0;
|
||||
orderTimeMoreThanTwoWeeks = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public Integer getPage() {
|
||||
return page == null ? 1 : page;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
package com.czg.market.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 店铺短信余额 实体类。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-10-16
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("sms_shop_money")
|
||||
public class SmsShopMoney implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id(keyType = KeyType.Auto)
|
||||
private Long id;
|
||||
|
||||
private Long shopId;
|
||||
|
||||
private BigDecimal money;
|
||||
|
||||
@Column(onInsertValue = "now()")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Column(onInsertValue = "now()", onUpdateValue = "now()")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
package com.czg.market.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 短信余额明细 实体类。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-10-16
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("sms_shop_money_detail")
|
||||
public class SmsShopMoneyDetail implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id(keyType = KeyType.Auto)
|
||||
private Long id;
|
||||
|
||||
private Long shopId;
|
||||
|
||||
/**
|
||||
* 变动原因
|
||||
*/
|
||||
private String reason;
|
||||
|
||||
/**
|
||||
* 1+ 2-
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 消费值
|
||||
*/
|
||||
private BigDecimal expense;
|
||||
|
||||
/**
|
||||
* 余额
|
||||
*/
|
||||
private BigDecimal balance;
|
||||
/**
|
||||
* 发送短信条数
|
||||
*/
|
||||
private Long sendRows;
|
||||
|
||||
@Column(onInsertValue = "now()")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Column(isLogicDelete = true)
|
||||
private Integer isDel;
|
||||
|
||||
}
|
||||
|
|
@ -17,7 +17,7 @@ public interface SmsPushEventService extends IService<SmsPushEvent> {
|
|||
/**
|
||||
* 分页查询营销推送发送记录列表
|
||||
*/
|
||||
Page<SmsPushEventDTO> getPushEventPage(BaseQueryParam param, Long shopId, Long id);
|
||||
Page<SmsPushEventDTO> getPushEventPage(Integer page, Integer size, Long shopId, Long id);
|
||||
|
||||
/**
|
||||
* 添加营销推送发送任务
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
package com.czg.market.service;
|
||||
|
||||
import com.czg.market.dto.SmsShopMoneyDetailDTO;
|
||||
import com.czg.market.entity.SmsShopMoneyDetail;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 短信余额明细 服务层。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-10-16
|
||||
*/
|
||||
public interface SmsShopMoneyDetailService extends IService<SmsShopMoneyDetail> {
|
||||
|
||||
Page<SmsShopMoneyDetailDTO> getSmsMoneyDetailPage(Long shopId);
|
||||
/**
|
||||
* 统计发送短信总数
|
||||
*/
|
||||
Long countSendTotal(Long shopId);
|
||||
/**
|
||||
* 统计发送短信累计金额
|
||||
*/
|
||||
BigDecimal countSendAmountTotal(Long shopId);
|
||||
}
|
||||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue