|
|
|
@ -10,6 +10,8 @@ import java.util.Map;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
import java.util.regex.Matcher;
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
|
|
|
@ -29,6 +31,9 @@ import com.doudian.open.api.material_getFolderInfo.data.ChildFolderItem;
|
|
|
|
|
import com.doudian.open.api.material_getFolderInfo.data.MaterialGetFolderInfoData;
|
|
|
|
|
import com.doudian.open.api.material_getFolderInfo.param.MaterialGetFolderInfoParam;
|
|
|
|
|
import com.doudian.open.api.product_addV2.data.ProductAddV2Data;
|
|
|
|
|
import com.doudian.open.api.product_detail.ProductDetailRequest;
|
|
|
|
|
import com.doudian.open.api.product_detail.ProductDetailResponse;
|
|
|
|
|
import com.doudian.open.api.product_detail.param.ProductDetailParam;
|
|
|
|
|
import com.doudian.open.api.product_getCatePropertyV2.ProductGetCatePropertyV2Request;
|
|
|
|
|
import com.doudian.open.api.product_getCatePropertyV2.ProductGetCatePropertyV2Response;
|
|
|
|
|
import com.doudian.open.api.product_getCatePropertyV2.param.ProductGetCatePropertyV2Param;
|
|
|
|
@ -1306,4 +1311,87 @@ public class MoveService {
|
|
|
|
|
|
|
|
|
|
return CommonTool.successResult("data", response.getData());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Ret getProductFromDdRequest(long productId, AccessToken accessToken) {
|
|
|
|
|
if (productId == 0) {
|
|
|
|
|
return CommonTool.failResult("请传有效的product_id或有效的out_product_id");
|
|
|
|
|
}
|
|
|
|
|
ProductDetailRequest request = new ProductDetailRequest();
|
|
|
|
|
ProductDetailParam param = request.getParam();
|
|
|
|
|
param.setProductId(String.valueOf(productId));
|
|
|
|
|
ProductDetailResponse response = request.execute(accessToken);
|
|
|
|
|
Ret checkRet = CommonTool.checkDdApiRetStatus(response);
|
|
|
|
|
if (CommonTool.isFailRet(checkRet)) {
|
|
|
|
|
return checkRet;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return CommonTool.successResult("data", response.getData());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Ret getProductFromDd(long productId, AccessToken accessToken) {
|
|
|
|
|
if (productId == 0) {
|
|
|
|
|
return CommonTool.failResult("商品id不能为空");
|
|
|
|
|
}
|
|
|
|
|
Ret ret = null;
|
|
|
|
|
for (int tryTimes = 0; tryTimes < 3; tryTimes++) {
|
|
|
|
|
ret = getProductFromDdRequest(productId, accessToken);
|
|
|
|
|
//这种情况是抖店后端超时,直接重试
|
|
|
|
|
Pattern pattern = Pattern.compile("系统错误读取(.*)失败", Pattern.CASE_INSENSITIVE | Pattern.DOTALL);
|
|
|
|
|
Matcher matcher = pattern.matcher(ret.getReason());
|
|
|
|
|
if (CommonTool.isFailRet(ret) && matcher.find()) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (CommonTool.isFailRet(ret) && (ret.getCode().equals(30001) || ret.getReason().contains("授权已被关闭"))) {
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (CommonTool.isFailRet(ret)) {
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO
|
|
|
|
|
//dd 返回字段首字母大写,全部转成小写处理。
|
|
|
|
|
// JSONObject product = (JSONObject)ret.getData().get("data");
|
|
|
|
|
|
|
|
|
|
// $productFormatNew = json_decode($ret['data']['product_format_new'], true);
|
|
|
|
|
// $productFormat = [];
|
|
|
|
|
// foreach ($productFormatNew as &$attrs) {
|
|
|
|
|
// foreach ($attrs as $index => $attr) {
|
|
|
|
|
// foreach ($attr as $key => $value) {
|
|
|
|
|
// unset($attr[$key]);
|
|
|
|
|
// $attr[lcfirst($key)] = $value;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// $propertyName = $attr['propertyName'];
|
|
|
|
|
// $productFormat[$propertyName] = $productFormat[$propertyName] ? $productFormat[$propertyName] . ' ' . $attr['name'] : $attr['name'];
|
|
|
|
|
// $attrs[$index] = $attr;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// $ret['data']['product_format_new'] = json_encode($productFormatNew, true);
|
|
|
|
|
// $ret['data']['product_format'] = $ret['data']['product_format'] ? $ret['data']['product_format'] : json_encode($productFormat, true);
|
|
|
|
|
//
|
|
|
|
|
// $specOrder = [];
|
|
|
|
|
// foreach ($ret['data']['specs'][0]['values'] as $index => $spec) {
|
|
|
|
|
// $specOrder[$spec['id']] = $index;
|
|
|
|
|
// }
|
|
|
|
|
// usort($ret['data']['spec_pics'], function ($specA, $specB) use ($specOrder) {
|
|
|
|
|
// return $specOrder[$specA['spec_detail_id']] - $specOrder[$specB['spec_detail_id']];
|
|
|
|
|
// });
|
|
|
|
|
//
|
|
|
|
|
// if(empty($ret['data']['quality_list'])) {
|
|
|
|
|
// if(!empty($ret['data']['extra'])) {
|
|
|
|
|
// $extra = json_decode($ret['data']['extra'], true);
|
|
|
|
|
// $ret['data']['quality_list'] = !empty($extra['quality_list']) ? $extra['quality_list'] : [];
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if ($ret['data']['name_prefix'] && (stripos($ret['data']['name'], $ret['data']['name_prefix']) === 0)) {
|
|
|
|
|
// $ret['data']['name'] = mb_substr($ret['data']['name'], mb_strlen($ret['data']['name_prefix']));
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
return CommonTool.successResult("product", ret.getData());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|