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

import com.neusoft.smart.pos.dto.fumao.request.PostFumaoTradeOrderRequest;
import com.neusoft.smart.pos.dto.payment.response.FumaoMemberInfoRes;
import com.neusoft.smart.pos.dto.payment.response.FumaoParameterforNextStep;
import com.neusoft.smart.pos.dto.promotion.request.GetPreferentialPriceRequest;
import com.neusoft.smart.pos.dto.promotion.request.PromotionPayChannelQueryRequest;
import com.neusoft.smart.pos.dto.promotion.request.PromotionPayChannelRequest;
import com.neusoft.smart.pos.dto.promotion.response.GetPreferentialPriceResponse;
import com.neusoft.smart.pos.dto.promotion.response.PromotionPayChannelResponse;
import com.neusoft.smart.pos.framework.bean.PaginationExtendBean;
import com.neusoft.smart.pos.framework.dto.ResponseData;
import com.neusoft.smart.pos.framework.utils.SpringUtils;
import com.neusoft.smart.pos.fumao.service.FumaoBusinessService;
import com.neusoft.smart.pos.fumao.service.IBusinessService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.val;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@CrossOrigin(origins = "*", maxAge = 3600)// TODO
@RestController("/fumao")
@Slf4j
@Api(value = "服务交易类接口", description = "服务交易类接口")
@RequestMapping(path = "/fumao")
public class FumaoController {
    
    @ApiOperation(value = "环境准备/登录")
    @PostMapping("/environmentPrepare/login")
    public FumaoParameterforNextStep environmentPrepare() {
    	val fumaoService = SpringUtils.getBean("FumaoBusinessService",IBusinessService.class);
    	return (FumaoParameterforNextStep)fumaoService.environmentPrepare();
        //return new ResponseData<>(fumaoService.getPreferentialPriceNew(getPreferentialPriceRequest));
    }
    
    @ApiOperation(value = "支付准备/会员及优惠券获取及试算")
    @PostMapping("/executePrepare/checkMem")
    public FumaoParameterforNextStep executePrepare(@RequestBody PostFumaoTradeOrderRequest postFumaoTradeOrderRequest) {
    	val fumaoService = SpringUtils.getBean("FumaoBusinessService",IBusinessService.class);
        return (FumaoParameterforNextStep)fumaoService.executePrepare(postFumaoTradeOrderRequest);
    }
    
    @ApiOperation(value = "支付交易")
//    @PutMapping("/execute/payment")
    @PostMapping("/execute/payment")
    public FumaoParameterforNextStep execute(@RequestBody PostFumaoTradeOrderRequest postFumaoTradeOrderRequest) {
    	val fumaoService = SpringUtils.getBean("FumaoBusinessService",IBusinessService.class);
        return (FumaoParameterforNextStep)fumaoService.execute(postFumaoTradeOrderRequest);
    }
    
    @ApiOperation(value = "完成/订单同步")
//    @DeleteMapping("/complete/syncOrder/{id}")
    @PutMapping("/complete/syncOrder")
    public FumaoParameterforNextStep complete(@RequestBody PostFumaoTradeOrderRequest postFumaoTradeOrderRequest) {
    	val fumaoService = SpringUtils.getBean("FumaoBusinessService",IBusinessService.class);
    	return (FumaoParameterforNextStep)fumaoService.complete(postFumaoTradeOrderRequest);
    }

//    @ApiOperation(value = "完成/订单同步")
//    @PutMapping("/complete/syncOrder")
//    public FumaoParameterforNextStep complete(@RequestBody PostFumaoTradeOrderRequest postFumaoTradeOrderRequest) {
//        val fumaoService = SpringUtils.getBean("FumaoBusinessService",IBusinessService.class);
//        return (FumaoParameterforNextStep)fumaoService.complete(postFumaoTradeOrderRequest);
//    }

}
