package org.jeecg.modules.api.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.bean.OrderPageBean;
import org.jeecg.modules.msgEvaluate.entity.MsgEvaluate;
import org.jeecg.modules.postBean.*;
import org.jeecg.modules.service.OrderCreateVipService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags="订单下单流程")
@RestController
@RequestMapping("/order")
@Slf4j
public class OrderVipController {


    @Resource
    private OrderCreateVipService orderCreateVipService;



    //第一步：用户下单
    @ApiOperation(value = "第一步：用户下单",notes = "用户/微信公众号授权登录")
    @PostMapping("/createVipOrder")
    public Result<?> createVipOrder(@RequestHeader("X-Access-Token") String token, OrderCreateBean bean){
        return orderCreateVipService.createOrder(token,bean);
    }

    //根据订单标识查询订单详情的方法
    @ApiOperation(value = "根据订单标识查询订单详情",notes = "根据订单标识查询订单详情")
    @GetMapping("/getOrderVipDetail")
    public Result<?> getOrderVipDetail(@RequestHeader("X-Access-Token") String token,String id){
        return orderCreateVipService.getOrderDetail(token,id);
    }


    //获取当前技师的排期
    @ApiOperation(value = "获取当前技师的排期",notes = "获取当前技师的排期")
    @GetMapping("/getVipTenOrderList")
    public Result<?> getVipTenOrderList(@RequestHeader("X-Access-Token") String token,String tenId,String name){
        return orderCreateVipService.getVipTenOrderList(token,tenId,name);
    }


    //第二步：用户支付
    @ApiOperation(value = "第二步：用户支付",notes = "第二步：用户支付")
    @PostMapping("/payVipOrder")
    public Result<?> payVipOrder(@RequestHeader("X-Access-Token") String token, OrderPayBean bean){
        return orderCreateVipService.payOrder(token,bean);
    }

    //立即支付
    @ApiOperation(value = "立即支付",notes = "立即支付")
    @PostMapping("/immediatelyPay")
    public Result<?> immediatelyPay(@RequestHeader("X-Access-Token") String token, OrderPayBean req){
        return orderCreateVipService.createWxPayOrder(token,req);
    }


    //获取手机验证码- 不需要token
    @ApiOperation(value = "获取手机验证码",notes = "获取手机验证码")
    @GetMapping("/getVipCode")
    public Result<?> getVipCode(String phone){
        return orderCreateVipService.getCode(phone);
    }


    //技师登录
    @ApiOperation(value = "技师登录",notes = "技师登录")
    @PostMapping("/wxTechnicianLogin")
    public Result<?> wxTechnicianLogin(String phone, String code){
        return orderCreateVipService.wxTechnicianLogin(phone,code);
    }


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


//    //技师根据标识查询自己的订单 - 技师端
//    @ApiOperation(value = "技师根据标识查询自己的订单",notes = "技师根据标识查询自己的订单")
//    @GetMapping("/getVipOrderList")
//    public Result<?> getVipOrderList(@RequestHeader("X-Access-Token") String token, OrderPageBean pageBean){
//        return orderCreateVipService.getOrderList(token,pageBean);
//    }


    //第三步：技师确认接单
    @ApiOperation(value = "第三步：技师确认接单",notes = "第三步：技师确认接单")
    @PostMapping("/confirmVipOrder")
    public Result<?> confirmVipOrder(@RequestHeader("X-Access-Token") String token, String orderId){
        return orderCreateVipService.confirmOrder(token,orderId);
    }


    //第四步：技师出发
    @ApiOperation(value = "第四步：技师出发",notes = "第四步：技师出发")
    @PostMapping("/startVipOrder")
    public Result<?> startVipOrder(@RequestHeader("X-Access-Token") String token, String orderId){
        return orderCreateVipService.startOrder(token,orderId);
    }


    //第五步：技师到达
    @ApiOperation(value = "第五步：技师到达",notes = "第五步：技师到达")
    @PostMapping("/arriveVipOrder")
    public Result<?> arriveVipOrder(@RequestHeader("X-Access-Token") String token, String orderId,String arrivalPicture
    ){
        return orderCreateVipService.arriveOrder(token,orderId,arrivalPicture);
    }


    //第六步：技师开始服务
    @ApiOperation(value = "第六步：技师开始服务",notes = "第六步：技师开始服务")
    @PostMapping("/startVipService")
    public Result<?> startVipService(@RequestHeader("X-Access-Token") String token, String orderId){
        return orderCreateVipService.startService(token,orderId);
    }


    //第七步：技师结束服务
    @ApiOperation(value = "第七步：技师结束服务",notes = "第七步：技师结束服务")
    @PostMapping("/endVipService")
    public Result<?> endVipService(@RequestHeader("X-Access-Token") String token, String orderId,String endPicture){
        return orderCreateVipService.endService(token,orderId,endPicture);
    }


    //第八步：用户评价
    @ApiOperation(value = "第八步：用户评价",notes = "第八步：用户评价")
    @PostMapping("/evaluateVipOrder")
    public Result<?> evaluateVipOrder(@RequestHeader("X-Access-Token") String token, MsgEvaluate bean){
        return orderCreateVipService.evaluateOrder(token,bean);
    }


    //收藏技师
    @ApiOperation(value = "收藏技师",notes = "收藏技师")
    @PostMapping("/collectVipTechnician")
    public Result<?> collectVipTechnician(@RequestHeader("X-Access-Token") String token, String tenId){
        return orderCreateVipService.collectVipTechnician(token,tenId);
    }

