package com.neusoft.smart.pos.card.controller;

import com.neusoft.smart.pos.card.dto.*;
import com.neusoft.smart.pos.card.service.CardCapitalChangeService;
import com.neusoft.smart.pos.dto.member.request.MemberCapitalChangeQueryRequest;
import com.neusoft.smart.pos.dto.member.response.MemberCapitalChangeResponse;
import com.neusoft.smart.pos.framework.bean.PaginationExtendBean;
import com.neusoft.smart.pos.framework.dto.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.math.BigDecimal;
import java.util.List;

@Api(value = "卡内资金变动restful接口", description = "卡内资金变动restful接口")
@RestController
public class CardCapitalChangeController {

    @Resource
    private CardCapitalChangeService cardCapitalChangeService;

	@GetMapping("/cardCapitalChanges")
	@ApiOperation(value = "卡资金积分变动列表接口", notes = "卡资金积分变动列表接口")
	public ResponseData<?> queryCardCapitalChangeList(@RequestParam("orgId") Integer orgId
			, @RequestParam(value="startTime",defaultValue = "") String startTime
			, @RequestParam(value="endTime",defaultValue = "") String endTime
			, @RequestParam(value="dateTime",defaultValue = "") String dateTime
			, @RequestParam(value="timeMode",defaultValue = "") String timeMode
			, @RequestParam(value="changeTypes",defaultValue = "") List<Integer> changeTypes
			, @RequestParam("cardNum") String cardNum
			, @RequestParam("offset") Integer offset
			, @RequestParam("limit") Integer limit
			, @RequestParam("isPage") Boolean isPage) {
		CardCapitalChangeQueryRequest cardCapitalChangeQueryRequest = new CardCapitalChangeQueryRequest();
		cardCapitalChangeQueryRequest.setStartTime(startTime);
		cardCapitalChangeQueryRequest.setEndTime(endTime);
		cardCapitalChangeQueryRequest.setDateTime(dateTime);
		cardCapitalChangeQueryRequest.setTimeMode(timeMode);
		cardCapitalChangeQueryRequest.setChangeTypes(changeTypes);
		cardCapitalChangeQueryRequest.setCardNum(cardNum);
		cardCapitalChangeQueryRequest.setOffset(offset);
		cardCapitalChangeQueryRequest.setLimit(limit);
		cardCapitalChangeQueryRequest.setIsPage(isPage);
		return new ResponseData<>(cardCapitalChangeService.queryCardCapitalChangeList(cardCapitalChangeQueryRequest));
	}
	
	//会员卡资金积分变得列表接口
	@PostMapping("/memberCapitalChanges")
	@ApiOperation(value = "会员卡资金积分变得列表接口", notes = "会员卡资金积分变得列表接口")
	public ResponseData<?> list(@RequestBody MemberCapitalChangeQueryRequest memberCapitalChangeQueryRequest) {
		//MemberCapitalChangeServiceInterface memberCapitalChangeService = SpringUtils.getBean(MemberCapitalChangeService.class);
		PaginationExtendBean<MemberCapitalChangeResponse> paginationExtendBean = new PaginationExtendBean<>();
		paginationExtendBean.setRows(cardCapitalChangeService.getList(memberCapitalChangeQueryRequest));
		paginationExtendBean.setTotal(cardCapitalChangeService.getCount(memberCapitalChangeQueryRequest));
		return new ResponseData<>(paginationExtendBean);
	}
}
