package cn.pluss.platform.controller.merchantProfit;

import cn.pluss.platform.api.Result;
import cn.pluss.platform.api.ResultGenerator;
import cn.pluss.platform.base.BaseModelController;
import cn.pluss.platform.entity.MerchantProfit;
import cn.pluss.platform.merchantProfit.MerchantProfitService;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.math.BigDecimal;
import java.util.Map;


/**
 * 商户订单分润表
 * @author Administrator
 * @date: 2022/2/9 18:18
 */
@Controller
@RequestMapping("merchantProfit")
public class MerchantProfitController extends BaseModelController<MerchantProfitService, MerchantProfit> {

    /**
     * 引导页
     *
     * @return
     */
    @RequestMapping(value = "/index", method = RequestMethod.GET)
    public String index() {
        return "merchantProfit/list";
    }

    @Override
    public Result<Page<MerchantProfit>> page(Page<MerchantProfit> page, MerchantProfit condition, OrderItem orderItem) {
        orderItem.setColumn("id");
        orderItem.setAsc(false);
        return super.page(page, condition, orderItem);
    }

    @RequestMapping(value = "countData")
    @ResponseBody
    public Result<Object> countData(MerchantProfit condition){
        Map<String, BigDecimal> count = baseService.getProfitAmtCount(condition);
        return ResultGenerator.genSuccessResult("获取成功",count);
    }
}


