Compare commits
16 Commits
pay
...
87797e5812
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
87797e5812 | ||
| 057f851dcf | |||
| dc3be2f1d8 | |||
| 232bfe84df | |||
| ff09e8e92b | |||
| 5d9c01f427 | |||
| 5d7aaa2dca | |||
| 5595a8009b | |||
| 233c226dca | |||
| 76c6e12c72 | |||
| 5b030ea361 | |||
| 266e782fc0 | |||
| aa7483b1b1 | |||
| 7eeeb8a30f | |||
| 70307e3833 | |||
| 8bde6b15f6 |
@@ -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 "";
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import com.czg.market.vo.InviteUserVO;
|
||||
import com.czg.market.vo.MkDistributionConfigVO;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.task.DistributionTask;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import jakarta.annotation.Resource;
|
||||
@@ -37,6 +38,22 @@ public class UDistributionController {
|
||||
private MkDistributionWithdrawFlowService withdrawFlowService;
|
||||
@Resource
|
||||
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("任务执行成功");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分销员中心-获取配置
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* market服务 任务总调度
|
||||
*
|
||||
* @author ww
|
||||
*/
|
||||
@Component
|
||||
@@ -18,9 +19,9 @@ public class AAMarketTasks {
|
||||
|
||||
|
||||
// 分销延时发放
|
||||
@Scheduled(fixedRate = 30000)
|
||||
@Scheduled(cron = "0 0 0/2 * * ? ")
|
||||
public void distributionTask() {
|
||||
distributionTask.deliver();
|
||||
distributionTask.deliver(null);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +30,7 @@ public class AAMarketTasks {
|
||||
public void birthdayGiftTask() {
|
||||
birthdayGiftTask.deliver();
|
||||
}
|
||||
|
||||
//会员生日弹窗提醒重置 每年1月1日
|
||||
@Scheduled(cron = "0 0 0 1 1 ?")
|
||||
public void birthdayGiftRemindTask() {
|
||||
@@ -39,6 +41,7 @@ public class AAMarketTasks {
|
||||
//优惠券 过期
|
||||
@Resource
|
||||
private CouponTask couponTask;
|
||||
|
||||
//每天每小时的30分 0秒 执行
|
||||
@Scheduled(cron = "0 30 * * * ? ")
|
||||
public void couponTask() {
|
||||
@@ -48,6 +51,7 @@ public class AAMarketTasks {
|
||||
//会员奖励发放
|
||||
@Resource
|
||||
private MemberTask memberTask;
|
||||
|
||||
//每天1点 0分 0秒 执行
|
||||
@Scheduled(cron = "0 0 1 * * ? ")
|
||||
public void memberTask() {
|
||||
@@ -57,6 +61,7 @@ public class AAMarketTasks {
|
||||
//满减活动/限时折扣 处理任务状态 定时任务
|
||||
@Resource
|
||||
private ActivityStatusTask activityStatusTask;
|
||||
|
||||
//每天0点 0分 1秒 执行
|
||||
@Scheduled(cron = "1 0 0 * * ? ")
|
||||
public void activityStatusTask() {
|
||||
@@ -67,6 +72,7 @@ public class AAMarketTasks {
|
||||
//月累计 发送条数 累计金额
|
||||
@Resource
|
||||
private SmsShopMoneyTask smsShopMoneyTask;
|
||||
|
||||
//每月1号 0点 0分 1秒 执行
|
||||
@Scheduled(cron = "1 0 0 1 * ?")
|
||||
public void smsShopMoneyTask() {
|
||||
|
||||
@@ -2,10 +2,13 @@ package com.czg.task;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.czg.account.entity.ShopInfo;
|
||||
import com.czg.account.entity.ShopUser;
|
||||
import com.czg.account.service.ShopInfoService;
|
||||
import com.czg.account.service.ShopUserService;
|
||||
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.service.MkDistributionFlowService;
|
||||
import com.czg.market.service.MkDistributionUserService;
|
||||
@@ -18,6 +21,7 @@ import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
@@ -40,8 +44,6 @@ public class DistributionTask {
|
||||
private OrderInfoService orderInfoService;
|
||||
@DubboReference
|
||||
private ShopInfoService shopInfoService;
|
||||
@DubboReference
|
||||
private ShopUserService shopUserService;
|
||||
|
||||
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(fixedRate = 30000)
|
||||
public void deliver() {
|
||||
// 1. 订单完成支付时(判断是否分销)产生流水记录。
|
||||
// 2. 判断入账时间。
|
||||
// 3. 如果是 0 天,再去判断商户余额是否足够。够则入账,不足则不管。
|
||||
// 4. 流水增加应该入账的时间(订单产生时带入)
|
||||
// 5. 定时任务 应该是一天执行一次。查询待入账状态和应入账时间小于当前时间的记录,循环处理:并且判断商户余额是否足够,余额不足忽略处理;余额足够变为已入账并扣除商户余额。
|
||||
// 6. 订单产生退款时,去流水表查询该订单的流水记录,如果未入账改为已入账,并插入一条退款扣钱的流水。
|
||||
|
||||
// shopInfo 查余额>0
|
||||
// 循环 shopId 查询 如果金额不足 终止
|
||||
//
|
||||
LocalDateTime localDateTime = DateUtil.date().toLocalDateTime();
|
||||
distributionFlowService.list(new QueryWrapper()
|
||||
.eq(MkDistributionFlow::getStatus, TableValueConstant.DistributionFlow.Status.PENDING.getCode()).le(MkDistributionFlow::getDeliverTime, localDateTime)).forEach(item -> {
|
||||
FunUtils.safeRunVoid(() -> {
|
||||
log.info("开始处理延时分账, id: {}, orderNo: {}, 类型: {}", item.getId(), item.getOrderNo(), item.getType());
|
||||
|
||||
public void deliver(Long shopId) {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
List<ShopInfo> shopInfos = shopInfoService.list(QueryWrapper.create()
|
||||
.eq(ShopInfo::getIsDeleted, SystemConstants.OneZero.ZERO)
|
||||
.isNotNull(ShopInfo::getExpireTime)
|
||||
.lt(ShopInfo::getExpireTime, now)
|
||||
.gt(ShopInfo::getAmount, BigDecimal.ZERO)
|
||||
.eq(ShopInfo::getId, shopId)
|
||||
);
|
||||
if (CollUtil.isEmpty(shopInfos)) {
|
||||
log.info("分销延时分账 无符合条件的店铺,无需处理分账");
|
||||
return;
|
||||
}
|
||||
for (ShopInfo shopInfo : shopInfos) {
|
||||
boolean breakCurrentShopFlow = false;
|
||||
List<MkDistributionFlow> flowList = distributionFlowService.list(new QueryWrapper()
|
||||
.eq(MkDistributionFlow::getShopId, shopInfo.getId())
|
||||
.eq(MkDistributionFlow::getStatus, TableValueConstant.DistributionFlow.Status.PENDING.getCode())
|
||||
.le(MkDistributionFlow::getDeliverTime, now)
|
||||
.orderBy(MkDistributionFlow::getId, true)
|
||||
);
|
||||
for (MkDistributionFlow item : flowList) {
|
||||
if (breakCurrentShopFlow) {
|
||||
break;
|
||||
}
|
||||
try {
|
||||
log.info("分销延时分账, id: {}, orderNo: {}, 类型: {}", item.getId(), item.getOrderNo(), item.getType());
|
||||
OrderInfo orderInfo = orderInfoService.getOne(new QueryWrapper().eq(OrderInfo::getOrderNo, item.getOrderNo()));
|
||||
if (orderInfo == null) {
|
||||
item.setStatus(TableValueConstant.DistributionFlow.Status.FAIL.getCode());
|
||||
distributionFlowService.updateById(item);
|
||||
log.warn("订单不存在, 订单号: {}", item.getOrderNo());
|
||||
return;
|
||||
log.warn("分销延时分账。订单不存在, 订单号: {}", item.getOrderNo());
|
||||
continue;
|
||||
}
|
||||
if (list.contains(orderInfo.getStatus())) {
|
||||
log.warn("订单已退款, 订单号: {}", item.getOrderNo());
|
||||
log.warn("分销延时分账。订单已退款, 订单号: {}", item.getOrderNo());
|
||||
distributionUserService.refund(orderInfo.getId(), orderInfo.getOrderNo());
|
||||
} else {
|
||||
item.setStatus(TableValueConstant.DistributionFlow.Status.SUCCESS.getCode());
|
||||
ShopUser shopUser = shopUserService.getById(item.getDistributionUserId());
|
||||
distributionUserService.updateShopInfoAmount(orderInfo.getShopId(), item.getRewardAmount().negate(), orderInfo.getId(), TableValueConstant.DistributionAmountFlow.Type.SUB, "分销扣减");
|
||||
distributionUserService.updateIncome(item.getRewardAmount().negate(), item.getRewardAmount(), BigDecimal.ZERO,
|
||||
item.getDistributionUserId(), shopUser.getUserId(), item.getShopUserId(), item.getShopId(), item.getLevel());
|
||||
distributionFlowService.updateById(item);
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -50,6 +50,8 @@ public class NotifyController {
|
||||
@Resource
|
||||
private MkShopConsumeDiscountRecordService consumeDiscountRecordService;
|
||||
|
||||
|
||||
//新客立减清除数据 测试用
|
||||
@RequestMapping("clear")
|
||||
public String clear(@RequestParam Integer shopId) {
|
||||
consumeDiscountRecordService.remove(new QueryWrapper().eq(MkShopConsumeDiscountRecord::getShopId, shopId));
|
||||
|
||||
@@ -21,7 +21,7 @@ public class StatisticTaskController {
|
||||
private StatisticTask statisticTask;
|
||||
|
||||
/**
|
||||
* 基础统计
|
||||
* 基础统计 预留重置统计
|
||||
*
|
||||
* @param date 日期yyyy-MM-dd
|
||||
*/
|
||||
|
||||
@@ -30,9 +30,6 @@ public class PrintMqListener {
|
||||
@Resource
|
||||
private FunUtil funUtil;
|
||||
|
||||
// 注入自定义线程池(建议单独配置,避免使用默认线程池)
|
||||
@Resource
|
||||
private ThreadPoolTaskExecutor asyncExecutor;
|
||||
@Lazy
|
||||
@Resource
|
||||
private PrinterHandler printerHandler;
|
||||
@@ -64,37 +61,10 @@ public class PrintMqListener {
|
||||
}
|
||||
Boolean printOrder = jsonObject.getBoolean("printOrder");
|
||||
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;
|
||||
}, 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})
|
||||
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})
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class OTimeTask {
|
||||
@Resource
|
||||
private CashierCartService cartService;
|
||||
@Resource
|
||||
private OrderPaymentService orderPaymentService;
|
||||
private OrderPaymentService paymentService;
|
||||
@Resource
|
||||
private GbOrderService gbOrderService;
|
||||
@Resource
|
||||
@@ -117,7 +117,7 @@ public class OTimeTask {
|
||||
|
||||
LocalDateTime tenMinutesAgo = LocalDateTime.now().minusMinutes(10);
|
||||
LocalDateTime thirdDayAgo = LocalDateTime.now().minusDays(3);
|
||||
List<OrderPayment> list = orderPaymentService.list(QueryWrapper.create()
|
||||
List<OrderPayment> list = paymentService.list(QueryWrapper.create()
|
||||
.gt(OrderPayment::getUpdateTime, thirdDayAgo)
|
||||
.lt(OrderPayment::getUpdateTime, tenMinutesAgo)
|
||||
.in(OrderPayment::getSourceType, ware)
|
||||
|
||||
@@ -54,7 +54,7 @@ public class FilteredNacosRegistry extends NacosRegistry {
|
||||
public void register(URL url) {
|
||||
// 1. 获取原始注册的方法列表
|
||||
String originalMethods = url.getParameter("methods");
|
||||
log.info("【过滤提示】服务 {} 注册方法:{}", url.getServiceInterface(), originalMethods);
|
||||
// log.info("【过滤提示】服务 {} 注册方法:{}", url.getServiceInterface(), originalMethods);
|
||||
if (originalMethods != null && !originalMethods.isEmpty()) {
|
||||
// 2. 过滤黑名单中的方法名
|
||||
List<String> filteredMethods = Arrays.stream(originalMethods.split(","))
|
||||
@@ -67,12 +67,12 @@ public class FilteredNacosRegistry extends NacosRegistry {
|
||||
// 3. 处理过滤后的结果
|
||||
if (filteredMethods.isEmpty()) {
|
||||
// 若所有方法都被过滤,直接终止注册(可选:根据业务决定是否保留服务注册)
|
||||
log.info("【过滤提示】服务 {} 所有方法均被过滤,终止注册", url.getServiceInterface());
|
||||
// log.info("【过滤提示】服务 {} 所有方法均被过滤,终止注册", url.getServiceInterface());
|
||||
return;
|
||||
} else {
|
||||
// 替换 URL 中的 methods 参数为过滤后的列表
|
||||
url = url.addParameter("methods", String.join(",", filteredMethods));
|
||||
log.info("【过滤提示】服务 {} 注册方法:{}", url.getServiceInterface(), filteredMethods);
|
||||
// log.info("【过滤提示】服务 {} 注册方法:{}", url.getServiceInterface(), filteredMethods);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.czg.config;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.mybatisflex.core.audit.AuditManager;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -17,8 +18,24 @@ public class MybatisFlexConfig {
|
||||
//设置 SQL 审计收集器
|
||||
AuditManager.setMessageCollector(auditMessage ->
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,4 +285,13 @@ public class ShopInfoEditDTO {
|
||||
*/
|
||||
private Integer isCountStick;
|
||||
|
||||
/**
|
||||
* 企业id
|
||||
*/
|
||||
private String weworkId;
|
||||
/**
|
||||
* 企业接入链接
|
||||
*/
|
||||
private String weworkUrl;
|
||||
|
||||
}
|
||||
|
||||
@@ -135,5 +135,13 @@ public class ShopConfig implements Serializable {
|
||||
|
||||
private String dingAppKey;
|
||||
private String dingAppSecret;
|
||||
/**
|
||||
* 企业id
|
||||
*/
|
||||
private String weworkId;
|
||||
/**
|
||||
* 企业接入链接
|
||||
*/
|
||||
private String weworkUrl;
|
||||
|
||||
}
|
||||
|
||||
@@ -363,4 +363,15 @@ public class ShopInfo implements Serializable {
|
||||
*/
|
||||
private BigDecimal amount;
|
||||
|
||||
/**
|
||||
* 企业id
|
||||
*/
|
||||
@Column(ignore = true)
|
||||
private String weworkId;
|
||||
/**
|
||||
* 企业接入链接
|
||||
*/
|
||||
@Column(ignore = true)
|
||||
private String weworkUrl;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,10 +7,12 @@ import com.czg.exception.CzgException;
|
||||
import com.czg.market.dto.MkDistributionUserDTO;
|
||||
import com.czg.market.dto.MkDistributionWithdrawFlowDTO;
|
||||
import com.czg.market.entity.MkDistributionConfig;
|
||||
import com.czg.market.entity.MkDistributionFlow;
|
||||
import com.czg.market.entity.MkDistributionUser;
|
||||
import com.czg.market.vo.DistributionCenterShopVO;
|
||||
import com.czg.market.vo.InviteUserVO;
|
||||
import com.czg.order.dto.MkDistributionPayDTO;
|
||||
import com.czg.order.entity.OrderInfo;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
|
||||
@@ -123,6 +125,8 @@ public interface MkDistributionUserService extends IService<MkDistributionUser>
|
||||
|
||||
void refund(Long orderId, String orderNo);
|
||||
|
||||
void distributionUserAmount(MkDistributionFlow item, OrderInfo orderInfo);
|
||||
|
||||
/**
|
||||
* 发放分销奖励
|
||||
*
|
||||
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -24,5 +24,9 @@ public class OrderInfoPrintDTO implements Serializable {
|
||||
*/
|
||||
@NotNull(message = "打印类型不为空")
|
||||
private Integer type;
|
||||
/**
|
||||
* 打印机id
|
||||
*/
|
||||
private Long machineId;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.czg.order.entity;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.czg.order.dto.LimitRateDTO;
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
@@ -298,8 +299,10 @@ public class OrderInfo implements Serializable {
|
||||
private Integer isDel;
|
||||
|
||||
private String failMsg;
|
||||
|
||||
|
||||
/**
|
||||
* 打印状态 Json格式
|
||||
*/
|
||||
private String printStatus;
|
||||
|
||||
|
||||
public String getRefundRemark() {
|
||||
@@ -342,4 +345,16 @@ public class OrderInfo implements Serializable {
|
||||
// 如果需要加上抹零金额,可以取消下面这行注释
|
||||
// .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();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ public class OrderDetailSmallVO implements Serializable {
|
||||
private LocalDateTime startOrderTime;
|
||||
private LocalDateTime dishOutTime;
|
||||
private LocalDateTime foodServeTime;
|
||||
|
||||
private Integer isTemporary;
|
||||
private String printStatus;
|
||||
}
|
||||
|
||||
|
||||
@@ -133,6 +133,11 @@ public class OrderInfoVo implements Serializable {
|
||||
* 备注
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
* 是否使用了霸王餐
|
||||
|
||||
@@ -99,7 +99,7 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
|
||||
if (shopInfo == null) {
|
||||
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("店铺已过期,请联系商家");
|
||||
}
|
||||
if (SystemConstants.OneZero.ZERO == shopInfo.getOnSale() || shopInfo.getStatus() != SystemConstants.OneZero.ONE) {
|
||||
|
||||
@@ -22,6 +22,8 @@ import com.czg.market.vo.InviteUserVO;
|
||||
import com.czg.market.vo.MemberConfigVO;
|
||||
import com.czg.order.entity.OrderInfo;
|
||||
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.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
@@ -61,6 +63,7 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
|
||||
private MemberLevelConfigService memberLevelConfigService;
|
||||
@DubboReference
|
||||
private TbMemberConfigService memberConfigService;
|
||||
|
||||
private ShopUser getUserInfo(Long shopUserId) {
|
||||
ShopUser shopUser = queryChain().eq(ShopUser::getId, shopUserId).one();
|
||||
if (shopUser == null) {
|
||||
@@ -240,9 +243,13 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
|
||||
shopUser.setBirthDay(null);
|
||||
}
|
||||
shopUser.setNickName(userInfo.getNickName());
|
||||
if (shopUser.getJoinTime() == null) {
|
||||
shopUser.setJoinTime(LocalDateTime.now());
|
||||
// if (shopUser.getJoinTime() == null) {
|
||||
// shopUser.setJoinTime(LocalDateTime.now());
|
||||
// }
|
||||
boolean b = saveOrUpdate(shopUser);
|
||||
if (b) {
|
||||
FunUtils.transactionSafeRun(() -> memberConfigService.joinMemberByCondition(shopId, userId, shopUser));
|
||||
}
|
||||
return saveOrUpdate(shopUser);
|
||||
return b;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import com.czg.market.entity.MkPointsUser;
|
||||
import com.czg.market.entity.MkShopCouponRecord;
|
||||
import com.czg.market.service.MkPointsUserService;
|
||||
import com.czg.market.service.MkShopCouponRecordService;
|
||||
import com.czg.market.service.TbMemberConfigService;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.service.RedisService;
|
||||
import com.czg.service.account.mapper.ShopConfigMapper;
|
||||
|
||||
@@ -85,8 +85,6 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
||||
private ShopUserService shopUserService;
|
||||
@DubboReference
|
||||
private UserInfoService userInfoService;
|
||||
@DubboReference
|
||||
private OrderPaymentService orderPaymentService;
|
||||
@Resource
|
||||
private OrderInfoService orderInfoService;
|
||||
@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
|
||||
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");
|
||||
|
||||
@@ -192,7 +192,7 @@ public class MkPointsUserServiceImpl extends ServiceImpl<MkPointsUserMapper, MkP
|
||||
.shopId(pointsUser.getShopId())
|
||||
.shopUserId(pointsUser.getShopUserId())
|
||||
.floatType(PointsConstant.SUB.getValue())
|
||||
.floatPoints(floatPoints)
|
||||
.floatPoints(-floatPoints)
|
||||
.balancePoints(pointsUser.getPointBalance())
|
||||
.sourceId(orderId.toString())
|
||||
.content(reason)
|
||||
|
||||
@@ -175,9 +175,9 @@ public class MkShopRechargeServiceImpl extends ServiceImpl<MkShopRechargeMapper,
|
||||
|
||||
// 标准充值
|
||||
if (rechargeDetailId != null) {
|
||||
FunUtils.asyncSafeRunVoid(() -> {
|
||||
MkShopRechargeDetail rechargeDetail = shopRechargeDetailService.getById(rechargeDetailId);
|
||||
shopUserMoneyEditDTO.setMoney(rechargeDetail.getAmount());
|
||||
FunUtils.asyncSafeRunVoid(() -> {
|
||||
// 赠送金额
|
||||
ShopUserMoneyEditDTO shopUserMoneyEditRewardDTO = new ShopUserMoneyEditDTO()
|
||||
.setId(shopUserId)
|
||||
|
||||
@@ -361,6 +361,7 @@ public class TbMemberConfigServiceImpl extends ServiceImpl<TbMemberConfigMapper,
|
||||
memberExpFlowService.save(expFlow);
|
||||
|
||||
upShopUser.setExperience(shopUser.getExperience() + exp);
|
||||
shopUser.setExperience(upShopUser.getExperience());
|
||||
// 修改会员等级
|
||||
MemberLevelConfig nextConfig = levelConfigService.getOne(new QueryWrapper().eq(MemberLevelConfig::getShopId, shopUser.getMainShopId())
|
||||
.gt(MemberLevelConfig::getExperienceValue, levelVO.getExperienceValue()).orderBy(MemberLevelConfig::getExperienceValue, true).limit(1));
|
||||
|
||||
@@ -49,9 +49,6 @@ public abstract class PrinterHandler {
|
||||
@Setter
|
||||
protected PrinterHandler nextPrinter;
|
||||
protected String printerBrand;
|
||||
// 创建 ThreadLocal 变量
|
||||
private static final ThreadLocal<String> ERR_MSG = ThreadLocal.withInitial(() -> "");
|
||||
|
||||
|
||||
@Resource
|
||||
protected OrderDetailService orderDetailService;
|
||||
@@ -148,16 +145,17 @@ public abstract class PrinterHandler {
|
||||
* @param printType 打印类型,JSON数组 refund-确认退款单 handover-交班单 queue-排队取号
|
||||
* @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()
|
||||
.eq(PrintMachine::getStatus, 1)
|
||||
.eq(PrintMachine::getId, machineId)
|
||||
.eq(PrintMachine::getShopId, shopId)
|
||||
.eq(PrintMachine::getSubType, subType)
|
||||
.eq(PrintMachine::getConnectionType, "网络");
|
||||
|
||||
if (StrUtil.isNotEmpty(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 "normal" -> Arrays.asList("normal", "all");
|
||||
default -> new ArrayList<>();
|
||||
@@ -188,10 +186,11 @@ public abstract class PrinterHandler {
|
||||
|
||||
/**
|
||||
* 处理打印
|
||||
*
|
||||
* @param data 传递的数据
|
||||
* @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;
|
||||
String printMethod = "";
|
||||
String printType = "";
|
||||
@@ -262,7 +261,7 @@ public abstract class PrinterHandler {
|
||||
}
|
||||
|
||||
Object finalObj = obj;
|
||||
getPrintMachine(shopId, "cash", printMethod, printType).forEach(machine -> {
|
||||
getPrintMachine(shopId, "cash", printMethod, printType, machineId).forEach(machine -> {
|
||||
handleRequest(machine, finalObj, printTypeEnum);
|
||||
// printPlaceTicket(isReturn, machine, orderInfo, shopInfo);
|
||||
});
|
||||
@@ -314,7 +313,7 @@ public abstract class PrinterHandler {
|
||||
item.setNum(item.getNum().subtract(printDetailInfo.getPrintNum()));
|
||||
item.setReturnNum(item.getReturnNum().subtract(printDetailInfo.getPrintReturnNum()));
|
||||
orderDetails.add(item);
|
||||
}else {
|
||||
} else {
|
||||
orderDetails.add(item);
|
||||
}
|
||||
|
||||
@@ -334,7 +333,7 @@ public abstract class PrinterHandler {
|
||||
log.info("准备开始打印交班");
|
||||
if (data instanceof HandoverRecordDTO record) {
|
||||
handoverPrint(machine, record);
|
||||
}else {
|
||||
} else {
|
||||
throw new RuntimeException("传递数据类型有误");
|
||||
}
|
||||
break;
|
||||
@@ -343,7 +342,7 @@ public abstract class PrinterHandler {
|
||||
if (data instanceof OrderInfo orderInfo) {
|
||||
List<OrderDetail> orderDetailList = orderDetailService.list(new QueryWrapper().eq(OrderDetail::getOrderId, orderInfo.getId()));
|
||||
onlyFrontDesk(machine, false, orderInfo, orderDetailList);
|
||||
}else {
|
||||
} else {
|
||||
throw new RuntimeException("传递数据类型有误");
|
||||
}
|
||||
break;
|
||||
@@ -352,7 +351,7 @@ public abstract class PrinterHandler {
|
||||
if (data instanceof OrderInfo orderInfo) {
|
||||
List<OrderDetail> orderDetailList = orderDetailService.list(new QueryWrapper().eq(OrderDetail::getOrderId, orderInfo.getId()));
|
||||
onlyFrontDesk(machine, true, orderInfo, orderDetailList);
|
||||
}else {
|
||||
} else {
|
||||
throw new RuntimeException("传递数据类型有误");
|
||||
}
|
||||
break;
|
||||
@@ -361,7 +360,7 @@ public abstract class PrinterHandler {
|
||||
if (data instanceof OrderInfo orderInfo) {
|
||||
List<OrderDetail> orderDetailList = orderDetailService.list(new QueryWrapper().eq(OrderDetail::getOrderId, orderInfo.getId()));
|
||||
onlyKitchen(machine, orderInfo, orderDetailList);
|
||||
}else {
|
||||
} else {
|
||||
throw new RuntimeException("传递数据类型有误");
|
||||
}
|
||||
break;
|
||||
@@ -369,7 +368,7 @@ public abstract class PrinterHandler {
|
||||
log.info("准备开始打印叫号单");
|
||||
if (data instanceof CallQueue queue) {
|
||||
onlyCallNumPrint(machine, queue);
|
||||
}else {
|
||||
} else {
|
||||
throw new RuntimeException("传递数据类型有误");
|
||||
}
|
||||
break;
|
||||
@@ -393,7 +392,7 @@ public abstract class PrinterHandler {
|
||||
default:
|
||||
throw new RuntimeException("打印方法有误");
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
throw new RuntimeException("传递数据类型有误");
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ public class DistributionPayServiceImpl implements DistributionPayService {
|
||||
private final BigDecimal MONEY_RATE = new BigDecimal("100");
|
||||
|
||||
@Resource
|
||||
private OrderPaymentService orderPaymentService;
|
||||
private OrderPaymentService paymentService;
|
||||
@Resource
|
||||
private MkDistributionConfigService configService;
|
||||
@Resource
|
||||
@@ -74,7 +74,7 @@ public class DistributionPayServiceImpl implements DistributionPayService {
|
||||
.setPayType(PayTypeConstants.PayType.PAY)
|
||||
.setOrderNo(payParam.getPlatformType() + IdUtil.getSnowflakeNextId())
|
||||
.setAmount(isRecharge ? payParam.getAmount() : detail.getPayAmount());
|
||||
orderPaymentService.save(orderPayment);
|
||||
paymentService.save(orderPayment);
|
||||
|
||||
InitInfo initInfo = new InitInfo().setConfig(detail);
|
||||
if (isRecharge) {
|
||||
|
||||
@@ -1523,13 +1523,13 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
||||
|
||||
switch (orderInfoPrintDTO.getType()) {
|
||||
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;
|
||||
case 1:
|
||||
printerHandler.handler(orderInfo.getId().toString(), PrinterHandler.PrintTypeEnum.PRE_ORDER);
|
||||
printerHandler.handler(orderInfo.getId().toString(), PrinterHandler.PrintTypeEnum.PRE_ORDER, orderInfoPrintDTO.getMachineId());
|
||||
break;
|
||||
case 2:
|
||||
printerHandler.handler(orderInfo.getId().toString(), PrinterHandler.PrintTypeEnum.ORDER);
|
||||
printerHandler.handler(orderInfo.getId().toString(), PrinterHandler.PrintTypeEnum.ORDER, orderInfoPrintDTO.getMachineId());
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -22,10 +22,10 @@ public class OrderPaymentServiceImpl extends ServiceImpl<OrderPaymentMapper, Ord
|
||||
@Override
|
||||
public BigDecimal countMemberInAmount(Long shopId, Long shopUserId) {
|
||||
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::getPayType, PayTypeConstants.PayType.PAY)
|
||||
.eq(OrderPayment::getSourceId, 127452)
|
||||
.eq(OrderPayment::getSourceId, shopUserId)
|
||||
.eq(OrderPayment::getPayStatus, PayTypeConstants.PayStatus.SUCCESS), BigDecimal.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.czg.service.order.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.map.MapProxy;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.text.UnicodeUtil;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
@@ -12,18 +11,15 @@ import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.czg.account.entity.PrintMachine;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.market.service.OrderInfoService;
|
||||
import com.czg.order.entity.PrintMachineLog;
|
||||
import com.czg.order.service.PrintMachineLogService;
|
||||
import com.czg.service.order.mapper.PrintMachineLogMapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -38,7 +34,7 @@ import java.util.*;
|
||||
@Slf4j
|
||||
@Service
|
||||
@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";
|
||||
//APPID
|
||||
@@ -53,6 +49,10 @@ public class PrintMachineLogServiceImpl extends ServiceImpl<PrintMachineLogMappe
|
||||
public static final String USER = "chaozhanggui2022@163.com";//*必填*:账号名
|
||||
public static final String UKEY = "UfWkhXxSkeSSscsU";//*必填*: 飞鹅云后台注册账号后生成的UKEY 【备注:这不是填打印机的KEY】
|
||||
public static final String SN = "960238952";//*必填*:打印机编号,必须要在管理后台里添加打印机或调用API接口添加之后,才能调用API
|
||||
|
||||
@Resource
|
||||
private OrderInfoService orderInfoService;
|
||||
|
||||
/**
|
||||
* 获取TOKEN值
|
||||
*
|
||||
@@ -77,10 +77,10 @@ public class PrintMachineLogServiceImpl extends ServiceImpl<PrintMachineLogMappe
|
||||
System.out.println("token" + token);
|
||||
Map<String, String> finalMap = new HashMap<>();
|
||||
finalMap.put("ENCODE", encode.toString());
|
||||
System.out.println("+++++++++++++++" + token + APP_SECRET);
|
||||
finalMap.put("TOKEN", SecureUtil.md5(token + APP_SECRET).toUpperCase());
|
||||
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);
|
||||
}
|
||||
|
||||
private static String signature(String USER, String UKEY, String STIME) {
|
||||
return DigestUtils.sha1Hex(USER + UKEY + STIME);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查飞鹅打印机打印任务是否已打印
|
||||
*
|
||||
@@ -135,6 +137,7 @@ public class PrintMachineLogServiceImpl extends ServiceImpl<PrintMachineLogMappe
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查飞鹅打印机是否在线
|
||||
*
|
||||
@@ -161,6 +164,7 @@ public class PrintMachineLogServiceImpl extends ServiceImpl<PrintMachineLogMappe
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存打印记录
|
||||
*
|
||||
@@ -170,6 +174,7 @@ public class PrintMachineLogServiceImpl extends ServiceImpl<PrintMachineLogMappe
|
||||
* @param respJson 打印机响应结果
|
||||
*/
|
||||
@Async
|
||||
@Override
|
||||
public void save(PrintMachine config, String bizType, String printContent, Object respJson) {
|
||||
if (config == null) {
|
||||
return;
|
||||
@@ -266,7 +271,6 @@ public class PrintMachineLogServiceImpl extends ServiceImpl<PrintMachineLogMappe
|
||||
entity.setPrintTime(null);
|
||||
entity.setRespMsg(StrUtil.concat(true, "打印失败,", "_", entity.getRespMsg()));
|
||||
}
|
||||
super.updateById(entity);
|
||||
}
|
||||
// 飞鹅云打印机
|
||||
} else if ("飞鹅".equals(config.getContentType())) {
|
||||
@@ -291,8 +295,7 @@ public class PrintMachineLogServiceImpl extends ServiceImpl<PrintMachineLogMappe
|
||||
entity.setRespMsg(StrUtil.concat(true, "打印失败,", "_", msg));
|
||||
}
|
||||
}
|
||||
}
|
||||
super.updateById(entity);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -153,6 +153,10 @@
|
||||
<foreach item="item" collection="idList" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
or t1.sync_id in
|
||||
<foreach item="item" collection="idList" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
order by t1.sort desc,t1.id desc
|
||||
</select>
|
||||
|
||||
Reference in New Issue
Block a user