From 9ce6183787088f0577f9975ac7b89de8284f2094 Mon Sep 17 00:00:00 2001 From: yuanye <418471657@qq.com> Date: Fri, 22 Nov 2024 16:22:52 +0800 Subject: [PATCH] /1 --- .../com/bweb/controller/TestController.java | 39 +++++++++++++++++++ .../controller/goods/GoodsController.java | 5 +++ .../business/BsOrderGoodsController.java | 6 +-- .../java/com/hfkj/jd/Impl/JdServiceImpl.java | 27 ++++++++++++- .../main/java/com/hfkj/jd/JdPostService.java | 9 +++++ .../src/main/java/com/hfkj/jd/JdService.java | 11 ++++++ .../hfkj/service/goods/GoodsSpecsService.java | 10 +++++ .../goods/impl/GoodsMsgServiceImpl.java | 3 ++ .../goods/impl/GoodsSpecsServiceImpl.java | 7 ++++ .../service/order/OrderCreateService.java | 3 +- 10 files changed, 111 insertions(+), 9 deletions(-) diff --git a/bweb/src/main/java/com/bweb/controller/TestController.java b/bweb/src/main/java/com/bweb/controller/TestController.java index d0b00a6..cb3a1ec 100644 --- a/bweb/src/main/java/com/bweb/controller/TestController.java +++ b/bweb/src/main/java/com/bweb/controller/TestController.java @@ -7,6 +7,7 @@ import com.hfkj.common.utils.*; import com.hfkj.config.CommonSysConst; import com.hfkj.entity.BsOrderGoods; +import com.hfkj.entity.GoodsUserAddress; import com.hfkj.jd.JdPostService; import com.hfkj.jd.JdService; import com.hfkj.mer.BsMerPayConfigService; @@ -15,6 +16,7 @@ import com.hfkj.model.ResponseData; import com.hfkj.service.card.BsUserCardService; import com.hfkj.service.coupon.channel.YouTuCouponService; import com.hfkj.service.goods.BsOrderGoodsService; +import com.hfkj.service.goods.GoodsUserAddressService; import com.hfkj.service.hlt.HuiLianTongUnionCardService; import com.hfkj.service.order.BsOrderService; import com.hfkj.service.order.OrderPayService; @@ -52,6 +54,12 @@ public class TestController { @Resource private JdService jdService; + @Resource + private BsOrderGoodsService getOrderGoodsService; + + @Resource + private GoodsUserAddressService goodsUserAddressService; + @RequestMapping(value="/thirdPayResult",method = RequestMethod.GET) @ResponseBody @@ -329,4 +337,35 @@ public class TestController { return ResponseMsgUtil.exception(e); } } + + + @RequestMapping(value="/getGoodsUpdate",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "更新商品") + public ResponseData getGoodsUpdate() { + try { + + Map map = new HashMap<>(); + map.put("status" , 2); + List orderGoodsList = getOrderGoodsService.getList(map); + + List userAddresses = goodsUserAddressService.getList(new HashMap<>()); + + for (BsOrderGoods orderGoods : orderGoodsList) { + GoodsUserAddress address = userAddresses.stream().filter(x -> Objects.equals(x.getId(), orderGoods.getGoodsId())).findFirst().orElse(null); + + if (address != null) { + orderGoods.setDeliveryAddress(address.getRegionName() + "-" + address.getAddress() + "-" + address.getConsignee() + "-" + address.getPhone()); + getOrderGoodsService.update(orderGoods); + } + + } + + return ResponseMsgUtil.success(""); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } } diff --git a/cweb/src/main/java/com/cweb/controller/goods/GoodsController.java b/cweb/src/main/java/com/cweb/controller/goods/GoodsController.java index 0573255..ebd2a18 100644 --- a/cweb/src/main/java/com/cweb/controller/goods/GoodsController.java +++ b/cweb/src/main/java/com/cweb/controller/goods/GoodsController.java @@ -186,6 +186,8 @@ public class GoodsController { GoodsMsg goodsMsg = goodsMsgService.queryDetail(id); + + GoodsModel goodsModel = new GoodsModel(); BeanUtils.copyProperties(goodsMsg, goodsModel); @@ -202,6 +204,9 @@ public class GoodsController { BeanUtils.copyProperties(goodsSpec, goodsModelSpec); GoodsVpd goodsVpd = goodsVpdService.queryDetailBySpecsId(goodsSpec.getId()); if (goodsVpd != null) { + + + BeanUtils.copyProperties(goodsVpd, goodsModelSpec); } goodsModelSpec.setSpecsId(goodsSpec.getId()); diff --git a/order/src/main/java/com/order/controller/business/BsOrderGoodsController.java b/order/src/main/java/com/order/controller/business/BsOrderGoodsController.java index e30992c..6a9dad0 100644 --- a/order/src/main/java/com/order/controller/business/BsOrderGoodsController.java +++ b/order/src/main/java/com/order/controller/business/BsOrderGoodsController.java @@ -346,16 +346,12 @@ public class BsOrderGoodsController { throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "暂无物流信息!"); } - GoodsUserAddress userAddress = addressService.queryDetail(orderGoods.getDeliveryAddressId()); - if (userAddress == null) { - throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "暂无物流信息!"); - } if (orderGoods.getLogisticsNo() == null) { throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "待揽收!"); } - GoodsLogistics logistics = (GoodsLogistics) bsOrderGoodsService.getLogisticsMsg(orderGoods.getLogisticsNo() , userAddress.getPhone()); + GoodsLogistics logistics = (GoodsLogistics) bsOrderGoodsService.getLogisticsMsg(orderGoods.getLogisticsNo() , orderGoods.getUserPhone()); if (logistics.getLogisticsStatus() != null) { orderGoods.setLogisticsStatus(logistics.getLogisticsStatus()); diff --git a/service/src/main/java/com/hfkj/jd/Impl/JdServiceImpl.java b/service/src/main/java/com/hfkj/jd/Impl/JdServiceImpl.java index 1300d10..33dabf2 100644 --- a/service/src/main/java/com/hfkj/jd/Impl/JdServiceImpl.java +++ b/service/src/main/java/com/hfkj/jd/Impl/JdServiceImpl.java @@ -17,6 +17,7 @@ import com.jd.open.api.sdk.domain.vopsp.SkuPoolGoodsProvider.response.getSkuPool import com.jd.open.api.sdk.response.vopsp.VopGoodsGetSkuDetailInfoResponse; import com.jd.open.api.sdk.response.vopsp.VopGoodsGetSkuImageListResponse; import com.jd.open.api.sdk.response.vopsp.VopGoodsGetSkuPoolInfoResponse; +import com.jd.open.api.sdk.response.vopsp.VopGoodsGetSkuStateListResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -62,7 +63,6 @@ public class JdServiceImpl implements JdService { JdPostService.getAccessToken(); getToken(); } - return token.toString(); } @@ -83,7 +83,8 @@ public class JdServiceImpl implements JdService { List goodsType = goodsTypeService.getList(new HashMap<>()); List brands = goodsBrandService.getList(new HashMap<>()); Map goodsMap = new HashMap<>(); - goodsMap.put("type", 3); + goodsMap.put("type", 1); + goodsMap.put("childType", 1); List goodsMsgs = goodsMsgService.getList(goodsMap); List goodsSpecsList = goodsSpecsService.getList(new HashMap<>()); BsProductConfig productConfig = productConfigService.queryDetail(OrderChildProductTypeEnum.type6.getCode()); @@ -289,4 +290,26 @@ public class JdServiceImpl implements JdService { } } } + + + @Override + public Boolean checkSkuSale(GoodsMsg goodsMsg) throws Exception { + + // 查询商品是否下架 + VopGoodsGetSkuStateListResponse skuStateListResponse = JdPostService.getSkuState(getToken(), goodsMsg.getThirdId()); + + if (skuStateListResponse.getOpenRpcResult().getResult().get(0).getSkuState() == 0) { + return true; + } + + // 查询规格 + GoodsSpecs specs = goodsSpecsService.queryDetailByThirdId(goodsMsg.getThirdId()); + + // 根据skuId 查询商品详情 + VopGoodsGetSkuDetailInfoResponse skuDetail = JdPostService.getSkuDetailInfo(getToken(), Long.valueOf(goodsMsg.getThirdId())); + GetSkuPoolInfoGoodsResp detail = skuDetail.getOpenRpcResult().getResult(); + // 根据skuId 查询商品售价 + OpenRpcResult priceResponse = JdPostService.getSellPrice(getToken(), String.valueOf(goodsMsg.getThirdId())).getOpenRpcResult(); + return null; + } } diff --git a/service/src/main/java/com/hfkj/jd/JdPostService.java b/service/src/main/java/com/hfkj/jd/JdPostService.java index 476e459..5d0f362 100644 --- a/service/src/main/java/com/hfkj/jd/JdPostService.java +++ b/service/src/main/java/com/hfkj/jd/JdPostService.java @@ -163,6 +163,15 @@ public class JdPostService { return client.execute(request); } + // 查询商品上下架状态 + public static VopGoodsGetSkuStateListResponse getSkuState(String token , String skuId) throws Exception { + JdClient client=new DefaultJdClient(SERVER_URL,token,CommonSysConst.getSysConfig().getJDAppKey(),CommonSysConst.getSysConfig().getJDAppSecret()); + VopGoodsGetSkuStateListRequest request=new VopGoodsGetSkuStateListRequest(); + request.setSkuId(skuId); + VopGoodsGetSkuStateListResponse response=client.execute(request); + return client.execute(request); + } + // 校验商品购买区域是否受限 public static VopGoodsCheckAreaLimitListResponse checkAreaLimitList(String token , String skuId , Long provinceId , Long cityId , Long countyId , Long townId) throws Exception { JdClient client=new DefaultJdClient(SERVER_URL,token,CommonSysConst.getSysConfig().getJDAppKey(),CommonSysConst.getSysConfig().getJDAppSecret()); diff --git a/service/src/main/java/com/hfkj/jd/JdService.java b/service/src/main/java/com/hfkj/jd/JdService.java index 483406c..12f2843 100644 --- a/service/src/main/java/com/hfkj/jd/JdService.java +++ b/service/src/main/java/com/hfkj/jd/JdService.java @@ -1,5 +1,7 @@ package com.hfkj.jd; +import com.hfkj.entity.GoodsMsg; + public interface JdService { /** @@ -22,4 +24,13 @@ public interface JdService { * @Date: 2024/10/16 下午3:21 */ void getGoodsJd() throws Exception; + + /** + * @MethodName checkSkuSale + * @Description: 校验商品可售性 + * @param goodsMsg + * @Author: Sum1Dream + * @Date: 2024/11/22 下午2:01 + */ + Boolean checkSkuSale(GoodsMsg goodsMsg) throws Exception; } diff --git a/service/src/main/java/com/hfkj/service/goods/GoodsSpecsService.java b/service/src/main/java/com/hfkj/service/goods/GoodsSpecsService.java index 2d914fa..dcfba81 100644 --- a/service/src/main/java/com/hfkj/service/goods/GoodsSpecsService.java +++ b/service/src/main/java/com/hfkj/service/goods/GoodsSpecsService.java @@ -56,6 +56,16 @@ public interface GoodsSpecsService { GoodsSpecs queryDetailByGoodsId(Long id); + /** + * @MethodName queryDetailByThirdId + * @Description: 根据第三方id查询 + * @param thirdId + * @return: com.hfkj.entity.GoodsSpecs + * @Author: Sum1Dream + * @Date: 2024/11/22 下午2:34 + */ + GoodsSpecs queryDetailByThirdId(String thirdId); + /** * @Author Sum1Dream * @Name queryDetailByMap diff --git a/service/src/main/java/com/hfkj/service/goods/impl/GoodsMsgServiceImpl.java b/service/src/main/java/com/hfkj/service/goods/impl/GoodsMsgServiceImpl.java index ac28bd1..e7e0dbc 100644 --- a/service/src/main/java/com/hfkj/service/goods/impl/GoodsMsgServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/goods/impl/GoodsMsgServiceImpl.java @@ -98,6 +98,9 @@ public class GoodsMsgServiceImpl implements GoodsMsgService { if (MapUtils.getInteger(map, "type") != null) { criteria.andTypeEqualTo(MapUtils.getInteger(map, "type")); } + if (MapUtils.getInteger(map, "childType") != null) { + criteria.andChildTypeEqualTo(MapUtils.getInteger(map, "childType")); + } if (MapUtils.getLong(map, "goodsBrand") != null) { criteria.andGoodsBrandEqualTo(MapUtils.getLong(map, "goodsBrand")); } diff --git a/service/src/main/java/com/hfkj/service/goods/impl/GoodsSpecsServiceImpl.java b/service/src/main/java/com/hfkj/service/goods/impl/GoodsSpecsServiceImpl.java index 83b0fc6..e24ae28 100644 --- a/service/src/main/java/com/hfkj/service/goods/impl/GoodsSpecsServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/goods/impl/GoodsSpecsServiceImpl.java @@ -77,6 +77,13 @@ public class GoodsSpecsServiceImpl implements GoodsSpecsService { return null; } + @Override + public GoodsSpecs queryDetailByThirdId(String thirdId) { + GoodsSpecsExample goodsSpecsExample = new GoodsSpecsExample(); + goodsSpecsExample.createCriteria().andThirdIdEqualTo(thirdId); + return null; + } + @Override public GoodsSpecs queryDetailByMap(Map map) { return null; diff --git a/service/src/main/java/com/hfkj/service/order/OrderCreateService.java b/service/src/main/java/com/hfkj/service/order/OrderCreateService.java index 80ff8a8..362c055 100644 --- a/service/src/main/java/com/hfkj/service/order/OrderCreateService.java +++ b/service/src/main/java/com/hfkj/service/order/OrderCreateService.java @@ -282,7 +282,6 @@ public class OrderCreateService { jsonObject.put("goodsJump", goodsJump); // 创建实物订单 - orderGoods.setOrderNo(orderChild.getOrderNo()); orderGoods.setChildOrderNo(orderChild.getChildOrderNo()); orderGoods.setMerId(orderChild.getMerId()); @@ -302,7 +301,7 @@ public class OrderCreateService { orderGoods.setGoodsSpecsOriginalPrice(goodsSpecs.getOriginalPrice()); orderGoods.setGoodsCount(orderChild.getProductCount()); orderGoods.setStatus(orderChild.getStatus()); - orderGoods.setDeliveryAddress(address.getAddress()); + orderGoods.setDeliveryAddress(address.getRegionName() + "-" + address.getAddress() + "-" + address.getConsignee() + "-" + address.getPhone()); orderGoods.setDeliveryAddressId(address.getId()); orderGoods.setCreateTime(new Date()); orderGoods.setUpdateTime(new Date());