package cn.freemud.controller.delivery;

import cn.freemud.base.entity.BaseResponse;
import cn.freemud.entities.dto.delivery.CallbackUrlRequestDto;
import cn.freemud.entities.dto.delivery.MacCafeCallbackUrlRequestDto;
import cn.freemud.entities.dto.delivery.MallCallbackRequestDto;
import cn.freemud.entities.dto.delivery.WeixinDeliveryAddressDto;
import cn.freemud.service.ThirdDeliveryService;
import com.freemud.application.sdk.api.log.ApiAnnotation;
import com.freemud.application.sdk.api.log.LogParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * All rights Reserved, Designed By www.freemud.cn
 *
 * @version V1.6.0
 * @Title: DeliveryController
 * @Description: 简单描述下这个类是做什么用的
 * @author: qin.zhou
 * @date: 2019/6/1119:47
 * @Copyright: ${DATE.YARE} www.freemud.cn Inc. All rights reserved.
 * 注意：本内容仅限于上海非码科技内部传阅，禁止外泄以及用于其他的商业目
 */
@RequestMapping("/order")
@RestController
@Validated
public class DeliveryController {

    @Autowired
    private ThirdDeliveryService deliveryService;

    @ApiAnnotation(logMessage = "配送回调")
    @ApiOperation(value = "配送回调", notes = "配送回调", produces = "application/json")
    @PostMapping("/delivery/callbackUrl")
    public BaseResponse callbackUrl(@Valid @LogParams @RequestBody CallbackUrlRequestDto request) {
        return deliveryService.callbackUrl(request);
    }

    @ApiAnnotation(logMessage = "配送异常回调")
    @ApiOperation(value = "配送异常回调", notes = "配送异常回调", produces = "application/json")
    @PostMapping("/delivery/errorCallbackUrl")
    public BaseResponse errorCallbackUrl(@Valid @LogParams @RequestBody CallbackUrlRequestDto request) {
        return deliveryService.errorCallbackUrl(request);
    }

    @ApiAnnotation(logMessage = "麦咖啡配送回调")
    @ApiOperation(value = "麦咖啡配送回调", notes = "麦咖啡配送回调", produces = "application/json")
    @PostMapping("/delivery/macCafeCallback")
    public BaseResponse macCafeCallback(@Valid @LogParams @RequestBody MacCafeCallbackUrlRequestDto request) {
//        return deliveryService.macCafeCallbackUrl(request);
        return new BaseResponse("1","101");
    }
    @ApiAnnotation(logMessage = "商城配送回调")
    @ApiOperation(value = "商城配送回调", notes = "商城配送回调", produces = "application/json")
    @PostMapping("/delivery/mallCallbackUrl")
    public BaseResponse mallCallbackUrl(@Valid @LogParams @RequestBody MallCallbackRequestDto request) {
        return deliveryService.mallCallbackUrl(request);
    }

    @ApiAnnotation(logMessage = "获取快递配送费")
    @ApiOperation(value = "获取快递配送费", notes = "获取快递配送费", produces = "application/json")
    @PostMapping("/delivery/queryDeliveryAmount")
    public BaseResponse queryDeliveryAmount(@Valid @LogParams @RequestBody WeixinDeliveryAddressDto request) {
        return deliveryService.queryDeliveryAmount(request);
    }
}
