package cn.superdesk.uniorder.service.accounting.unified.supplier.Impl;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONUtil;
import cn.superdesk.uniorder.common.enums.accounting.AccountingOrderDimCreateByEnum;
import cn.superdesk.uniorder.common.enums.accounting.supplier.AccountingOrderSupplierAccountingStatusEnum;
import cn.superdesk.uniorder.common.enums.common.CommonAccountingStateEnum;
import cn.superdesk.uniorder.common.enums.common.CommonSourceFromEnum;
import cn.superdesk.uniorder.common.exception.UnifiedOrderRuntimeException;
import cn.superdesk.uniorder.common.json.AnJsonUtils;
import cn.superdesk.uniorder.common.lamda.AnLamdaUtils;
import cn.superdesk.uniorder.common.security.dto.LoginSysUser;
import cn.superdesk.uniorder.dao.entity.accounting.unified.supplier.AccountingUnifiedSupplier;
import cn.superdesk.uniorder.dao.entity.accounting.unified.supplier.AccountingUnifiedSupplierOrder;
import cn.superdesk.uniorder.dao.entity.accounting.unified.supplier.AccountingUnifiedSupplierXGoods;
import cn.superdesk.uniorder.dao.mapper.accounting.unified.supplier.*;
import cn.superdesk.uniorder.dao.mapper.base.*;
import cn.superdesk.uniorder.executor.scheduler.kafka._thirdpart.qchjc.QchjcStatementKafkaEventPublisher;
import cn.superdesk.uniorder.executor.scheduler.kafka._thirdpart.qchjc.dto.accounting.supplier.QchjcSupplierStatementEvent;
import cn.superdesk.uniorder.executor.scheduler.kafka._thirdpart.qchjc.dto.accounting.supplier.QchjcSupplierStatementEventSingleStructVo;
import cn.superdesk.uniorder.pattern.state.accounting.supplier.accountingUnifiedSupplier.accountingStatus.context.AccountingUnifiedSupplierFieldAccountingStatusContext;
import cn.superdesk.uniorder.service.accounting.unified.supplier.AccountingUnifiedSupplierFieldAccountingStatusService;
import cn.superdesk.uniorder.service.accounting.unified.supplier.AccountingUnifiedSupplierService;
import cn.superdesk.uniorder.service.accounting.unified.supplier.AccountingUnifiedSupplierXGoodsService;
import cn.superdesk.uniorder.service.order.base.UnifiedOrderCreditService;
import cn.superdesk.uniorder.service.order.base.UnifiedOrderGoodsService;
import cn.superdesk.uniorder.service.order.base.UnifiedOrderService;
import cn.superdesk.uniorder.service.invoice.supplier.InvoiceApplySupplierService;
import cn.superdesk.uniorder.service.invoice.supplier.InvoiceApplySupplierXGoodsService;
import cn.superdesk.uniorder.service.setting.UnifiedSnConfigService;
import cn.superdesk.uniorder.service.sys.SysUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @Description: 简易状态机 星型结构
 * @Author: linjinyu
 * @CreateDate: 10/12/20 4:28 PM
 * @UpdateUser: linjinyu
 * @UpdateDate: 10/12/20 4:28 PM
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
@Slf4j
@Service
public class AccountingUnifiedSupplierFieldAccountingStatusServiceImpl implements AccountingUnifiedSupplierFieldAccountingStatusService {

    @Autowired
    private AccountingUnifiedSupplierService accountingUnifiedSupplierService;

    @Autowired
    private UnifiedOrderMapper unifiedOrderMapper;
    @Autowired
    private UnifiedOrderMapperEx unifiedOrderMapperEx;
    @Autowired
    private UnifiedOrderMapperExSupplierDimOrder unifiedOrderMapperExSupplierDimOrder;
    @Autowired
    private UnifiedOrderService unifiedOrderService;

    @Autowired
    private UnifiedOrderGoodsMapper unifiedOrderGoodsMapper;
    @Autowired
    private UnifiedOrderGoodsMapperEx unifiedOrderGoodsMapperEx;
    @Autowired
    private UnifiedOrderGoodsService unifiedOrderGoodsService;

