package com.liquidnet.service.platform.controller.erp;

import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.goblin.service.IGoblinErpService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


@Api(tags = "erp-旺店通")
@RestController
@RequestMapping("wdt")
@Validated
public class WdtController {

    @Autowired
    IGoblinErpService goblinErpService;

    @PostMapping("syncErpSpuStock")
    @ApiOperation("同步库存")
    @ApiResponse(code = 200, message = "接口返回对象参数")
    @ApiImplicitParams({
            @ApiImplicitParam(type = "form", required = false, dataType = "String", name = "spuId", value = "spuId"),
            @ApiImplicitParam(type = "form", required = false, dataType = "Integer", name = "min", value = "间隔时间"),
    })
    public ResponseDto<Boolean> initErpStock(@RequestParam(value = "spuId", required = false) String spuId,
                                             @RequestParam(value = "min", required = false) Integer min) {
        if (min <= 0) {
            min = 5;
        }
        return goblinErpService.initErpStock(spuId, min);
    }


    @PostMapping("pushErpTrade")
    @ApiOperation("推送订单")
    @ApiResponse(code = 200, message = "接口返回对象参数")
    @ApiImplicitParams({
            @ApiImplicitParam(type = "form", required = true, dataType = "String", name = "orderId", value = "orderId"),
    })
    public ResponseDto<Boolean> pushTrade(@RequestParam(value = "orderId") String orderId) {
        return goblinErpService.pushTrade(orderId);
    }

}
