7 changed files with 114 additions and 14 deletions
@ -0,0 +1,53 @@ |
|||||
|
package com.qs.serve.modules.third; |
||||
|
|
||||
|
import com.qs.serve.common.model.dto.R; |
||||
|
import com.qs.serve.modules.goods.entity.GoodsSku; |
||||
|
import com.qs.serve.modules.goods.entity.GoodsSpu; |
||||
|
import com.qs.serve.modules.goods.service.GoodsSkuService; |
||||
|
import com.qs.serve.modules.goods.service.GoodsSpuService; |
||||
|
import com.qs.serve.modules.oms.entity.dto.OmsSpuToSkuKey; |
||||
|
import com.qs.serve.modules.third.entity.param.SkuToGetSpuParam; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
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 java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
import java.util.stream.Collectors; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/10/16 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@AllArgsConstructor |
||||
|
@RestController |
||||
|
@RequestMapping("thirty/goods") |
||||
|
public class PortalGoodsController { |
||||
|
|
||||
|
private GoodsSkuService goodsSkuService; |
||||
|
private GoodsSpuService goodsSpuService; |
||||
|
|
||||
|
/** |
||||
|
* 通过invCode获取spuCode |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
@PostMapping("getSpuBySku") |
||||
|
public List<OmsSpuToSkuKey> getSpuBySku(@RequestBody SkuToGetSpuParam param){ |
||||
|
List<GoodsSku> skuList = goodsSkuService.getByCodes(param.getInvCodes()); |
||||
|
List<OmsSpuToSkuKey> rs = new ArrayList<>(); |
||||
|
for (GoodsSku sku : skuList) { |
||||
|
GoodsSpu goodsSpu = goodsSpuService.getById(sku.getSpuId()); |
||||
|
OmsSpuToSkuKey key = new OmsSpuToSkuKey(); |
||||
|
key.setSkuCode(goodsSpu.getSpuCode()); |
||||
|
key.setInvCode(sku.getSkuCode()); |
||||
|
rs.add(key); |
||||
|
} |
||||
|
return rs; |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,13 @@ |
|||||
|
package com.qs.serve.modules.third.entity.param; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2023/10/16 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class SkuToGetSpuParam { |
||||
|
List<String> invCodes; |
||||
|
} |
Loading…
Reference in new issue