    @Autowired
    private UnifiedOrderCreditMapper unifiedOrderCreditMapper;
    @Autowired
    private UnifiedOrderCreditService unifiedOrderCreditService;

    @Autowired
    private AccountingUnifiedSupplierMapper accountingUnifiedSupplierMapper;
    @Autowired
    private AccountingUnifiedSupplierMapperEx accountingUnifiedSupplierMapperEx;

    @Autowired
    private AccountingUnifiedSupplierOrderMapper accountingUnifiedSupplierOrderMapper;
    @Autowired
    private AccountingUnifiedSupplierXOrderMapperEx accountingUnifiedSupplierXOrderMapperEx;

    @Autowired
    private AccountingUnifiedSupplierXGoodsMapper accountingUnifiedSupplierXGoodsMapper;
    @Autowired
    private AccountingUnifiedSupplierXGoodsMapperEx accountingUnifiedSupplierXGoodsMapperEx;
    @Autowired
    private InvoiceApplySupplierService invoiceApplySupplierService;
    @Autowired
    private InvoiceApplySupplierXGoodsService invoiceApplySupplierXGoodsService;

    @Autowired
    private AccountingUnifiedSupplierXGoodsService accountingUnifiedSupplierXGoodsService;

    @Autowired
    private UnifiedSnConfigService unifiedSnConfigService;

    @Autowired
    private SysUserService sysUserService;

    /**************************************** superdesk-uniorder-executor start ****************************************/

    @Autowired
    private QchjcStatementKafkaEventPublisher qchjcStatementEventPublisher;

    /**************************************** superdesk-uniorder-executor   end ****************************************/

    /****************************************** 状态机 公共方法 机内使用 实际流转 重用 start ******************************************/

    // 状态流转为 待提交(3, "待提交")
    public void opInitOrResetByStateMachine(AccountingUnifiedSupplier entity, LoginSysUser loginSysUser) {

        AccountingUnifiedSupplier forUpdate = new AccountingUnifiedSupplier();
        forUpdate.setId(entity.getId());

        // TODO 更新状态逻辑...

        forUpdate.setAccountingStatus(AccountingOrderSupplierAccountingStatusEnum.待提交.getKey());
        forUpdate.setUpdateTime(DateUtil.date());
        forUpdate.setUpdateUserId(loginSysUser.getSysUserId());

        accountingUnifiedSupplierService.updateFieldByPrimaryKeySelective(forUpdate);
    }

    // 状态流转为 未确认(0, "未确认")
    public void opSubmitByStateMachine(AccountingUnifiedSupplier entity, LoginSysUser loginSysUser) {

        AccountingUnifiedSupplier forUpdate = new AccountingUnifiedSupplier();
        forUpdate.setId(entity.getId());

        // TODO 更新状态逻辑...

        forUpdate.setAccountingStatus(AccountingOrderSupplierAccountingStatusEnum.未确认.getKey());
        forUpdate.setUpdateTime(DateUtil.date());
        forUpdate.setUpdateUserId(loginSysUser.getSysUserId());

        accountingUnifiedSupplierService.updateFieldByPrimaryKeySelective(forUpdate);
    }

    // 状态流转为 已确认(1, "已确认")
    public void opConfirmByStateMachine(AccountingUnifiedSupplier entity, LoginSysUser loginSysUser) {

        AccountingUnifiedSupplier forUpdate = new AccountingUnifiedSupplier();
        forUpdate.setId(entity.getId());

        // TODO 更新状态逻辑...

        forUpdate.setAccountingStatus(AccountingOrderSupplierAccountingStatusEnum.已确认.getKey());
        forUpdate.setUpdateTime(DateUtil.date());
        forUpdate.setUpdateUserId(loginSysUser.getSysUserId());

        accountingUnifiedSupplierService.updateFieldByPrimaryKeySelective(forUpdate);
    }

    // 状态流转为 已拒绝(2, "已拒绝")
    public void opRejectByStateMachine(AccountingUnifiedSupplier entity, LoginSysUser loginSysUser) {

        AccountingUnifiedSupplier forUpdate = new AccountingUnifiedSupplier();
        forUpdate.setId(entity.getId());

        // TODO 更新状态逻辑...

        forUpdate.setAccountingStatus(AccountingOrderSupplierAccountingStatusEnum.已拒绝.getKey());
        forUpdate.setUpdateTime(DateUtil.date());
        forUpdate.setUpdateUserId(loginSysUser.getSysUserId());

        accountingUnifiedSupplierService.updateFieldByPrimaryKeySelective(forUpdate);
    }

