diff --git a/src/main/java/com/demo/jsl/service/impl/GoodsServiceImpl.java b/src/main/java/com/demo/jsl/service/impl/GoodsServiceImpl.java index 4c1287b..e29fe24 100644 --- a/src/main/java/com/demo/jsl/service/impl/GoodsServiceImpl.java +++ b/src/main/java/com/demo/jsl/service/impl/GoodsServiceImpl.java @@ -28,7 +28,11 @@ public class GoodsServiceImpl implements GoodsService { final String sqlCountJslSpecValue = "SELECT `id` FROM `goods_spec_value` where spec_id=? and name=?"; public DbContext getJslDbContext() { - return new DbContext("test", "jdbc:mysql://192.168.0.9:3306/jsl_mall_qs_dev2?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true", "kpjsl", "123456"); + return new DbContext("pro", + "jdbc:mysql://183.56.249.148/jsl_cost_base?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true", + "root", + "@Jsl2282125"); + //return new DbContext("test", "jdbc:mysql://192.168.0.9:3306/jsl_mall_qs_dev2?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true", "kpjsl", "123456"); } public DbContext getXltDbContext() { @@ -230,10 +234,8 @@ public class GoodsServiceImpl implements GoodsService { if (spuId == null) { //加载销路通spu XltSpu xltSpu = xltDb.sql(sql4XltSpu, xltGoods.getSpuId()).getItem(XltSpu.class); - spuId = StringUtils.genShortLong(); String xltSpuId = xltSpu.getId(); JslGoodSpu goodSpu = new JslGoodSpu(); - goodSpu.setId(spuId); goodSpu.setSpuCode(xltSpu.getCode()); goodSpu.setName(xltSpu.getName()); goodSpu.setTasteValue(tasteSku); @@ -264,11 +266,13 @@ public class GoodsServiceImpl implements GoodsService { } //保存spu - jslDb.table("goods_spu").setEntity(goodSpu).insert(); + System.out.println("新增spu:"+goodSpu.getSpuCode()); + spuId = jslDb.table("goods_spu").setEntity(goodSpu).insert(); + goodSpu.setId(spuId); } //保存sku JslGoodsSku goodsSku = new JslGoodsSku(); - goodsSku.setId(StringUtils.genShortLong()); + //goodsSku.setId(StringUtils.genShortLong()); goodsSku.setSkuCode(xltGoods.getCode()); goodsSku.setSpuId(spuId); goodsSku.setPicUrl(""); @@ -280,7 +284,9 @@ public class GoodsServiceImpl implements GoodsService { goodsSku.setCostFlag(1); goodsSku.setEnable(shelf); goodsSku.setTenantId(TENANT_ID); - jslDb.table("goods_sku").setEntity(goodsSku).insert(); + System.out.println("新增SKU:"+goodsSku.getSkuCode()); + Long skuId = jslDb.table("goods_sku").setEntity(goodsSku).insert(); + goodsSku.setId(skuId); //保存spec List specValueIds = new ArrayList<>(); specValueIds.add(initSpecValue(jslDb, 3L, address)); @@ -366,13 +372,10 @@ public class GoodsServiceImpl implements GoodsService { Long specValueId = jslDb.sql(sqlCountJslSpecValue, specId, specValueName).getDataItem().getLong("id"); if (specValueId == null) { JslGoodSpecValue specValue = new JslGoodSpecValue(); - specValueId = StringUtils.genShortLong(); - specValue.setId(specValueId); specValue.setTenantId("001"); specValue.setSpecId(specId); specValue.setName(specValueName); - jslDb.table("goods_spec_value").setEntity(specValue).insert(); - return specValueId; + return jslDb.table("goods_spec_value").setEntity(specValue).insert(); } return specValueId; }