<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2018/8/16
 * Time: 10:27
 */
namespace App\Http\Controllers\Channel\Behavior;

use App\Http\Controllers\Channel\BaseController;
use App\Modules\Channel\Models\Behavior;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;

class BehaviorController extends BaseController {
    /**
     * @apiDefine behavior 用户行为
     */


    /**
     * @apiVersion 1.0.0
     * @apiDescription 用户行为上传
     * @api {post} behavior/upload 自主评分
     * @apiGroup behavior
     * @apiParam {String} action 点击行为 ['manual'-操作指南,'bookRecom'-书籍推荐,'noticePromote'-促销活动(通知公告),'withdraw'-提现事宜,'notice'-平台通知
    'query'-用户查询,
    'sumData'-数据汇总,
    'promoteNovel'-小说推广,'rankNovel'-小说排行,'pagePromote'-页面推广,'businessPromote'-促销活动(推广运营),'smartPush'-智能推送,'templateMsg'-模版消息,'clientMsg'-客服消息,'picArtElem'-图文素材,'miniProgram'-小程序,'keywordRe'-关键字回复
    'promoteStats'-推广统计,'pushStats'-推送统计,'rechargeRecord'-充值记录,'balanceCenter'-结算中心
    'serviceAccountSet'-服务号设置,'ClientSet'-客服设置,'siteList'-站点列表]
     * @apiName score
     * @apiSuccess  {int}  code 状态码
     * @apiSuccess  {String}  msg 信息
     * @apiSuccess  {object}  data 结果集
     * @apiSuccessExample {json} Success-Response:
     *     {
     *       "code": 0,
     *       "msg": "",
     *       "data": {
     *       }
     */
    public function userBehaviorUpload(Request $request) {
        if(!$request->has('action')){
            return response()->error('PARAM_EMPTY');
        }
        $action = $request->input('action');
        $hay_stack = ['manual','bookRecom','noticePromote',
        'withdraw','notice', 'query', 'sumData','promotionNovel',
        'rankNovel','pagePromote','businessPromote','smartPush',
        'templateMsg','clientMsg','picArtElem','miniProgram','keywordRe',
        'promoteStats','pushStats','rechargeRecord','balanceCenter',
        'serviceAccountSet','ClientSet','siteList'];
        if(!in_array($action,$hay_stack)){
            return response()->error('PARAM_ERROR');
        }
        $data = array(
            'uid'=>$this->getChannelUserId(),
            'action' =>$action,
        );
        Behavior::create($data);
        return response()->success();
    }
}