/*
 * Copyright (c) 2018-2999 广州亚米信息科技有限公司 All rights reserved.
 *
 * https://www.gz-yami.com/
 *
 */

package com.yami.shop.multishop.controller;

import cn.hutool.core.util.StrUtil;
import com.yami.shop.bean.model.ShopWalletLog;
import com.yami.shop.security.multishop.util.SecurityUtils;
import com.yami.shop.service.ShopWalletLogService;
import com.yami.shop.common.annotation.SysLog;

import javax.validation.Valid;

import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import lombok.AllArgsConstructor;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yami.shop.common.util.PageParam;
import com.baomidou.mybatisplus.core.metadata.IPage;


/**
 * 商家钱包记录
 *
 * @author Dwl
 * @date 2019-09-19 14:02:57
 */
@RestController
@AllArgsConstructor
@RequestMapping("/shop/shopWalletLog" )
public class ShopWalletLogController {

    private final ShopWalletLogService shopWalletLogService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param shopWalletLog 商家钱包记录
     * @return 分页数据
     */
    @GetMapping("/page" )
    public ResponseEntity<IPage<ShopWalletLog>> getShopWalletLogPage(PageParam<ShopWalletLog> page, ShopWalletLog shopWalletLog) {
        return ResponseEntity.ok(shopWalletLogService.page(page, new LambdaQueryWrapper<ShopWalletLog>()
                .eq(StrUtil.isNotBlank(shopWalletLog.getOrderNumber()), ShopWalletLog::getOrderNumber, shopWalletLog.getOrderNumber())
                .eq(shopWalletLog.getAmountType() != null, ShopWalletLog::getAmountType, shopWalletLog.getAmountType())
                .eq(shopWalletLog.getIoType() != null, ShopWalletLog::getIoType, shopWalletLog.getIoType())
                .eq(shopWalletLog.getReason() != null, ShopWalletLog::getReason,shopWalletLog.getReason())
                .eq(ShopWalletLog::getShopId, SecurityUtils.getShopUser().getShopId()).orderByDesc(ShopWalletLog::getWalletLogId)));
    }

}
