package com.hzs.sale.order.service.impl;

import cn.hutool.json.JSONUtil;
import com.google.gson.JsonObject;
import com.hzs.common.core.enums.EApprovalBusiness;
import com.hzs.common.domain.sale.order.SaOrder;
import com.hzs.common.security.utils.SecurityUtils;
import com.hzs.sale.order.service.ISaOrderRevokeService;
import com.hzs.system.sys.IApprovalServiceApi;
import com.hzs.system.sys.dto.ApprovalSubmitDTO;
import com.hzs.system.sys.dto.LoginUser;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

/**
 * @Description: 撤单逻辑类
 * @Author: sui q
 * @Time: 2022/10/27 10:50
 * @Classname: SaOrderRevokeServiceImpl
 * @PackageName: com.hzs.sale.order.service.impl
 */
@Service
public class SaOrderRevokeServiceImpl implements ISaOrderRevokeService {

    @DubboReference
    private IApprovalServiceApi approvalServiceApi;

    @Override
    public void revokeSaOrder(SaOrder saOrder, LoginUser loginUser) {
        ApprovalSubmitDTO approvalSubmitDTO = ApprovalSubmitDTO.builder()
                .eApprovalBusiness(EApprovalBusiness.ORDER_CANCEL)
                .businessCode(saOrder.getOrderCode())
                .businessData(JSONUtil.toJsonStr(saOrder))
                .build();
        approvalServiceApi.submit(approvalSubmitDTO, loginUser);
    }
}
