package org.springblade.gateway.client_gateway.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.core.tool.api.R;
import org.springblade.ldt.bills.entity.Bills;
import org.springblade.ldt.bills.service.IBillsService;
import org.springblade.gateway.client_gateway.entity.vo.AgenterInfoVO;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;

/**
 * @author: lianghanqiang
 * @description: 代理控制器
 * @since: 8/23/21 -- 2:54 PM
 */
@RestController
@RequestMapping("/app/agent")
@Api(tags = "APP代理商模块")
@AllArgsConstructor
public class AgentController {

	private IBillsService billsService;

	@ApiOperation("获取代理商信息")
	@GetMapping("agenterInfo")
	public R<AgenterInfoVO> agenterInfo(@NotBlank String userId){
		return R.data(AgenterInfoVO.builder().build());
	}

	@ApiOperation("获取收益明细")
	@GetMapping("earningsDetail")
	public R earningsDetail(@NotBlank String userId){
		return R.data(null);
	}

	@ApiOperation("获取推广明细")
	@GetMapping("promoteDetail")
	public R promoteDetail(@NotBlank String userId){
		return R.data(null);
	}

	@ApiOperation("提交申请订单")
	@PostMapping("addAgentOrder")
	public R addAgentOrder(@Valid @RequestBody Bills bills){

		return billsService.saveOrUpdate(bills)?
			 R.data(bills): R.fail("提交订单失败！");
	}
}
