CosPlayPlayerController.java 5.13 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 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;	
    }

}