记得上下班打卡 | git大法好,push需谨慎

Commit d60d0654 authored by 胡佳晨's avatar 胡佳晨

提交 erp 检查 商品编号是否能查询到数据

parent 6ddf87b3
......@@ -10,4 +10,6 @@ public interface IGoblinErpService {
ResponseDto<Boolean> syncErpLogistic();
ResponseDto<Boolean> checkGoodsNo(String specNo,String goodsNo);
}
......@@ -35,6 +35,10 @@ public class ErpEnum {
* 查询后需要调用 logistics_sync_ack 应答
*/
LOGISTICS_SYNC_ACK("logistics_sync_ack.php"),
/**
* goods_query.php(查询货品档案)
*/
GOODS_QUERY("goods_query.php"),
// /**
// * 查询库存同步
// * 建议间隔时间3~5分钟查询一次,集中获取待同步数据,注意上一次回写完成以后,再从数据池获取待同步的数据。 查询后需要调用 api_goods_stock_change_ack 应答
......
package com.liquidnet.service.erp.vo;
import lombok.Data;
import java.util.List;
@Data
public class CheckGoodsBaseVo {
// 状态码:0表示成功,其他表示失败
private int code;
// 错误原因
private String message;
// 符合条件的数据条数,用来分页 当page_no = 0时返回
private int total_count;
}
......@@ -5,10 +5,7 @@ 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.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
@Api(tags = "erp-旺店通")
......@@ -53,4 +50,17 @@ public class WdtController {
return goblinErpService.syncErpLogistic();
}
@GetMapping("checkGoodsNo")
@ApiOperation("查询商品编号")
@ApiImplicitParams({
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "spec_no", value = "商家编码"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "goods_no", value = "货品编号"),
})
@ApiResponse(code = 200, message = "接口返回对象参数")
public ResponseDto<Boolean> checkGoodsNo(@RequestParam(value = "spec_no") String spec_no,
@RequestParam(value = "goods_no") String goods_no) {
return goblinErpService.checkGoodsNo(spec_no,goods_no);
}
}
......@@ -79,7 +79,7 @@ public class WdtServiceImpl implements IGoblinErpService {
if (null != spuId && !"".equals(spuId)) {
//查询 spu下的sku
GoblinGoodsInfoVo goblinGoodsInfoVo = goblinRedisUtils.getGoodsInfoVo(spuId);
if(goblinGoodsInfoVo==null){
if (goblinGoodsInfoVo == null) {
return ResponseDto.failure("参数错误");
}
for (String skuId : goblinGoodsInfoVo.getSkuIdList()) {
......@@ -90,8 +90,8 @@ public class WdtServiceImpl implements IGoblinErpService {
param.remove("sign");
json = erpWdtClient.execute(ErpEnum.WdtAPI.STOCK_QUERY.getUri(), param);
ArrayList<SyncStockVo> list = baseStock(json);
String error = syncStockError(list,json,spuId);
if(!"".equals(error)){
String error = syncStockError(list, json, spuId);
if (!"".equals(error)) {
return ResponseDto.failure(error);
}
syncStock(list);
......@@ -118,10 +118,10 @@ public class WdtServiceImpl implements IGoblinErpService {
return ResponseDto.success();
}
private String syncStockError(ArrayList<SyncStockVo> list,String json,String spuId){
if(list.size()==0){
log.error("erp未找到相关商品,同步失败 spuId : {} json : {}",spuId,json);
return "erp未找到相关商品,同步失败";
private String syncStockError(ArrayList<SyncStockVo> list, String json, String spuId) {
if (list.size() == 0) {
log.error("erp未找到相关商品,同步失败 spuId : {} json : {}", spuId, json);
return "erp未找到相关商品,同步失败";
}
return "";
}
......@@ -201,7 +201,7 @@ public class WdtServiceImpl implements IGoblinErpService {
List<String> list = CollectionUtil.arrayListString();
for (int i = 0; i < contentSize; i++) {
String orderId = goblinRedisUtils.erpLeftPop(i);
if(orderId!=null) {
if (orderId != null) {
list.add(orderId);
}
}
......@@ -408,4 +408,23 @@ public class WdtServiceImpl implements IGoblinErpService {
}
return ResponseDto.success();
}
@Override
public ResponseDto<Boolean> checkGoodsNo(String spec_no, String goods_no) {
// Date nowTime = DateUtil.now();
Map<String, String> paramAck = CollectionUtil.linkMapStringString();
// paramAck.put("start_time", DateUtil.format(DateUtil.addMin(nowTime, -5), DateUtil.Formatter.yyyyMMddHHmmss));
// paramAck.put("end_time", DateUtil.format(nowTime, DateUtil.Formatter.yyyyMMddHHmmss));
paramAck.put("spec_no", spec_no);
paramAck.put("goods_no", goods_no);
String json = erpWdtClient.execute(ErpEnum.WdtAPI.GOODS_QUERY.getUri(), paramAck);
log.error("json = " + json);
CheckGoodsBaseVo checkGoodsBaseVo = JsonUtils.fromJson(json, CheckGoodsBaseVo.class);
log.error("checkGoodsBaseVo = " + checkGoodsBaseVo);
if (checkGoodsBaseVo.getTotal_count() == 0) {
return ResponseDto.failure("商品不存在");
} else {
return ResponseDto.success(true);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment