<?php
/*
 本代码由 焕岱科技 创建
 技术支持 WX：15285007200
 严禁反编译、逆向等任何形式的侵权行为，违者将追究法律责任
*/

namespace app\api\controller\contribution;

use app\api\controller\Base;
use think\Db;

class User extends Base
{
    protected $noNeedLogin = [];
    protected $noNeedRight = ['*'];
    
    public $model = null;
    public function _initialize(){
        parent::_initialize();
        $this->model = new \app\common\model\bbfxshop\Contribution;
    }

    public function index(){

        $contribution_value1 = Db::name("bbfx_money_log")->where(['uniacid'=>UNIACID,'type'=>8,'money'=>['>',0],'user_id'=>$this->user['id'],'item_type'=>38])->sum("money");
        $contribution_value2 = Db::name("bbfx_money_log")->where(['uniacid'=>UNIACID,'type'=>8,'money'=>['>',0],'user_id'=>$this->user['id'],'item_type'=>39])->sum("money");
        $contribution_value3 = Db::name("bbfx_money_log")->where(['uniacid'=>UNIACID,'type'=>8,'money'=>['>',0],'user_id'=>$this->user['id'],'item_type'=>40])->sum("money");
        $contribution_value4 = Db::name("bbfx_money_log")->where(['uniacid'=>UNIACID,'type'=>8,'money'=>['>',0],'user_id'=>$this->user['id'],'item_type'=>42])->sum("money");
        $score = Db::name("bbfx_money_log")->where(['uniacid'=>UNIACID,'type'=>2,'money'=>['>',0],'user_id'=>$this->user['id'],'item_type'=>43])->sum("money");

        $result = [
            'contribution_value'=>$this->user['contribution_value_total'],
            'contribution_value1'=>round($contribution_value1,2),
            'contribution_value2'=>round($contribution_value2,2),
            'contribution_value3'=>round($contribution_value3,2),
            'contribution_value4'=>round($contribution_value4,2),
            'score'=>round($score,2),
        ];

        __success('操作成功',$result);
    }
}