16 Commits

Author SHA1 Message Date
gong
87797e5812 关联商品查询同步商品 2025-12-29 15:32:23 +08:00
057f851dcf 返回数据 尝试 2025-12-29 14:51:26 +08:00
dc3be2f1d8 打印状态字段 2025-12-29 14:40:39 +08:00
232bfe84df 多余打印 2025-12-29 14:29:10 +08:00
ff09e8e92b 打印状态标识 允许重新操作 2025-12-29 14:26:51 +08:00
5d9c01f427 打印状态标识 允许重新操作 2025-12-29 14:23:05 +08:00
5d7aaa2dca 企业Id 信息 2025-12-29 10:08:25 +08:00
5595a8009b 绑定手机号 判断 是否成为 会员 2025-12-26 11:42:18 +08:00
233c226dca 精简sql 2025-12-26 11:34:22 +08:00
76c6e12c72 统计充值金额 2025-12-26 11:19:43 +08:00
5b030ea361 名字问题 2025-12-26 11:06:07 +08:00
266e782fc0 Merge branch 'dev' into prod 2025-12-26 10:50:58 +08:00
aa7483b1b1 临时菜标识
扣除积分 负数
2025-12-26 10:49:36 +08:00
7eeeb8a30f 分销 定时任务 2025-12-26 10:44:43 +08:00
70307e3833 分销问题
会员充值问题
2025-12-26 10:37:32 +08:00
8bde6b15f6 成长值问题 2025-12-26 09:24:28 +08:00
32 changed files with 234 additions and 435 deletions

View File

@@ -1,39 +0,0 @@
package com.czg.controller;
import com.czg.account.entity.ShopUser;
import com.czg.account.service.ShopInfoService;
import com.czg.account.service.ShopUserFlowService;
import com.czg.account.service.ShopUserService;
import com.czg.account.service.TestService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author GYJoker
*/
@RestController
@RequestMapping("/notify/test")
public class TestController {
@Resource
private ShopUserFlowService shopUserFlowService;
@Resource
private ShopInfoService shopInfoService;
@Resource
private ShopUserService shopUserService;
@Resource
private TestService testService;
@RequestMapping("/hello")
public String hello() {
shopUserFlowService.list().forEach(item -> {
ShopUser shopUserInfo = shopUserService.getShopUserInfo(item.getShopId(), item.getUserId());
if (shopUserInfo != null) {
item.setShopUserId(shopUserInfo.getId());
shopUserFlowService.updateById(item);
}
});
// return testService.insertData();
return "";
}
}

View File

