package cn.pluss.platform.controller.openAccount;


import cn.pluss.platform.api.Result;
import cn.pluss.platform.api.ResultGenerator;
import cn.pluss.platform.base.BaseModelController;
import cn.pluss.platform.entity.OpenAccountRecord;
import cn.pluss.platform.openAccount.OpenAccountRecordService;
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.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 用户开户奖励明细 前端控制器
 * </p>
 *
 * @author crystal
 * @since 2022-06-14
 */
@Controller
@RequestMapping("/openAccountRecord")
public class OpenAccountRecordController extends BaseModelController<OpenAccountRecordService, OpenAccountRecord> {


    @RequestMapping(method = {RequestMethod.GET, RequestMethod.POST}, value = "/index")
    public String index(HttpServletRequest request) {
        return "openAccount/recordList";
    }

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

    @RequestMapping(method = {RequestMethod.GET, RequestMethod.POST}, value = "/refund/{orderNumber}")
    @ResponseBody
    public Result refund(@PathVariable("orderNumber") String orderNumber) {
        return baseService.refund(orderNumber);
    }

    /**
     * 数据统计
     * @param condition
     * @return
     */
    @RequestMapping(value = "countData")
    @ResponseBody
    public Result countData(OpenAccountRecord condition){
        return baseService.countData(condition);
    }
}
