获取商品详情返回抖店信息

20230922-ljl-fixBug
cxxxxxxx详 1 year ago
parent 748cd87635
commit 9befe75f4a

@ -25,6 +25,8 @@ public interface MoveCollectTaskDetailService {
int updateByPrimaryKey(MoveCollectTaskDetail record);
int getMoveCollectTaskProcessingCount(Long shopId);
MoveCollectTaskDetail getMoveCollectTaskDetail(long shopId, long moveCollectTaskDetailId) ;
Pager<MoveCollectTaskDetail> getMoveCollectTaskList(GetMoveHistoryProductListRequestDTO condition);

@ -54,6 +54,11 @@ public class MoveCollectTaskDetailServiceImpl implements MoveCollectTaskDetailSe
return moveCollectTaskDetailMapper.updateByPrimaryKey(record);
}
@Override
public int getMoveCollectTaskProcessingCount(Long shopId) {
return moveCollectTaskDetailMapper.getMoveCollectTaskProcessingCount(shopId);
}
@Override
public MoveCollectTaskDetail getMoveCollectTaskDetail(long shopId, long moveCollectTaskDetailId) {
return moveCollectTaskDetailMapper.selectByPrimaryKey(moveCollectTaskDetailId);

@ -46,11 +46,12 @@ public class GetMoveHistoryProductListService extends SPIBaseService implements
condition.setPageSize(fields.getPageSize());
condition.setShopId(shopId);
Pager<MoveCollectTaskDetail> moveCollectTaskPager = moveCollectTaskDetailService.getMoveCollectTaskList(condition);
int processingTaskCount = moveCollectTaskDetailService.getMoveCollectTaskProcessingCount(shopId);
Map<String, Object> result = new HashMap<>();
result.put("taskDetailList", moveCollectTaskPager.getData());
result.put("taskTotal", moveCollectTaskPager.getTotal());
result.put("processingTaskCount", moveCollectTaskPager.getTotal());
result.put("processingTaskCount", processingTaskCount);
result.put("page", moveCollectTaskPager.getPage());
result.put("pageSize", moveCollectTaskPager.getPageSize());
// ----结果返回----

@ -11,8 +11,10 @@ import com.ms.api.common.R;
import com.ms.api.common.Ret;
import com.ms.api.common.SPIBaseService;
import com.ms.api.dto.move.GetProductInfoRequestDTO;
import com.ms.api.service.CategoryService;
import com.ms.api.service.MoveSystemSourceCategoryService;
import com.ms.api.tool.DsJsonRequestTemplate;
import com.ms.dal.entity.Category;
import com.ms.dal.entity.MoveSystemSourceCategory;
import lombok.extern.slf4j.Slf4j;
import org.phprpc.util.AssocArray;
@ -39,6 +41,9 @@ public class GetProductInfoByProductId extends SPIBaseService implements Extensi
@Autowired
private MoveSystemSourceCategoryService moveSystemSourceCategoryService;
@Autowired
private CategoryService categoryService;
@Override
public BaseResponse<Ret> handle(BaseRequest<GetProductInfoRequestDTO> req) {
// ----逻辑校验----
@ -69,14 +74,16 @@ public class GetProductInfoByProductId extends SPIBaseService implements Extensi
String content = moveSystemSourceCategory.getMatchCategoryList();
AssocArray assocArray = (AssocArray) p.unserialize(content.getBytes());
Map assocMap = assocArrayToHash(assocArray);
List<Object> assocMapValues = new ArrayList<>(assocMap.values());
Map inMap = (Map) assocMapValues.get(assocMapValues.size() - 1);
List<String> assocMapKeys = new ArrayList<>(assocMap.keySet());
log.info("assocArrayToHash" + inMap.get("path"));
log.info("assocArrayToHash" + assocMapKeys.get(assocMapKeys.size() - 1));
product.put("ddCid", inMap.get("path"));
product.put("ddCategoryList", assocMapKeys.get(assocMapKeys.size() - 1));
Long categoryId = Long.valueOf(assocMapKeys.get(assocMapKeys.size() - 1));
List<Long> categoryIds = this.getCategoryIdList(categoryId);
Category category = categoryService.selectByPrimaryKey(Long.valueOf(assocMapKeys.get(assocMapKeys.size() - 1)));
String path = category.getPath();
List<String> pathArr = Arrays.asList(path.split(">"));
product.put("ddCid", categoryIds);
product.put("ddCategoryList", pathArr);
} else {
product.put("ddCid", "");
product.put("ddCategoryList", "");
@ -98,6 +105,17 @@ public class GetProductInfoByProductId extends SPIBaseService implements Extensi
return R.ok(Ret.success(result));
}
private List<Long> getCategoryIdList(Long categoryId) {
List<Long> categoryIdList = new ArrayList<>();
while(categoryId != 0) {
Category category = categoryService.selectByPrimaryKey(categoryId);
categoryIdList.add(categoryId);
categoryId = Long.valueOf(category.getParentCategoryId());
}
Collections.reverse(categoryIdList);
return categoryIdList;
}
private static Map assocArrayToHash(AssocArray assocArray) {
HashMap hashMap = assocArray.toHashMap();
Map result = new HashMap();

@ -11,9 +11,11 @@ import com.ms.api.common.R;
import com.ms.api.common.Ret;
import com.ms.api.common.SPIBaseService;
import com.ms.api.dto.move.GetProductInfoRequestDTO;
import com.ms.api.service.CategoryService;
import com.ms.api.service.MoveSystemSourceCategoryService;
import com.ms.api.tool.DsJsonRequestTemplate;
import com.ms.api.common.UniqueKeyMultiValueMap;
import com.ms.dal.entity.Category;
import com.ms.dal.entity.MoveSystemSourceCategory;
import lombok.extern.slf4j.Slf4j;
import org.phprpc.util.AssocArray;
@ -21,10 +23,7 @@ import org.phprpc.util.PHPSerializer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.MultiValueMap;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -45,6 +44,9 @@ public class GetProductInfoService extends SPIBaseService implements ExtensionSe
@Autowired
private MoveSystemSourceCategoryService moveSystemSourceCategoryService;
@Autowired
private CategoryService categoryService;
@Override
public BaseResponse<Ret> handle(BaseRequest<GetProductInfoRequestDTO> req) {
initHandle(req);
@ -80,14 +82,16 @@ public class GetProductInfoService extends SPIBaseService implements ExtensionSe
String content = moveSystemSourceCategory.getMatchCategoryList();
AssocArray assocArray = (AssocArray) p.unserialize(content.getBytes());
Map assocMap = assocArrayToHash(assocArray);
List<Object> assocMapValues = new ArrayList<>(assocMap.values());
Map inMap = (Map) assocMapValues.get(assocMapValues.size() - 1);
List<String> assocMapKeys = new ArrayList<>(assocMap.keySet());
log.info("assocArrayToHash" + inMap.get("path"));
log.info("assocArrayToHash" + assocMapKeys.get(assocMapKeys.size() - 1));
product.put("ddCid", assocMapKeys.get(assocMapKeys.size() - 1));
product.put("ddCategoryList", inMap.get("path"));
Long categoryId = Long.valueOf(assocMapKeys.get(assocMapKeys.size() - 1));
List<Long> categoryIds = this.getCategoryIdList(categoryId);
Category category = categoryService.selectByPrimaryKey(Long.valueOf(assocMapKeys.get(assocMapKeys.size() - 1)));
String path = category.getPath();
List<String> pathArr = Arrays.asList(path.split(">"));
product.put("ddCid", categoryIds);
product.put("ddCategoryList", pathArr);
} else {
product.put("ddCid", "");
product.put("ddCategoryList", "");
@ -114,6 +118,16 @@ public class GetProductInfoService extends SPIBaseService implements ExtensionSe
// ----结果返回----
return R.ok(Ret.success(result));
}
private List<Long> getCategoryIdList(Long categoryId) {
List<Long> categoryIdList = new ArrayList<>();
while(categoryId != 0) {
Category category = categoryService.selectByPrimaryKey(categoryId);
categoryIdList.add(categoryId);
categoryId = Long.valueOf(category.getParentCategoryId());
}
Collections.reverse(categoryIdList);
return categoryIdList;
}
private static Map assocArrayToHash(AssocArray assocArray) {
HashMap hashMap = assocArray.toHashMap();
Map result = new HashMap();

@ -28,6 +28,8 @@ public interface MoveCollectTaskDetailMapper {
Integer getMoveCollectTaskCount(Long shopId, String status);
Integer getMoveCollectTaskProcessingCount(Long shopId);
List<MoveCollectTaskDetail> getMoveCollectTaskListByDetailIds(Long shopId, List<Long> moveCollectTaskDetailIds);
List<Long> getMoveDetailIdsByStatus(Long shopId, String status);

@ -250,6 +250,11 @@
and status = #{status}
</if>
</select>
<select id="getMoveCollectTaskProcessingCount" resultType="java.lang.Integer">
select COUNT(move_collect_task_detail_id)
from move_collect_task_detail
where shop_id = #{shopId} and status = "processing"
</select>
<select id="getMoveCollectTaskListByDetailIds" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />

Loading…
Cancel
Save