@@ -13,6 +13,7 @@ import com.czg.market.vo.InviteUserVO;
import com.czg.market.vo.MkDistributionConfigVO; import com.czg.market.vo.MkDistributionConfigVO;
import com.czg.resp.CzgResult; import com.czg.resp.CzgResult;
import com.czg.sa.StpKit; import com.czg.sa.StpKit;
import com.czg.task.DistributionTask;
import com.czg.utils.AssertUtil; import com.czg.utils.AssertUtil;
import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.paginate.Page;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
@@ -37,6 +38,22 @@ public class UDistributionController {
private MkDistributionWithdrawFlowService withdrawFlowService; private MkDistributionWithdrawFlowService withdrawFlowService;
@Resource @Resource
private MkDistributionFlowService distributionFlowService; private MkDistributionFlowService distributionFlowService;
@Resource
private DistributionTask distributionTask;
/**
* 分销员中心-获取配置
*/
@GetMapping("/task")
public CzgResult<String> task(@RequestParam Long shopId) {
try {
distributionTask.deliver(shopId);
} catch (Exception e) {
return CzgResult.failure(e.getMessage());
}
return CzgResult.success("任务执行成功");
}
/** /**
* 分销员中心-获取配置 * 分销员中心-获取配置

View File

@@ -6,6 +6,7 @@ import org.springframework.stereotype.Component;
/** /**
* market服务 任务总调度 * market服务 任务总调度
*
* @author ww * @author ww
*/ */
@Component @Component
@@ -18,9 +19,9 @@ public class AAMarketTasks {
// 分销延时发放 // 分销延时发放
@Scheduled(fixedRate = 30000) @Scheduled(cron = "0 0 0/2 * * ? ")
public void distributionTask() { public void distributionTask() {
distributionTask.deliver(); distributionTask.deliver(null);
} }
@@ -29,6 +30,7 @@ public class AAMarketTasks {
public void birthdayGiftTask() { public void birthdayGiftTask() {
birthdayGiftTask.deliver(); birthdayGiftTask.deliver();
} }
//会员生日弹窗提醒重置 每年1月1日 //会员生日弹窗提醒重置 每年1月1日
@Scheduled(cron = "0 0 0 1 1 ?") @Scheduled(cron = "0 0 0 1 1 ?")
public void birthdayGiftRemindTask() { public void birthdayGiftRemindTask() {
@@ -39,6 +41,7 @@ public class AAMarketTasks {
//优惠券 过期 //优惠券 过期
@Resource @Resource
private CouponTask couponTask; private CouponTask couponTask;
//每天每小时的30分 0秒 执行 //每天每小时的30分 0秒 执行
@Scheduled(cron = "0 30 * * * ? ") @Scheduled(cron = "0 30 * * * ? ")
public void couponTask() { public void couponTask() {
@@ -48,6 +51,7 @@ public class AAMarketTasks {
//会员奖励发放 //会员奖励发放
@Resource @Resource
private MemberTask memberTask; private MemberTask memberTask;
//每天1点 0分 0秒 执行 //每天1点 0分 0秒 执行
@Scheduled(cron = "0 0 1 * * ? ") @Scheduled(cron = "0 0 1 * * ? ")
public void memberTask() { public void memberTask() {
@@ -57,6 +61,7 @@ public class AAMarketTasks {
//满减活动/限时折扣 处理任务状态 定时任务 //满减活动/限时折扣 处理任务状态 定时任务
@Resource @Resource
private ActivityStatusTask activityStatusTask; private ActivityStatusTask activityStatusTask;
//每天0点 0分 1秒 执行 //每天0点 0分 1秒 执行
@Scheduled(cron = "1 0 0 * * ? ") @Scheduled(cron = "1 0 0 * * ? ")
public void activityStatusTask() { public void activityStatusTask() {
@@ -67,6 +72,7 @@ public class AAMarketTasks {
//月累计 发送条数 累计金额 //月累计 发送条数 累计金额
@Resource @Resource
private SmsShopMoneyTask smsShopMoneyTask; private SmsShopMoneyTask smsShopMoneyTask;
//每月1号 0点 0分 1秒 执行 //每月1号 0点 0分 1秒 执行
@Scheduled(cron = "1 0 0 1 * ?") @Scheduled(cron = "1 0 0 1 * ?")
public void smsShopMoneyTask() { public void smsShopMoneyTask() {

View File

@@ -2,10 +2,13 @@ package com.czg.task;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.czg.account.entity.ShopInfo;
import com.czg.account.entity.ShopUser; import com.czg.account.entity.ShopUser;
import com.czg.account.service.ShopInfoService; import com.czg.account.service.ShopInfoService;
import com.czg.account.service.ShopUserService; import com.czg.account.service.ShopUserService;
import com.czg.constant.TableValueConstant; import com.czg.constant.TableValueConstant;
import com.czg.constants.SystemConstants;
import com.czg.exception.CzgException;
import com.czg.market.entity.MkDistributionFlow; import com.czg.market.entity.MkDistributionFlow;
import com.czg.market.service.MkDistributionFlowService; import com.czg.market.service.MkDistributionFlowService;
import com.czg.market.service.MkDistributionUserService; import com.czg.market.service.MkDistributionUserService;
@@ -18,6 +21,7 @@ import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference; import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@@ -40,8 +44,6 @@ public class DistributionTask {
private OrderInfoService orderInfoService; private OrderInfoService orderInfoService;
@DubboReference @DubboReference
private ShopInfoService shopInfoService; private ShopInfoService shopInfoService;
@DubboReference
private ShopUserService shopUserService;
List<String> list = List.of(OrderStatusEnums.REFUND.getCode(), OrderStatusEnums.PART_REFUND.getCode()); List<String> list = List.of(OrderStatusEnums.REFUND.getCode(), OrderStatusEnums.PART_REFUND.getCode());
@@ -51,44 +53,55 @@ public class DistributionTask {
*/ */
// @Scheduled(cron = "0 0 0 * * ?") // @Scheduled(cron = "0 0 0 * * ?")
// @Scheduled(fixedRate = 30000) // @Scheduled(fixedRate = 30000)
public void deliver() { public void deliver(Long shopId) {
// 1. 订单完成支付时(判断是否分销)产生流水记录。 LocalDateTime now = LocalDateTime.now();
// 2. 判断入账时间。 List<ShopInfo> shopInfos = shopInfoService.list(QueryWrapper.create()
// 3. 如果是 0 天,再去判断商户余额是否足够。够则入账,不足则不管。 .eq(ShopInfo::getIsDeleted, SystemConstants.OneZero.ZERO)
// 4. 流水增加应该入账的时间(订单产生时带入) .isNotNull(ShopInfo::getExpireTime)
// 5. 定时任务 应该是一天执行一次。查询待入账状态和应入账时间小于当前时间的记录,循环处理:并且判断商户余额是否足够,余额不足忽略处理;余额足够变为已入账并扣除商户余额。 .lt(ShopInfo::getExpireTime, now)
// 6. 订单产生退款时,去流水表查询该订单的流水记录,如果未入账改为已入账,并插入一条退款扣钱的流水。 .gt(ShopInfo::getAmount, BigDecimal.ZERO)
.eq(ShopInfo::getId, shopId)
// shopInfo 查余额>0 );
// 循环 shopId 查询 如果金额不足 终止 if (CollUtil.isEmpty(shopInfos)) {
// log.info("分销延时分账 无符合条件的店铺,无需处理分账");
LocalDateTime localDateTime = DateUtil.date().toLocalDateTime(); return;
distributionFlowService.list(new QueryWrapper() }
.eq(MkDistributionFlow::getStatus, TableValueConstant.DistributionFlow.Status.PENDING.getCode()).le(MkDistributionFlow::getDeliverTime, localDateTime)).forEach(item -> { for (ShopInfo shopInfo : shopInfos) {
FunUtils.safeRunVoid(() -> { boolean breakCurrentShopFlow = false;
log.info("开始处理延时分账, id: {}, orderNo: {}, 类型: {}", item.getId(), item.getOrderNo(), item.getType()); List<MkDistributionFlow> flowList = distributionFlowService.list(new QueryWrapper()
.eq(MkDistributionFlow::getShopId, shopInfo.getId())
OrderInfo orderInfo = orderInfoService.getOne(new QueryWrapper().eq(OrderInfo::getOrderNo, item.getOrderNo())); .eq(MkDistributionFlow::getStatus, TableValueConstant.DistributionFlow.Status.PENDING.getCode())
if (orderInfo == null) { .le(MkDistributionFlow::getDeliverTime, now)
item.setStatus(TableValueConstant.DistributionFlow.Status.FAIL.getCode()); .orderBy(MkDistributionFlow::getId, true)
distributionFlowService.updateById(item); );
log.warn("订单不存在, 订单号: {}", item.getOrderNo()); for (MkDistributionFlow item : flowList) {
return; if (breakCurrentShopFlow) {
break;
} }
if (list.contains(orderInfo.getStatus())) { try {
log.warn("订单已退款, 订单号: {}", item.getOrderNo()); log.info("分销延时分账, id: {}, orderNo: {}, 类型: {}", item.getId(), item.getOrderNo(), item.getType());
distributionUserService.refund(orderInfo.getId(), orderInfo.getOrderNo()); OrderInfo orderInfo = orderInfoService.getOne(new QueryWrapper().eq(OrderInfo::getOrderNo, item.getOrderNo()));
} else { if (orderInfo == null) {
item.setStatus(TableValueConstant.DistributionFlow.Status.SUCCESS.getCode()); item.setStatus(TableValueConstant.DistributionFlow.Status.FAIL.getCode());
ShopUser shopUser = shopUserService.getById(item.getDistributionUserId()); distributionFlowService.updateById(item);
distributionUserService.updateShopInfoAmount(orderInfo.getShopId(), item.getRewardAmount().negate(), orderInfo.getId(), TableValueConstant.DistributionAmountFlow.Type.SUB, "分销扣减"); log.warn("分销延时分账。订单不存在, 订单号: {}", item.getOrderNo());
distributionUserService.updateIncome(item.getRewardAmount().negate(), item.getRewardAmount(), BigDecimal.ZERO, continue;
item.getDistributionUserId(), shopUser.getUserId(), item.getShopUserId(), item.getShopId(), item.getLevel()); }
distributionFlowService.updateById(item); if (list.contains(orderInfo.getStatus())) {
log.warn("分销延时分账。订单已退款, 订单号: {}", item.getOrderNo());
distributionUserService.refund(orderInfo.getId(), orderInfo.getOrderNo());
} else {
item.setStatus(TableValueConstant.DistributionFlow.Status.SUCCESS.getCode());
distributionUserService.distributionUserAmount(item, orderInfo);
}
} catch (CzgException e) {
log.error("店铺{}:{}分销延时分账异常:{}", shopInfo.getId(), shopInfo.getShopName(), e.getMessage());
breakCurrentShopFlow = true;
} catch (Exception e) {
log.error("店铺{}:{}分销延时分账异常", shopInfo.getId(), shopInfo.getShopName(), e);
breakCurrentShopFlow = true;
} }
}); }
}); }
} }
} }

View File

@@ -50,6 +50,8 @@ public class NotifyController {
@Resource @Resource
private MkShopConsumeDiscountRecordService consumeDiscountRecordService; private MkShopConsumeDiscountRecordService consumeDiscountRecordService;
//新客立减清除数据 测试用
@RequestMapping("clear") @RequestMapping("clear")
public String clear(@RequestParam Integer shopId) { public String clear(@RequestParam Integer shopId) {
consumeDiscountRecordService.remove(new QueryWrapper().eq(MkShopConsumeDiscountRecord::getShopId, shopId)); consumeDiscountRecordService.remove(new QueryWrapper().eq(MkShopConsumeDiscountRecord::getShopId, shopId));

View File

@@ -21,7 +21,7 @@ public class StatisticTaskController {
private StatisticTask statisticTask; private StatisticTask statisticTask;
/** /**
* 基础统计 * 基础统计 预留重置统计
* *
* @param date 日期yyyy-MM-dd * @param date 日期yyyy-MM-dd
*/ */

View File

@@ -30,9 +30,6 @@ public class PrintMqListener {
@Resource @Resource
private FunUtil funUtil; private FunUtil funUtil;
// 注入自定义线程池(建议单独配置,避免使用默认线程池)
@Resource
private ThreadPoolTaskExecutor asyncExecutor;
@Lazy @Lazy
@Resource @Resource
private PrinterHandler printerHandler; private PrinterHandler printerHandler;
@@ -64,37 +61,10 @@ public class PrintMqListener {
} }
Boolean printOrder = jsonObject.getBoolean("printOrder"); Boolean printOrder = jsonObject.getBoolean("printOrder");
funUtil.runFunAndCheckKey(() -> { funUtil.runFunAndCheckKey(() -> {
printerHandler.handler(orderId, printOrder != null && !printOrder ? PrinterHandler.PrintTypeEnum.ONE : PrinterHandler.PrintTypeEnum.ONE_AND_ORDER); printerHandler.handler(orderId, printOrder != null && !printOrder ? PrinterHandler.PrintTypeEnum.ONE : PrinterHandler.PrintTypeEnum.ONE_AND_ORDER, null);
return null; return null;
}, RedisCst.getLockKey("orderPrint", orderId)); }, RedisCst.getLockKey("orderPrint", orderId));
}); });
// // 使用异步线程池执行延迟任务,不阻塞当前消费者线程
// CompletableFuture.runAsync(() -> {
// try {
// // 延迟3秒处理
// TimeUnit.SECONDS.sleep(3);
// // 执行核心打印逻辑
// invokeFun("orderPrint", "java.order", req, (data) -> {
// JSONObject jsonObject = JSONObject.parseObject(data);
// String orderId = jsonObject.getString("orderId");
// if (orderId == null) {
// throw new RuntimeException("订单打印失败未传递orderId");
// }
// Boolean printOrder = jsonObject.getBoolean("printOrder");
// funUtil.runFunAndCheckKey(() -> {
// printerHandler.handler(orderId, printOrder != null && !printOrder ? PrinterHandler.PrintTypeEnum.ONE : PrinterHandler.PrintTypeEnum.ONE_AND_ORDER);
// return null;
// }, RedisCst.getLockKey("orderPrint", orderId));
// });
// } catch (InterruptedException e) {
// Thread.currentThread().interrupt();
// // 记录中断日志
// log.warn("打印任务被中断req:{}", req, e);
// } catch (Exception e) {
// // 记录业务异常日志
// log.error("打印任务处理失败req:{}", req, e);
// }
// }, asyncExecutor);
} }
/** /**
@@ -102,14 +72,14 @@ public class PrintMqListener {
*/ */
@RabbitListener(queues = {"${spring.profiles.active}-" + RabbitConstants.Queue.ORDER_HANDOVER_PRINT_QUEUE}) @RabbitListener(queues = {"${spring.profiles.active}-" + RabbitConstants.Queue.ORDER_HANDOVER_PRINT_QUEUE})
public void handoverPrint(String id) { public void handoverPrint(String id) {
invokeFun("handoverPrint", "java.order", id, (data) -> printerHandler.handler(data, PrinterHandler.PrintTypeEnum.HANDOVER)); invokeFun("handoverPrint", "java.order", id, (data) -> printerHandler.handler(data, PrinterHandler.PrintTypeEnum.HANDOVER, null));
} }
/** /**
* 交班打印 * 叫号打印
*/ */
@RabbitListener(queues = {"${spring.profiles.active}-" + RabbitConstants.Queue.CALL_TABLE_PRINT_QUEUE}) @RabbitListener(queues = {"${spring.profiles.active}-" + RabbitConstants.Queue.CALL_TABLE_PRINT_QUEUE})
public void callTablePrint(String id) { public void callTablePrint(String id) {
invokeFun("handoverPrint", "java.order", id, (data) -> printerHandler.handler(data, PrinterHandler.PrintTypeEnum.CALL)); invokeFun("handoverPrint", "java.order", id, (data) -> printerHandler.handler(data, PrinterHandler.PrintTypeEnum.CALL, null));
} }
} }

View File

@@ -39,7 +39,7 @@ public class OTimeTask {
@Resource @Resource
private CashierCartService cartService; private CashierCartService cartService;
@Resource @Resource
private OrderPaymentService orderPaymentService; private OrderPaymentService paymentService;
@Resource @Resource
private GbOrderService gbOrderService; private GbOrderService gbOrderService;
@Resource @Resource
@@ -117,7 +117,7 @@ public class OTimeTask {
LocalDateTime tenMinutesAgo = LocalDateTime.now().minusMinutes(10); LocalDateTime tenMinutesAgo = LocalDateTime.now().minusMinutes(10);
LocalDateTime thirdDayAgo = LocalDateTime.now().minusDays(3); LocalDateTime thirdDayAgo = LocalDateTime.now().minusDays(3);
List<OrderPayment> list = orderPaymentService.list(QueryWrapper.create() List<OrderPayment> list = paymentService.list(QueryWrapper.create()
.gt(OrderPayment::getUpdateTime, thirdDayAgo) .gt(OrderPayment::getUpdateTime, thirdDayAgo)
.lt(OrderPayment::getUpdateTime, tenMinutesAgo) .lt(OrderPayment::getUpdateTime, tenMinutesAgo)
.in(OrderPayment::getSourceType, ware) .in(OrderPayment::getSourceType, ware)

View File

@@ -54,7 +54,7 @@ public class FilteredNacosRegistry extends NacosRegistry {
public void register(URL url) { public void register(URL url) {
// 1. 获取原始注册的方法列表 // 1. 获取原始注册的方法列表
String originalMethods = url.getParameter("methods"); String originalMethods = url.getParameter("methods");
log.info("【过滤提示】服务 {} 注册方法:{}", url.getServiceInterface(), originalMethods); // log.info("【过滤提示】服务 {} 注册方法:{}", url.getServiceInterface(), originalMethods);
if (originalMethods != null && !originalMethods.isEmpty()) { if (originalMethods != null && !originalMethods.isEmpty()) {
// 2. 过滤黑名单中的方法名 // 2. 过滤黑名单中的方法名
List<String> filteredMethods = Arrays.stream(originalMethods.split(",")) List<String> filteredMethods = Arrays.stream(originalMethods.split(","))
@@ -67,12 +67,12 @@ public class FilteredNacosRegistry extends NacosRegistry {
// 3. 处理过滤后的结果 // 3. 处理过滤后的结果
if (filteredMethods.isEmpty()) { if (filteredMethods.isEmpty()) {
// 若所有方法都被过滤,直接终止注册(可选:根据业务决定是否保留服务注册) // 若所有方法都被过滤,直接终止注册(可选:根据业务决定是否保留服务注册)
log.info("【过滤提示】服务 {} 所有方法均被过滤,终止注册", url.getServiceInterface()); // log.info("【过滤提示】服务 {} 所有方法均被过滤,终止注册", url.getServiceInterface());
return; return;
} else { } else {
// 替换 URL 中的 methods 参数为过滤后的列表 // 替换 URL 中的 methods 参数为过滤后的列表
url = url.addParameter("methods", String.join(",", filteredMethods)); url = url.addParameter("methods", String.join(",", filteredMethods));
log.info("【过滤提示】服务 {} 注册方法:{}", url.getServiceInterface(), filteredMethods); // log.info("【过滤提示】服务 {} 注册方法:{}", url.getServiceInterface(), filteredMethods);
} }
} }

View File

@@ -1,5 +1,6 @@
package com.czg.config; package com.czg.config;
import cn.hutool.core.util.StrUtil;
import com.mybatisflex.core.audit.AuditManager; import com.mybatisflex.core.audit.AuditManager;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@@ -17,8 +18,24 @@ public class MybatisFlexConfig {
//设置 SQL 审计收集器 //设置 SQL 审计收集器
AuditManager.setMessageCollector(auditMessage -> AuditManager.setMessageCollector(auditMessage ->
log.info("[sql] time: {}, size: {}, sql:\n{}", log.info("[sql] time: {}, size: {}, sql:\n{}",
auditMessage.getElapsedTime(), auditMessage.getQueryCount(), auditMessage.getFullSql()) auditMessage.getElapsedTime(), auditMessage.getQueryCount(), compressSql(auditMessage.getFullSql())));
);
} }
/**
* 精简SQL去除多余换行、制表符、连续空格保留语法必需空格
*
* @param originalSql 原始带换行/空格的SQL
* @return 精简后的SQL
*/
public static String compressSql(String originalSql) {
if (StrUtil.isBlank(originalSql)) {
return "";
}
// 1. 替换所有换行、制表符为单个空格
String tempSql = originalSql.replaceAll("\\r\\n|\\r|\\n|\\t", " ");
// 2. 替换多个连续空格为单个空格
tempSql = tempSql.replaceAll("\\s+", " ");
// 3. 去除首尾空格
return tempSql.trim();
}
} }

View File

@@ -285,4 +285,13 @@ public class ShopInfoEditDTO {
*/ */
private Integer isCountStick; private Integer isCountStick;
/**
* 企业id
*/
private String weworkId;
/**
* 企业接入链接
*/
private String weworkUrl;
} }

View File

@@ -135,5 +135,13 @@ public class ShopConfig implements Serializable {
private String dingAppKey; private String dingAppKey;
private String dingAppSecret; private String dingAppSecret;
/**
* 企业id
*/
private String weworkId;
/**
* 企业接入链接
*/
private String weworkUrl;
} }

View File

@@ -363,4 +363,15 @@ public class ShopInfo implements Serializable {
*/ */
private BigDecimal amount; private BigDecimal amount;
/**
* 企业id
*/
@Column(ignore = true)
private String weworkId;
/**
* 企业接入链接
*/
@Column(ignore = true)
private String weworkUrl;
} }

View File

@@ -7,10 +7,12 @@ import com.czg.exception.CzgException;
import com.czg.market.dto.MkDistributionUserDTO; import com.czg.market.dto.MkDistributionUserDTO;
import com.czg.market.dto.MkDistributionWithdrawFlowDTO; import com.czg.market.dto.MkDistributionWithdrawFlowDTO;
import com.czg.market.entity.MkDistributionConfig; import com.czg.market.entity.MkDistributionConfig;
import com.czg.market.entity.MkDistributionFlow;
import com.czg.market.entity.MkDistributionUser; import com.czg.market.entity.MkDistributionUser;
import com.czg.market.vo.DistributionCenterShopVO; import com.czg.market.vo.DistributionCenterShopVO;
import com.czg.market.vo.InviteUserVO; import com.czg.market.vo.InviteUserVO;
import com.czg.order.dto.MkDistributionPayDTO; import com.czg.order.dto.MkDistributionPayDTO;
import com.czg.order.entity.OrderInfo;
import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.service.IService; import com.mybatisflex.core.service.IService;
@@ -123,6 +125,8 @@ public interface MkDistributionUserService extends IService<MkDistributionUser>
void refund(Long orderId, String orderNo); void refund(Long orderId, String orderNo);
void distributionUserAmount(MkDistributionFlow item, OrderInfo orderInfo);
/** /**
* 发放分销奖励 * 发放分销奖励
* *

View File

@@ -1,267 +0,0 @@
package com.czg.order.dto;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import com.alibaba.fastjson2.annotation.JSONField;
import java.io.Serial;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 订单表 实体类。
*
* @author ww
* @since 2025-02-13
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class OrderInfoDTO implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
private Long id;
/**
* 订单编号
* pc 收银机客户端 PC+雪花ID
* wechat 微信小程序 WX+雪花ID
* alipay 支付宝小程序 ALI+雪花ID
* admin-pc PC管理端 WEB+雪花ID
* admin-app APP管理端 APP+雪花ID
*/
private String orderNo;
/**
* 店铺Id
*/
private Long shopId;
/**
* 用户Id user_info表的id
*/
private Long userId;
/**
* 退单金额
*/
private BigDecimal refundAmount;
/**
* 订单原金额 不含折扣价格
*/
private BigDecimal originAmount;
/**
* 抹零金额 减免多少钱
*/
private BigDecimal roundAmount;
/**
* 优惠总金额
*/
private BigDecimal discountAllAmount;
/**
* 订单金额 (扣除各类折扣)
*/
private BigDecimal orderAmount;
/**
* 实际支付金额
*/
private BigDecimal payAmount;
/**
* 积分抵扣金额
*/
private BigDecimal pointsDiscountAmount;
/**
* 使用的积分数量
*/
private Integer pointsNum;
/**
* 商品优惠券抵扣金额
*/
private BigDecimal productCouponDiscountAmount;
/**
* 用户使用的卡券
*/
private String couponInfoList;
/**
* 满减活动抵扣金额
*/
private BigDecimal discountActAmount;
/**
* 折扣金额
*/
private BigDecimal discountAmount;
// /**
// * 折扣比例
// */
// private BigDecimal discountRatio;
/**
* 打包费
*/
private BigDecimal packFee;
/**
* 台桌Id
*/
private String tableCode;
/**
* 台桌名称
*/
private String tableName;
/**
* 订单类型-
* cash收银(除小程序以外 都属于收银)
* miniapp小程序
*/
private String orderType;
/**
* 平台类型 pc 收银机客户端 wechat 微信小程序 alipay 支付宝小程序 admin-pc PC管理端 admin-app APP管理端
*/
private String platformType;
/**
* 用餐模式 堂食 dine-in 外带 take-out 外卖 take-away
*/
private String dineMode;
/**
* 支付模式:
* 后付费 after-pay
* 先付费 before-pay
* 无桌码 no-table
*/
private String payMode;
/**
* 支付类型
* 主扫 main-scan
* 被扫 back-scan
* 微信小程序 wechat-mini
* 支付宝小程序 alipay-mini
* 会员支付 vip-pay
* 现金支付 cash-pay
*/
private String payType;
/**
* 状态: unpaid-待支付;in-production 制作中;wait_out 待取餐;;done-订单完成;refunding-申请退单;refund-退单;part_refund 部分退单;cancelled-取消订单
*/
private String status;
/**
* 折扣信息 json
*/
private String discountInfo;
/**
* 限时折扣信息 json
*/
private String limitRate;
/**
* 是否支持退款1支持退单 0不支持退单
*/
private Integer refundAble;
/**
* 支付时间
*/
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime paidTime;
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime;
/**
* 支付订单号
* tb_order_payment.id
* tb_shop_user_flow.id
*/
private Long payOrderId;
/**
* 交易日期
*/
private String tradeDay;
/**
* 备注
*/
private String remark;
/**
* 取餐码
*/
private String takeCode;
/**
* 员工id
*/
private Long staffId;
/**
* 当前订单下单次数
*/
private Integer placeNum;
/**
* 用餐人数
*/
private Integer seatNum;
/**
* 餐位费
*/
private BigDecimal seatAmount;
/**
* 退款备注
*/
private String refundRemark;
/**
* 是否使用了霸王餐
*/
private Integer isFreeDine;
/**
* 是否等叫 0 否 1 等叫
*/
private Integer isWaitCall;
/**
* 挂账人id
*/
private Long creditBuyerId;
/**
* 是否回收站 0-否1回收站
*/
private Integer isDel;
private String failMsg;
}

View File

@@ -24,5 +24,9 @@ public class OrderInfoPrintDTO implements Serializable {
*/ */
@NotNull(message = "打印类型不为空") @NotNull(message = "打印类型不为空")
private Integer type; private Integer type;
/**
* 打印机id
*/
private Long machineId;
} }

View File

@@ -1,6 +1,7 @@
package com.czg.order.entity; package com.czg.order.entity;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONArray;
import com.czg.order.dto.LimitRateDTO; import com.czg.order.dto.LimitRateDTO;
import com.mybatisflex.annotation.Column; import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id; import com.mybatisflex.annotation.Id;
@@ -298,8 +299,10 @@ public class OrderInfo implements Serializable {
private Integer isDel; private Integer isDel;
private String failMsg; private String failMsg;
/**
* 打印状态 Json格式
*/
private String printStatus;
public String getRefundRemark() { public String getRefundRemark() {
@@ -342,4 +345,16 @@ public class OrderInfo implements Serializable {
// 如果需要加上抹零金额,可以取消下面这行注释 // 如果需要加上抹零金额,可以取消下面这行注释
// .add(this.getRoundAmount() != null ? this.getRoundAmount() : BigDecimal.ZERO); // .add(this.getRoundAmount() != null ? this.getRoundAmount() : BigDecimal.ZERO);
} }
// public JSONArray getPrintStatus() {
// if (StrUtil.isBlank(printStatus)) {
// return new JSONArray();
// }
// try {
// return JSONArray.parseArray(printStatus.trim());
// } catch (Exception e) {
// return new JSONArray();
// }
// }
} }

View File

@@ -41,6 +41,7 @@ public class OrderDetailSmallVO implements Serializable {
private LocalDateTime startOrderTime; private LocalDateTime startOrderTime;
private LocalDateTime dishOutTime; private LocalDateTime dishOutTime;
private LocalDateTime foodServeTime; private LocalDateTime foodServeTime;
private Integer isTemporary;
private String printStatus;
} }

View File

@@ -133,6 +133,11 @@ public class OrderInfoVo implements Serializable {
* 备注 * 备注
*/ */
private String remark; private String remark;
/**
* 打印状态 Json格式
* [{"id":"124","name":"111","time":"2025-12-29 11:05:18"},{"id":"111","name":"标签","time":"2025-12-29 11:05:30"}]
*/
private String printStatus;
/** /**
* 是否使用了霸王餐 * 是否使用了霸王餐

View File

@@ -99,7 +99,7 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
if (shopInfo == null) { if (shopInfo == null) {
throw new CzgException("店铺不存在"); throw new CzgException("店铺不存在");
} }
if (shopInfo.getExpireTime() != null && (DateUtil.date().toLocalDateTime().isAfter(shopInfo.getExpireTime()))) { if (shopInfo.getExpireTime() != null && (LocalDateTime.now().isAfter(shopInfo.getExpireTime()))) {
throw new CzgException("店铺已过期,请联系商家"); throw new CzgException("店铺已过期,请联系商家");
} }
if (SystemConstants.OneZero.ZERO == shopInfo.getOnSale() || shopInfo.getStatus() != SystemConstants.OneZero.ONE) { if (SystemConstants.OneZero.ZERO == shopInfo.getOnSale() || shopInfo.getStatus() != SystemConstants.OneZero.ONE) {

View File

@@ -22,6 +22,8 @@ import com.czg.market.vo.InviteUserVO;
import com.czg.market.vo.MemberConfigVO; import com.czg.market.vo.MemberConfigVO;
import com.czg.order.entity.OrderInfo; import com.czg.order.entity.OrderInfo;
import com.czg.service.account.mapper.ShopUserMapper; import com.czg.service.account.mapper.ShopUserMapper;
import com.czg.service.account.util.FunUtil;
import com.czg.utils.FunUtils;
import com.czg.utils.PageUtil; import com.czg.utils.PageUtil;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
@@ -61,6 +63,7 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
private MemberLevelConfigService memberLevelConfigService; private MemberLevelConfigService memberLevelConfigService;
@DubboReference @DubboReference
private TbMemberConfigService memberConfigService; private TbMemberConfigService memberConfigService;
private ShopUser getUserInfo(Long shopUserId) { private ShopUser getUserInfo(Long shopUserId) {
ShopUser shopUser = queryChain().eq(ShopUser::getId, shopUserId).one(); ShopUser shopUser = queryChain().eq(ShopUser::getId, shopUserId).one();
if (shopUser == null) { if (shopUser == null) {
@@ -240,9 +243,13 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
shopUser.setBirthDay(null); shopUser.setBirthDay(null);
} }
shopUser.setNickName(userInfo.getNickName()); shopUser.setNickName(userInfo.getNickName());
if (shopUser.getJoinTime() == null) { // if (shopUser.getJoinTime() == null) {
shopUser.setJoinTime(LocalDateTime.now()); // shopUser.setJoinTime(LocalDateTime.now());
// }
boolean b = saveOrUpdate(shopUser);
if (b) {
FunUtils.transactionSafeRun(() -> memberConfigService.joinMemberByCondition(shopId, userId, shopUser));
} }
return saveOrUpdate(shopUser); return b;
} }
} }

View File

@@ -14,6 +14,7 @@ import com.czg.market.entity.MkPointsUser;
import com.czg.market.entity.MkShopCouponRecord; import com.czg.market.entity.MkShopCouponRecord;
import com.czg.market.service.MkPointsUserService; import com.czg.market.service.MkPointsUserService;
import com.czg.market.service.MkShopCouponRecordService; import com.czg.market.service.MkShopCouponRecordService;
import com.czg.market.service.TbMemberConfigService;
import com.czg.resp.CzgResult; import com.czg.resp.CzgResult;
import com.czg.service.RedisService; import com.czg.service.RedisService;
import com.czg.service.account.mapper.ShopConfigMapper; import com.czg.service.account.mapper.ShopConfigMapper;

View File

@@ -85,8 +85,6 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
private ShopUserService shopUserService; private ShopUserService shopUserService;
@DubboReference @DubboReference
private UserInfoService userInfoService; private UserInfoService userInfoService;
@DubboReference
private OrderPaymentService orderPaymentService;
@Resource @Resource
private OrderInfoService orderInfoService; private OrderInfoService orderInfoService;
@DubboReference @DubboReference
@@ -706,6 +704,16 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
}); });
} }
@Transactional
@Override
public void distributionUserAmount(MkDistributionFlow item, OrderInfo orderInfo) {
ShopUser shopUser = shopUserService.getById(item.getDistributionUserId());
updateShopInfoAmount(orderInfo.getShopId(), item.getRewardAmount().negate(), orderInfo.getId(), TableValueConstant.DistributionAmountFlow.Type.SUB, "分销扣减");
updateIncome(item.getRewardAmount().negate(), item.getRewardAmount(), BigDecimal.ZERO,
item.getDistributionUserId(), shopUser.getUserId(), item.getShopUserId(), item.getShopId(), item.getLevel());
distributionFlowService.updateById(item);
}
@Override @Override
public void distribute(Long sourceId, String orderNo, BigDecimal amount, Long sourceUserId, Long shopId, String type) { public void distribute(Long sourceId, String orderNo, BigDecimal amount, Long sourceUserId, Long shopId, String type) {
MkDistributionDeliver deliver = new MkDistributionDeliver().setSourceId(sourceId).setOrderNo(orderNo).setShopId(shopId).setType(type).setStatus("success"); MkDistributionDeliver deliver = new MkDistributionDeliver().setSourceId(sourceId).setOrderNo(orderNo).setShopId(shopId).setType(type).setStatus("success");

View File

@@ -192,7 +192,7 @@ public class MkPointsUserServiceImpl extends ServiceImpl<MkPointsUserMapper, MkP
.shopId(pointsUser.getShopId()) .shopId(pointsUser.getShopId())
.shopUserId(pointsUser.getShopUserId()) .shopUserId(pointsUser.getShopUserId())
.floatType(PointsConstant.SUB.getValue()) .floatType(PointsConstant.SUB.getValue())
.floatPoints(floatPoints) .floatPoints(-floatPoints)
.balancePoints(pointsUser.getPointBalance()) .balancePoints(pointsUser.getPointBalance())
.sourceId(orderId.toString()) .sourceId(orderId.toString())
.content(reason) .content(reason)

View File

@@ -175,9 +175,9 @@ public class MkShopRechargeServiceImpl extends ServiceImpl<MkShopRechargeMapper,
// 标准充值 // 标准充值
if (rechargeDetailId != null) { if (rechargeDetailId != null) {
MkShopRechargeDetail rechargeDetail = shopRechargeDetailService.getById(rechargeDetailId);
shopUserMoneyEditDTO.setMoney(rechargeDetail.getAmount());
FunUtils.asyncSafeRunVoid(() -> { FunUtils.asyncSafeRunVoid(() -> {
MkShopRechargeDetail rechargeDetail = shopRechargeDetailService.getById(rechargeDetailId);
shopUserMoneyEditDTO.setMoney(rechargeDetail.getAmount());
// 赠送金额 // 赠送金额
ShopUserMoneyEditDTO shopUserMoneyEditRewardDTO = new ShopUserMoneyEditDTO() ShopUserMoneyEditDTO shopUserMoneyEditRewardDTO = new ShopUserMoneyEditDTO()
.setId(shopUserId) .setId(shopUserId)

View File

@@ -361,6 +361,7 @@ public class TbMemberConfigServiceImpl extends ServiceImpl<TbMemberConfigMapper,
memberExpFlowService.save(expFlow); memberExpFlowService.save(expFlow);
upShopUser.setExperience(shopUser.getExperience() + exp); upShopUser.setExperience(shopUser.getExperience() + exp);
shopUser.setExperience(upShopUser.getExperience());
// 修改会员等级 // 修改会员等级
MemberLevelConfig nextConfig = levelConfigService.getOne(new QueryWrapper().eq(MemberLevelConfig::getShopId, shopUser.getMainShopId()) MemberLevelConfig nextConfig = levelConfigService.getOne(new QueryWrapper().eq(MemberLevelConfig::getShopId, shopUser.getMainShopId())
.gt(MemberLevelConfig::getExperienceValue, levelVO.getExperienceValue()).orderBy(MemberLevelConfig::getExperienceValue, true).limit(1)); .gt(MemberLevelConfig::getExperienceValue, levelVO.getExperienceValue()).orderBy(MemberLevelConfig::getExperienceValue, true).limit(1));

View File

@@ -49,9 +49,6 @@ public abstract class PrinterHandler {
@Setter @Setter
protected PrinterHandler nextPrinter; protected PrinterHandler nextPrinter;
protected String printerBrand; protected String printerBrand;
// 创建 ThreadLocal 变量
private static final ThreadLocal<String> ERR_MSG = ThreadLocal.withInitial(() -> "");
@Resource @Resource
protected OrderDetailService orderDetailService; protected OrderDetailService orderDetailService;
@@ -148,16 +145,17 @@ public abstract class PrinterHandler {
* @param printType 打印类型JSON数组 refund-确认退款单 handover-交班单 queue-排队取号 * @param printType 打印类型JSON数组 refund-确认退款单 handover-交班单 queue-排队取号
* @return 打印机列表 * @return 打印机列表
*/ */
private List<PrintMachine> getPrintMachine(Long shopId, String subType, String printMethod, String printType) { private List<PrintMachine> getPrintMachine(Long shopId, String subType, String printMethod, String printType, Long machineId) {
QueryWrapper wrapper = new QueryWrapper() QueryWrapper wrapper = new QueryWrapper()
.eq(PrintMachine::getStatus, 1) .eq(PrintMachine::getStatus, 1)
.eq(PrintMachine::getId, machineId)
.eq(PrintMachine::getShopId, shopId) .eq(PrintMachine::getShopId, shopId)
.eq(PrintMachine::getSubType, subType) .eq(PrintMachine::getSubType, subType)
.eq(PrintMachine::getConnectionType, "网络"); .eq(PrintMachine::getConnectionType, "网络");
if (StrUtil.isNotEmpty(printMethod)) { if (StrUtil.isNotEmpty(printMethod)) {
List<String> arrayList = switch (printMethod) { List<String> arrayList = switch (printMethod) {
case "all" ->Arrays.asList("one", "normal", "all"); case "all" -> Arrays.asList("one", "normal", "all");
case "one" -> Arrays.asList("one", "all"); case "one" -> Arrays.asList("one", "all");
case "normal" -> Arrays.asList("normal", "all"); case "normal" -> Arrays.asList("normal", "all");
default -> new ArrayList<>(); default -> new ArrayList<>();
@@ -188,10 +186,11 @@ public abstract class PrinterHandler {
/** /**
* 处理打印 * 处理打印
* @param data 传递的数据 *
* @param data 传递的数据
* @param printTypeEnum order returnOrder preOrder one call handover * @param printTypeEnum order returnOrder preOrder one call handover
*/ */
public void handler(String data, PrintTypeEnum printTypeEnum) { public void handler(String data, PrintTypeEnum printTypeEnum, Long machineId) {
Long shopId; Long shopId;
String printMethod = ""; String printMethod = "";
String printType = ""; String printType = "";
@@ -262,7 +261,7 @@ public abstract class PrinterHandler {
} }
Object finalObj = obj; Object finalObj = obj;
getPrintMachine(shopId, "cash", printMethod, printType).forEach(machine -> { getPrintMachine(shopId, "cash", printMethod, printType, machineId).forEach(machine -> {
handleRequest(machine, finalObj, printTypeEnum); handleRequest(machine, finalObj, printTypeEnum);
// printPlaceTicket(isReturn, machine, orderInfo, shopInfo); // printPlaceTicket(isReturn, machine, orderInfo, shopInfo);
}); });
@@ -314,7 +313,7 @@ public abstract class PrinterHandler {
item.setNum(item.getNum().subtract(printDetailInfo.getPrintNum())); item.setNum(item.getNum().subtract(printDetailInfo.getPrintNum()));
item.setReturnNum(item.getReturnNum().subtract(printDetailInfo.getPrintReturnNum())); item.setReturnNum(item.getReturnNum().subtract(printDetailInfo.getPrintReturnNum()));
orderDetails.add(item); orderDetails.add(item);
}else { } else {
orderDetails.add(item); orderDetails.add(item);
} }
@@ -334,7 +333,7 @@ public abstract class PrinterHandler {
log.info("准备开始打印交班"); log.info("准备开始打印交班");
if (data instanceof HandoverRecordDTO record) { if (data instanceof HandoverRecordDTO record) {
handoverPrint(machine, record); handoverPrint(machine, record);
}else { } else {
throw new RuntimeException("传递数据类型有误"); throw new RuntimeException("传递数据类型有误");
} }
break; break;
@@ -343,7 +342,7 @@ public abstract class PrinterHandler {
if (data instanceof OrderInfo orderInfo) { if (data instanceof OrderInfo orderInfo) {
List<OrderDetail> orderDetailList = orderDetailService.list(new QueryWrapper().eq(OrderDetail::getOrderId, orderInfo.getId())); List<OrderDetail> orderDetailList = orderDetailService.list(new QueryWrapper().eq(OrderDetail::getOrderId, orderInfo.getId()));
onlyFrontDesk(machine, false, orderInfo, orderDetailList); onlyFrontDesk(machine, false, orderInfo, orderDetailList);
}else { } else {
throw new RuntimeException("传递数据类型有误"); throw new RuntimeException("传递数据类型有误");
} }
break; break;
@@ -352,7 +351,7 @@ public abstract class PrinterHandler {
if (data instanceof OrderInfo orderInfo) { if (data instanceof OrderInfo orderInfo) {
List<OrderDetail> orderDetailList = orderDetailService.list(new QueryWrapper().eq(OrderDetail::getOrderId, orderInfo.getId())); List<OrderDetail> orderDetailList = orderDetailService.list(new QueryWrapper().eq(OrderDetail::getOrderId, orderInfo.getId()));
onlyFrontDesk(machine, true, orderInfo, orderDetailList); onlyFrontDesk(machine, true, orderInfo, orderDetailList);
}else { } else {
throw new RuntimeException("传递数据类型有误"); throw new RuntimeException("传递数据类型有误");
} }
break; break;
@@ -361,7 +360,7 @@ public abstract class PrinterHandler {
if (data instanceof OrderInfo orderInfo) { if (data instanceof OrderInfo orderInfo) {
List<OrderDetail> orderDetailList = orderDetailService.list(new QueryWrapper().eq(OrderDetail::getOrderId, orderInfo.getId())); List<OrderDetail> orderDetailList = orderDetailService.list(new QueryWrapper().eq(OrderDetail::getOrderId, orderInfo.getId()));
onlyKitchen(machine, orderInfo, orderDetailList); onlyKitchen(machine, orderInfo, orderDetailList);
}else { } else {
throw new RuntimeException("传递数据类型有误"); throw new RuntimeException("传递数据类型有误");
} }
break; break;
@@ -369,7 +368,7 @@ public abstract class PrinterHandler {
log.info("准备开始打印叫号单"); log.info("准备开始打印叫号单");
if (data instanceof CallQueue queue) { if (data instanceof CallQueue queue) {
onlyCallNumPrint(machine, queue); onlyCallNumPrint(machine, queue);
}else { } else {
throw new RuntimeException("传递数据类型有误"); throw new RuntimeException("传递数据类型有误");
} }
break; break;
@@ -393,7 +392,7 @@ public abstract class PrinterHandler {
default: default:
throw new RuntimeException("打印方法有误"); throw new RuntimeException("打印方法有误");
} }
}else { } else {
throw new RuntimeException("传递数据类型有误"); throw new RuntimeException("传递数据类型有误");
} }

View File

@@ -36,7 +36,7 @@ public class DistributionPayServiceImpl implements DistributionPayService {
private final BigDecimal MONEY_RATE = new BigDecimal("100"); private final BigDecimal MONEY_RATE = new BigDecimal("100");
@Resource @Resource
private OrderPaymentService orderPaymentService; private OrderPaymentService paymentService;
@Resource @Resource
private MkDistributionConfigService configService; private MkDistributionConfigService configService;
@Resource @Resource
@@ -74,7 +74,7 @@ public class DistributionPayServiceImpl implements DistributionPayService {
.setPayType(PayTypeConstants.PayType.PAY) .setPayType(PayTypeConstants.PayType.PAY)
.setOrderNo(payParam.getPlatformType() + IdUtil.getSnowflakeNextId()) .setOrderNo(payParam.getPlatformType() + IdUtil.getSnowflakeNextId())
.setAmount(isRecharge ? payParam.getAmount() : detail.getPayAmount()); .setAmount(isRecharge ? payParam.getAmount() : detail.getPayAmount());
orderPaymentService.save(orderPayment); paymentService.save(orderPayment);
InitInfo initInfo = new InitInfo().setConfig(detail); InitInfo initInfo = new InitInfo().setConfig(detail);
if (isRecharge) { if (isRecharge) {

View File

@@ -1523,13 +1523,13 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
switch (orderInfoPrintDTO.getType()) { switch (orderInfoPrintDTO.getType()) {
case 0: case 0:
printerHandler.handler(orderInfo.getId().toString(), PrinterHandler.PrintTypeEnum.ONE_AND_ORDER); printerHandler.handler(orderInfo.getId().toString(), PrinterHandler.PrintTypeEnum.ONE_AND_ORDER, orderInfoPrintDTO.getMachineId());
break; break;
case 1: case 1:
printerHandler.handler(orderInfo.getId().toString(), PrinterHandler.PrintTypeEnum.PRE_ORDER); printerHandler.handler(orderInfo.getId().toString(), PrinterHandler.PrintTypeEnum.PRE_ORDER, orderInfoPrintDTO.getMachineId());
break; break;
case 2: case 2:
printerHandler.handler(orderInfo.getId().toString(), PrinterHandler.PrintTypeEnum.ORDER); printerHandler.handler(orderInfo.getId().toString(), PrinterHandler.PrintTypeEnum.ORDER, orderInfoPrintDTO.getMachineId());
break; break;
} }
return true; return true;

View File

@@ -22,10 +22,10 @@ public class OrderPaymentServiceImpl extends ServiceImpl<OrderPaymentMapper, Ord
@Override @Override
public BigDecimal countMemberInAmount(Long shopId, Long shopUserId) { public BigDecimal countMemberInAmount(Long shopId, Long shopUserId) {
return getOneAs(QueryWrapper.create().select("IFNULL(sum(amount), 0) as total_amount") return getOneAs(QueryWrapper.create().select("IFNULL(sum(amount), 0) as total_amount")
.eq(OrderPayment::getShopId, 143) .eq(OrderPayment::getShopId, shopId)
.eq(OrderPayment::getSourceType, PayTypeConstants.SourceType.MEMBER_IN) .eq(OrderPayment::getSourceType, PayTypeConstants.SourceType.MEMBER_IN)
.eq(OrderPayment::getPayType, PayTypeConstants.PayType.PAY) .eq(OrderPayment::getPayType, PayTypeConstants.PayType.PAY)
.eq(OrderPayment::getSourceId, 127452) .eq(OrderPayment::getSourceId, shopUserId)
.eq(OrderPayment::getPayStatus, PayTypeConstants.PayStatus.SUCCESS), BigDecimal.class); .eq(OrderPayment::getPayStatus, PayTypeConstants.PayStatus.SUCCESS), BigDecimal.class);
} }
} }

View File

@@ -2,7 +2,6 @@ package com.czg.service.order.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapProxy;
import cn.hutool.core.map.MapUtil; import cn.hutool.core.map.MapUtil;
import cn.hutool.core.text.UnicodeUtil; import cn.hutool.core.text.UnicodeUtil;
import cn.hutool.core.thread.ThreadUtil; import cn.hutool.core.thread.ThreadUtil;
@@ -12,18 +11,15 @@ import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.czg.account.entity.PrintMachine; import com.czg.account.entity.PrintMachine;
import com.github.pagehelper.PageHelper; import com.czg.market.service.OrderInfoService;
import com.github.pagehelper.PageInfo;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.czg.order.entity.PrintMachineLog; import com.czg.order.entity.PrintMachineLog;
import com.czg.order.service.PrintMachineLogService; import com.czg.order.service.PrintMachineLogService;
import com.czg.service.order.mapper.PrintMachineLogMapper; import com.czg.service.order.mapper.PrintMachineLogMapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.codec.digest.DigestUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -38,7 +34,7 @@ import java.util.*;
@Slf4j @Slf4j
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class PrintMachineLogServiceImpl extends ServiceImpl<PrintMachineLogMapper, PrintMachineLog> implements PrintMachineLogService{ public class PrintMachineLogServiceImpl extends ServiceImpl<PrintMachineLogMapper, PrintMachineLog> implements PrintMachineLogService {
//请求地址 //请求地址
private static final String URL_STR = "https://ioe.car900.com/v1/openApi/dev/customPrint.json"; private static final String URL_STR = "https://ioe.car900.com/v1/openApi/dev/customPrint.json";
//APPID //APPID
@@ -53,6 +49,10 @@ public class PrintMachineLogServiceImpl extends ServiceImpl<PrintMachineLogMappe
public static final String USER = "chaozhanggui2022@163.com";//*必填*:账号名 public static final String USER = "chaozhanggui2022@163.com";//*必填*:账号名
public static final String UKEY = "UfWkhXxSkeSSscsU";//*必填*: 飞鹅云后台注册账号后生成的UKEY 【备注这不是填打印机的KEY】 public static final String UKEY = "UfWkhXxSkeSSscsU";//*必填*: 飞鹅云后台注册账号后生成的UKEY 【备注这不是填打印机的KEY】
public static final String SN = "960238952";//*必填*打印机编号必须要在管理后台里添加打印机或调用API接口添加之后才能调用API public static final String SN = "960238952";//*必填*打印机编号必须要在管理后台里添加打印机或调用API接口添加之后才能调用API
@Resource
private OrderInfoService orderInfoService;
/** /**
* 获取TOKEN值 * 获取TOKEN值
* *
@@ -77,10 +77,10 @@ public class PrintMachineLogServiceImpl extends ServiceImpl<PrintMachineLogMappe
System.out.println("token" + token); System.out.println("token" + token);
Map<String, String> finalMap = new HashMap<>(); Map<String, String> finalMap = new HashMap<>();
finalMap.put("ENCODE", encode.toString()); finalMap.put("ENCODE", encode.toString());
System.out.println("+++++++++++++++" + token + APP_SECRET);
finalMap.put("TOKEN", SecureUtil.md5(token + APP_SECRET).toUpperCase()); finalMap.put("TOKEN", SecureUtil.md5(token + APP_SECRET).toUpperCase());
return finalMap; return finalMap;
} }
/** /**
* 检查打印状态 * 检查打印状态
* *
@@ -106,9 +106,11 @@ public class PrintMachineLogServiceImpl extends ServiceImpl<PrintMachineLogMappe
return HttpUtil.get("https://ioe.car900.com/v1/openApi/dev/findOrder.json", paramMap, 1000 * 5); return HttpUtil.get("https://ioe.car900.com/v1/openApi/dev/findOrder.json", paramMap, 1000 * 5);
} }
private static String signature(String USER, String UKEY, String STIME) { private static String signature(String USER, String UKEY, String STIME) {
return DigestUtils.sha1Hex(USER + UKEY + STIME); return DigestUtils.sha1Hex(USER + UKEY + STIME);
} }
/** /**
* 检查飞鹅打印机打印任务是否已打印 * 检查飞鹅打印机打印任务是否已打印
* *
@@ -135,6 +137,7 @@ public class PrintMachineLogServiceImpl extends ServiceImpl<PrintMachineLogMappe
} }
return ret; return ret;
} }
/** /**
* 检查飞鹅打印机是否在线 * 检查飞鹅打印机是否在线
* *
@@ -161,6 +164,7 @@ public class PrintMachineLogServiceImpl extends ServiceImpl<PrintMachineLogMappe
} }
return msg; return msg;
} }
/** /**
* 保存打印记录 * 保存打印记录
* *
@@ -170,6 +174,7 @@ public class PrintMachineLogServiceImpl extends ServiceImpl<PrintMachineLogMappe
* @param respJson 打印机响应结果 * @param respJson 打印机响应结果
*/ */
@Async @Async
@Override
public void save(PrintMachine config, String bizType, String printContent, Object respJson) { public void save(PrintMachine config, String bizType, String printContent, Object respJson) {
if (config == null) { if (config == null) {
return; return;
@@ -266,7 +271,6 @@ public class PrintMachineLogServiceImpl extends ServiceImpl<PrintMachineLogMappe
entity.setPrintTime(null); entity.setPrintTime(null);
entity.setRespMsg(StrUtil.concat(true, "打印失败,", "_", entity.getRespMsg())); entity.setRespMsg(StrUtil.concat(true, "打印失败,", "_", entity.getRespMsg()));
} }
super.updateById(entity);
} }
// 飞鹅云打印机 // 飞鹅云打印机
} else if ("飞鹅".equals(config.getContentType())) { } else if ("飞鹅".equals(config.getContentType())) {
@@ -291,8 +295,7 @@ public class PrintMachineLogServiceImpl extends ServiceImpl<PrintMachineLogMappe
entity.setRespMsg(StrUtil.concat(true, "打印失败,", "_", msg)); entity.setRespMsg(StrUtil.concat(true, "打印失败,", "_", msg));
} }
} }
super.updateById(entity);
} }
super.updateById(entity);
} }
} }

View File

@@ -153,6 +153,10 @@
<foreach item="item" collection="idList" separator="," open="(" close=")"> <foreach item="item" collection="idList" separator="," open="(" close=")">
#{item} #{item}
</foreach> </foreach>
or t1.sync_id in
<foreach item="item" collection="idList" separator="," open="(" close=")">
#{item}
</foreach>
</if> </if>
order by t1.sort desc,t1.id desc order by t1.sort desc,t1.id desc
</select> </select>