AiccWeChatLogic.php 1.3 KB
<?php

namespace App\Http\Logic\Aside\Aicc;

use App\Enums\Common\Code;
use App\Http\Logic\Logic;
use App\Models\AICC\AiccWechat;
use Illuminate\Support\Facades\DB;

class AiccWeChatLogic extends Logic
{
    public function saveData($data)
    {
        $wx = new AiccWechat();
        DB::beginTransaction();
        try {
            $status = $wx->saveData($data);
            DB::commit();
        } catch (\Exception $e) {
            DB::rollBack();
            $e->getMessage();
            errorLog('V6与AICC关联失败', $wx, $e);
            $this->fail('请检查操作是否正确!', Code::SERVER_MYSQL_ERROR);
        }
        return $status;
    }

    /**
     * @return array
     */
    public function AiccWeChatLists($page = 1, $perPage = 15)
    {
        $status      = 1; # 1 - 正常, 0 - 禁用
        $lists       = AiccWechat::query()->where('status', $status)
                                 ->whereNotNull('project_id')
                                 ->whereNotNull('wx_user_id')
                                 ->paginate($perPage, ['project_id', 'wx_id', 'wx_user_id'], 'page', $page);
        $items       = $lists->Items();
        $totalPage   = $lists->lastPage();
        $total       = $lists->total();
        $currentPage = $lists->currentPage();
        return compact('total', 'items', 'totalPage', 'currentPage');
    }
}