package com.sqx.modules.shop.controller;

import com.sqx.common.utils.Result;
import com.sqx.modules.shop.dto.ShopAuditDTO;
import com.sqx.modules.shop.dto.ShopAuditUpdateDTO;
import com.sqx.modules.shop.service.ShopMessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.math.BigDecimal;

@Api(tags={"管理端-商户管理"})
@RestController
@RequestMapping("/admin/shop")
public class AdminShopMessageController {

    @Autowired
    private ShopMessageService shopMessageService;

    @ApiOperation("审核商户入驻")
    @PutMapping(value = "/audit-shop/{shopId}")
    public Result auditShopAuthentication(@PathVariable Long shopId, @Valid ShopAuditDTO dto){

        return shopMessageService.auditShopAuthentication(shopId, dto);
    }

    @ApiOperation("修改商户入驻申请")
    @PutMapping(value = "{shopId}")
    public Result updateShopAuthentication(@PathVariable Long shopId, @RequestBody ShopAuditUpdateDTO dto){
        shopMessageService.updateShopAuthentication(shopId, dto);
        return Result.success();
    }

    @ApiOperation("查看商户列表")
    @GetMapping(value = "selectShopList")
    public Result selectShopList(Integer page, Integer limit, String shopName, Integer status, Integer shopType){

        return shopMessageService.selectShopList(page, limit, shopName, status, shopType);
    }

    @ApiOperation("修改商户保证金")
    @GetMapping(value = "updateShopCashDeposit")
    public Result updateShopCashDeposit(Long shopId, BigDecimal money, Integer type){

        return shopMessageService.updateShopCashDeposit(shopId, money, type);
    }

    @ApiOperation("查看商户保证金明细")
    @GetMapping(value = "selectShopCashDepositList")
    public Result selectShopCashDepositList(Integer page, Integer limit, Long shopId){

        return shopMessageService.selectShopCashDepositList(page, limit, shopId);
    }

}
