<?php
namespace app\common\listener;

use app\api\logic\PropertyCommissionLogic;
use think\facade\Log;

/**
 * 物业分成收益事件监听
 * Class PropertyCommissionListener
 * @package app\listener
 */
class PropertyCommissionListener
{
    public function handle($params)
    {
        try {
            if (empty($params['id'])) {
                throw new \Exception('工单id不能为空');
            }
            $result = PropertyCommissionLogic::commissionSurplus($params);
            if (false === $result) {
                throw new \Exception(PropertyCommissionLogic::getError());
            }
            return true;
        } catch (\Exception $e) {
            Log::write('物业收益分成失败:'.$e->getMessage());
            return $e->getMessage();
        }
    }
}