    // 状态流转为 已取消(-1, "已取消")
    public void opCancelByStateMachine(AccountingUnifiedSupplier entity, LoginSysUser loginSysUser) {

        AccountingUnifiedSupplier forUpdate = new AccountingUnifiedSupplier();
        forUpdate.setId(entity.getId());

        // TODO 更新状态逻辑...

        forUpdate.setAccountingStatus(AccountingOrderSupplierAccountingStatusEnum.已取消.getKey());

        forUpdate.setUpdateTime(DateUtil.date());
        forUpdate.setUpdateUserId(loginSysUser.getSysUserId());

        accountingUnifiedSupplierService.updateFieldByPrimaryKeySelective(forUpdate);

        // 释放关系 相关商品对账状态
        opRejectFaceInner(entity, loginSysUser);
    }

    /****************************************** 状态机 公共方法 机内使用 实际流转 重用   end ******************************************/


    /****************************************** 状态机 外部使用 类门面 start ******************************************/

    // 状态流转为 待提交(3, "待提交")
    public void opInitOrReset(AccountingUnifiedSupplier entity, LoginSysUser loginSysUser) {
        AccountingUnifiedSupplierFieldAccountingStatusContext context = new AccountingUnifiedSupplierFieldAccountingStatusContext(entity, loginSysUser);
        context.opInitOrReset();
    }

    // 状态流转为 未确认(0, "未确认")
    public void opSubmit(AccountingUnifiedSupplier entity, LoginSysUser loginSysUser) {
        AccountingUnifiedSupplierFieldAccountingStatusContext context = new AccountingUnifiedSupplierFieldAccountingStatusContext(entity, loginSysUser);
        context.opSubmit();
    }

    // 状态流转为 已确认(1, "已确认")
    public void opConfirm(AccountingUnifiedSupplier entity, LoginSysUser loginSysUser) {
        AccountingUnifiedSupplierFieldAccountingStatusContext context = new AccountingUnifiedSupplierFieldAccountingStatusContext(entity, loginSysUser);
        context.opConfirm();
    }

    // 状态流转为 已拒绝(2, "已拒绝")
    public void opReject(AccountingUnifiedSupplier entity, LoginSysUser loginSysUser) {
        AccountingUnifiedSupplierFieldAccountingStatusContext context = new AccountingUnifiedSupplierFieldAccountingStatusContext(entity, loginSysUser);
        context.opReject();
    }

    // 状态流转为 已取消(-1, "已取消")
    public void opCancel(AccountingUnifiedSupplier entity, LoginSysUser loginSysUser) {
        AccountingUnifiedSupplierFieldAccountingStatusContext context = new AccountingUnifiedSupplierFieldAccountingStatusContext(entity, loginSysUser);
        context.opCancel();
    }

    /****************************************** 状态机 外部使用 类门面   end ******************************************/


    /****************************************** 旧 start ******************************************/


