CosPlayPlayerController.java 9.99 KB
package com.pipi.qa.controller.common;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;
import com.pipi.qa.bean.Player;
import com.pipi.qa.bean.Room;
import com.pipi.qa.bean.User;
import com.pipi.qa.service.CosPlayPlayerService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * Created by dennis.dong on 2021/5/18
 */
@CrossOrigin(origins = "*", maxAge = 3600)
@Controller
@RequestMapping(value = "/play")
@Api(value = "", tags = "")
public class CosPlayPlayerController {
    @Autowired
    private CosPlayPlayerService cosPlayPlayerService;
    
    private String token = null;
    
    private String userId = null;
    
    public Logger logger = LoggerFactory.getLogger(CosPlayPlayerController.class);

    /**
     * 申请陪玩师
     * @param PlayerApply
     * @return
     */
    @ApiOperation(value = "申请陪玩师", notes = "输入手机号")
    @RequestMapping(value = "/PlayerApply", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject PlayerApply(@RequestBody Player player) {
    	String mobile = player.getMobile();
    	String env = player.getEnv();
    	JSONObject loginRes = cosPlayPlayerService.login(mobile, env);
    	token = loginRes.getJSONObject("data").getString("token");
		userId = loginRes.getJSONObject("data").getString("id");
    	cosPlayPlayerService.SubmitAuthentication(token, userId, env);
    	JSONObject jsonObj = cosPlayPlayerService.saveUserInfo(token, userId, env);
    	logger.info("env:"+env+"mobile:"+mobile);
		return jsonObj;	
    }
    
    /**
     * 陪玩师申请入驻
     * @param PlayerApply
     * @return
  */
    @ApiOperation(value = "陪玩师申请入驻", notes = "输入手机号")
    @RequestMapping(value = "/saveInfoTech", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject saveInfoTech(@RequestBody Player player) {
    	String mobile = player.getMobile();
    	String env = player.getEnv();
    	String techLevelId = player.getTechLevelId();
		String id =player.getId();
		String categoryId = player.getCategoryId();
		//登录获取token、userId
		JSONObject loginRes = cosPlayPlayerService.login(mobile, env);
    	token = loginRes.getJSONObject("data").getString("token");
		userId = loginRes.getJSONObject("data").getString("id");
		JSONObject jsonObj = cosPlayPlayerService.saveInfoTech(token, userId, categoryId, techLevelId, env);
    	logger.info("env:"+env+"mobile:"+mobile);
		return jsonObj;	
    }
       
    /**
     * 申请陪玩师及入驻
     * @param PlayerApply
     * @return
  */
    @ApiOperation(value = "申请陪玩师及入驻", notes = "输入手机号")
    @RequestMapping(value = "/playerApplyAndSaveInfoTech", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject playerApplyAndSaveInfoTech(@RequestBody Player player) {
    	String mobile = player.getMobile();
    	String env = player.getEnv();
    	String techLevelId = player.getTechLevelId();
		String id =player.getId();
		String categoryId = player.getCategoryId();
		//登录获取token、userId
		JSONObject loginRes = cosPlayPlayerService.login(mobile, env);
		token = loginRes.getJSONObject("data").getString("token");
		userId = loginRes.getJSONObject("data").getString("id");
		//申请陪玩师
		cosPlayPlayerService.SubmitAuthentication(token, userId, env);
		//提交陪玩师资料
    	cosPlayPlayerService.saveUserInfo(token, userId, env);
    	//申请陪玩师技能
		JSONObject jsonObj = cosPlayPlayerService.saveInfoTech(token, userId, categoryId, techLevelId, env);
    	logger.info("env:"+env+"mobile:"+mobile);
		return jsonObj;	
    }
       
    
    /**
     *充钻石
     * @param User
     * @return
     */
    @ApiOperation(value = "充钻石", notes = "输入手机号,充值金额")
    @RequestMapping(value = "/virtualMoneyModify", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject virtualMoneyModify(@RequestBody User user) {
    	String mobile = user.getMobile();
    	long money = user.getMoney();
    	String env = user.getEnv();
    	JSONObject jsonObj = cosPlayPlayerService.virtualMoneyModify(mobile, money, env);
		return jsonObj;	
    }
    
    /**
     *充皮皮币
     * @param User
     * @return
     */
    @ApiOperation(value = "充皮皮币", notes = "输入手机号,充值金额")
    @RequestMapping(value = "/moneyDetailsSave", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject moneyDetailsSave(@RequestBody User user) {
    	String mobile = user.getMobile();
    	long money = user.getMoney();
    	String env = user.getEnv();
    	JSONObject jsonObj = cosPlayPlayerService.moneyDetailsSave(mobile, money, env);
		return jsonObj;	
    }

    /**
     *送礼物
     * @param PlayerApply
     * @return
     */
    @ApiOperation(value = "送礼物", notes = "输入手机号,房间ID、用户")
    @RequestMapping(value = "/roomGiftSend", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject roomGiftSend(@RequestBody Room room) {
    	String mobile = room.getMobile();
    	String env = room.getEnv();
    	String userIds = room.getUserIds();
    	String productId = room.getProductId();
    	String roomNo = room.getRoomNo();
		String amount = room.getAmount();
		JSONObject jsonObj = cosPlayPlayerService.send(mobile, roomNo, productId, amount ,userIds, env);
		return jsonObj;	
    } 
    
    /**
     *查询礼物列表
     * @param PlayerApply
     * @return
     */
    @ApiOperation(value = "查询礼物列表", notes = "选择环境")
    @RequestMapping(value = "/giftList", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject giftList(@RequestBody Room room) {
    	String env = room.getEnv();
		JSONObject jsonObj = cosPlayPlayerService.giftList(env);
		return jsonObj;	
    }
    
    /**
     *幸运夺宝箱列表
     * @param PlayerApply
     * @return
     */
    @ApiOperation(value = "幸运夺宝箱列表", notes = "选择环境")
    @RequestMapping(value = "/activityList", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject activityList(@RequestBody Room room) {
    	String env = room.getEnv();
		JSONObject jsonObj = cosPlayPlayerService.activityList(env);
		return jsonObj;	
    }
    
    /**
     *开宝箱
     * @param PlayerApply
     * @return
     */
    @ApiOperation(value = "开宝箱", notes = "输入手机号,房间ID、用户")
    @RequestMapping(value = "/lotteryActivity", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject lotteryActivity(@RequestBody Room room) {
    	String mobile = room.getMobile();
    	String env = room.getEnv();
    	String roomNo = room.getRoomNo();
		String times = room.getTimes();
		String activityId = room.getActivityId();
		JSONObject jsonObj = cosPlayPlayerService.lotteryActivity(mobile, roomNo, activityId, times, env);
		return jsonObj;	
    }
    
    /**
     *创建公会
     * @param PlayerApply
     * @return
     */
    @ApiOperation(value = "创建公会", notes = "是否开启自定义分成,1开启,0不开启,guildBiz语音1,游戏2,全部0")
    @RequestMapping(value = "/guildCreate", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject guildCreate(@RequestBody User user) {
    	String mobile = user.getMobile();
    	String env = user.getEnv();
    	long guildBiz = user.getGuildBiz();
    	long openStatus = user.getOpenStatus();
    	JSONObject jsonObj = cosPlayPlayerService.guildCreate(mobile, openStatus, guildBiz, env);
		return jsonObj;	
    }
    
    /**
     *申请加入公会
     * @param guildCenter
     * @return
     */
    @ApiOperation(value = "申请加入公会", notes = "支持按公会ID申请加入,需要审核")
    @RequestMapping(value = "/guildCenter", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject guildCenter(@RequestBody Room room) {
    	String mobile = room.getMobile();
    	String env = room.getEnv();
    	String guildCode = room.getGuildCode();
    	JSONObject jsonObj = cosPlayPlayerService.guildCenter(mobile, guildCode, env);
		return jsonObj;	
    }
    
    /**
     *审核加入公会
     * @param applyList
     * @return
     */
    @ApiOperation(value = "审核加入公会", notes = "审核人员")
    @RequestMapping(value = "/applyList", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject applyList(@RequestBody Room room) {
    	String mobile = room.getMobile();
    	String env = room.getEnv();
    	String guildCode = room.getGuildCode();
    	JSONObject jsonObj = cosPlayPlayerService.applyList(mobile, env);
		return jsonObj;	
    }
    
    /**
     *加入公会及审核
     * @param applyList
     * @return
     */
    @ApiOperation(value = "申请加入公会及审核", notes = "审核人员")
    @RequestMapping(value = "/auditGuild", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject auditGuild(@RequestBody Room room) {
    	String mobile = room.getMobile();
    	String env = room.getEnv();
    	String guildCode = room.getGuildCode();
    	JSONObject jsonObj = cosPlayPlayerService.auditGuild(mobile, guildCode, env);
		return jsonObj;	
    }
    
    
    
    /**
     *创建厅
     * @param roomSave
     * @return
     */
    @ApiOperation(value = "创建厅", notes = "")
    @RequestMapping(value = "/roomSave", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject roomSave(@RequestBody Room room) {
    	String mobile = room.getMobile();
    	String env = room.getEnv();
    	long roomCategoryId = room.getRoomCategoryId();
    	long roomType = room.getRoomType();
    	String roomName = room.getRoomName();
    	JSONObject jsonObj = cosPlayPlayerService.roomSave(mobile, roomName, roomType, roomCategoryId, env);
		return jsonObj;	
    } 
}