package com.iformall.controller.market;

import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.dto.WxUserCouponDto;
import com.iformall.service.WxUserCouponService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by syf on 2018/8/10.
 */
@RestController
@RequestMapping("wxUserCoupon")
@Api(description = "会员卡券查询接口")
public class WxUserCouponController extends BaseController {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());


    @Autowired
    private WxUserCouponService wxUserCouponService;


    @ApiOperation("查询用户卡券接口")
    @PostMapping("findByStatus")
    @SystemControllerLog(description = "会员管理-查询用户卡券接口")
    public ResultData findByStatus(@RequestBody WxUserCouponDto wxUserCoupon) {
        logger.debug("[" + getIpAddr() + "] WxUserCouponController::findByStatus");
        //根据用户id,用户卡券状态查找
        if(wxUserCoupon==null||wxUserCoupon.getCUserId()==null||wxUserCoupon.getCouponStatus()==null){
            return new ResultData(Result.ERROR,"查询失败");
        }
        return new ResultData(Result.SUCCESS,"查询成功",wxUserCouponService.findList(wxUserCoupon.getCUserId(),wxUserCoupon.getCouponStatus()));
    }




}
