package org.jeecg.api.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.api.bean.PageBean;
import org.jeecg.api.service.AppletIndexService;
import org.jeecg.api.service.AppletOrderService;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.commonAddOrder.entity.CommonAddOrder;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags="订单接口")
@RestController
@RequestMapping("/order")
@Slf4j
public class AppletOrderController {

    @Resource
    private AppletOrderService appletOrderService;

    // 获取订单列表带分页
    @ApiOperation(value="获取订单列表带分页", notes="获取订单列表带分页")
    @GetMapping(value = "/getOrderPageBean")
    public Result<?> getOrderPageBean(@RequestHeader("X-Access-Token") String token,Integer state, PageBean pageBean)
    {
        return appletOrderService.getOrderPageBean(token,state,pageBean);
    }

    @ApiOperation(value="获取订单详情", notes="获取订单详情")
    @GetMapping(value = "/getOrderInfo")
    public Result<?> getOrderInfo(@RequestHeader("X-Access-Token") String token,String orderId)
    {
        return appletOrderService.getOrderInfo(token,orderId);
    }


    //再次支付
    @ApiOperation(value="再次支付", notes="再次支付")
    @PostMapping(value = "/payOrder")
    public Result<?> payOrder(@RequestHeader("X-Access-Token") String token,Integer type,String orderId)
    {
        return appletOrderService.payOrder(token,type,orderId);
    }

    //确认收货
    @ApiOperation(value="确认收货", notes="确认收货")
    @PostMapping(value = "/confirmOrder")
    public Result<?> confirmOrder(@RequestHeader("X-Access-Token") String token,String orderId)
    {
        return appletOrderService.confirmOrder(token,orderId);
    }


    //取消订单
    @ApiOperation(value="取消订单", notes="取消订单")
    @PostMapping(value = "/cancelOrder")
    public Result<?> cancelOrder(@RequestHeader("X-Access-Token") String token,String orderId)
    {
        return appletOrderService.cancelOrder(token,orderId);
    }



    //支付回调
    @PostMapping("/payNotify")
    public Object payNotify(@RequestBody String requestBody){
        return appletOrderService.payNotify(requestBody);
    }


    //商城-加入购物车之后一次下多个订单
    @ApiOperation(value="商城-加入购物车之后一次下多个订单", notes="商城-加入购物车之后一次下多个订单")
    @PostMapping("/createSumOrder")
    public Result<?> createSumOrder(@RequestHeader("X-Access-Token") String token,String list,String addressId,Integer payType,String orderId){
        return appletOrderService.createSumOrder(token,list,addressId,payType,orderId);
    }


}
