Commit 69fe08bc authored by shiyu's avatar shiyu

查询交换商品信息

parent 285a2302
...@@ -164,9 +164,8 @@ public class ExchangeServiceImpl implements ExchangeService { ...@@ -164,9 +164,8 @@ public class ExchangeServiceImpl implements ExchangeService {
list.add(supplierItemVo); list.add(supplierItemVo);
} }
logger.info("查询用户标签下的藏品数目:{}", list.size()); logger.info("查询用户标签下的藏品数目:{}", list.size());
//查询交换的商品 //查询交换的商品
SupplierItem supplierItem = supplierItemDao.findById(dto.getExchangeItemId()); /* SupplierItem supplierItem = supplierItemDao.findById(dto.getExchangeItemId());
SupplierItemVo supplierItemVo = new SupplierItemVo(); SupplierItemVo supplierItemVo = new SupplierItemVo();
EntityMapper.copyAttribute(supplierItem, supplierItemVo); EntityMapper.copyAttribute(supplierItem, supplierItemVo);
supplierItemVo.setItemId(supplierItem.getId()); supplierItemVo.setItemId(supplierItem.getId());
...@@ -177,14 +176,33 @@ public class ExchangeServiceImpl implements ExchangeService { ...@@ -177,14 +176,33 @@ public class ExchangeServiceImpl implements ExchangeService {
supplierItemVo.setHomePageImage(MediaUtil.getHomePageImage(supplierItem.getImages(), supplierItem.getVideos())); supplierItemVo.setHomePageImage(MediaUtil.getHomePageImage(supplierItem.getImages(), supplierItem.getVideos()));
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("itemList", PageSearchResult.of(pageInfo, list)); map.put("itemList", PageSearchResult.of(pageInfo, list));
map.put("exchangeItem", supplierItemVo); map.put("exchangeItem", supplierItemVo);*/
return Result.success(map); return Result.success(PageSearchResult.of(pageInfo, list));
}catch (Exception e) { } catch (Exception e) {
logger.error("查询用户可交换的藏品失败 error: {}", e); logger.error("查询用户可交换的藏品失败 error: {}", e);
} }
return Result.failed(); return Result.failed();
} }
@Override
public Result findExchangeItem(ExchangeRequestDto dto) {
try {
SupplierItem supplierItem = supplierItemDao.findById(dto.getExchangeItemId());
SupplierItemVo supplierItemVo = new SupplierItemVo();
EntityMapper.copyAttribute(supplierItem, supplierItemVo);
supplierItemVo.setItemId(supplierItem.getId());
supplierItemVo.setItemNum(dto.getExchangeItemNum());
supplierItemVo.setSupplyPrice(PriceUtil.convertPriceFenToYuan(supplierItem.getSupplyPrice()));
supplierItemVo.setDistributionPrice(PriceUtil.convertPriceFenToYuan(supplierItem.getDistributionPrice()));
supplierItemVo.setOfficialEstimatedPrice(PriceUtil.convertPriceFenToYuan(supplierItem.getOfficialEstimatedPrice()));
supplierItemVo.setHomePageImage(MediaUtil.getHomePageImage(supplierItem.getImages(), supplierItem.getVideos()));
return Result.success(supplierItemVo);
} catch (Exception e) {
logger.error("查询交换的藏品失败 error: {}", e);
}
return Result.failed();
}
@Transactional @Transactional
@Override @Override
public Result exchange(ExchangeRequestDto dto) { public Result exchange(ExchangeRequestDto dto) {
......
...@@ -21,6 +21,13 @@ public interface ExchangeService { ...@@ -21,6 +21,13 @@ public interface ExchangeService {
*/ */
Result findItemList(ExchangeRequestDto dto); Result findItemList(ExchangeRequestDto dto);
/**
* 查询交换商品信息
* @param dto
* @return
*/
Result findExchangeItem(ExchangeRequestDto dto);
/** /**
* 以物换物 * 以物换物
......
...@@ -75,6 +75,23 @@ public class ExchangeController { ...@@ -75,6 +75,23 @@ public class ExchangeController {
} }
@ApiOperation(value = "查询交换商品信息")
@PostMapping("/findExchangeItem")
public Result findExchangeItem(@RequestBody ExchangeRequestDto dto) {
logger.info("查询交换商品信息,请求参数:{}", JSON.toJSONString(dto));
Validator validator = new Validator(FormHandler.ofEntity(dto));
validator.set("exchangeItemId", "被交换的商品id").must().number()
.set("exchangeItemNum", "被交换的商品数量").must().number()
.end();
if (!validator.isValid()) {
return Result.failed(validator.getErrorInfo());
}
return exchangeService.findExchangeItem(dto);
}
@ApiOperation(value = "用户换藏发货") @ApiOperation(value = "用户换藏发货")
@PostMapping("/delivery") @PostMapping("/delivery")
public Result delivery(@RequestBody DistributionOrderRequestDto dto) { public Result delivery(@RequestBody DistributionOrderRequestDto dto) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment