order服务拆分

This commit is contained in:
2025-11-26 16:49:02 +08:00
parent 6c4458113e
commit a7dbe0e251
25 changed files with 305 additions and 846 deletions

View File

@@ -31,7 +31,7 @@ dubbo:
qos-enable: true
registry:
address: nacos://121.40.109.122:8848 # Nacos 服务地址
group: server-zs
group: server-dev
protocol:
threads: 20
name: dubbo

View File

@@ -4,12 +4,9 @@ import cn.hutool.core.date.DateUtil;
import com.czg.account.entity.ShopUser;
import com.czg.account.service.ShopUserService;
import com.czg.constant.TableValueConstant;
import com.czg.market.service.OrderInfoService;
import com.czg.market.service.TbMemberConfigService;
import com.czg.order.entity.OrderInfo;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.scheduling.annotation.Scheduled;
@@ -27,8 +24,6 @@ import java.util.List;
@Slf4j
@Component
public class MemberTask {
@Resource
private OrderInfoService orderInfoService;
@DubboReference
private ShopUserService shopUserService;

View File

@@ -5,7 +5,7 @@ import com.czg.market.entity.MkShopCouponRecord;
import com.czg.market.service.AcPushEventService;
import com.czg.market.service.MkShopCouponRecordService;
import com.czg.market.service.SmsPushEventService;
import com.czg.service.order.service.impl.OrderInfoCustomServiceImpl;
import com.czg.order.service.OrderInfoCustomService;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
@@ -31,7 +31,7 @@ public class RedisKeyExpirationListener implements MessageListener {
@Value("${spring.data.redis.database}")
private String database;
@Resource
private OrderInfoCustomServiceImpl orderInfoService;
private OrderInfoCustomService orderInfoCustomService;
@DubboReference
private ShopTableService tableService;
@Resource
@@ -60,7 +60,7 @@ public class RedisKeyExpirationListener implements MessageListener {
if (expiredKey.startsWith(RedisCst.classKeyExpired.EXPIRED_ORDER)) {
log.info("监听到订单过期,订单Id: {}", expiredKey);
String orderId = expiredKey.substring(RedisCst.classKeyExpired.EXPIRED_ORDER.length());
orderInfoService.expired(Long.parseLong(orderId));
orderInfoCustomService.expired(Long.parseLong(orderId));
} else if (expiredKey.startsWith(RedisCst.classKeyExpired.EXPIRED_TABLE)) {
log.info("监听到台桌清台过期,台桌Id: {}", expiredKey);
String tableId = expiredKey.substring(RedisCst.classKeyExpired.EXPIRED_TABLE.length());

View File

@@ -8,11 +8,12 @@ import com.czg.entity.CzgBaseRespParams;
import com.czg.market.entity.MkShopConsumeDiscountRecord;
import com.czg.market.service.MkDistributionUserService;
import com.czg.market.service.MkShopConsumeDiscountRecordService;
import com.czg.market.service.OrderInfoService;
import com.czg.order.entity.OrderInfo;
import com.czg.order.entity.OrderPayment;
import com.czg.order.service.OrderInfoCustomService;
import com.czg.order.service.OrderPaymentService;
import com.czg.service.market.service.impl.AppWxServiceImpl;
import com.czg.service.order.service.impl.OrderInfoCustomServiceImpl;
import com.czg.utils.AssertUtil;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
@@ -37,8 +38,9 @@ public class NotifyController {
private static final String SUCCESS = "SUCCESS";
@Resource
private OrderInfoCustomServiceImpl orderInfoService;
private OrderInfoCustomService orderInfoCustomService;
@Resource
private OrderInfoService orderInfoService;
@Resource
private AppWxServiceImpl wxService;
@Resource
@@ -61,7 +63,7 @@ public class NotifyController {
JSONObject czg = CzgPayUtils.getCzg(respParams);
AssertUtil.isNull(czg, "支付回调数据为空");
log.info("支付回调数据为:{}", czg);
orderInfoService.payCallBackOrder(czg.getString("mchOrderNo"), czg, 0);
orderInfoCustomService.payCallBackOrder(czg.getString("mchOrderNo"), czg, 0);
return SUCCESS;
}
@@ -127,7 +129,7 @@ public class NotifyController {
JSONObject czg = CzgPayUtils.getCzg(respParams);
AssertUtil.isNull(czg, "退款回调数据为空");
log.info("退款回调数据为:{}", czg);
orderInfoService.refundCallBackOrder(czg.getString("mchOrderNo"), czg);
orderInfoCustomService.refundCallBackOrder(czg.getString("mchOrderNo"), czg);
return SUCCESS;
}
}

View File

@@ -3,13 +3,13 @@ package com.czg.controller;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.URLUtil;
import com.czg.annotation.Debounce;
import com.czg.market.service.OrderInfoService;
import com.czg.order.dto.CheckOrderPay;
import com.czg.order.entity.OrderInfo;
import com.czg.order.service.OrderInfoCustomService;
import com.czg.resp.CzgResult;
import com.czg.service.order.dto.OrderPayParamDTO;
import com.czg.service.order.service.PayService;
import com.czg.service.order.service.impl.OrderInfoCustomServiceImpl;
import com.czg.system.enums.SysParamCodeEnum;
import com.czg.system.service.SysParamsService;
import com.czg.utils.AssertUtil;
@@ -37,7 +37,9 @@ public class OrderPayController {
@Resource
private PayService payService;
@Resource
private OrderInfoCustomServiceImpl orderInfoService;
private OrderInfoCustomService orderInfoCustomService;
@Resource
private OrderInfoService orderInfoService;
@DubboReference
private SysParamsService paramsService;
@@ -155,7 +157,7 @@ public class OrderPayController {
map.put("payAmount", checkOrderPay.getOrderAmount());
map.put("extend", StrUtil.isEmpty(checkOrderPay.getExtend()) ? "" : checkOrderPay.getExtend());
if (checkOrderPay.getOrderId() != null) {
OrderInfo orderInfo = orderInfoService.checkOrderPay(checkOrderPay);
OrderInfo orderInfo = orderInfoCustomService.checkOrderPay(checkOrderPay);
map.put("payAmount", orderInfo.getOrderAmount());
}
String baseUrl = paramsService.getSysParamValue(SysParamCodeEnum.SHOP_ORDER_PAY_BASE_URL.getCode());

View File

@@ -2,9 +2,12 @@ package com.czg.controller.admin;
import com.czg.log.annotation.OperationLog;
import com.czg.order.dto.CreditBuyerOrderDTO;
import com.czg.order.dto.CreditPaymentRecordDTO;
import com.czg.order.entity.CreditPaymentRecord;
import com.czg.order.param.CreditBuyerOrderQueryParam;
import com.czg.order.param.CreditPaymentRecordQueryParam;
import com.czg.order.service.CreditBuyerOrderService;
import com.czg.order.service.CreditPaymentRecordService;
import com.czg.order.vo.CreditBuyerOrderSummaryVo;
import com.czg.resp.CzgResult;
import com.mybatisflex.core.paginate.Page;
@@ -20,14 +23,15 @@ import org.springframework.web.bind.annotation.*;
*/
@AllArgsConstructor
@RestController
@RequestMapping("/admin/order/credit/buyerOrder")
@RequestMapping("/admin/order/credit")
public class CreditBuyerOrderController {
private final CreditBuyerOrderService creditBuyerOrderService;
private final CreditPaymentRecordService creditPaymentRecordService;
/**
* 分页
*/
@GetMapping("page")
@GetMapping("/buyerOrder/page")
@OperationLog("挂账账单-分页")
//@SaAdminCheckPermission("creditBuyerOrder:page")
public CzgResult<Page<CreditBuyerOrderDTO>> getCreditBuyerOrderPage(CreditBuyerOrderQueryParam param) {
@@ -38,7 +42,7 @@ public class CreditBuyerOrderController {
/**
* 付款
*/
@PostMapping("pay")
@PostMapping("/buyerOrder/pay")
@OperationLog("挂账账单-付款")
//@SaAdminCheckPermission("creditBuyerOrder:pay")
public CzgResult<Void> pay(@RequestBody CreditPaymentRecord record) {
@@ -49,7 +53,7 @@ public class CreditBuyerOrderController {
/**
* 统计
*/
@GetMapping("summary")
@GetMapping("/buyerOrder/summary")
@OperationLog("挂账账单-统计")
//@SaAdminCheckPermission("creditBuyerOrder:summary")
public CzgResult<CreditBuyerOrderSummaryVo> summary(CreditBuyerOrderQueryParam param) {
@@ -57,4 +61,15 @@ public class CreditBuyerOrderController {
return CzgResult.success(data);
}
/**
* 挂账账单付款记录分页
*/
@GetMapping("/paymentRecord/page")
@OperationLog("挂账账单付款记录-分页")
//@SaAdminCheckPermission("creditPaymentRecord:page")
public CzgResult<Page<CreditPaymentRecordDTO>> getCreditPaymentRecordPage(CreditPaymentRecordQueryParam param) {
Page<CreditPaymentRecordDTO> data = creditPaymentRecordService.getCreditPaymentRecordPage(param);
return CzgResult.success(data);
}
}

View File

@@ -1,38 +0,0 @@
package com.czg.controller.admin;
import com.czg.log.annotation.OperationLog;
import com.czg.order.dto.CreditPaymentRecordDTO;
import com.czg.order.param.CreditPaymentRecordQueryParam;
import com.czg.order.service.CreditPaymentRecordService;
import com.czg.resp.CzgResult;
import com.mybatisflex.core.paginate.Page;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 挂账账单付款记录
*
* @author Tankaikai tankaikai@aliyun.com
* @since 1.0 2025-03-04
*/
@AllArgsConstructor
@RestController
@RequestMapping("/admin/order/credit/paymentRecord")
public class CreditPaymentRecordController {
private final CreditPaymentRecordService creditPaymentRecordService;
/**
* 分页
*/
@GetMapping("page")
@OperationLog("挂账账单付款记录-分页")
//@SaAdminCheckPermission("creditPaymentRecord:page")
public CzgResult<Page<CreditPaymentRecordDTO>> getCreditPaymentRecordPage(CreditPaymentRecordQueryParam param) {
Page<CreditPaymentRecordDTO> data = creditPaymentRecordService.getCreditPaymentRecordPage(param);
return CzgResult.success(data);
}
}

View File

@@ -1,7 +1,6 @@
package com.czg.controller.admin;
import com.czg.annotation.SaAdminCheckPermission;
import com.czg.log.annotation.OperationLog;
import com.czg.order.entity.ShopOrderStatistic;
import com.czg.order.entity.ShopProdStatistic;
import com.czg.order.param.DataSummaryTradeParam;
@@ -46,7 +45,6 @@ public class DataSummaryController {
* 营业板块-上半部分
*/
@GetMapping("trade")
@OperationLog("营业板块-上半部分")
@SaAdminCheckPermission(value = "dataSummary:trade", name = "营业板块-上半部分")
public CzgResult<ShopOrderStatistic> getTradeData(@Validated DataSummaryTradeParam param) {
Boolean hasKey = redisService.hasKey("task:statistic:date:");
@@ -65,7 +63,6 @@ public class DataSummaryController {
* 商品销售 右下
*/
@GetMapping("productSaleDate")
@OperationLog("商品销售-右下")
@SaAdminCheckPermission(value = "dataSummary:productSaleData", name = "商品销售-右下")
public CzgResult<List<ShopProdStatistic>> getProductSaleData(@RequestParam Integer day) {
Long shopId = StpKit.USER.getShopId();
@@ -80,7 +77,6 @@ public class DataSummaryController {
* @param shopId 店铺id
*/
@GetMapping("dateAmount")
@OperationLog("销售趋势柱状图 左下")
@SaAdminCheckPermission(value = "dataSummary:dateAmount", name = "销售趋势柱状图 左下")
public CzgResult<List<TotalVo>> getDateAmount(@RequestParam Integer day, @RequestParam(required = false) Long shopId) {
AssertUtil.isNull(day, "天数不能为空");
@@ -98,7 +94,6 @@ public class DataSummaryController {
* @param shopId 店铺id
*/
@GetMapping("datePayType")
@OperationLog("支付占比饼图 左下")
@SaAdminCheckPermission(value = "dataSummary:datePayType", name = "支付占比饼图 左下2")
public CzgResult<List<CountPayTypeVo>> shopSummaryPayType(@RequestParam Integer day, @RequestParam(required = false) Long shopId) {
if (shopId == null) {

View File

@@ -3,18 +3,19 @@ package com.czg.controller.user;
import com.czg.annotation.Debounce;
import com.czg.exception.CzgException;
import com.czg.market.dto.MemberOrderDTO;
import com.czg.market.entity.MemberOrder;
import com.czg.market.service.MemberOrderService;
import com.czg.market.service.OrderInfoService;
import com.czg.order.dto.OrderCannelDTO;
import com.czg.order.dto.OrderInfoAddDTO;
import com.czg.order.dto.OrderInfoQueryDTO;
import com.czg.market.entity.MemberOrder;
import com.czg.order.entity.OrderInfo;
import com.czg.market.service.MemberOrderService;
import com.czg.order.service.OrderInfoCustomService;
import com.czg.order.vo.HistoryOrderVo;
import com.czg.order.vo.OrderInfoVo;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import com.czg.service.order.enums.OrderStatusEnums;
import com.czg.service.order.service.impl.OrderInfoCustomServiceImpl;
import com.czg.utils.AssertUtil;
import com.czg.utils.ServletUtil;
import com.mybatisflex.core.paginate.Page;
@@ -36,8 +37,9 @@ import org.springframework.web.bind.annotation.*;
public class UserOrderController {
@Resource
private OrderInfoCustomServiceImpl orderInfoService;
private OrderInfoCustomService orderInfoCustomService;
@Resource
private OrderInfoService orderInfoService;
@Resource
private MemberOrderService memberOrderService;
/**
@@ -47,19 +49,19 @@ public class UserOrderController {
public CzgResult<Page<OrderInfoVo>> getOrderPage(OrderInfoQueryDTO queryDTO) {
queryDTO.setIsDel(0);
queryDTO.setUserId(StpKit.USER.getLoginIdAsLong());
return CzgResult.success(orderInfoService.getOrderByPage(queryDTO));
return CzgResult.success(orderInfoCustomService.getOrderByPage(queryDTO));
}
@GetMapping("/getOrderById")
public CzgResult<HistoryOrderVo> getOrderById(Long orderId) {
return orderInfoService.getOrderDetails(orderId);
return orderInfoCustomService.getOrderDetails(orderId);
}
@GetMapping("/historyOrder")
public CzgResult<HistoryOrderVo> historyOrder(
@RequestParam(required = false) Long orderId,
@RequestParam(required = false) String tableCode) {
return CzgResult.success(orderInfoService.historyOrder(orderId, tableCode));
return CzgResult.success(orderInfoCustomService.historyOrder(orderId, tableCode));
}
/**
@@ -72,7 +74,7 @@ public class UserOrderController {
// addDto.setUserId(StpKit.USER.getLoginIdAsLong());
addDto.setShopId(StpKit.USER.getShopId());
addDto.setOrderType("miniapp");
return CzgResult.success(orderInfoService.createOrder(addDto));
return CzgResult.success(orderInfoCustomService.createOrder(addDto));
}
/**
@@ -98,17 +100,14 @@ public class UserOrderController {
if (orderInfo.getStatus().equals(OrderStatusEnums.UNPAID.getCode())) {
throw new CzgException("待支付订单不可删除");
}
orderInfoService.updateChain()
.set(OrderInfo::getIsDel, 1)
.eq(OrderInfo::getId, id)
.update();
orderInfoService.updateById(new OrderInfo().setIsDel(1).setId(id));
return CzgResult.success();
}
@PostMapping("/cancelOrder")
@Debounce(value = "#param.orderId")
public CzgResult<Void> cancelOrder(@Validated @RequestBody OrderCannelDTO param) {
orderInfoService.cancelledOrder(param.getShopId(), param.getOrderId());
orderInfoCustomService.cancelledOrder(param.getShopId(), param.getOrderId());
return CzgResult.success();
}
@@ -116,7 +115,7 @@ public class UserOrderController {
@Debounce(value = "#param.orderId")
public CzgResult<Void> cancelledPlaceOrder(@Validated @RequestBody OrderCannelDTO param) {
AssertUtil.isNull(param.getPlaceNum(), "{}不能为空", "取消单次");
orderInfoService.cancelledPlaceOrder(param.getShopId(), param.getOrderId(), param.getPlaceNum());
orderInfoCustomService.cancelledPlaceOrder(param.getShopId(), param.getOrderId(), param.getPlaceNum());
return CzgResult.success();
}
}

View File

@@ -5,12 +5,10 @@ import cn.hutool.core.exceptions.ExceptionUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.czg.config.RabbitConstants;
import com.czg.market.service.OrderInfoService;
import com.czg.order.entity.MqLog;
import com.czg.order.service.MqLogService;
import com.czg.order.service.OrderInfoCustomService;
import com.czg.order.service.OrderInfoRpcService;
import com.czg.service.order.service.impl.OrderInfoCustomServiceImpl;
import com.czg.service.order.utils.FunUtil;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
@@ -31,7 +29,7 @@ public class OrderMqListener {
@Resource
private MqLogService mqLogService;
@Resource
private OrderInfoCustomServiceImpl orderInfoService;
private OrderInfoCustomService orderInfoCustomService;
@Resource
private FunUtil funUtil;
@@ -47,7 +45,7 @@ public class OrderMqListener {
log.info("接收到修改菜品状态mq, info: {}", info);
String finalInfo = info;
funUtil.debounce("UP_ORDER_DETAIL:" + info, 5, () -> {
orderInfoService.updateOrderDetailStatus(Long.valueOf(finalInfo));
orderInfoCustomService.updateOrderDetailStatus(Long.valueOf(finalInfo));
});
info = info.replace("UP_ORDER_DETAIL:", "");

View File

@@ -1,9 +1,9 @@
package com.czg.task;
import cn.hutool.core.date.DateUtil;
import com.czg.market.service.OrderInfoService;
import com.czg.order.entity.OrderInfo;
import com.czg.service.order.enums.OrderStatusEnums;
import com.czg.service.order.service.impl.OrderInfoCustomServiceImpl;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
@@ -20,7 +20,7 @@ import org.springframework.stereotype.Component;
@Component
public class OTimeTask {
@Resource
private OrderInfoCustomServiceImpl orderInfoService;
private OrderInfoService orderInfoService;
/**
* order 过期

View File

@@ -39,7 +39,7 @@ dubbo:
qos-enable: true
registry:
address: nacos://121.40.109.122:8848 # Nacos 服务地址
group: server-zs
group: server-dev
protocol:
port: 10401
threads: 20