package com.jsh.erp.controller;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.MaterialVo4Unit;
import com.jsh.erp.service.MaterialService;
import com.jsh.erp.service.SyncTescoSystemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @Description 外部接口
 * @Author MS.BLUE
 * @Date 2025-04-12
 */
@RestController
@RequestMapping(value = "/open-api")
@Api(tags = {"外部接口"})
public class OpenController {

    private Logger logger = LoggerFactory.getLogger(OpenController.class);

    @Resource
    private SyncTescoSystemService syncTescoSystemService;

    /**
     * 获取商品系统sku，返回结果为json格式
     * @param param 商品条码 ,[{"barCode":"1"},{"barCode":"2"}]
     * @return 返回结果,JSON格式,{"code":0,"data":[{"barCode":"1","systemSku":"20230412100000000001"}]}
     */
    @ApiOperation(value = "获取商品系统sku，返回信息集采系统")
    @PostMapping(value = "/sync-system-sku")
    public String syncSystemSku(@RequestBody String param) {
        return syncTescoSystemService.syncSystemSku(param);
    }


    @ApiOperation(value = "同步集采订单-》销售订单")
    @PostMapping(value = "/sync-order")
    public String syncOrder(@RequestBody String param){
        return syncTescoSystemService.syncOrder(param);
    }

    @ApiOperation(value = "同步集采库存")
    @PostMapping(value = "/sync-tesco-stock")
    public String sycnTescoStock(@RequestBody List<Long> mIdList){
        return syncTescoSystemService.sycnTescoStock(mIdList);
    }

    @PostMapping(value = "/sync-tesco-saleprice")
    public String sycnTescoSalePrice(@RequestBody List<Long> mIdList){
        return syncTescoSystemService.sycnTescoSalePrice(mIdList);
    }



}