    /**
     * 拒绝接受;不予考虑
     * <p>
     * 重新对账 取消对账 申诉对账 等 操作指向
     * <p>
     * 取消操作 -> 对账单状态 -> 已取消(-1, "已取消"), void opCancel(AccountingUnifiedSupplier statementOfAccount);
     * 重新对账 -> 对账单状态 -> 已取消(-1, "已取消"), void opAgain(AccountingUnifiedSupplier statementOfAccount);
     *
     * @param existDB
     * @param loginSysUser
     */
    @Transactional(rollbackFor = Exception.class)
    private void opRejectFaceInner(AccountingUnifiedSupplier existDB, LoginSysUser loginSysUser) {

        log.info("##################### cn/superdesk/uniorder/service/unified/impl/UnifiedSupplierDzServiceImpl.java start #####################");
        log.info("params UnifiedSupplierDz:\n" + AnJsonUtils.toPrettyJson(existDB));

        // 重新对帐嘛 这边先是更新一下这个 供应商对帐单 状态 状态是什么呢? 这个是要查一下
//        accountingUnifiedSupplierMapper.updateByPrimaryKeySelective(statementOfAccount);


        /****************************************** 更新 供应商 对账单 状态 start ******************************************/

//		AccountingUnifiedSupplier forUpdate = new AccountingUnifiedSupplier();
//		forUpdate.setId(statementOfAccount.getId());
//		forUpdate.setAccountingStatus(AccountingOrderCustomerAccountingStatusEnum.已取消.getKey());
//		forUpdate.setUpdateTime(DateUtil.date());
//		forUpdate.setUpdateUserId(loginSysUser.getSysUserId());
//
//		accountingUnifiedSupplierService.updateObj(forUpdate);

        /****************************************** 更新 供应商 对账单 状态   end ******************************************/

        List<String> processOrderSn = new ArrayList<>();
        List<Long> processSysUnifiedOrderGoodsIds = new ArrayList<>();
        List<Long> processOutGoodsIds = new ArrayList<>();

        DateTime now = DateUtil.date();


        switch (AccountingOrderDimCreateByEnum.get(existDB.getDimCreateBy())) {

            case 订单:

                // 拿 供应商对帐单 sn 来查出 这个对帐单 的订单
                Map<String, Object> params = new HashMap<>();
                params.put("accountingOrderSn", existDB.getAccountingOrderSn());

                // 此为一个中间表吧 反正不是原始的订单
                // 只有四个字段
                // 1. 供应商对帐单SN
                // 2. 原始订单SN(来源各业务系统)
                // 3. 销售价?(整个订单?包含运费什么的吗?)
                // 4. 成品价?
                List<AccountingUnifiedSupplierOrder> statementOfAccountXOrders = accountingUnifiedSupplierXOrderMapperEx.findAll(params);

                if (CollUtil.isNotEmpty(statementOfAccountXOrders)) {

                    processOrderSn = statementOfAccountXOrders
                            .stream()
                            .filter(AnLamdaUtils.distinctByKey(o -> o.getOrderSn()))
                            .map(AccountingUnifiedSupplierOrder::getOrderSn)
                            .collect(Collectors.toList());

                    // 更新 订单 供应商对账状态
                    unifiedOrderService.updateAccountingStateSupplierByOrderSns(processOrderSn, CommonAccountingStateEnum.未对账);

                    // 更新 商品 供应商对账状态
                    unifiedOrderGoodsService.updateAccountingStateSupplierByOrderSn(processOrderSn, CommonAccountingStateEnum.未对账);

                    // 更新 流水 供应商对账状态 20200925 供应商结算 创建对账单 如果 积分流水 有的话 关联 更新状态 为 已对账状态
                    unifiedOrderCreditService.updateFieldAccountingStateSupplierByOrderSn(processOrderSn, CommonAccountingStateEnum.未对账);
                }


                break;

            case 商品:

                List<AccountingUnifiedSupplierXGoods> statementOfAccountXGoods = accountingUnifiedSupplierXGoodsService.findByAccountingOrderSn(existDB.getAccountingOrderSn());

                if (CollUtil.isNotEmpty(statementOfAccountXGoods)) {

                    processOrderSn = statementOfAccountXGoods.stream().filter(AnLamdaUtils.distinctByKey(o -> o.getOrderSn())).map(AccountingUnifiedSupplierXGoods::getOrderSn).collect(Collectors.toList());
                    processSysUnifiedOrderGoodsIds = statementOfAccountXGoods.stream().filter(AnLamdaUtils.distinctByKey(o -> o.getUnifiedOrderGoodsId())).map(AccountingUnifiedSupplierXGoods::getUnifiedOrderGoodsId).collect(Collectors.toList());
                    processOutGoodsIds = statementOfAccountXGoods.stream().filter(o -> o.getGoodsId() != null).filter(AnLamdaUtils.distinctByKey(o -> o.getGoodsId())).map(AccountingUnifiedSupplierXGoods::getGoodsId).collect(Collectors.toList());
                    if (CommonSourceFromEnum.企业商城_侨城汇.getSourceFromCode().equals(existDB.getSourceFrom())) {
                        /**
                         * 集采重新对账 -> 改为不对账
                         */
                        // 更新 订单 供应商对账状态 -> 已对账 这个是错的,商品维度可能有部分对账的情况
                        unifiedOrderService.updateAccountingStateSupplierByOrderSns(processOrderSn, CommonAccountingStateEnum.不对账);

                        // 更新 商品 供应商对账状态 -> 已对账
                        unifiedOrderGoodsService.updateAccountingStateSupplierByOrderSnAndSysUnifiedOrderGoodsIds(processOrderSn, processSysUnifiedOrderGoodsIds, CommonAccountingStateEnum.不对账);

                        // 更新 流水 供应商对账状态  -> 已对账 20200925 供应商结算 创建对账单 如果 积分 流水 有的话 关联 更新状态 为 已对账状态
                        unifiedOrderCreditService.updateFieldAccountingStateSupplierByOrderSnAndOutGoodsIds(processOrderSn, processOutGoodsIds, CommonAccountingStateEnum.不对账);

                    } else {
                        // 更新 订单 供应商对账状态 -> 已对账 这个是错的,商品维度可能有部分对账的情况
                        unifiedOrderService.updateAccountingStateSupplierByOrderSns(processOrderSn, CommonAccountingStateEnum.未对账);

                        // 更新 商品 供应商对账状态 -> 已对账
                        unifiedOrderGoodsService.updateAccountingStateSupplierByOrderSnAndSysUnifiedOrderGoodsIds(processOrderSn, processSysUnifiedOrderGoodsIds, CommonAccountingStateEnum.未对账);

                        // 更新 流水 供应商对账状态  -> 已对账 20200925 供应商结算 创建对账单 如果 积分 流水 有的话 关联 更新状态 为 已对账状态
                        unifiedOrderCreditService.updateFieldAccountingStateSupplierByOrderSnAndOutGoodsIds(processOrderSn, processOutGoodsIds, CommonAccountingStateEnum.未对账);
                    }
                }


                break;

            case 流水:

                throw new UnifiedOrderRuntimeException(500, "供应商结算 对账单 目前不支持 流水维度");
            default:
                break;
        }


        // TODO 20200925 供应商结算 对账单 重新对账 如果 积分 流水 有的话 关联 更新状态 为 未对账状态


        /****************************************** 重构 上边的逻辑 20200925   end ******************************************/

        log.info("##################### cn/superdesk/uniorder/service/unified/impl/UnifiedSupplierDzServiceImpl.java end   #####################");

        // 触发事件点;
        // 1. 来源于“企业商城”的对账单在**“供应商结算-对账单-【重新对账】”成功时**；
        qchjcStatementEventPublisher.supplierStatementEventStatementCancelSync(
                QchjcSupplierStatementEvent
                        .builder()
                        .msg("供应商结算v2.3-对账单-op重新对账")

                        .singleStructVo(
                                QchjcSupplierStatementEventSingleStructVo
                                        .builder()
                                        .accountingOrderId(existDB.getId())
                                        .accountingOrderSn(existDB.getAccountingOrderSn())

                                        .invoiceApplyId(0L)
                                        .invoiceApplySn("")
                                        .build()
                        )


                        .loginSysUser(JSONUtil.toJsonStr(loginSysUser))
                        .touchTime(now)

                        .build()
        );

    }

