|
|
@@ -140,7 +140,7 @@ public class HBGoodsService implements IHBGoodsService {
|
|
|
XSBSkuVO xsbSkuVO = new XSBSkuVO();
|
|
|
//复制sku.的值到xsbProductVO 字段一样
|
|
|
BeanUtils.copyProperties(sku, xsbSkuVO);
|
|
|
- xsbSkuVO.setThirdSkuId(String.valueOf(sku.getProdId()));
|
|
|
+ xsbSkuVO.setThirdSkuId(String.valueOf(sku.getSkuId()));
|
|
|
xsbSkuVO.setBusinessType("XSB");
|
|
|
shopSkuList.add(xsbSkuVO);
|
|
|
String syncUrl = smqjhUtil.getSmqjhPmsUrl() + "/syncSkuData";
|
|
|
@@ -218,7 +218,7 @@ public class HBGoodsService implements IHBGoodsService {
|
|
|
XSBSkuVO xsbSkuVO = new XSBSkuVO();
|
|
|
//复制sku.的值到xsbProductVO 字段一样
|
|
|
BeanUtils.copyProperties(sku, xsbSkuVO);
|
|
|
- xsbSkuVO.setThirdSkuId(String.valueOf(sku.getProdId()));
|
|
|
+ xsbSkuVO.setThirdSkuId(String.valueOf(sku.getSkuId()));
|
|
|
xsbSkuVO.setBusinessType("XSB");
|
|
|
shopSkuList.add(xsbSkuVO);
|
|
|
String syncUrl = smqjhUtil.getSmqjhPmsUrl() + "/syncSkuData";
|
|
|
@@ -413,71 +413,71 @@ public class HBGoodsService implements IHBGoodsService {
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public HBR updateGoodsPrice(JSONObject hbRequest) {
|
|
|
- try {
|
|
|
- String bodyStr = hbRequest.getString("body");
|
|
|
- log.info("商品,body:{}", bodyStr);
|
|
|
- JSONObject bodyJson = JSON.parseObject(bodyStr);
|
|
|
- JSONArray requestList = bodyJson.getJSONArray("requestList");
|
|
|
- for (Object request : requestList) {
|
|
|
- JSONObject jsonObject = JSON.parseObject(request.toString());
|
|
|
- String skuId = jsonObject.getString("skuId");
|
|
|
- Double currentPrice = jsonObject.getDouble("currentPrice");
|
|
|
- String stationId = jsonObject.getString("stationId");//海博门店编码
|
|
|
- ShopDetail shopDetail = shopDetailMapper.selectByHbStationId(stationId);
|
|
|
- if (ObjectUtil.isEmpty(shopDetail)) {
|
|
|
- log.error("系统找不到对应的门店(门店编码:{})信息", stationId);
|
|
|
- return HBR.error("系统找不到对应的门店(门店编码:" + stationId + ")信息");
|
|
|
- }
|
|
|
-
|
|
|
- //改变单品价格
|
|
|
- Sku sku = skuMapper.selectByHbSkuId(skuId);
|
|
|
- if (ObjectUtil.isEmpty(sku)) {
|
|
|
- log.error("更改价格系统找不到对应商品(单品):{}", skuId);
|
|
|
- return HBR.error("更改价格系统找不到对应商品(单品):" + skuId);
|
|
|
- }
|
|
|
-
|
|
|
- ShopSku shopSku = shopSkuMapper.selectByShopAndSku(sku.getSkuId(), shopDetail.getShopId());
|
|
|
- if (ObjectUtil.isEmpty(shopSku)) {
|
|
|
- ShopSku shopSkuInfo = new ShopSku();
|
|
|
- shopSkuInfo.setShopId(shopDetail.getShopId());
|
|
|
- shopSkuInfo.setShopSkuPrice(currentPrice == null ? 0.0 : currentPrice);
|
|
|
- shopSkuInfo.setSkuId(sku.getSkuId());
|
|
|
- shopSkuInfo.setSpuId(sku.getProdId());
|
|
|
- shopSkuInfo.setIsDelete(0);
|
|
|
- shopSkuInfo.setRecTime(new Date());
|
|
|
- shopSkuMapper.insert(shopSkuInfo);
|
|
|
- log.info("门店对应商品系统不存在直接添加");
|
|
|
- try {
|
|
|
- String syncUrl = smqjhUtil.getSmqjhPmsUrl() + "/syncShopSkuData";
|
|
|
- log.info("推送url: {}",syncUrl);
|
|
|
- // 将frontCategory对象作为JSON放入请求体
|
|
|
- String response = com.yami.shop.common.util.HttpUtil.post(syncUrl, shopSkuInfo);
|
|
|
- log.info("推送frontCategory到同步服务器结果: {}", response);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("推送frontCategory到同步服务器失败: {}", e.getMessage(), e);
|
|
|
- }
|
|
|
- } else {
|
|
|
- shopSku.setSpuId(sku.getProdId());
|
|
|
- shopSku.setShopSkuPrice(currentPrice == null ? 0.0 : currentPrice);
|
|
|
- shopSku.setUpdateTime(new Date());
|
|
|
- shopSkuMapper.updateById(shopSku);
|
|
|
- log.info("价格更改成功");
|
|
|
- try {
|
|
|
- String syncUrl = smqjhUtil.getSmqjhPmsUrl() + "/syncShopSkuData";
|
|
|
- log.info("推送url: {}",syncUrl);
|
|
|
- // 将frontCategory对象作为JSON放入请求体
|
|
|
- String response = com.yami.shop.common.util.HttpUtil.post(syncUrl, shopSku);
|
|
|
- log.info("推送frontCategory到同步服务器结果: {}", response);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("推送frontCategory到同步服务器失败: {}", e.getMessage(), e);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("商品失败:{}", e.getMessage(), e);
|
|
|
- return HBR.error("未知异常");
|
|
|
-
|
|
|
- }
|
|
|
+// try {
|
|
|
+// String bodyStr = hbRequest.getString("body");
|
|
|
+// log.info("商品,body:{}", bodyStr);
|
|
|
+// JSONObject bodyJson = JSON.parseObject(bodyStr);
|
|
|
+// JSONArray requestList = bodyJson.getJSONArray("requestList");
|
|
|
+// for (Object request : requestList) {
|
|
|
+// JSONObject jsonObject = JSON.parseObject(request.toString());
|
|
|
+// String skuId = jsonObject.getString("skuId");
|
|
|
+// Double currentPrice = jsonObject.getDouble("currentPrice");
|
|
|
+// String stationId = jsonObject.getString("stationId");//海博门店编码
|
|
|
+// ShopDetail shopDetail = shopDetailMapper.selectByHbStationId(stationId);
|
|
|
+// if (ObjectUtil.isEmpty(shopDetail)) {
|
|
|
+// log.error("系统找不到对应的门店(门店编码:{})信息", stationId);
|
|
|
+// return HBR.error("系统找不到对应的门店(门店编码:" + stationId + ")信息");
|
|
|
+// }
|
|
|
+//
|
|
|
+// //改变单品价格
|
|
|
+// Sku sku = skuMapper.selectByHbSkuId(skuId);
|
|
|
+// if (ObjectUtil.isEmpty(sku)) {
|
|
|
+// log.error("更改价格系统找不到对应商品(单品):{}", skuId);
|
|
|
+// return HBR.error("更改价格系统找不到对应商品(单品):" + skuId);
|
|
|
+// }
|
|
|
+
|
|
|
+// ShopSku shopSku = shopSkuMapper.selectByShopAndSku(sku.getSkuId(), shopDetail.getShopId());
|
|
|
+// if (ObjectUtil.isEmpty(shopSku)) {
|
|
|
+// ShopSku shopSkuInfo = new ShopSku();
|
|
|
+// shopSkuInfo.setShopId(shopDetail.getShopId());
|
|
|
+// shopSkuInfo.setShopSkuPrice(currentPrice == null ? 0.0 : currentPrice);
|
|
|
+// shopSkuInfo.setSkuId(sku.getSkuId());
|
|
|
+// shopSkuInfo.setSpuId(sku.getProdId());
|
|
|
+// shopSkuInfo.setIsDelete(0);
|
|
|
+// shopSkuInfo.setRecTime(new Date());
|
|
|
+// shopSkuMapper.insert(shopSkuInfo);
|
|
|
+// log.info("门店对应商品系统不存在直接添加");
|
|
|
+// try {
|
|
|
+// String syncUrl = smqjhUtil.getSmqjhPmsUrl() + "/syncShopSkuData";
|
|
|
+// log.info("推送url: {}",syncUrl);
|
|
|
+// // 将frontCategory对象作为JSON放入请求体
|
|
|
+// String response = com.yami.shop.common.util.HttpUtil.post(syncUrl, shopSkuInfo);
|
|
|
+// log.info("推送frontCategory到同步服务器结果: {}", response);
|
|
|
+// } catch (Exception e) {
|
|
|
+// log.error("推送frontCategory到同步服务器失败: {}", e.getMessage(), e);
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// shopSku.setSpuId(sku.getProdId());
|
|
|
+// shopSku.setShopSkuPrice(currentPrice == null ? 0.0 : currentPrice);
|
|
|
+// shopSku.setUpdateTime(new Date());
|
|
|
+// shopSkuMapper.updateById(shopSku);
|
|
|
+// log.info("价格更改成功");
|
|
|
+// try {
|
|
|
+// String syncUrl = smqjhUtil.getSmqjhPmsUrl() + "/syncShopSkuData";
|
|
|
+// log.info("推送url: {}",syncUrl);
|
|
|
+// // 将frontCategory对象作为JSON放入请求体
|
|
|
+// String response = com.yami.shop.common.util.HttpUtil.post(syncUrl, shopSku);
|
|
|
+// log.info("推送frontCategory到同步服务器结果: {}", response);
|
|
|
+// } catch (Exception e) {
|
|
|
+// log.error("推送frontCategory到同步服务器失败: {}", e.getMessage(), e);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// } catch (Exception e) {
|
|
|
+// log.error("商品失败:{}", e.getMessage(), e);
|
|
|
+// return HBR.error("未知异常");
|
|
|
+//
|
|
|
+// }
|
|
|
return HBR.success();
|
|
|
}
|
|
|
|
|
|
@@ -513,6 +513,7 @@ public class HBGoodsService implements IHBGoodsService {
|
|
|
shopSkuInfo.setShopId(shopDetail.getShopId());
|
|
|
shopSkuInfo.setShopSkuStocks(currentStock);
|
|
|
shopSkuInfo.setSkuId(sku.getSkuId());
|
|
|
+ shopSkuInfo.setSpuId(sku.getProdId());
|
|
|
|
|
|
shopSkuInfo.setIsDelete(0);
|
|
|
shopSkuInfo.setRecTime(new Date());
|
|
|
@@ -558,36 +559,40 @@ public class HBGoodsService implements IHBGoodsService {
|
|
|
JSONObject body = hbRequest.getJSONObject("body");
|
|
|
log.info("商品删除,body:{}", body);
|
|
|
|
|
|
- JSONArray productList = body.getJSONArray("productList");
|
|
|
- for (Object hbProductObject : productList) {
|
|
|
- JSONObject hbProduct = JSON.parseObject(hbProductObject.toString());
|
|
|
-
|
|
|
- String spuId = hbProduct.getString("spuId");
|
|
|
- String skuId = hbProduct.getString("skuId");
|
|
|
- Product product;
|
|
|
- if (ObjectUtil.isNotEmpty(spuId)) {
|
|
|
- product = productMapper.selectByHbSpuId(spuId);
|
|
|
- } else {
|
|
|
- Sku sku = skuMapper.selectByHbSkuId(skuId);
|
|
|
- product = productMapper.selectByHbSpuId(sku.getHbSpuId());
|
|
|
- }
|
|
|
- if (!ObjectUtil.isEmpty(product)) {
|
|
|
- product.setIsDelete(1);
|
|
|
- productMapper.updateById(product);
|
|
|
- try {
|
|
|
- String syncUrl = smqjhUtil.getSmqjhPmsUrl() + "/syncProductDel" + product.getHbSpuId();
|
|
|
- log.info("推送url: {}",syncUrl);
|
|
|
- // 将frontCategory对象作为JSON放入请求体
|
|
|
- String response = com.yami.shop.common.util.HttpUtil.post(syncUrl, product);
|
|
|
- log.info("推送frontCategory到同步服务器结果: {}", response);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("推送frontCategory到同步服务器失败: {}", e.getMessage(), e);
|
|
|
+ try {
|
|
|
+ JSONArray productList = body.getJSONArray("productList");
|
|
|
+ for (Object hbProductObject : productList) {
|
|
|
+ JSONObject hbProduct = JSON.parseObject(hbProductObject.toString());
|
|
|
+
|
|
|
+ String spuId = hbProduct.getString("spuId");
|
|
|
+ String skuId = hbProduct.getString("skuId");
|
|
|
+ Product product;
|
|
|
+ if (ObjectUtil.isNotEmpty(spuId)) {
|
|
|
+ product = productMapper.selectByHbSpuId(spuId);
|
|
|
+ } else {
|
|
|
+ Sku sku = skuMapper.selectByHbSkuId(skuId);
|
|
|
+ product = productMapper.selectByHbSpuId(sku.getHbSpuId());
|
|
|
}
|
|
|
+ if (!ObjectUtil.isEmpty(product)) {
|
|
|
+ product.setIsDelete(1);
|
|
|
+ productMapper.updateById(product);
|
|
|
+ try {
|
|
|
+ String syncUrl = smqjhUtil.getSmqjhPmsUrl() + "/syncProductDel" + product.getHbSpuId();
|
|
|
+ log.info("推送url: {}", syncUrl);
|
|
|
+ // 将frontCategory对象作为JSON放入请求体
|
|
|
+ String response = com.yami.shop.common.util.HttpUtil.post(syncUrl, product);
|
|
|
+ log.info("推送frontCategory到同步服务器结果: {}", response);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("推送frontCategory到同步服务器失败: {}", e.getMessage(), e);
|
|
|
+ }
|
|
|
|
|
|
- skuMapper.deleteByProdId(product.getProdId());
|
|
|
- //删除门店对应商品
|
|
|
- shopSkuMapper.deleteByProdId(product.getProdId());
|
|
|
+ skuMapper.deleteByProdId(product.getProdId());
|
|
|
+ //删除门店对应商品
|
|
|
+ shopSkuMapper.deleteByProdId(product.getProdId());
|
|
|
+ }
|
|
|
}
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("商品删除失败:{}", e.getMessage(), e);
|
|
|
}
|
|
|
}
|
|
|
|