<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的多应用管理平台
// +----------------------------------------------------------------------
// | 官方网址:https://www.niucloud.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------

namespace app\adminapi\controller\shop\site;

use app\dict\shop\ShopAccountDict;
use app\service\admin\shop\site\ShopAccountLogService;
use app\service\admin\shop\site\ShopService;
use core\base\BaseAdminController;
use think\Response;

class Shop extends BaseAdminController
{
    /**
     * 店铺资产概况
     * @return Response
     */
    public function accountInfo():Response
    {
        return success((new ShopService())->getAccountInfo());
    }

    /**
     * 店铺账单记录
     * @return Response
     */
    public function accountLists()
    {
        $data = $this->request->params([
            ['from_type', ''],
            ['related_id', ''],
            ['create_time', []],
        ]);
        return success((new ShopAccountLogService())->getPage($data));
    }

    /**
     * 店铺账单类型
     * @return Response
     */
    public function getAccountType()
    {
        return success(ShopAccountDict::getType());
    }

    /**
     * 店铺收款方式编辑
     */
    public function setShopAccount()
    {
        $data = $this->request->params([
            ['bank_type', ''],
            ['bank_account_name', ''],
            ['bank_account_no', ''],
            ['bank_name', ''],
            ['bank_address', ''],
            ['alipay_name', ''],
            ['alipay_account_no', ''],
            ['alipay_payment_code', ''],
            ['wechat_name', ''],
            ['wechat_account_no', ''],
            ['wechat_payment_code', ''],
        ]);
        ( new ShopService() )->edit($data);
        return success('EDIT_SUCCESS');
    }

    /**
     * 检查店铺配置信息是否完善
     */
    public function checkAccountPayInfo()
    {
        $data = [];
        if (( new ShopService() )->check()) {
            $data['is_fill'] = 1;
        } else {
            $data['is_fill'] = 0;
        }
        return success($data);
    }
}