package com.fdkankan.platform.user.controller.api;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fdkankan.platform.goods.vo.ResponseGoods;
import com.fdkankan.platform.goods.vo.ResponseGoodsSku;
import com.fdkankan.platform.order.request.RequestPlaceOrder;
import com.fdkankan.platform.order.service.IOrderService;
import com.fdkankan.platform.order.vo.ResponseCommerceOrder;
import com.fdkankan.platform.order.vo.ResponseExpansionOrder;
import com.fdkankan.platform.user.request.*;
import com.fdkankan.platform.user.vo.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 个人中心-增值发票
 */
@RestController
@RequestMapping("/service/platform/user/order")
public class UserOrderController {

    private static Logger log = LoggerFactory.getLogger("programLog");

    @Autowired
    private IOrderService orderService;


    /**
     * 获取用户订单
     * type     0-待支付，1-待发货，2-已发货，空-全部
     */
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    public Page<ResponseOrder> getOrders(@RequestBody RequestOrder param, @RequestHeader String token) throws Exception {
        return orderService.getOrders(param,token);
    }
    /**
     * 获取订单详情
     * orderId     订单id
     */
    @RequestMapping(value = "/detail", method = RequestMethod.POST)
    public ResponseOrder getOrderDetail(@RequestBody RequestOrder param, @RequestHeader String token) throws Exception {
        return orderService.getOrderDetail(param.getOrderId());
    }
    /**
     * 取消订单
     * orderId     订单id
     */
    @RequestMapping(value = "/cancel", method = RequestMethod.POST)
    public String cancelOrder(@RequestBody RequestOrder param, @RequestHeader String token) throws Exception {
        return orderService.cancelOrder(param,token);
    }
    /**
     * 确认收货
     * orderId     订单id
     */
    @RequestMapping(value = "/receipt", method = RequestMethod.POST)
    public String receiptOrder(@RequestBody RequestOrder param, @RequestHeader String token) throws Exception {
        return orderService.receiptOrder(param,token);
    }
    /**
     * 获取订单发票信息
     * orderId     订单id
     * @return
     */
    @RequestMapping(value = "/getInvoiceDetail", method = RequestMethod.POST)
    public ResponseInvoice getInvoiceDetail(@RequestBody RequestOrder param, @RequestHeader String token) throws Exception {
        return orderService.getInvoiceDetail(param,token);
    }
    /**
     * 确认订单 购物提交订单
     * goods     商品信息
     * abroad     0表示国内订单，1表示国外订单
     * orderId     订单id
     * receiver     收货人信息
     * payType     付款方式，0表示微信，1表示支付宝，2表示paypal，3表示其他，4表示货到付款
     * invoice     发票信息
     * @return
     */
    @RequestMapping(value = "/placeOrder", method = RequestMethod.POST)
    public ResponseOrder placeOrder(@RequestBody RequestPlaceOrder param, @RequestHeader String token) throws Exception {
        return orderService.placeOrder(param,token);
    }
    /**
     * 充值提交订单
     * cameraId     相机id
     * points     重置点数
     * @return
     */
    @RequestMapping(value = "/rechargeOrder", method = RequestMethod.POST)
    public ResponseVirtualOrder rechargeOrder(@RequestBody RequestCamera param, @RequestHeader String token) throws Exception {
        return orderService.rechargeOrder(param,token);
    }
    /**
     * 扩容提交订单
     * cameraId     相机id
     * payType     付款方式，0表示微信，1表示支付宝，2表示paypal，3表示其他
     * skuSn     商品编码
     * abroad     0表示国内订单，1表示国外订单
     * @return
     */
    @RequestMapping(value = "/expansionOrder", method = RequestMethod.POST)
    public ResponseExpansionOrder expansionOrder(@RequestBody RequestExpansionOrder param, @RequestHeader String token) throws Exception {
        return orderService.expansionOrder(param,token);
    }
    /**
     * 商业相机提交订单
     * cameraId     相机id
     * payType     付款方式，0表示微信，1表示支付宝，2表示paypal，3表示其他
     * skuSn     商品编码
     * count     数量
     * abroad     0表示国内订单，1表示国外订单
     * @return
     */
    @RequestMapping(value = "/commerceOrder", method = RequestMethod.POST)
    public ResponseCommerceOrder commerceOrder(@RequestBody RequestCommerceOrder param, @RequestHeader String token) throws Exception {
        return orderService.commerceOrder(param,token);
    }
    /**
     * 增值权益提交订单
     * cameraId     相机id
     * payType     付款方式，0表示微信，1表示支付宝，2表示paypal，3表示其他
     * skuSn     商品编码
     * count     数量
     * abroad     0表示国内订单，1表示国外订单
     * @return
     */
    @RequestMapping(value = "/incrementOrder", method = RequestMethod.POST)
    public ResponseIncrementOrder incrementOrder(@RequestBody RequestIncrementOrder param, @RequestHeader String token) throws Exception {
        return orderService.incrementOrder(param,token);
    }
    /**
     * 下载场景提交订单
     * payType     付款方式，0表示微信，1表示支付宝，2表示paypal，3表示其他
     * skuSn     商品编码
     * count     数量
     * abroad     0表示国内订单，1表示国外订单
     * @return
     */
    @RequestMapping(value = "/downloadOrder", method = RequestMethod.POST)
    public ResponseDownloadOrder downloadOrder(@RequestBody RequestIncrementOrder param, @RequestHeader String token) throws Exception {
        return orderService.downloadOrder(param,token);
    }
    /**
     * 交易查询
     * orderSn      订单编码
     * payType     付款方式，0表示微信，1表示支付宝，2表示paypal，3表示其他
     * orderType     订单类型，0表示购物，1表示点数充值，2表示扩充容量
     * @return
     */
    @RequestMapping(value = "/queryOrderStatus", method = RequestMethod.POST)
    public Boolean queryOrderStatus(@RequestBody RequestVirtualOrder param, @RequestHeader String token) throws Exception {
        return orderService.queryOrderStatus(param,token);
    }
    /**
     * 获取扩容价格
     * dateType      日期价格类型，2为年其余为月
     * @return
     */
    @RequestMapping(value = "/getExpansionPrice", method = RequestMethod.POST)
    public ResponseGoods getExpansionPrice(@RequestBody RequestCamera param, @RequestHeader String token) throws Exception {
        return orderService.getExpansionPrice(param,token);
    }
    /**
     * 获取增值权益或场景下载价格
     * dateType      5增值权益，6场景下载
     * @return
     */
    @RequestMapping(value = "/getIncrementOrDownloadPrice", method = RequestMethod.POST)
    public ResponseGoodsSku getIncrementOrDownloadPrice(@RequestBody RequestCamera param, @RequestHeader String token) throws Exception {
        return orderService.getIncrementOrDownloadPrice(param,token);
    }


}