    //取消收藏接口
    @ApiOperation(value = "取消收藏接口",notes = "取消收藏接口")
    @PostMapping("/cancelVipCollect")
    public Result<?> cancelVipCollect(@RequestHeader("X-Access-Token") String token, String tenId){
        return orderCreateVipService.cancelCollect(token,tenId);
    }


    //收藏列表
    @ApiOperation(value = "收藏列表",notes = "收藏列表")
    @GetMapping("/getVipCollectList")
    public Result<?> getVipCollectList(@RequestHeader("X-Access-Token") String token, CollectPageBean bean){
        return orderCreateVipService.getVipCollectList(token,bean);
    }


    //分享生成签名
    @ApiOperation(value = "分享生成签名",notes = "分享生成签名")
    @GetMapping("/getVipShareSign")
    public Result<?> getVipShareSign(String url){
        return orderCreateVipService.getVipShareSign(url);
    }


    //用户充值
    @ApiOperation(value = "用户充值",notes = "用户充值")
    @PostMapping("/giveVipWithdrawal")
    public Result<?> giveVipWithdrawal(@RequestHeader("X-Access-Token") String token, WithdrawalBean bean){
        return orderCreateVipService.giveWithdrawal(token,bean);
    }



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



    //根据用户手机号码验证码更换手机号码绑定信息
    @ApiOperation(value = "根据用户手机号码验证码更换手机号码绑定信息",notes = "根据用户手机号码验证码更换手机号码绑定信息")
    @PostMapping("/changePhone")
    public Result<?> changePhone(@RequestHeader("X-Access-Token") String token, String phone, String code){
        return orderCreateVipService.changePhone(token,phone,code);
    }



    //技师端接口------------
    //技师端-获取技师个人信息
    @ApiOperation(value = "技师端-获取技师个人信息",notes = "技师端-获取技师个人信息")
    @GetMapping("/giveTenInfo")
    public Result<?> giveTenInfo(@RequestHeader("X-Access-Token") String token){
        return orderCreateVipService.giveTenInfo(token);
    }


    //技师端-资料上传
    @ApiOperation(value = "技师端-资料上传",notes = "技师端-资料上传")
    @PostMapping("/uploadTenInfo")
    public Result<?> uploadTenInfo(@RequestHeader("X-Access-Token") String token, TenInfoBean bean){
        return orderCreateVipService.uploadTenInfo(token,bean);
    }


    //技师端-提现
    @ApiOperation(value = "技师端-提现",notes = "技师端-提现")
    @PostMapping("/giveWithdrawal")
    public Result<?> giveWithdrawal(@RequestHeader("X-Access-Token") String token, WithdrawalBean bean){
        return orderCreateVipService.giveWithdrawal(token,bean);
    }


    //技师-上线下线
    @ApiOperation(value = "技师端-上线下线",notes = "技师端-上线下线")
    @PostMapping("/online")
    public Result<?> online(@RequestHeader("X-Access-Token") String token, OnlineBean bean){
        return orderCreateVipService.online(token,bean);
    }



//    //技师端-公告
//    @ApiOperation(value = "技师端-公告",notes = "技师端-公告")
//    @GetMapping("/getTenNotice")
//    public Result<?> getTenNotice(@RequestHeader("X-Access-Token") String token){
//        return orderCreateVipService.getTenNotice(token);
//    }

    //技师端-首页-统计数据
    @ApiOperation(value = "技师端-首页-统计数据",notes = "技师端-首页-统计数据")
    @GetMapping("/getTenOrderStatistics")
    public Result<?> getTenOrderStatistics(@RequestHeader("X-Access-Token") String token){
        return orderCreateVipService.getTenOrderStatistics(token);
    }


    //技师端-首页-获取待确认订单
    @ApiOperation(value = "技师端-首页-获取待确认订单-带分页",notes = "技师端-首页-获取待确认订单-带分页")
    @GetMapping("/getTenOrderList")
    public Result<?> getTenOrderList(@RequestHeader("X-Access-Token") String token, OrderPageBean pageBean){
        return orderCreateVipService.getOrderList(token,pageBean);
    }


    //技师端-订单页面获取订单列表带分页
    @ApiOperation(value = "技师端-订单页面获取订单列表带分页",notes = "技师端-订单页面获取订单列表带分页")
    @GetMapping("/getTenOrderPageList")
    public Result<?> getTenOrderPageList(@RequestHeader("X-Access-Token") String token, OrderPageBean pageBean){
        return orderCreateVipService.getTenOrderPageList(token,pageBean);
    }



    //技师端-技师实名认证
    @ApiOperation(value = "技师端-技师实名认证",notes = "技师端-技师实名认证")
    @PostMapping("/tenRealName")
    public Result<?> tenRealName(@RequestHeader("X-Access-Token") String token, TenRealNameBean bean){
        return orderCreateVipService.tenRealName(token,bean);
    }

    //获取技师实名认证
    @ApiOperation(value = "获取技师实名认证",notes = "获取技师实名认证")
    @GetMapping("/getTenRealName")
    public Result<?> getTenRealName(@RequestHeader("X-Access-Token") String token){
        return orderCreateVipService.getTenRealName(token);
    }


    //修改技师相册
    @ApiOperation(value = "修改技师相册",notes = "修改技师相册")
    @PostMapping("/uploadTenImg")
    public Result<?> uploadTenImg(@RequestHeader("X-Access-Token") String token,String file){
        return orderCreateVipService.uploadTenImg(token,file);
    }


    //获取我推荐的技师记录
    @ApiOperation(value = "获取我推荐的技师记录",notes = "获取我推荐的技师记录")
    @GetMapping("/getTenFans")
    public Result<?> getTenFans(@RequestHeader("X-Access-Token") String token){
        return orderCreateVipService.getTenFans(token);
    }




}
