package com.hai.order.service.impl;

import com.hai.entity.HighChildOrder;
import com.hai.entity.HighCouponCode;
import com.hai.order.service.OrderCancelHandleService;
import com.hai.service.HighCouponCodeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @className: CancelOrderBusServiceImpl
 * @author: HuRui
 * @date: 2022/8/29
 **/
@Service("cancelOrderHandleService")
public class OrderCancelHandleServiceImpl implements OrderCancelHandleService {

    @Resource
    private HighCouponCodeService couponCodeService;

    @Override
    public void couponHandle(HighChildOrder childOrder)  {
        // 解除兑换码与订单的关系
        HighCouponCode couponCode = couponCodeService.getCodeByChildOrderNo(childOrder.getChildOrderNo());
        if (couponCode != null ) {
            couponCode.setChildOrderNo(null);
            couponCode.setStatus(1);
            couponCodeService.updateCouponCode(couponCode);
        }
    }
}
