<?php

namespace app\api\controller\company;

use app\common\controller\Apic;
use think\Db;

/**
 * 会员接口
 */
class Index extends Apic
{
    protected $noNeedLogin = [];
    protected $noNeedRight = '*';


    //首页
    public function index(){


    }

    //首页轮播
    public function banner(){
        $where = [
            'status'     => 1,
            'position'  => 1
        ];
        $list = Db::name('platform_banner')->where($where)->order('weigh asc,id asc')->select();
        $list = list_domain_image($list,['image']);
        $this->success(1,$list);
    }

    //商家钱包明细
    public function money_log(){
        $type = input('type',0);

        $map = [
            'user_id' => $this->auth->id,
        ];
        if($type){
            $map['log_type'] = $type;
        }

        $list = Db::name('company_money_log')
            ->field('id,log_type,change_value,remain,remark,createtime')
            ->where($map)->order('id desc')->autopage()->select();
        $list = $this->list_appen_logtext($list);

        $this->success(1,$list);
    }

    //追加log_text
    private function list_appen_logtext($list){
        if(!empty($list)){
            $conf = config('wallet.logtype');
            foreach($list as $key => $val){
                $list[$key]['log_text'] = isset($conf[$val['log_type']]) ? $conf[$val['log_type']] : '';
            }
        }
        return $list;
    }



}