    @Transactional
    @Override
    public int opDelete(AccountingUnifiedSupplier statementOfAccount, LoginSysUser loginSysUser) {

        opRejectFaceInner(statementOfAccount, loginSysUser);

        return accountingUnifiedSupplierMapper.deleteByPrimaryKey(statementOfAccount.getId());

    }


    /****************************************** 状态机 公共方法 机内使用 实际流转 重用 start ******************************************/

//	@Transactional
//	@Override
//	public void opCancelByStateMachine(AccountingUnifiedSupplier statementOfAccount, LoginSysUser loginSysUser) {
//
//		opRejectFaceInner(statementOfAccount, loginSysUser);
//	}

//	@Transactional
//	@Override
//	public void opAgainByStateMachine(AccountingUnifiedSupplier statementOfAccount, LoginSysUser loginSysUser) {
//
//		opRejectFaceInner(statementOfAccount, loginSysUser);
//	}

//	@Transactional
//	@Override
//	public void opSubmitByStateMachine(AccountingUnifiedSupplier statementOfAccount, LoginSysUser loginSysUser) {
//
//		AccountingUnifiedSupplier forUpdate = new AccountingUnifiedSupplier();
//		forUpdate.setId(statementOfAccount.getId());
//		forUpdate.setAccountingStatus(AccountingOrderCustomerAccountingStatusEnum.未确认.getKey());
//		forUpdate.setUpdateTime(DateUtil.date());
//		forUpdate.setUpdateUserId(loginSysUser.getSysUserId());
//
//		accountingUnifiedSupplierService.updateObj(forUpdate);
//	}

//	@Transactional
//	@Override
//	public void opConfirmByStateMachine(AccountingUnifiedSupplier statementOfAccount, LoginSysUser loginSysUser) {
//
//		AccountingUnifiedSupplier forUpdate = new AccountingUnifiedSupplier();
//		forUpdate.setId(statementOfAccount.getId());
//		forUpdate.setAccountingStatus(AccountingOrderCustomerAccountingStatusEnum.已确认.getKey());
//		forUpdate.setUpdateTime(DateUtil.date());
//		forUpdate.setUpdateUserId(loginSysUser.getSysUserId());
//
//		accountingUnifiedSupplierService.updateObj(forUpdate);
//	}

//	@Transactional
//	@Override
//	public void opAppealByStateMachine(AccountingUnifiedSupplier statementOfAccount, LoginSysUser loginSysUser) {
//
//		AccountingUnifiedSupplier forUpdate = new AccountingUnifiedSupplier();
//		forUpdate.setId(statementOfAccount.getId());
//		forUpdate.setAccountingStatus(AccountingOrderCustomerAccountingStatusEnum.已拒绝.getKey());
//		forUpdate.setUpdateTime(DateUtil.date());
//		forUpdate.setUpdateUserId(loginSysUser.getSysUserId());
//
//		accountingUnifiedSupplierService.updateObj(forUpdate);
//	}

