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

View File

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

View File

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

View File

@@ -18,6 +18,6 @@ public interface OrderDetailService extends IService<OrderDetail> {
List<OrderDetailPrintVo> getOrderDetailPrint(Long orderId);
// 更新订单详情状态 将订单详情的状态为wait-pay 更新为 payed
// 更新订单详情状态 将订单详情的状态为wait-pay 更新为 done
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.mybatisflex.spring.service.impl.ServiceImpl;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.context.annotation.Primary;
/**
* @author Administrator
*/
@DubboService
@Primary
public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo> implements OrderInfoService {
}

View File

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

View File

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

View File

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