package com.sqx.modules.shopping.controller.app;


import com.sqx.modules.app.annotation.Login;
import com.sqx.modules.shopping.service.OrdersRelationService;
import com.sqx.modules.shopping.utils.Result;
import com.sqx.modules.shopping.utils.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(value="自营商城订单分销",tags={"自营商城订单分销管理"})
@RequestMapping(value = "/app/ordersRelation")
public class AppOrdersRelationController {
    @Autowired
    private OrdersRelationService service;

    @Login
    @GetMapping("/list")
    @ApiOperation("订单分销列表")
    public Result findAll(Integer page, Integer size,
                          @ApiParam("用户id") @RequestParam(required = false) Long userId,
                          @ApiParam("用户手机号") @RequestParam(required = false) String phone,
                          @ApiParam("分销 0全部 1未到账 2已到账") @RequestParam(required = false) Integer status,
                          @ApiParam("佣金来源 0全部 1团队 2自己)") @RequestParam(required = false) Integer moneyFrom) {
        return service.findAll(page, size, userId, phone, status, moneyFrom);
    }

    @GetMapping("/find")
    @ApiOperation("查询")
    public Result findOne(Long id) {
        return service.findOne(id);
    }

    @Login
    @GetMapping("/statistaical")
    @ApiOperation("我的佣金统计")
    public Result statistaical(@RequestAttribute Long userId) {
        return service.statistaical(userId);
    }

    @Login
    @GetMapping("/tuanStatistaical")
    @ApiOperation("团队佣金统计")
    public Result tuanStatistaical(@RequestAttribute Long userId) {
        return service.tuanStatistaical(userId);
    }

    @Login
    @GetMapping(value = "/tuanSum")
    @ApiOperation("获取团队总收益")
    public Result tuanSum(@RequestAttribute Long userId) {
        return ResultUtil.success(service.tuanSum(userId));
    }



}
