package com.cool.store.controller.webb;

import com.cool.store.request.store.PreAllocationAddRequest;
import com.cool.store.request.store.PreAllocationEditRequest;
import com.cool.store.request.store.PreAllocationQueryShopRequest;
import com.cool.store.request.store.PreAllocationSaveRequest;
import com.cool.store.request.store.TransRequest;
import com.cool.store.response.ResponseResult;
import com.cool.store.service.store.PreAllocationRecordService;
import com.cool.store.vo.order.PreAllocationRecordVO;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @Auther zx_szh
 * @Date 2026/2/4 16:37
 * @Version 1.0
 */
@Api(tags="标准店-预分账明细管理")
@RestController
@RequestMapping("/pc/preAllocation")
@RequiredArgsConstructor
public class PreAllocationRecordController {

    private final PreAllocationRecordService preAllocationRecordService;

    @ApiOperation("批量保存预分账明细")
    @PostMapping("/saveBatch")
    public ResponseResult<Boolean> saveBatch(@RequestBody @Valid PreAllocationSaveRequest req){
        return ResponseResult.success(preAllocationRecordService.saveBatch(req));
    }

    @ApiOperation("单费用类型独立分账")
    @PostMapping("/trans")
    public ResponseResult<Boolean> queryByShop(@RequestBody @Valid TransRequest request ){
        return ResponseResult.success(preAllocationRecordService.trans(request));
    }

    @ApiOperation("按门店查询预分账明细")
    @GetMapping("/queryByShop")
    public ResponseResult<List<PreAllocationRecordVO>> queryByShop(@RequestParam(value = "shopId" ,required = true) Long shopId){
        return ResponseResult.success(preAllocationRecordService.queryByShop(shopId));
    }

    @ApiOperation("新增预分账记录")
    @PostMapping("/add")
    public ResponseResult<Boolean> add(@RequestBody @Valid PreAllocationAddRequest request){
        return ResponseResult.success(preAllocationRecordService.add(request));
    }

    @ApiOperation("编辑预分账记录")
    @PostMapping("/edit")
    public ResponseResult<Boolean> edit(@RequestBody @Valid PreAllocationEditRequest request){
        return ResponseResult.success(preAllocationRecordService.edit(request));
    }

    @ApiOperation("删除预分账记录")
    @PostMapping("/delete")
    public ResponseResult<Boolean> delete(@RequestParam(value = "id" ,required = true) Long id){
        return ResponseResult.success(preAllocationRecordService.delete(id));
    }

}
