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 qos-enable: true
registry: registry:
address: nacos://121.40.109.122:8848 # Nacos 服务地址 address: nacos://121.40.109.122:8848 # Nacos 服务地址
group: server-zs group: server-dev
protocol: protocol:
threads: 20 threads: 20
name: dubbo name: dubbo

View File

@@ -4,12 +4,9 @@ import cn.hutool.core.date.DateUtil;
import com.czg.account.entity.ShopUser; import com.czg.account.entity.ShopUser;
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.market.service.OrderInfoService;
import com.czg.market.service.TbMemberConfigService; import com.czg.market.service.TbMemberConfigService;
import com.czg.order.entity.OrderInfo;
import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.Data;
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.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
@@ -27,8 +24,6 @@ import java.util.List;
@Slf4j @Slf4j
@Component @Component
public class MemberTask { public class MemberTask {
@Resource
private OrderInfoService orderInfoService;
@DubboReference @DubboReference
private ShopUserService shopUserService; 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.AcPushEventService;
import com.czg.market.service.MkShopCouponRecordService; import com.czg.market.service.MkShopCouponRecordService;
import com.czg.market.service.SmsPushEventService; 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 com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -31,7 +31,7 @@ public class RedisKeyExpirationListener implements MessageListener {
@Value("${spring.data.redis.database}") @Value("${spring.data.redis.database}")
private String database; private String database;
@Resource @Resource
private OrderInfoCustomServiceImpl orderInfoService; private OrderInfoCustomService orderInfoCustomService;
@DubboReference @DubboReference
private ShopTableService tableService; private ShopTableService tableService;
@Resource @Resource
@@ -60,7 +60,7 @@ public class RedisKeyExpirationListener implements MessageListener {
if (expiredKey.startsWith(RedisCst.classKeyExpired.EXPIRED_ORDER)) { if (expiredKey.startsWith(RedisCst.classKeyExpired.EXPIRED_ORDER)) {
log.info("监听到订单过期,订单Id: {}", expiredKey); log.info("监听到订单过期,订单Id: {}", expiredKey);
String orderId = expiredKey.substring(RedisCst.classKeyExpired.EXPIRED_ORDER.length()); 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)) { } else if (expiredKey.startsWith(RedisCst.classKeyExpired.EXPIRED_TABLE)) {
log.info("监听到台桌清台过期,台桌Id: {}", expiredKey); log.info("监听到台桌清台过期,台桌Id: {}", expiredKey);
String tableId = expiredKey.substring(RedisCst.classKeyExpired.EXPIRED_TABLE.length()); 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.entity.MkShopConsumeDiscountRecord;
import com.czg.market.service.MkDistributionUserService; import com.czg.market.service.MkDistributionUserService;
import com.czg.market.service.MkShopConsumeDiscountRecordService; import com.czg.market.service.MkShopConsumeDiscountRecordService;
import com.czg.market.service.OrderInfoService;
import com.czg.order.entity.OrderInfo; import com.czg.order.entity.OrderInfo;
import com.czg.order.entity.OrderPayment; import com.czg.order.entity.OrderPayment;
import com.czg.order.service.OrderInfoCustomService;
import com.czg.order.service.OrderPaymentService; import com.czg.order.service.OrderPaymentService;
import com.czg.service.market.service.impl.AppWxServiceImpl; import com.czg.service.market.service.impl.AppWxServiceImpl;
import com.czg.service.order.service.impl.OrderInfoCustomServiceImpl;
import com.czg.utils.AssertUtil; import com.czg.utils.AssertUtil;
import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
@@ -37,8 +38,9 @@ public class NotifyController {
private static final String SUCCESS = "SUCCESS"; private static final String SUCCESS = "SUCCESS";
@Resource @Resource
private OrderInfoCustomServiceImpl orderInfoService; private OrderInfoCustomService orderInfoCustomService;
@Resource
private OrderInfoService orderInfoService;
@Resource @Resource
private AppWxServiceImpl wxService; private AppWxServiceImpl wxService;
@Resource @Resource
@@ -61,7 +63,7 @@ public class NotifyController {
JSONObject czg = CzgPayUtils.getCzg(respParams); JSONObject czg = CzgPayUtils.getCzg(respParams);
AssertUtil.isNull(czg, "支付回调数据为空"); AssertUtil.isNull(czg, "支付回调数据为空");
log.info("支付回调数据为:{}", czg); log.info("支付回调数据为:{}", czg);
orderInfoService.payCallBackOrder(czg.getString("mchOrderNo"), czg, 0); orderInfoCustomService.payCallBackOrder(czg.getString("mchOrderNo"), czg, 0);
return SUCCESS; return SUCCESS;
} }
@@ -127,7 +129,7 @@ public class NotifyController {
JSONObject czg = CzgPayUtils.getCzg(respParams); JSONObject czg = CzgPayUtils.getCzg(respParams);
AssertUtil.isNull(czg, "退款回调数据为空"); AssertUtil.isNull(czg, "退款回调数据为空");
log.info("退款回调数据为:{}", czg); log.info("退款回调数据为:{}", czg);
orderInfoService.refundCallBackOrder(czg.getString("mchOrderNo"), czg); orderInfoCustomService.refundCallBackOrder(czg.getString("mchOrderNo"), czg);
return SUCCESS; return SUCCESS;
} }
} }

View File

@@ -3,13 +3,13 @@ package com.czg.controller;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.URLUtil; import cn.hutool.core.util.URLUtil;
import com.czg.annotation.Debounce; import com.czg.annotation.Debounce;
import com.czg.market.service.OrderInfoService;
import com.czg.order.dto.CheckOrderPay; import com.czg.order.dto.CheckOrderPay;
import com.czg.order.entity.OrderInfo; import com.czg.order.entity.OrderInfo;
import com.czg.order.service.OrderInfoCustomService; import com.czg.order.service.OrderInfoCustomService;
import com.czg.resp.CzgResult; import com.czg.resp.CzgResult;
import com.czg.service.order.dto.OrderPayParamDTO; import com.czg.service.order.dto.OrderPayParamDTO;
import com.czg.service.order.service.PayService; 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.enums.SysParamCodeEnum;
import com.czg.system.service.SysParamsService; import com.czg.system.service.SysParamsService;
import com.czg.utils.AssertUtil; import com.czg.utils.AssertUtil;
@@ -37,7 +37,9 @@ public class OrderPayController {
@Resource @Resource
private PayService payService; private PayService payService;
@Resource @Resource
private OrderInfoCustomServiceImpl orderInfoService; private OrderInfoCustomService orderInfoCustomService;
@Resource
private OrderInfoService orderInfoService;
@DubboReference @DubboReference
private SysParamsService paramsService; private SysParamsService paramsService;
@@ -155,7 +157,7 @@ public class OrderPayController {
map.put("payAmount", checkOrderPay.getOrderAmount()); map.put("payAmount", checkOrderPay.getOrderAmount());
map.put("extend", StrUtil.isEmpty(checkOrderPay.getExtend()) ? "" : checkOrderPay.getExtend()); map.put("extend", StrUtil.isEmpty(checkOrderPay.getExtend()) ? "" : checkOrderPay.getExtend());
if (checkOrderPay.getOrderId() != null) { if (checkOrderPay.getOrderId() != null) {
OrderInfo orderInfo = orderInfoService.checkOrderPay(checkOrderPay); OrderInfo orderInfo = orderInfoCustomService.checkOrderPay(checkOrderPay);
map.put("payAmount", orderInfo.getOrderAmount()); map.put("payAmount", orderInfo.getOrderAmount());
} }
String baseUrl = paramsService.getSysParamValue(SysParamCodeEnum.SHOP_ORDER_PAY_BASE_URL.getCode()); 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.log.annotation.OperationLog;
import com.czg.order.dto.CreditBuyerOrderDTO; import com.czg.order.dto.CreditBuyerOrderDTO;
import com.czg.order.dto.CreditPaymentRecordDTO;
import com.czg.order.entity.CreditPaymentRecord; import com.czg.order.entity.CreditPaymentRecord;
import com.czg.order.param.CreditBuyerOrderQueryParam; import com.czg.order.param.CreditBuyerOrderQueryParam;
import com.czg.order.param.CreditPaymentRecordQueryParam;
import com.czg.order.service.CreditBuyerOrderService; import com.czg.order.service.CreditBuyerOrderService;
import com.czg.order.service.CreditPaymentRecordService;
import com.czg.order.vo.CreditBuyerOrderSummaryVo; import com.czg.order.vo.CreditBuyerOrderSummaryVo;
import com.czg.resp.CzgResult; import com.czg.resp.CzgResult;
import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.paginate.Page;
@@ -20,14 +23,15 @@ import org.springframework.web.bind.annotation.*;
*/ */
@AllArgsConstructor @AllArgsConstructor
@RestController @RestController
@RequestMapping("/admin/order/credit/buyerOrder") @RequestMapping("/admin/order/credit")
public class CreditBuyerOrderController { public class CreditBuyerOrderController {
private final CreditBuyerOrderService creditBuyerOrderService; private final CreditBuyerOrderService creditBuyerOrderService;
private final CreditPaymentRecordService creditPaymentRecordService;
/** /**
* 分页 * 分页
*/ */
@GetMapping("page") @GetMapping("/buyerOrder/page")
@OperationLog("挂账账单-分页") @OperationLog("挂账账单-分页")
//@SaAdminCheckPermission("creditBuyerOrder:page") //@SaAdminCheckPermission("creditBuyerOrder:page")
public CzgResult<Page<CreditBuyerOrderDTO>> getCreditBuyerOrderPage(CreditBuyerOrderQueryParam param) { public CzgResult<Page<CreditBuyerOrderDTO>> getCreditBuyerOrderPage(CreditBuyerOrderQueryParam param) {
@@ -38,7 +42,7 @@ public class CreditBuyerOrderController {
/** /**
* 付款 * 付款
*/ */
@PostMapping("pay") @PostMapping("/buyerOrder/pay")
@OperationLog("挂账账单-付款") @OperationLog("挂账账单-付款")
//@SaAdminCheckPermission("creditBuyerOrder:pay") //@SaAdminCheckPermission("creditBuyerOrder:pay")
public CzgResult<Void> pay(@RequestBody CreditPaymentRecord record) { public CzgResult<Void> pay(@RequestBody CreditPaymentRecord record) {
@@ -49,7 +53,7 @@ public class CreditBuyerOrderController {
/** /**
* 统计 * 统计
*/ */
@GetMapping("summary") @GetMapping("/buyerOrder/summary")
@OperationLog("挂账账单-统计") @OperationLog("挂账账单-统计")
//@SaAdminCheckPermission("creditBuyerOrder:summary") //@SaAdminCheckPermission("creditBuyerOrder:summary")
public CzgResult<CreditBuyerOrderSummaryVo> summary(CreditBuyerOrderQueryParam param) { public CzgResult<CreditBuyerOrderSummaryVo> summary(CreditBuyerOrderQueryParam param) {
@@ -57,4 +61,15 @@ public class CreditBuyerOrderController {
return CzgResult.success(data); 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; package com.czg.controller.admin;
import com.czg.annotation.SaAdminCheckPermission; import com.czg.annotation.SaAdminCheckPermission;
import com.czg.log.annotation.OperationLog;
import com.czg.order.entity.ShopOrderStatistic; import com.czg.order.entity.ShopOrderStatistic;
import com.czg.order.entity.ShopProdStatistic; import com.czg.order.entity.ShopProdStatistic;
import com.czg.order.param.DataSummaryTradeParam; import com.czg.order.param.DataSummaryTradeParam;
@@ -46,7 +45,6 @@ public class DataSummaryController {
* 营业板块-上半部分 * 营业板块-上半部分
*/ */
@GetMapping("trade") @GetMapping("trade")
@OperationLog("营业板块-上半部分")
@SaAdminCheckPermission(value = "dataSummary:trade", name = "营业板块-上半部分") @SaAdminCheckPermission(value = "dataSummary:trade", name = "营业板块-上半部分")
public CzgResult<ShopOrderStatistic> getTradeData(@Validated DataSummaryTradeParam param) { public CzgResult<ShopOrderStatistic> getTradeData(@Validated DataSummaryTradeParam param) {
Boolean hasKey = redisService.hasKey("task:statistic:date:"); Boolean hasKey = redisService.hasKey("task:statistic:date:");
@@ -65,7 +63,6 @@ public class DataSummaryController {
* 商品销售 右下 * 商品销售 右下
*/ */
@GetMapping("productSaleDate") @GetMapping("productSaleDate")
@OperationLog("商品销售-右下")
@SaAdminCheckPermission(value = "dataSummary:productSaleData", name = "商品销售-右下") @SaAdminCheckPermission(value = "dataSummary:productSaleData", name = "商品销售-右下")
public CzgResult<List<ShopProdStatistic>> getProductSaleData(@RequestParam Integer day) { public CzgResult<List<ShopProdStatistic>> getProductSaleData(@RequestParam Integer day) {
Long shopId = StpKit.USER.getShopId(); Long shopId = StpKit.USER.getShopId();
@@ -80,7 +77,6 @@ public class DataSummaryController {
* @param shopId 店铺id * @param shopId 店铺id
*/ */
@GetMapping("dateAmount") @GetMapping("dateAmount")
@OperationLog("销售趋势柱状图 左下")
@SaAdminCheckPermission(value = "dataSummary:dateAmount", name = "销售趋势柱状图 左下") @SaAdminCheckPermission(value = "dataSummary:dateAmount", name = "销售趋势柱状图 左下")
public CzgResult<List<TotalVo>> getDateAmount(@RequestParam Integer day, @RequestParam(required = false) Long shopId) { public CzgResult<List<TotalVo>> getDateAmount(@RequestParam Integer day, @RequestParam(required = false) Long shopId) {
AssertUtil.isNull(day, "天数不能为空"); AssertUtil.isNull(day, "天数不能为空");
@@ -98,7 +94,6 @@ public class DataSummaryController {
* @param shopId 店铺id * @param shopId 店铺id
*/ */
@GetMapping("datePayType") @GetMapping("datePayType")
@OperationLog("支付占比饼图 左下")
@SaAdminCheckPermission(value = "dataSummary:datePayType", name = "支付占比饼图 左下2") @SaAdminCheckPermission(value = "dataSummary:datePayType", name = "支付占比饼图 左下2")
public CzgResult<List<CountPayTypeVo>> shopSummaryPayType(@RequestParam Integer day, @RequestParam(required = false) Long shopId) { public CzgResult<List<CountPayTypeVo>> shopSummaryPayType(@RequestParam Integer day, @RequestParam(required = false) Long shopId) {
if (shopId == null) { if (shopId == null) {

View File

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

View File

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

View File

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

View File

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

View File

@@ -21,7 +21,6 @@ import java.time.LocalDateTime;
* @since 2025-02-14 * @since 2025-02-14
*/ */
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@Table("tb_order_detail") @Table("tb_order_detail")
@@ -131,6 +130,9 @@ public class OrderDetail implements Serializable {
* 状态: in-production 制作中;wait_out 待取餐;refunding 退款中; part_refund 部分退单; refund-退单; done 完成; * 状态: in-production 制作中;wait_out 待取餐;refunding 退款中; part_refund 部分退单; refund-退单; done 完成;
*/ */
private String status; private String status;
/**
* 菜品状态:待起菜 PENDING_PREP 待出菜 READY_TO_SERVE 已出菜 SENT_OUT 已上菜 DELIVERED
*/
private String subStatus; private String subStatus;
/** /**
@@ -176,6 +178,22 @@ public class OrderDetail implements Serializable {
@Column(onInsertValue = "now()", onUpdateValue = "now()") @Column(onInsertValue = "now()", onUpdateValue = "now()")
private LocalDateTime updateTime; private LocalDateTime updateTime;
/**
* 下单时间 为订单支付成功时间
*/
private LocalDateTime orderTime;
/**
* 起菜时间
*/
private LocalDateTime startOrderTime;
/**
* 出菜时间
*/
private LocalDateTime dishOutTime;
/**
* 上菜时间
*/
private LocalDateTime foodServeTime;
/** /**
* 是否赠送 0否 1是 * 是否赠送 0否 1是

View File

@@ -16,6 +16,7 @@ import java.io.Serial;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
/** /**
* 订单表 实体类。 * 订单表 实体类。
@@ -27,6 +28,7 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@Table("tb_order_info") @Table("tb_order_info")
@Accessors(chain = true)
public class OrderInfo implements Serializable { public class OrderInfo implements Serializable {
@Serial @Serial

View File

@@ -18,6 +18,6 @@ public interface OrderDetailService extends IService<OrderDetail> {
List<OrderDetailPrintVo> getOrderDetailPrint(Long orderId); List<OrderDetailPrintVo> getOrderDetailPrint(Long orderId);
// 更新订单详情状态 将订单详情的状态为wait-pay 更新为 payed // 更新订单详情状态 将订单详情的状态为wait-pay 更新为 done
void updateOrderDetailStatus(Long orderId,String status); void updateOrderDetailStatus(Long orderId,String status);
} }

View File

@@ -1,52 +0,0 @@
package com.czg.order.vo;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 数据汇总-商品销量排名
* @author tankaikai
* @since 2025-03-07 15:50
*/
@NoArgsConstructor
@Data
public class DataSummaryProductSaleRankingVo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 商品名称
*/
private Long productId;
/**
* 商品名称
*/
private String productName;
/**
* 数量
*/
private BigDecimal number;
/**
* 金额
*/
private BigDecimal amount;
/**
* 退单量
*/
private BigDecimal refundCount;
/**
* 退单金额
*/
private BigDecimal refundAmount;
}

View File

@@ -1,173 +0,0 @@
package com.czg.order.vo;
import com.mybatisflex.core.paginate.Page;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
/**
* 数据汇总-商品销售
* @author tankaikai
* @since 2025-03-07 15:50
*/
@NoArgsConstructor
@Data
public class DataSummaryProductSaleVo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* productSum
*/
private ProductSumVo productSum = new ProductSumVo();
/**
* countList
*/
private List<CountListVo> countList = new ArrayList<>();
/**
* productCount
*/
private ProductCountVo productCount = new ProductCountVo();
/**
* productList
*/
private Page<ContentVo> productList = new Page<ContentVo>(new ArrayList<ContentVo>(), 1, 10, 0);
/**
* ProductSumVo
*/
@NoArgsConstructor
@Data
public static class ProductSumVo {
/**
* icon
*/
private String icon;
/**
* isAmount
*/
private String isAmount;
/**
* payAmount
*/
private BigDecimal payAmount;
/**
* payType
*/
private String payType;
/**
* saveAmount
*/
private BigDecimal saveAmount;
}
/**
* ProductCountVo
*/
@NoArgsConstructor
@Data
public static class ProductCountVo {
/**
* icon
*/
private String icon;
/**
* isAmount
*/
private String isAmount;
/**
* payAmount
*/
private BigDecimal payAmount;
/**
* payType
*/
private String payType;
/**
* saveAmount
*/
private BigDecimal saveAmount;
}
/**
* ContentVo
*/
@NoArgsConstructor
@Data
public static class ContentVo {
/**
* cateName
*/
private String cateName;
/**
* num
*/
private BigDecimal num;
/**
* price
*/
private BigDecimal price;
/**
* productId
*/
private Object productId;
/**
* productName
*/
private String productName;
/**
* productSkuId
*/
private Long productSkuId;
/**
* productSkuName
*/
private String productSkuName;
/**
* refAmount
*/
private BigDecimal refAmount;
/**
* refNum
*/
private BigDecimal refNum;
/**
* salesAmount
*/
private BigDecimal salesAmount;
/**
* 销售数量
*/
private BigDecimal salesNum;
/**
* 单位名称
*/
private String unitName;
}
/**
* CountListVo
*/
@NoArgsConstructor
@Data
public static class CountListVo {
/**
* 销售额
*/
private BigDecimal saleAmount;
/**
* 销售量
*/
private BigDecimal saleNum;
/**
* 日期
*/
private String tradeDay;
}
}

View File

@@ -1,148 +0,0 @@
package com.czg.order.vo;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
/**
* 数据统计-营业-上半部分
* @author tankaikai
* @since 2025-03-07 15:35
*/
@NoArgsConstructor
@Data
public class DataSummaryTradeVo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* sale
*/
private SaleVo sale = new SaleVo();
/**
* count
*/
private CountVo count = new CountVo();
/**
* vip
*/
private VipVo vip = new VipVo();
/**
* SaleVo
*/
@NoArgsConstructor
@Data
public static class SaleVo {
/**
* 会员退款金额
*/
private BigDecimal outAmount;
/**
* 总金额
*/
private BigDecimal totalSaleAmount;
/**
* 会员总金额
*/
private BigDecimal totalVipAmount;
/**
* 会员充值金额
*/
private BigDecimal inAmount;
/**
* 总实收
*/
private BigDecimal incomeAmountAll;
/**
* 销售收款金额
*/
private BigDecimal incomeAmount;
/**
* payCount
*/
private List<PayCountVo> payCount = new ArrayList<>();
/**
* 销售退款金额
*/
private BigDecimal refundAmount;
/**
* PayCountVo
*/
@NoArgsConstructor
@Data
public static class PayCountVo {
/**
* 图标
*/
private String icon;
/**
* isAmount
*/
private String isAmount;
/**
* 金额
*/
private Integer payAmount;
/**
* 描述
*/
private String payType;
/**
* saveAmount
*/
private BigDecimal saveAmount;
}
}
/**
* CountVo
*/
@NoArgsConstructor
@Data
public static class CountVo {
/**
* 客单价
*/
private Integer unitPrice;
/**
* 翻台率
*/
private String turnoverRate;
/**
* 优惠单数
*/
private Integer saveNum;
/**
* 优惠金额
*/
private BigDecimal saveAmount;
}
/**
* VipVo
*/
@NoArgsConstructor
@Data
public static class VipVo {
/**
* 会员消费笔数
*/
private Integer useNum;
/**
* 新增会员数
*/
private Integer newFlow;
/**
* 会员消费金额
*/
private BigDecimal useAmount;
}
}

View File

@@ -1,69 +0,0 @@
package com.czg.order.vo;
import cn.idev.excel.annotation.ExcelIgnore;
import cn.idev.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.write.style.ColumnWidth;
import com.alibaba.fastjson2.annotation.JSONField;
import com.pig4cloud.plugin.excel.annotation.ExcelLine;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 销量统计导出
*
* @author tankaikai
* @since 2025-03-07 16:22
*/
@Data
@ColumnWidth(30)
public class SaleSummaryExportVo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 导入时候回显行号
*/
@ExcelLine
@ExcelIgnore
@JSONField(serialize = false)
private Long lineNum;
/**
* 商品分类
*/
@ExcelProperty("商品分类")
private String categoryName;
/**
* 商品名称
*/
@ExcelProperty("商品名称")
private String productName;
/**
* 商品规格
*/
@ExcelProperty("商品规格")
private String specName;
/**
* 销售额
*/
@ExcelProperty("销售额")
private BigDecimal salesAmount;
/**
* 退单额
*/
@ExcelProperty("退单额")
private BigDecimal refundAmount;
/**
* 实际销量
*/
@ExcelProperty("实际销量")
private BigDecimal salesNum;
/**
* 退单量
*/
@ExcelProperty("退单量")
private BigDecimal refundNum;
}

View File

@@ -1,75 +0,0 @@
package com.czg.order.vo;
import cn.idev.excel.annotation.ExcelIgnore;
import cn.idev.excel.annotation.ExcelProperty;
import cn.idev.excel.annotation.write.style.ColumnWidth;
import com.alibaba.fastjson2.annotation.JSONField;
import com.pig4cloud.plugin.excel.annotation.ExcelLine;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 台桌统计明细
* @author tankaikai
* @since 2025-03-07 16:22
*/
@NoArgsConstructor
@Data
@ColumnWidth(20)
public class TableSummaryInfoVo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 导入时候回显行号
*/
@ExcelLine
@ExcelIgnore
@JSONField(serialize = false)
private Long lineNum;
/**
* 台桌id
*/
@ExcelIgnore
private Long tableId;
/**
* 台桌码
*/
@ExcelIgnore
private String tableCode;
/**
* 区域名称
*/
@ExcelProperty("区域名称")
private String areaName;
/**
* 台桌号
*/
@ExcelProperty("台桌号")
private String tableName;
/**
* 订单数量
*/
@ExcelProperty("订单数量")
private Long orderCount;
/**
* 订单金额
*/
@ExcelProperty("订单金额")
private BigDecimal orderAmount;
/**
* 退款数量
*/
@ExcelProperty("退款数量")
private Long refundCount;
/**
* 退款金额
*/
@ExcelProperty("退款金额")
private BigDecimal refundAmount;
}

View File

@@ -5,9 +5,10 @@ import com.czg.order.entity.OrderInfo;
import com.czg.service.market.mapper.OrderInfoMapper; import com.czg.service.market.mapper.OrderInfoMapper;
import com.mybatisflex.spring.service.impl.ServiceImpl; import com.mybatisflex.spring.service.impl.ServiceImpl;
import org.apache.dubbo.config.annotation.DubboService; import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.context.annotation.Primary;
/**
* @author Administrator
*/
@DubboService @DubboService
@Primary
public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo> implements OrderInfoService { public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo> implements OrderInfoService {
} }

View File

@@ -1,143 +1,141 @@
//package com.czg.service.order.mapper; package com.czg.service.order.mapper;
//
//import com.czg.account.vo.HandoverCategoryListVo; import com.czg.account.vo.HandoverCategoryListVo;
//import com.czg.account.vo.HandoverProductListVo; import com.czg.account.vo.HandoverProductListVo;
//import com.czg.order.entity.OrderInfo; import org.apache.ibatis.annotations.Param;
//import com.mybatisflex.core.BaseMapper;
//import org.apache.ibatis.annotations.Param; import java.math.BigDecimal;
// import java.util.List;
//import java.math.BigDecimal;
//import java.util.List; /**
// * 订单表 映射层。
///** *
// * 订单表 映射层。 * @author ww
// * * @since 2025-02-13
// * @author ww */
// * @since 2025-02-13 public interface OrderInfoCustomMapper{
// */
//public interface OrderInfoCustomMapper extends BaseMapper<OrderInfo> { /**
// * 交班现金支付统计
// /** *
// * 交班现金支付统计 * @param shopId 店铺id
// * * @param loginTime 上岗时间
// * @param shopId 店铺id * @param handoverTime 交班时间
// * @param loginTime 上岗时间 * @return 现金支付总额
// * @param handoverTime 交班时间 */
// * @return 现金支付总额 BigDecimal getHandoverCashAmount(Long shopId, String loginTime, String handoverTime);
// */
// BigDecimal getHandoverCashAmount(Long shopId, String loginTime, String handoverTime); /**
// * 交班微信支付统计
// /** *
// * 交班微信支付统计 * @param shopId 店铺id
// * * @param loginTime 上岗时间
// * @param shopId 店铺id * @param handoverTime 交班时间
// * @param loginTime 上岗时间 * @return 现金支付总额
// * @param handoverTime 交班时间 */
// * @return 现金支付总额 BigDecimal getHandoverWechatAmount(Long shopId, String loginTime, String handoverTime);
// */
// BigDecimal getHandoverWechatAmount(Long shopId, String loginTime, String handoverTime); /**
// * 交班支付宝支付统计
// /** *
// * 交班支付宝支付统计 * @param shopId 店铺id
// * * @param loginTime 上岗时间
// * @param shopId 店铺id * @param handoverTime 交班时间
// * @param loginTime 上岗时间 * @return 支付宝支付总额
// * @param handoverTime 交班时间 */
// * @return 支付宝支付总额 BigDecimal getHandoverAlipayAmount(Long shopId, String loginTime, String handoverTime);
// */
// BigDecimal getHandoverAlipayAmount(Long shopId, String loginTime, String handoverTime); /**
// * 交班VIP支付统计
// /** *
// * 交班VIP支付统计 * @param shopId 店铺id
// * * @param loginTime 上岗时间
// * @param shopId 店铺id * @param handoverTime 交班时间
// * @param loginTime 上岗时间 * @return VIP支付总额
// * @param handoverTime 交班时间 */
// * @return VIP支付总额 BigDecimal getHandoverVipPayAmount(Long shopId, String loginTime, String handoverTime);
// */
// BigDecimal getHandoverVipPayAmount(Long shopId, String loginTime, String handoverTime); /**
// * 交班VIP充值统计
// /** *
// * 交班VIP充值统计 * @param shopId 店铺id
// * * @param loginTime 上岗时间
// * @param shopId 店铺id * @param handoverTime 交班时间
// * @param loginTime 上岗时间 * @return VIP充值总额
// * @param handoverTime 交班时间 */
// * @return VIP充值总额 BigDecimal getHandoverVipChargeAmount(Long shopId, String loginTime, String handoverTime);
// */
// BigDecimal getHandoverVipChargeAmount(Long shopId, String loginTime, String handoverTime); /**
// * 交班快捷支付统计
// /** *
// * 交班快捷支付统计 * @param shopId 店铺id
// * * @param loginTime 上岗时间
// * @param shopId 店铺id * @param handoverTime 交班时间
// * @param loginTime 上岗时间 * @return 快捷支付总额
// * @param handoverTime 交班时间 */
// * @return 快捷支付总额 BigDecimal getHandoverQuickPayAmount(Long shopId, String loginTime, String handoverTime);
// */
// BigDecimal getHandoverQuickPayAmount(Long shopId, String loginTime, String handoverTime); /**
// * 交班退款统计
// /** *
// * 交班退款统计 * @param shopId 店铺id
// * * @param loginTime 上岗时间
// * @param shopId 店铺id * @param handoverTime 交班时间
// * @param loginTime 上岗时间 * @return 退款总额
// * @param handoverTime 交班时间 */
// * @return 退款总额 BigDecimal getHandoverRefundAmount(Long shopId, String loginTime, String handoverTime);
// */
// BigDecimal getHandoverRefundAmount(Long shopId, String loginTime, String handoverTime); /**
// * 交班挂账统计
// /** *
// * 交班挂账统计 * @param shopId 店铺id
// * * @param loginTime 上岗时间
// * @param shopId 店铺id * @param handoverTime 交班时间
// * @param loginTime 上岗时间 * @return 挂账总额
// * @param handoverTime 交班时间 */
// * @return 挂账总额 BigDecimal getHandoverCreditAmount(Long shopId, String loginTime, String handoverTime);
// */
// BigDecimal getHandoverCreditAmount(Long shopId, String loginTime, String handoverTime); /**
// * 交班营业额统计
// /** *
// * 交班营业额统计 * @param shopId 店铺id
// * * @param loginTime 上岗时间
// * @param shopId 店铺id * @param handoverTime 交班时间
// * @param loginTime 上岗时间 * @return 营业额
// * @param handoverTime 交班时间 */
// * @return 营业额 BigDecimal getHandoverTotalAmount(Long shopId, String loginTime, String handoverTime);
// */
// BigDecimal getHandoverTotalAmount(Long shopId, String loginTime, String handoverTime); /**
// * 交班订单数统计
// /** *
// * 交班订单数统计 * @param shopId 店铺id
// * * @param loginTime 上岗时间
// * @param shopId 店铺id * @param handoverTime 交班时间
// * @param loginTime 上岗时间 * @return 交班订单数
// * @param handoverTime 交班时间 */
// * @return 交班订单数 int getHandoverOrderNum(Long shopId, String loginTime, String handoverTime);
// */
// int getHandoverOrderNum(Long shopId, String loginTime, String handoverTime); /**
// * 交班售出商品明细
// /** *
// * 交班售出商品明细 * @param shopId 店铺id
// * * @param loginTime 上岗时间
// * @param shopId 店铺id * @param handoverTime 交班时间
// * @param loginTime 上岗时间 * @return 交班售出商品明细
// * @param handoverTime 交班时间 */
// * @return 交班售出商品明细 List<HandoverProductListVo> getHandoverDetailList(Long shopId, String loginTime, String handoverTime);
// */
// List<HandoverProductListVo> getHandoverDetailList(Long shopId, String loginTime, String handoverTime); /**
// * 交班售出商品分类统计
// /** *
// * 交班售出商品分类统计 * @param shopId 店铺id
// * * @param loginTime 上岗时间
// * @param shopId 店铺id * @param handoverTime 交班时间
// * @param loginTime 上岗时间 * @return 售出商品分类统计
// * @param handoverTime 交班时间 */
// * @return 售出商品分类统计 List<HandoverCategoryListVo> getHandoverCategoryList(Long shopId, String loginTime, String handoverTime);
// */
// List<HandoverCategoryListVo> getHandoverCategoryList(Long shopId, String loginTime, String handoverTime); int decrMoney(@Param("id") Long id, @Param("amount") BigDecimal amount);
//
// int decrMoney(@Param("id") Long id, @Param("amount") BigDecimal amount); int updatePayOrderId(@Param("orderId") Long orderId, @Param("paymentId") Long paymentId, @Param("payType") String payType, @Param("remark") String remark);
// }
// int updatePayOrderId(@Param("orderId") Long orderId, @Param("paymentId") Long paymentId, @Param("payType") String payType, @Param("remark") String remark);
//}

View File

@@ -8,6 +8,7 @@ import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl; import com.mybatisflex.spring.service.impl.ServiceImpl;
import org.apache.dubbo.config.annotation.DubboService; import org.apache.dubbo.config.annotation.DubboService;
import java.time.LocalDateTime;
import java.util.List; import java.util.List;
/** /**
@@ -33,6 +34,7 @@ public class OrderDetailServiceImpl extends ServiceImpl<OrderDetailMapper, Order
public void updateOrderDetailStatus(Long orderId,String status) { public void updateOrderDetailStatus(Long orderId,String status) {
OrderDetail orderDetail = new OrderDetail(); OrderDetail orderDetail = new OrderDetail();
orderDetail.setStatus(status); orderDetail.setStatus(status);
orderDetail.setOrderTime(LocalDateTime.now());
update(orderDetail, QueryWrapper.create() update(orderDetail, QueryWrapper.create()
.eq(OrderDetail::getOrderId,orderId) .eq(OrderDetail::getOrderId,orderId)
.eq(OrderDetail::getStatus,"wait-pay") .eq(OrderDetail::getStatus,"wait-pay")

View File

@@ -45,24 +45,20 @@ import com.czg.product.service.ProductService;
import com.czg.resp.CzgResult; import com.czg.resp.CzgResult;
import com.czg.sa.StpKit; import com.czg.sa.StpKit;
import com.czg.service.RedisService; import com.czg.service.RedisService;
import com.czg.service.market.mapper.OrderInfoMapper;
import com.czg.service.market.service.impl.OrderInfoServiceImpl;
import com.czg.service.order.enums.OrderStatusEnums; import com.czg.service.order.enums.OrderStatusEnums;
import com.czg.service.order.mapper.OrderInfoCustomMapper;
import com.czg.service.order.print.PrinterHandler; import com.czg.service.order.print.PrinterHandler;
import com.czg.utils.AssertUtil; import com.czg.utils.AssertUtil;
import com.czg.utils.CzgStrUtils; import com.czg.utils.CzgStrUtils;
import com.czg.utils.PageUtil; import com.czg.utils.PageUtil;
import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.update.UpdateChain;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotBlank;
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.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionSynchronization; import org.springframework.transaction.support.TransactionSynchronization;
@@ -87,8 +83,11 @@ import java.util.stream.Collectors;
*/ */
@Slf4j @Slf4j
@Service @Service
public class OrderInfoCustomServiceImpl extends OrderInfoServiceImpl implements OrderInfoCustomService { public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
@Resource
private OrderInfoCustomMapper orderInfoCustomMapper;
@Resource
private OrderInfoService orderInfoService;
@Lazy @Lazy
@Resource @Resource
private PrinterHandler printerHandler; private PrinterHandler printerHandler;
@@ -176,7 +175,7 @@ public class OrderInfoCustomServiceImpl extends OrderInfoServiceImpl implements
.le(OrderInfo::getCreateTime, CzgStrUtils.getStrOrNull(param.getEndTime())) .le(OrderInfo::getCreateTime, CzgStrUtils.getStrOrNull(param.getEndTime()))
.in(OrderInfo::getId, like) .in(OrderInfo::getId, like)
.orderBy(OrderInfo::getId).desc(); .orderBy(OrderInfo::getId).desc();
Page<OrderInfoVo> orderInfoVoPage = pageAs(PageUtil.buildPage(), queryWrapper, OrderInfoVo.class); Page<OrderInfoVo> orderInfoVoPage = orderInfoService.pageAs(PageUtil.buildPage(), queryWrapper, OrderInfoVo.class);
orderInfoVoPage.getRecords().parallelStream().forEach(s -> { orderInfoVoPage.getRecords().parallelStream().forEach(s -> {
List<OrderDetailSmallVO> orderDetails = orderDetailService.listAs( List<OrderDetailSmallVO> orderDetails = orderDetailService.listAs(
QueryWrapper.create().eq(OrderDetail::getOrderId, s.getId()).eq(OrderDetail::getShopId, s.getShopId()), OrderDetailSmallVO.class); QueryWrapper.create().eq(OrderDetail::getOrderId, s.getId()).eq(OrderDetail::getShopId, s.getShopId()), OrderDetailSmallVO.class);
@@ -194,7 +193,7 @@ public class OrderInfoCustomServiceImpl extends OrderInfoServiceImpl implements
@Override @Override
public CzgResult<HistoryOrderPrintVo> getOrderByIdPrint(Long orderId) { public CzgResult<HistoryOrderPrintVo> getOrderByIdPrint(Long orderId) {
HistoryOrderPrintVo historyOrderVo = getOneAs(new QueryWrapper() HistoryOrderPrintVo historyOrderVo = orderInfoService.getOneAs(new QueryWrapper()
.eq(OrderInfo::getId, orderId), HistoryOrderPrintVo.class); .eq(OrderInfo::getId, orderId), HistoryOrderPrintVo.class);
AssertUtil.isNull(historyOrderVo, "订单不存在"); AssertUtil.isNull(historyOrderVo, "订单不存在");
List<OrderDetailPrintVo> orderDetails = orderDetailService.getOrderDetailPrint(orderId); List<OrderDetailPrintVo> orderDetails = orderDetailService.getOrderDetailPrint(orderId);
@@ -211,11 +210,11 @@ public class OrderInfoCustomServiceImpl extends OrderInfoServiceImpl implements
resultMap.computeIfAbsent(placeNum.toString(), k -> new ArrayList<>()).add(orderDetail); resultMap.computeIfAbsent(placeNum.toString(), k -> new ArrayList<>()).add(orderDetail);
} }
historyOrderVo.setDetailMap(resultMap); historyOrderVo.setDetailMap(resultMap);
long count = queryChain() long count = orderInfoService.count(QueryWrapper.create()
.eq(OrderInfo::getTradeDay, historyOrderVo.getTradeDay()) .eq(OrderInfo::getTradeDay, historyOrderVo.getTradeDay())
.eq(OrderInfo::getStatus, OrderStatusEnums.DONE.getCode()) .eq(OrderInfo::getStatus, OrderStatusEnums.DONE.getCode())
.eq(OrderInfo::getShopId, historyOrderVo.getShopId()) .eq(OrderInfo::getShopId, historyOrderVo.getShopId())
.le(OrderInfo::getCreateTime, historyOrderVo.getCreateTime()).count(); .le(OrderInfo::getCreateTime, historyOrderVo.getCreateTime()));
historyOrderVo.setOrderNum(count); historyOrderVo.setOrderNum(count);
return CzgResult.success(historyOrderVo); return CzgResult.success(historyOrderVo);
} }
@@ -230,15 +229,13 @@ public class OrderInfoCustomServiceImpl extends OrderInfoServiceImpl implements
} }
HistoryOrderVo historyOrderVo; HistoryOrderVo historyOrderVo;
if (orderId == null) { if (orderId == null) {
historyOrderVo = queryChain() historyOrderVo = orderInfoService.getOneAs(QueryWrapper.create()
.select()
.eq(OrderInfo::getShopId, StpKit.USER.getShopId()) .eq(OrderInfo::getShopId, StpKit.USER.getShopId())
.eq(OrderInfo::getTableCode, tableCode) .eq(OrderInfo::getTableCode, tableCode)
.eq(OrderInfo::getStatus, OrderStatusEnums.UNPAID.getCode()) .eq(OrderInfo::getStatus, OrderStatusEnums.UNPAID.getCode())
.gt(OrderInfo::getCreateTime, DateUtil.offsetDay(new Date(), -1)) .gt(OrderInfo::getCreateTime, DateUtil.offsetDay(new Date(), -1)), HistoryOrderVo.class);
.oneAs(HistoryOrderVo.class);
} else { } else {
historyOrderVo = getOneAs(new QueryWrapper() historyOrderVo = orderInfoService.getOneAs(new QueryWrapper()
.eq(OrderInfo::getId, orderId), HistoryOrderVo.class); .eq(OrderInfo::getId, orderId), HistoryOrderVo.class);
} }
if (historyOrderVo == null || historyOrderVo.getId() == null) { if (historyOrderVo == null || historyOrderVo.getId() == null) {
@@ -323,7 +320,7 @@ public class OrderInfoCustomServiceImpl extends OrderInfoServiceImpl implements
@Override @Override
public OrderInfo checkOrderPay(CheckOrderPay param) throws OrderValidateException, OrderCancelException, CzgException { public OrderInfo checkOrderPay(CheckOrderPay param) throws OrderValidateException, OrderCancelException, CzgException {
AssertUtil.isNull(param.getOrderId(), "支付失败订单id不能为空"); AssertUtil.isNull(param.getOrderId(), "支付失败订单id不能为空");
OrderInfo orderInfo = getById(param.getOrderId()); OrderInfo orderInfo = orderInfoService.getById(param.getOrderId());
if (!orderInfo.getStatus().equals(OrderStatusEnums.UNPAID.getCode())) { if (!orderInfo.getStatus().equals(OrderStatusEnums.UNPAID.getCode())) {
throw new OrderCancelException("生成支付订单失败,订单不可支付"); throw new OrderCancelException("生成支付订单失败,订单不可支付");
} }
@@ -333,10 +330,10 @@ public class OrderInfoCustomServiceImpl extends OrderInfoServiceImpl implements
} else { } else {
if (!orderInfo.getStatus().equals(OrderStatusEnums.CANCELLED.getCode())) { if (!orderInfo.getStatus().equals(OrderStatusEnums.CANCELLED.getCode())) {
ThreadUtil.execAsync(() -> { ThreadUtil.execAsync(() -> {
updateChain() OrderInfo orderInfoUpdate = new OrderInfo();
.set(OrderInfo::getStatus, OrderStatusEnums.CANCELLED.getCode()) orderInfoUpdate.setId(orderInfo.getId());
.eq(OrderInfo::getId, param.getOrderId()) orderInfoUpdate.setStatus(OrderStatusEnums.CANCELLED.getCode());
.update(); orderInfoService.updateById(orderInfoUpdate);
rabbitPublisher.sendOrderCancelMsg(orderInfo.getId().toString()); rabbitPublisher.sendOrderCancelMsg(orderInfo.getId().toString());
}); });
} }
@@ -550,15 +547,13 @@ public class OrderInfoCustomServiceImpl extends OrderInfoServiceImpl implements
if (param.getTargetOrderId() == null && StrUtil.isBlank(param.getTargetTableCode())) { if (param.getTargetOrderId() == null && StrUtil.isBlank(param.getTargetTableCode())) {
throw new CzgException("转台失败,请选择目标台桌后转台"); throw new CzgException("转台失败,请选择目标台桌后转台");
} }
OrderInfo sourceOrder = getById(param.getSourceOrderId()); OrderInfo sourceOrder = orderInfoService.getById(param.getSourceOrderId());
if (sourceOrder == null || !sourceOrder.getStatus().equals(OrderStatusEnums.UNPAID.getCode())) { if (sourceOrder == null || !sourceOrder.getStatus().equals(OrderStatusEnums.UNPAID.getCode())) {
throw new CzgException("转台失败,无可转订单"); throw new CzgException("转台失败,无可转订单");
} }
OrderInfo targetOrder = queryChain() OrderInfo targetOrder = orderInfoService.getOne(QueryWrapper.create().eq(OrderInfo::getId, param.getTargetOrderId())
.eq(OrderInfo::getId, param.getTargetOrderId())
.eq(OrderInfo::getTableCode, param.getTargetTableCode()) .eq(OrderInfo::getTableCode, param.getTargetTableCode())
.eq(OrderInfo::getStatus, OrderStatusEnums.UNPAID.getCode()) .eq(OrderInfo::getStatus, OrderStatusEnums.UNPAID.getCode()));
.one();
if (targetOrder == null) { if (targetOrder == null) {
OrderInfoAddDTO addDTO = new OrderInfoAddDTO(); OrderInfoAddDTO addDTO = new OrderInfoAddDTO();
addDTO.setShopId(sourceOrder.getShopId()); addDTO.setShopId(sourceOrder.getShopId());
@@ -576,7 +571,10 @@ public class OrderInfoCustomServiceImpl extends OrderInfoServiceImpl implements
} else { } else {
targetOrder.setPlaceNum(targetOrder.getPlaceNum() + 1); targetOrder.setPlaceNum(targetOrder.getPlaceNum() + 1);
//下单次数+1 //下单次数+1
updateChain().set(OrderInfo::getPlaceNum, targetOrder.getPlaceNum() + 1).eq(OrderInfo::getId, targetOrder.getId()).update(); OrderInfo updateTargetOrder = new OrderInfo();
updateTargetOrder.setId(targetOrder.getId());
updateTargetOrder.setPlaceNum(targetOrder.getPlaceNum() + 1);
orderInfoService.updateById(updateTargetOrder);
} }
if (CollUtil.isEmpty(param.getDetailIds())) { if (CollUtil.isEmpty(param.getDetailIds())) {
long count = orderDetailService.queryChain().eq(OrderDetail::getOrderId, sourceOrder.getId()).count(); long count = orderDetailService.queryChain().eq(OrderDetail::getOrderId, sourceOrder.getId()).count();
@@ -1047,7 +1045,7 @@ public class OrderInfoCustomServiceImpl extends OrderInfoServiceImpl implements
if ("TRADE_SUCCESS".equals(czgCallBackDto.getState())) { if ("TRADE_SUCCESS".equals(czgCallBackDto.getState())) {
payment.setPayStatus("success"); payment.setPayStatus("success");
if ("order".equals(payment.getPayType())) { if ("order".equals(payment.getPayType())) {
OrderInfo orderInfo = getById(payment.getSourceId()); OrderInfo orderInfo = orderInfoService.getById(payment.getSourceId());
if (orderInfo == null) { if (orderInfo == null) {
log.error("订单支付回调失败,订单不存在,支付记录Id,{}", payment.getId()); log.error("订单支付回调失败,订单不存在,支付记录Id,{}", payment.getId());
return; return;
@@ -1079,7 +1077,7 @@ public class OrderInfoCustomServiceImpl extends OrderInfoServiceImpl implements
bizEnum = ShopUserFlowBizEnum.CASH_IN; bizEnum = ShopUserFlowBizEnum.CASH_IN;
} }
if (isFree) { if (isFree) {
orderInfo = getOne(new QueryWrapper().eq(OrderInfo::getId, payment.getRelatedId())); orderInfo = orderInfoService.getOne(new QueryWrapper().eq(OrderInfo::getId, payment.getRelatedId()));
if (orderInfo == null) { if (orderInfo == null) {
log.error("霸王餐支付订单不存在支付记录Id,{}", payment.getId()); log.error("霸王餐支付订单不存在支付记录Id,{}", payment.getId());
} else { } else {
@@ -1098,7 +1096,7 @@ public class OrderInfoCustomServiceImpl extends OrderInfoServiceImpl implements
orderInfo1.setPayAmount(BigDecimal.ZERO); orderInfo1.setPayAmount(BigDecimal.ZERO);
orderInfo1.setPaidTime(LocalDateTime.now()); orderInfo1.setPaidTime(LocalDateTime.now());
orderInfo1.setPayType(PayEnums.FREE_PAY.getValue()); orderInfo1.setPayType(PayEnums.FREE_PAY.getValue());
updateById(orderInfo1); orderInfoService.updateById(orderInfo1);
orderDetailService.updateOrderDetailStatus(orderInfo.getId(), OrderStatusEnums.DONE.getCode()); orderDetailService.updateOrderDetailStatus(orderInfo.getId(), OrderStatusEnums.DONE.getCode());
redisService.del(RedisCst.classKeyExpired.EXPIRED_ORDER + orderInfo.getId()); redisService.del(RedisCst.classKeyExpired.EXPIRED_ORDER + orderInfo.getId());
} }
@@ -1106,16 +1104,17 @@ public class OrderInfoCustomServiceImpl extends OrderInfoServiceImpl implements
shopRechargeService.recharge(payment.getShopId(), payment.getSourceId(), payment.getRelatedId(), shopRechargeService.recharge(payment.getShopId(), payment.getSourceId(), payment.getRelatedId(),
BigDecimal.valueOf(czgCallBackDto.getAmount()).divide(BigDecimal.valueOf(100), 2, RoundingMode.DOWN), payment.getId(), payment.getPayType(), bizEnum); BigDecimal.valueOf(czgCallBackDto.getAmount()).divide(BigDecimal.valueOf(100), 2, RoundingMode.DOWN), payment.getId(), payment.getPayType(), bizEnum);
//充值并支付 ↓ //充值并支付 ↓
orderInfo = getOne(new QueryWrapper() orderInfo = orderInfoService.getOne(new QueryWrapper()
.eq(OrderInfo::getPayOrderId, payment.getId()) .eq(OrderInfo::getPayOrderId, payment.getId())
.eq(OrderInfo::getPayType, PayEnums.VIP_PAY.getValue())); .eq(OrderInfo::getPayType, PayEnums.VIP_PAY.getValue()));
if (orderInfo != null) { if (orderInfo != null) {
updateChain().eq(OrderInfo::getId, orderInfo.getId()) OrderInfo upOrderInfo = new OrderInfo()
.set(OrderInfo::getPayType, PayEnums.VIP_PAY.getValue()) .setId(orderInfo.getId())
.set(OrderInfo::getStatus, OrderStatusEnums.DONE.getCode()) .setPayType(PayEnums.VIP_PAY.getValue())
.set(OrderInfo::getPaidTime, LocalDateTime.now()) .setPaidTime(LocalDateTime.now())
.set(OrderInfo::getPayAmount, orderInfo.getOrderAmount()) .setPayAmount(orderInfo.getOrderAmount())
.update(); .setStatus(OrderStatusEnums.DONE.getCode());
orderInfoService.updateById(upOrderInfo);
orderDetailService.updateOrderDetailStatus(orderInfo.getId(), OrderStatusEnums.DONE.getCode()); orderDetailService.updateOrderDetailStatus(orderInfo.getId(), OrderStatusEnums.DONE.getCode());
ShopUserMoneyEditDTO shopUserMoneyEditDTO = new ShopUserMoneyEditDTO() ShopUserMoneyEditDTO shopUserMoneyEditDTO = new ShopUserMoneyEditDTO()
.setId(shopUser.getId()) .setId(shopUser.getId())
@@ -1190,10 +1189,9 @@ public class OrderInfoCustomServiceImpl extends OrderInfoServiceImpl implements
payment.setPayStatus("fail"); payment.setPayStatus("fail");
if ("refund".equals(payment.getPayType())) { if ("refund".equals(payment.getPayType())) {
//TODO 订单退款失败 暂不考虑回滚 填充退款原因 //TODO 订单退款失败 暂不考虑回滚 填充退款原因
updateChain() orderInfoService.updateById(new OrderInfo()
.set(OrderInfo::getRefundRemark, czgCallBackDto.getRefundReason()) .setId(payment.getSourceId())
.eq(OrderInfo::getId, payment.getSourceId()) .setRefundRemark(czgCallBackDto.getRefundReason()));
.update();
} else if ("memberRefund".equals(payment.getPayType())) { } else if ("memberRefund".equals(payment.getPayType())) {
//TODO 会员退款 暂不考虑回滚(钱 赠送金额 赠送的券) 填充退款原因 //TODO 会员退款 暂不考虑回滚(钱 赠送金额 赠送的券) 填充退款原因
flowService flowService
@@ -1224,24 +1222,24 @@ public class OrderInfoCustomServiceImpl extends OrderInfoServiceImpl implements
*/ */
@Override @Override
public void upOrderInfo(OrderInfo orderInfo, BigDecimal payAmount, LocalDateTime payTime, Long payOrderId, PayEnums payType) { public void upOrderInfo(OrderInfo orderInfo, BigDecimal payAmount, LocalDateTime payTime, Long payOrderId, PayEnums payType) {
UpdateChain<OrderInfo> updateChain = updateChain() OrderInfo upOrderInfo = new OrderInfo()
.set(OrderInfo::getPayAmount, payAmount) .setId(orderInfo.getId())
.set(OrderInfo::getStatus, OrderStatusEnums.DONE.getCode()) .setPayAmount(payAmount)
.set(OrderInfo::getPaidTime, payTime) .setPaidTime(payTime)
.set(OrderInfo::getRemark, orderInfo.getRemark()) .setRemark(orderInfo.getRemark())
.where(OrderInfo::getId).eq(orderInfo.getId()); .setStatus(OrderStatusEnums.DONE.getCode());
if (payOrderId != null) { if (payOrderId != null) {
updateChain.set(OrderInfo::getPayOrderId, payOrderId); upOrderInfo.setPayOrderId(payOrderId);
orderInfo.setPayOrderId(payOrderId); orderInfo.setPayOrderId(payOrderId);
} }
if (orderInfo.getCreditBuyerId() != null) { if (orderInfo.getCreditBuyerId() != null) {
updateChain.set(OrderInfo::getCreditBuyerId, orderInfo.getCreditBuyerId()); upOrderInfo.setCreditBuyerId(orderInfo.getCreditBuyerId());
} }
if (ObjectUtil.isNotNull(payType)) { if (ObjectUtil.isNotNull(payType)) {
updateChain.set(OrderInfo::getPayType, payType.getValue()); upOrderInfo.setPayType(payType.getValue());
orderInfo.setPayType(payType.getValue()); orderInfo.setPayType(payType.getValue());
} }
boolean update = updateChain.update(); boolean update = orderInfoService.updateById(upOrderInfo);
if (update) { if (update) {
orderInfo.setPayAmount(payAmount); orderInfo.setPayAmount(payAmount);
orderInfo.setStatus(OrderStatusEnums.DONE.getCode()); orderInfo.setStatus(OrderStatusEnums.DONE.getCode());
@@ -1339,12 +1337,9 @@ public class OrderInfoCustomServiceImpl extends OrderInfoServiceImpl implements
@Override @Override
@Transactional @Transactional
public void expired(Long orderId) { public void expired(Long orderId) {
OrderInfo orderInfo = getById(orderId); OrderInfo orderInfo = orderInfoService.getById(orderId);
if (orderInfo.getStatus().equals(OrderStatusEnums.UNPAID.getCode())) { if (orderInfo.getStatus().equals(OrderStatusEnums.UNPAID.getCode())) {
updateChain().set(OrderInfo::getStatus, OrderStatusEnums.CANCELLED.getCode()) orderInfoService.updateById(new OrderInfo().setId(orderId).setStatus(OrderStatusEnums.CANCELLED.getCode()));
.where(OrderInfo::getId).eq(orderId)
.update();
if (StrUtil.isNotBlank(orderInfo.getTableCode())) { if (StrUtil.isNotBlank(orderInfo.getTableCode())) {
ShopTable table = shopTableService.getOneByTableCode(orderInfo.getShopId(), orderInfo.getTableCode()); ShopTable table = shopTableService.getOneByTableCode(orderInfo.getShopId(), orderInfo.getTableCode());
if (table != null) { if (table != null) {
@@ -1391,7 +1386,7 @@ public class OrderInfoCustomServiceImpl extends OrderInfoServiceImpl implements
private OrderInfo initOrderInfo(OrderInfoAddDTO param, ShopInfo shopInfo, ShopTable table) throws CzgException { private OrderInfo initOrderInfo(OrderInfoAddDTO param, ShopInfo shopInfo, ShopTable table) throws CzgException {
OrderInfo orderInfo = new OrderInfo(); OrderInfo orderInfo = new OrderInfo();
if (param.getOrderId() != null) { if (param.getOrderId() != null) {
orderInfo = getById(param.getOrderId()); orderInfo = orderInfoService.getById(param.getOrderId());
if (!OrderStatusEnums.UNPAID.getCode().equals(orderInfo.getStatus())) { if (!OrderStatusEnums.UNPAID.getCode().equals(orderInfo.getStatus())) {
throw new CzgException("生成订单失败,订单已结束,请重新下单"); throw new CzgException("生成订单失败,订单已结束,请重新下单");
} }
@@ -1440,7 +1435,7 @@ public class OrderInfoCustomServiceImpl extends OrderInfoServiceImpl implements
orderInfo.setPackFee(orderInfo.getPackFee().add(param.getPackFee())); orderInfo.setPackFee(orderInfo.getPackFee().add(param.getPackFee()));
orderInfo.setRoundAmount(BigDecimal.ZERO); orderInfo.setRoundAmount(BigDecimal.ZERO);
orderInfo.setPointsNum(0); orderInfo.setPointsNum(0);
saveOrUpdate(orderInfo); orderInfoService.saveOrUpdate(orderInfo);
return orderInfo; return orderInfo;
} }
@@ -1510,7 +1505,7 @@ public class OrderInfoCustomServiceImpl extends OrderInfoServiceImpl implements
} }
} }
} }
saveOrUpdate(orderInfo); orderInfoService.saveOrUpdate(orderInfo);
} }
/** /**
@@ -1562,7 +1557,7 @@ public class OrderInfoCustomServiceImpl extends OrderInfoServiceImpl implements
@Override @Override
public Boolean printOrder(Long shopId, OrderInfoPrintDTO orderInfoPrintDTO) { public Boolean printOrder(Long shopId, OrderInfoPrintDTO orderInfoPrintDTO) {
OrderInfo orderInfo = getOne(new QueryWrapper().eq(OrderInfo::getShopId, shopId).eq(OrderInfo::getId, orderInfoPrintDTO.getId())); OrderInfo orderInfo = orderInfoService.getOne(new QueryWrapper().eq(OrderInfo::getShopId, shopId).eq(OrderInfo::getId, orderInfoPrintDTO.getId()));
if (orderInfo == null) { if (orderInfo == null) {
throw new CzgException("订单信息不存在"); throw new CzgException("订单信息不存在");
} }
@@ -1584,7 +1579,7 @@ public class OrderInfoCustomServiceImpl extends OrderInfoServiceImpl implements
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Boolean removeOrderDetail(Long shopId, Long orderId, Long detailId) { public Boolean removeOrderDetail(Long shopId, Long orderId, Long detailId) {
OrderInfo orderInfo = getOne(new QueryWrapper().eq(OrderInfo::getId, orderId).eq(OrderInfo::getShopId, shopId)); OrderInfo orderInfo = orderInfoService.getOne(new QueryWrapper().eq(OrderInfo::getId, orderId).eq(OrderInfo::getShopId, shopId));
if (orderInfo == null) { if (orderInfo == null) {
throw new CzgException("订单不存在"); throw new CzgException("订单不存在");
} }
@@ -1598,7 +1593,7 @@ public class OrderInfoCustomServiceImpl extends OrderInfoServiceImpl implements
throw new CzgException("不处于待支付或订单详情不存在"); throw new CzgException("不处于待支付或订单详情不存在");
} }
int i = mapper.decrMoney(orderInfo.getId(), orderDetail.getPayAmount().add(orderDetail.getPackAmount())); int i = orderInfoCustomMapper.decrMoney(orderInfo.getId(), orderDetail.getPayAmount().add(orderDetail.getPackAmount()));
if (i > 0) { if (i > 0) {
return orderDetailService.removeById(orderDetail.getId()); return orderDetailService.removeById(orderDetail.getId());
} }
@@ -1608,7 +1603,7 @@ public class OrderInfoCustomServiceImpl extends OrderInfoServiceImpl implements
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Boolean cancelledOrder(Long shopId, Long orderId) throws OrderCancelException { public Boolean cancelledOrder(Long shopId, Long orderId) throws OrderCancelException {
OrderInfo orderInfo = getById(orderId); OrderInfo orderInfo = orderInfoService.getById(orderId);
if (orderInfo == null) { if (orderInfo == null) {
// throw new OrderCancelException("订单不存在"); // throw new OrderCancelException("订单不存在");
return true; return true;
@@ -1617,11 +1612,8 @@ public class OrderInfoCustomServiceImpl extends OrderInfoServiceImpl implements
// throw new OrderCancelException("订单不可取消"); // throw new OrderCancelException("订单不可取消");
return true; return true;
} }
updateChain() orderInfoService.updateById(new OrderInfo().setId(orderId)
.set(OrderInfo::getStatus, OrderStatusEnums.CANCELLED.getCode()) .setStatus(OrderStatusEnums.CANCELLED.getCode()));
.eq(OrderInfo::getShopId, shopId)
.eq(OrderInfo::getId, orderId)
.update();
redisService.del(RedisCst.classKeyExpired.EXPIRED_ORDER + orderInfo.getId()); redisService.del(RedisCst.classKeyExpired.EXPIRED_ORDER + orderInfo.getId());
rabbitPublisher.sendOrderCancelMsg(orderInfo.getId().toString()); rabbitPublisher.sendOrderCancelMsg(orderInfo.getId().toString());
orderDetailService.updateOrderDetailStatus(orderId, OrderStatusEnums.CANCELLED.getCode()); orderDetailService.updateOrderDetailStatus(orderId, OrderStatusEnums.CANCELLED.getCode());
@@ -1647,7 +1639,7 @@ public class OrderInfoCustomServiceImpl extends OrderInfoServiceImpl implements
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Boolean cancelledPlaceOrder(Long shopId, Long orderId, Integer placeNum) { public Boolean cancelledPlaceOrder(Long shopId, Long orderId, Integer placeNum) {
OrderInfo orderInfo = getById(orderId); OrderInfo orderInfo = orderInfoService.getById(orderId);
if (orderInfo == null) { if (orderInfo == null) {
// throw new OrderCancelException("订单不存在"); // throw new OrderCancelException("订单不存在");
return true; return true;
@@ -1657,11 +1649,8 @@ public class OrderInfoCustomServiceImpl extends OrderInfoServiceImpl implements
return true; return true;
} }
if (orderInfo.getPlaceNum().equals(1)) { if (orderInfo.getPlaceNum().equals(1)) {
updateChain() orderInfoService.updateById(new OrderInfo().setId(orderId)
.set(OrderInfo::getStatus, OrderStatusEnums.CANCELLED.getCode()) .setStatus(OrderStatusEnums.CANCELLED.getCode()));
.eq(OrderInfo::getShopId, shopId)
.eq(OrderInfo::getId, orderId)
.update();
rabbitPublisher.sendOrderCancelMsg(orderInfo.getId().toString()); rabbitPublisher.sendOrderCancelMsg(orderInfo.getId().toString());
return true; return true;
} }
@@ -1680,11 +1669,9 @@ public class OrderInfoCustomServiceImpl extends OrderInfoServiceImpl implements
} }
List<OrderDetail> list = orderDetailService.queryChain().eq(OrderDetail::getOrderId, orderId).eq(OrderDetail::getShopId, shopId).list(); List<OrderDetail> list = orderDetailService.queryChain().eq(OrderDetail::getOrderId, orderId).eq(OrderDetail::getShopId, shopId).list();
if (CollUtil.isEmpty(list)) { if (CollUtil.isEmpty(list)) {
updateChain() orderInfoService.updateById(new OrderInfo().setId(orderId)
.set(OrderInfo::getStatus, OrderStatusEnums.CANCELLED.getCode()) .setStatus(OrderStatusEnums.CANCELLED.getCode())
.set(OrderInfo::getOriginAmount, BigDecimal.ZERO) .setOriginAmount(BigDecimal.ZERO));
.eq(OrderInfo::getShopId, shopId)
.eq(OrderInfo::getId, orderId);
return true; return true;
} else { } else {
BigDecimal totalAmount = BigDecimal.ZERO; BigDecimal totalAmount = BigDecimal.ZERO;
@@ -1712,11 +1699,9 @@ public class OrderInfoCustomServiceImpl extends OrderInfoServiceImpl implements
.update(); .update();
} }
} }
updateChain().eq(OrderInfo::getId, orderId) orderInfoService.updateById(new OrderInfo().setId(orderId)
.eq(OrderInfo::getShopId, shopId) .setOriginAmount(totalAmount)
.set(OrderInfo::getOriginAmount, totalAmount) .setPlaceNum(orderInfo.getPlaceNum() - 1));
.set(OrderInfo::getPlaceNum, orderInfo.getPlaceNum() - 1)
.update();
} }
return true; return true;
} }
@@ -1724,7 +1709,7 @@ public class OrderInfoCustomServiceImpl extends OrderInfoServiceImpl implements
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Boolean updatePayOrderId(Long orderId, Long paymentId, String payType, String remark) { public Boolean updatePayOrderId(Long orderId, Long paymentId, String payType, String remark) {
mapper.updatePayOrderId(orderId, paymentId, payType, remark); orderInfoCustomMapper.updatePayOrderId(orderId, paymentId, payType, remark);
return true; return true;
} }
@@ -1767,12 +1752,12 @@ public class OrderInfoCustomServiceImpl extends OrderInfoServiceImpl implements
orderDetailService.updateChain().set(OrderDetail::getSubStatus, TableValueConstant.OrderDetail.SubStatus.READY_TO_SERVE.getCode()) orderDetailService.updateChain().set(OrderDetail::getSubStatus, TableValueConstant.OrderDetail.SubStatus.READY_TO_SERVE.getCode())
.eq(OrderDetail::getId, detailStatusDTO.getOrderDetailId()).update(); .eq(OrderDetail::getId, detailStatusDTO.getOrderDetailId()).update();
// 上菜 // 上菜
}else { } else {
if (detailStatusDTO.getOrderId() != null) { if (detailStatusDTO.getOrderId() != null) {
orderDetailService.updateChain().eq(OrderDetail::getSubStatus, TableValueConstant.OrderDetail.SubStatus.READY_TO_SERVE.getCode()) orderDetailService.updateChain().eq(OrderDetail::getSubStatus, TableValueConstant.OrderDetail.SubStatus.READY_TO_SERVE.getCode())
.set(OrderDetail::getSubStatus, TableValueConstant.OrderDetail.SubStatus.SENT_OUT.getCode()) .set(OrderDetail::getSubStatus, TableValueConstant.OrderDetail.SubStatus.SENT_OUT.getCode())
.eq(OrderDetail::getOrderId, detailStatusDTO.getOrderId()).update(); .eq(OrderDetail::getOrderId, detailStatusDTO.getOrderId()).update();
}else { } else {
orderDetailService.updateChain().eq(OrderDetail::getSubStatus, TableValueConstant.OrderDetail.SubStatus.READY_TO_SERVE.getCode()) orderDetailService.updateChain().eq(OrderDetail::getSubStatus, TableValueConstant.OrderDetail.SubStatus.READY_TO_SERVE.getCode())
.set(OrderDetail::getSubStatus, TableValueConstant.OrderDetail.SubStatus.SENT_OUT.getCode()) .set(OrderDetail::getSubStatus, TableValueConstant.OrderDetail.SubStatus.SENT_OUT.getCode())
.eq(OrderDetail::getId, detailStatusDTO.getOrderDetailId()).update(); .eq(OrderDetail::getId, detailStatusDTO.getOrderDetailId()).update();

View File

@@ -94,7 +94,9 @@ public class PayServiceImpl implements PayService {
@Resource @Resource
private CzgPayService czgPayService; private CzgPayService czgPayService;
@Resource @Resource
private OrderInfoCustomServiceImpl orderInfoService; private OrderInfoCustomService orderInfoCustomService;
@Resource
private OrderInfoService orderInfoService;
@Resource @Resource
private OrderDetailService orderDetailService; private OrderDetailService orderDetailService;
@Resource @Resource
@@ -121,7 +123,7 @@ public class PayServiceImpl implements PayService {
private final BigDecimal MONEY_RATE = new BigDecimal("100"); private final BigDecimal MONEY_RATE = new BigDecimal("100");
private OrderInfo checkPay(CheckOrderPay checkOrderPay) { private OrderInfo checkPay(CheckOrderPay checkOrderPay) {
OrderInfo orderInfo = orderInfoService.checkOrderPay(checkOrderPay); OrderInfo orderInfo = orderInfoCustomService.checkOrderPay(checkOrderPay);
if (orderInfo.getOrderAmount().compareTo(BigDecimal.ZERO) == 0) { if (orderInfo.getOrderAmount().compareTo(BigDecimal.ZERO) == 0) {
//发送打票信息 //发送打票信息
//orderId_0_0 订单ID_先付后付(1先付0后付)_订单状态 0未完成 1完成 //orderId_0_0 订单ID_先付后付(1先付0后付)_订单状态 0未完成 1完成
@@ -151,7 +153,7 @@ public class PayServiceImpl implements PayService {
} }
CheckOrderPay checkOrderPay = payParam.getCheckOrderPay(); CheckOrderPay checkOrderPay = payParam.getCheckOrderPay();
// CheckOrderPay checkOrderPay = BeanUtil.copyProperties(payParam, CheckOrderPay.class); // CheckOrderPay checkOrderPay = BeanUtil.copyProperties(payParam, CheckOrderPay.class);
OrderInfo orderInfo = orderInfoService.checkOrderPay(checkOrderPay.setFreeDine(true).setWithCoupon(freeConfig.getWithCoupon()).setWithPoints(freeConfig.getWithPoints())); OrderInfo orderInfo = orderInfoCustomService.checkOrderPay(checkOrderPay.setFreeDine(true).setWithCoupon(freeConfig.getWithCoupon()).setWithPoints(freeConfig.getWithPoints()));
payParam.setAmount(orderInfo.getOrderAmount().multiply(BigDecimal.valueOf(freeConfig.getRechargeTimes()))); payParam.setAmount(orderInfo.getOrderAmount().multiply(BigDecimal.valueOf(freeConfig.getRechargeTimes())));
return true; return true;
} }
@@ -165,7 +167,7 @@ public class PayServiceImpl implements PayService {
AssertUtil.isNull(payParam.getCreditBuyerId(), "请选择挂账人后支付"); AssertUtil.isNull(payParam.getCreditBuyerId(), "请选择挂账人后支付");
OrderInfo orderInfo = checkPay(payParam.getCheckOrderPay()); OrderInfo orderInfo = checkPay(payParam.getCheckOrderPay());
orderInfo.setCreditBuyerId(payParam.getCreditBuyerId()); orderInfo.setCreditBuyerId(payParam.getCreditBuyerId());
orderInfoService.upOrderInfo(orderInfo, orderInfo.getOrderAmount(), orderInfoCustomService.upOrderInfo(orderInfo, orderInfo.getOrderAmount(),
LocalDateTime.now(), null, PayEnums.CREDIT_PAY); LocalDateTime.now(), null, PayEnums.CREDIT_PAY);
//挂账后续逻辑 //挂账后续逻辑
buyerOrderService.save(payParam.getCreditBuyerId().toString(), orderInfo.getId()); buyerOrderService.save(payParam.getCreditBuyerId().toString(), orderInfo.getId());
@@ -176,7 +178,7 @@ public class PayServiceImpl implements PayService {
@Transactional(noRollbackFor = PaySuccessException.class) @Transactional(noRollbackFor = PaySuccessException.class)
public CzgResult<Object> cashPayOrder(OrderPayParamDTO payParam) { public CzgResult<Object> cashPayOrder(OrderPayParamDTO payParam) {
OrderInfo orderInfo = checkPay(payParam.getCheckOrderPay()); OrderInfo orderInfo = checkPay(payParam.getCheckOrderPay());
orderInfoService.upOrderInfo(orderInfo, orderInfo.getOrderAmount(), orderInfoCustomService.upOrderInfo(orderInfo, orderInfo.getOrderAmount(),
LocalDateTime.now(), null, PayEnums.CASH_PAY); LocalDateTime.now(), null, PayEnums.CASH_PAY);
return CzgResult.success(); return CzgResult.success();
} }
@@ -247,7 +249,7 @@ public class PayServiceImpl implements PayService {
memberConfigService.deliver(shopUser, TableValueConstant.MemberExpFlow.Type.COST, orderInfo.getOrderAmount(), null, orderInfo.getId()); memberConfigService.deliver(shopUser, TableValueConstant.MemberExpFlow.Type.COST, orderInfo.getOrderAmount(), null, orderInfo.getId());
Long flowId = shopUserService.updateMoney(shopUserMoneyEditDTO); Long flowId = shopUserService.updateMoney(shopUserMoneyEditDTO);
orderInfoService.upOrderInfo(orderInfo, orderInfo.getOrderAmount(), orderInfoCustomService.upOrderInfo(orderInfo, orderInfo.getOrderAmount(),
LocalDateTime.now(), flowId, PayEnums.VIP_PAY); LocalDateTime.now(), flowId, PayEnums.VIP_PAY);
@@ -327,7 +329,7 @@ public class PayServiceImpl implements PayService {
if (payParam.getCheckOrderPay().getOrderAmount() == null || payParam.getCheckOrderPay().getOrderAmount().compareTo(BigDecimal.ZERO) <= 0) { if (payParam.getCheckOrderPay().getOrderAmount() == null || payParam.getCheckOrderPay().getOrderAmount().compareTo(BigDecimal.ZERO) <= 0) {
throw new CzgException("支付金额不合法"); throw new CzgException("支付金额不合法");
} }
orderInfo = orderInfoService.createPayOrder(payParam.getShopId(), payParam.getCheckOrderPay().getOrderAmount(), orderInfo = orderInfoCustomService.createPayOrder(payParam.getShopId(), payParam.getCheckOrderPay().getOrderAmount(),
payParam.getCheckOrderPay().getRemark()); payParam.getCheckOrderPay().getRemark());
} else { } else {
orderInfo = orderInfoService.getById(payParam.getCheckOrderPay().getOrderId()); orderInfo = orderInfoService.getById(payParam.getCheckOrderPay().getOrderId());
@@ -403,7 +405,7 @@ public class PayServiceImpl implements PayService {
CzgResult<Map<String, Object>> mapCzgResult = microPay(payParam.getShopId(), new CzgMicroPayReq(payOrderNo, orderInfo.getOrderAmount().multiply(MONEY_RATE).longValue(), CzgResult<Map<String, Object>> mapCzgResult = microPay(payParam.getShopId(), new CzgMicroPayReq(payOrderNo, orderInfo.getOrderAmount().multiply(MONEY_RATE).longValue(),
"点餐支付", payParam.getAuthCode(), payParam.getBuyerRemark(), "")); "点餐支付", payParam.getAuthCode(), payParam.getBuyerRemark(), ""));
if (mapCzgResult.getCode() == 200) { if (mapCzgResult.getCode() == 200) {
orderInfoService.upOrderInfo(orderInfo, orderInfo.getOrderAmount(), orderInfoCustomService.upOrderInfo(orderInfo, orderInfo.getOrderAmount(),
LocalDateTime.now(), paymentId, PayEnums.BACK_SCAN); LocalDateTime.now(), paymentId, PayEnums.BACK_SCAN);
} else { } else {
upOrderPayInfo(orderInfo.getId(), PayEnums.BACK_SCAN, paymentId, upOrderPayInfo(orderInfo.getId(), PayEnums.BACK_SCAN, paymentId,
@@ -860,7 +862,7 @@ public class PayServiceImpl implements PayService {
if (paymentId == null) { if (paymentId == null) {
throw new CzgException("未获取到支付记录"); throw new CzgException("未获取到支付记录");
} }
orderInfoService.updatePayOrderId(orderId, paymentId, payType.getValue(), remark); orderInfoCustomService.updatePayOrderId(orderId, paymentId, payType.getValue(), remark);
} }