    /****************************************** 状态机 公共方法 机内使用 实际流转 重用   end ******************************************/


//	/****************************************** 状态机 外部使用 类门面 start ******************************************/
//
//	// 创建操作 -> 对账单状态 -> 待提交(3, "待提交"),
//	public void opCreate(AccountingUnifiedSupplier statementOfAccount, LoginSysUser loginSysUser) {
//
//
//	}
//
//	// 提交操作 -> 对账单状态 -> 未确认(0, "未确认"),// 已提交
//	public void opSubmit(AccountingUnifiedSupplier statementOfAccount, LoginSysUser loginSysUser) {
//		StatementOfAccountContext context = new StatementOfAccountContext(statementOfAccount, loginSysUser);
//		context.opSubmit();
//	}
//
//	// 取消操作 -> 对账单状态 -> 已取消(-1, "已取消"),
//	public void opCancel(AccountingUnifiedSupplier statementOfAccount, LoginSysUser loginSysUser) {
//		StatementOfAccountContext context = new StatementOfAccountContext(statementOfAccount, loginSysUser);
//		context.opCancel();
//	}
//
//	// 重新对账操作 -> 对账单状态 -> 已取消(-1, "已取消"),
//	public void opAgain(AccountingUnifiedSupplier statementOfAccount, LoginSysUser loginSysUser) {
//		StatementOfAccountContext context = new StatementOfAccountContext(statementOfAccount, loginSysUser);
//		context.opAgain();
//	}
//
//	// 确认操作 -> 对账单状态 -> 已确认(1, "已确认"),
//	public void opConfirm(AccountingUnifiedSupplier statementOfAccount, LoginSysUser loginSysUser) {
//		StatementOfAccountContext context = new StatementOfAccountContext(statementOfAccount, loginSysUser);
//		context.opConfirm();
//	}
//
//	// 申诉操作 -> 对账单状态 -> 已拒绝(2, "已拒绝"),
//	public void opAppeal(AccountingUnifiedSupplier statementOfAccount, LoginSysUser loginSysUser) {
//		StatementOfAccountContext context = new StatementOfAccountContext(statementOfAccount, loginSysUser);
//		context.opAppeal();
//	}
//
//	/****************************************** 状态机 外部使用 类门面   end ******************************************/
}
