|
|
@@ -1,21 +1,29 @@
|
|
|
package org.dromara.external.controller.zhongzhi;
|
|
|
|
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.lang.UUID;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.crypto.SecureUtil;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
-import org.dromara.auth.api.RemoteAuthService;
|
|
|
-import org.dromara.auth.api.domain.RemoteLoginVo;
|
|
|
-import org.dromara.external.controller.zhongzhi.domain.Attribute;
|
|
|
-import org.dromara.external.controller.zhongzhi.domain.Result;
|
|
|
-import org.dromara.external.controller.zhongzhi.domain.bo.*;
|
|
|
-import org.dromara.external.controller.zhongzhi.domain.vo.*;
|
|
|
+import org.dromara.common.json.utils.JsonUtils;
|
|
|
+import org.dromara.external.api.zhongzhi.domain.Attribute;
|
|
|
+import org.dromara.external.api.zhongzhi.domain.Result;
|
|
|
+import org.dromara.external.api.zhongzhi.domain.bo.*;
|
|
|
+import org.dromara.external.api.zhongzhi.domain.vo.*;
|
|
|
+import org.dromara.external.domain.ExternalProductCategory;
|
|
|
+import org.dromara.external.service.IExternalProductBrandService;
|
|
|
+import org.dromara.external.service.IExternalProductCategoryService;
|
|
|
+import org.dromara.product.api.RemoteExternalOrderService;
|
|
|
import org.dromara.product.api.RemoteProductService;
|
|
|
import org.dromara.product.api.domain.ProductChangeLogApiVo;
|
|
|
import org.dromara.product.api.domain.ProductVo;
|
|
|
+import org.dromara.product.api.domain.dto.OrderNoticeDto;
|
|
|
+import org.dromara.product.api.domain.dto.OrderPushDto;
|
|
|
import org.dromara.system.api.RemoteUserService;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
@@ -23,6 +31,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
|
|
|
@@ -39,12 +48,17 @@ import java.util.Objects;
|
|
|
@RequestMapping("/zhongzhi/api")
|
|
|
public class ZhongZhiPushController {
|
|
|
|
|
|
- @DubboReference
|
|
|
- private final RemoteAuthService remoteAuthService;
|
|
|
|
|
|
@DubboReference
|
|
|
private final RemoteProductService remoteProductService;
|
|
|
|
|
|
+ @DubboReference
|
|
|
+ private final RemoteExternalOrderService remoteOrderService;
|
|
|
+
|
|
|
+ private final IExternalProductCategoryService externalProductCategoryService;
|
|
|
+
|
|
|
+ private final IExternalProductBrandService externalProductBrandService;
|
|
|
+
|
|
|
/**
|
|
|
* 校验token
|
|
|
* */
|
|
|
@@ -61,35 +75,6 @@ public class ZhongZhiPushController {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取 Access Token
|
|
|
- * @param username 用户名
|
|
|
- * @param password 密码(明文,生产环境建议加密后再传)
|
|
|
- * @return 包含 access_token 和 expires_at 的 Result,失败则 success=false
|
|
|
- */
|
|
|
- @PostMapping("/auth2/access_token")
|
|
|
- public Result getAccessToken(String timestamp, String username, String password, String sign) {
|
|
|
- // 2. 生成 sign = MD5(username + password + timestamp + password).toLowerCase()
|
|
|
- String signStr = username + password + timestamp + password;
|
|
|
- String sign1 = SecureUtil.md5(signStr).toLowerCase();
|
|
|
-
|
|
|
- if(Objects.equals(sign1,sign)){
|
|
|
- RemoteLoginVo loginVo= remoteAuthService.getAccessToken(username, password);
|
|
|
- if(ObjectUtil.isEmpty(loginVo)){
|
|
|
- return Result.fail(5002,"授权失败");
|
|
|
- }
|
|
|
- if(ObjectUtil.isNotEmpty(loginVo.getMsg())){
|
|
|
- return Result.fail(loginVo.getCode(),loginVo.getMsg());
|
|
|
- }
|
|
|
- DateTime date = DateUtil.offsetSecond(DateUtil.date(), (int) StpUtil.getTokenTimeout(loginVo.getAccessToken()));
|
|
|
- String format = DateUtil.format(date, "yyyy-MM-dd HH:mm:ss");
|
|
|
- return Result.tokenOk(loginVo.getAccessToken(), format);
|
|
|
- } else {
|
|
|
- return Result.fail(5004,"签名错误,请检查后重试");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 获取电商商品变动消息
|
|
|
* */
|
|
|
@@ -120,7 +105,7 @@ public class ZhongZhiPushController {
|
|
|
return Result.ok(productMessageInfos);
|
|
|
}
|
|
|
/**
|
|
|
- * 获取商品详情
|
|
|
+ * 获取商品详情 362031
|
|
|
* */
|
|
|
@PostMapping("/product/detail_standard")
|
|
|
public Result<ExternalProductVo> detailStandard(GetProductDetailBo bo) {
|
|
|
@@ -133,6 +118,19 @@ public class ZhongZhiPushController {
|
|
|
}
|
|
|
|
|
|
ProductVo productDetail = remoteProductService.getProductDetail(Long.valueOf(bo.getSku()));
|
|
|
+ //获取第三方分类
|
|
|
+// ExternalProductBrand one = externalProductBrandService.getOne(Wrappers.lambdaQuery(ExternalProductBrand.class)
|
|
|
+// .eq(ExternalProductBrand::getProductBrandId, productDetail.getBrandId())
|
|
|
+// .eq(ExternalProductBrand::getPlatformCode, bo.getPlatformCode())
|
|
|
+// .last("limit 1")
|
|
|
+// );
|
|
|
+ ExternalProductCategory one = externalProductCategoryService.getOne(Wrappers.lambdaQuery(ExternalProductCategory.class)
|
|
|
+ .eq(ExternalProductCategory::getProductCategoryId, productDetail.getBottomCategoryId())
|
|
|
+ .eq(ExternalProductCategory::getDataSource, bo.getPlatformCode())
|
|
|
+ .last("limit 1")
|
|
|
+ );
|
|
|
+
|
|
|
+
|
|
|
ExternalProductVo externalProductVo = ExternalProductVo.builder()
|
|
|
.sku(String.valueOf(productDetail.getId()))
|
|
|
.url(productDetail.getProductImage())
|
|
|
@@ -145,18 +143,22 @@ public class ZhongZhiPushController {
|
|
|
.product_area(null)
|
|
|
.upc(productDetail.getUpcBarcode())
|
|
|
.unit(productDetail.getUnitName())
|
|
|
- .category(productDetail.getCategoryName())
|
|
|
+ .category(null)
|
|
|
.service(productDetail.getAfterSalesService())
|
|
|
.code_69(null)
|
|
|
.introduction(productDetail.getMainLibraryIntro())
|
|
|
.build();
|
|
|
+ if(ObjectUtil.isNotEmpty(one)){
|
|
|
+ externalProductVo.setCategory(one.getCategoryNo());
|
|
|
+ }
|
|
|
+
|
|
|
return Result.ok(externalProductVo);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取商品参数信息
|
|
|
* */
|
|
|
- @PostMapping("/product/ product_attributes_standard")
|
|
|
+ @PostMapping("/product/product_attributes_standard")
|
|
|
public Result<Attribute> productAttributesStandard(GetProductDetailBo bo) {
|
|
|
Result result = checkToken(bo.getToken(), bo.getPlatformCode());
|
|
|
if(ObjectUtil.isNotEmpty(result)){
|
|
|
@@ -256,8 +258,8 @@ public class ZhongZhiPushController {
|
|
|
List<ProductPriceVo> prices = productDetails.stream().map(productVo -> {
|
|
|
ProductPriceVo productPriceVo = new ProductPriceVo();
|
|
|
productPriceVo.setSku(String.valueOf(productVo.getId()));
|
|
|
- productPriceVo.setPrice(productVo.getMarketPrice());
|
|
|
- productPriceVo.setMall_price(productVo.getMemberPrice());
|
|
|
+ productPriceVo.setPrice(productVo.getMemberPrice());
|
|
|
+ productPriceVo.setMall_price(productVo.getMarketPrice());
|
|
|
productPriceVo.setStock(String.valueOf(productVo.getTotalInventory()));
|
|
|
return productPriceVo;
|
|
|
}).toList();
|
|
|
@@ -296,6 +298,7 @@ public class ZhongZhiPushController {
|
|
|
if(ObjectUtil.isEmpty(bo.getSku())){
|
|
|
return Result.fail(5006,"订单商品不能为空");
|
|
|
}
|
|
|
+ List<OrderPushBo.SkuItem> sku = JsonUtils.parseArray(bo.getSku(), OrderPushBo.SkuItem.class);
|
|
|
if(ObjectUtil.isEmpty(bo.getName())){
|
|
|
return Result.fail(5006,"收货人名称不能为空");
|
|
|
}
|
|
|
@@ -358,10 +361,42 @@ public class ZhongZhiPushController {
|
|
|
if(ObjectUtil.isEmpty(bo.getOrderCode())){
|
|
|
return Result.fail(5006,"卖场订单编号不能为空");
|
|
|
}
|
|
|
+ OrderPushDto dto = BeanUtil.toBean(bo, OrderPushDto.class);
|
|
|
+// remoteOrderService.pushOrder(dto);
|
|
|
OrderPushVo orderPushVo = new OrderPushVo();
|
|
|
+ orderPushVo.setOrderPrice(bo.getOrder_price());
|
|
|
+ List<OrderPushVo.Sku> list = sku.stream().map(skuItem -> {
|
|
|
+ OrderPushVo.Sku skuVo = new OrderPushVo.Sku();
|
|
|
+ skuVo.setSku(skuItem.getSku());
|
|
|
+ skuVo.setNum(String.valueOf(skuItem.getNum()));
|
|
|
+ skuVo.setPrice(String.valueOf(skuItem.getPrice()));
|
|
|
+ return skuVo;
|
|
|
+ }).toList();
|
|
|
+ orderPushVo.setMall_order_id(UUID.randomUUID().toString());
|
|
|
+ orderPushVo.setSku(list);
|
|
|
+// sku.setSku("1");
|
|
|
+// sku.setNum(bo.get);
|
|
|
+// orderPushVo.setSku();
|
|
|
+
|
|
|
return Result.ok(orderPushVo);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 确认接收订单
|
|
|
+ * */
|
|
|
+ @PostMapping("/order/confirm")
|
|
|
+ public Result confirm(OrderPushBo bo) {
|
|
|
+ Result result = checkToken(bo.getToken(),bo.getPlatformCode());
|
|
|
+ if(ObjectUtil.isNotEmpty(result)){
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ if(ObjectUtil.isEmpty(bo.getOrder_id())){
|
|
|
+ return Result.fail(5006,"订单编号不能为空");
|
|
|
+ }
|
|
|
+// remoteOrderService.confirmOrder(Long.valueOf(bo.getOrder_id()));
|
|
|
+ return Result.ok("成功确认接收订单",null);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 订单状态通知接口
|
|
|
* */
|
|
|
@@ -377,9 +412,33 @@ public class ZhongZhiPushController {
|
|
|
if(ObjectUtil.isEmpty(bo.getOrderState())){
|
|
|
return Result.fail(5006,"订单状态不能为空");
|
|
|
}
|
|
|
+ OrderNoticeDto dto = BeanUtil.toBean(bo, OrderNoticeDto.class);
|
|
|
+// remoteOrderService.notice(dto);
|
|
|
return Result.ok("成功收到通知",null);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 商品状态通知接口
|
|
|
+ * */
|
|
|
+ @PostMapping("/product/notice")
|
|
|
+ public Result notice(ProductNoticeBo bo) {
|
|
|
+ Result result = checkToken(bo.getToken(),bo.getPlatformCode());
|
|
|
+ if(ObjectUtil.isNotEmpty(result)){
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ if(ObjectUtil.isEmpty(bo.getSku())){
|
|
|
+ return Result.fail(5006,"商品编号不能为空");
|
|
|
+ }
|
|
|
+ if(ObjectUtil.isEmpty(bo.getStatus())){
|
|
|
+ return Result.fail(5006,"商品状态不能为空");
|
|
|
+ }
|
|
|
+ if(ObjectUtil.isEmpty(bo.getMessage())){
|
|
|
+ return Result.fail(5006,"商品状态通知不能为空");
|
|
|
+ }
|
|
|
+ return Result.ok("成功收到通知",null);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|