Commit 67ee305b authored by shiyu's avatar shiyu

新增商品

parent 6b20d566
...@@ -23,7 +23,7 @@ public class SysSupplierItemController { ...@@ -23,7 +23,7 @@ public class SysSupplierItemController {
private static final Logger logger = LoggerFactory.getLogger(SysSupplierItemController.class); private static final Logger logger = LoggerFactory.getLogger(SysSupplierItemController.class);
@Autowired @Autowired
SysSupplierItemService supplierItemService; SysSupplierItemService sysSupplierItemService;
@ApiOperation(value = "新增商品") @ApiOperation(value = "新增商品")
...@@ -38,6 +38,14 @@ public class SysSupplierItemController { ...@@ -38,6 +38,14 @@ public class SysSupplierItemController {
if (!validator.isValid()) { if (!validator.isValid()) {
return Result.failed(validator.getErrorInfo()); return Result.failed(validator.getErrorInfo());
} }
return supplierItemService.create(dto); return sysSupplierItemService.create(dto);
}
@ApiOperation(value = "查询商品列表")
@PostMapping("/findList")
public Result findList(@RequestBody SupplierItemRequestDto dto) {
logger.info("查询商品列表,请求参数:{}", JSON.toJSONString(dto));
return sysSupplierItemService.findList(dto);
} }
} }
...@@ -57,6 +57,8 @@ public class SysSupplierItemServiceImpl implements SysSupplierItemService { ...@@ -57,6 +57,8 @@ public class SysSupplierItemServiceImpl implements SysSupplierItemService {
@Autowired @Autowired
AuctionConfigDao auctionConfigDao; AuctionConfigDao auctionConfigDao;
@Override @Override
@Transactional @Transactional
public Result create(SupplierItemRequestDto dto) { public Result create(SupplierItemRequestDto dto) {
...@@ -110,6 +112,9 @@ public class SysSupplierItemServiceImpl implements SysSupplierItemService { ...@@ -110,6 +112,9 @@ public class SysSupplierItemServiceImpl implements SysSupplierItemService {
supplierItemVo.setDistributionPrice(PriceUtil.convertPriceFenToYuan(supplierItem.getDistributionPrice())); supplierItemVo.setDistributionPrice(PriceUtil.convertPriceFenToYuan(supplierItem.getDistributionPrice()));
supplierItemVo.setHomePageImage(MediaUtil.getHomePageImage(supplierItem.getImages(), supplierItem.getVideos())); supplierItemVo.setHomePageImage(MediaUtil.getHomePageImage(supplierItem.getImages(), supplierItem.getVideos()));
supplierItemVos.add(supplierItemVo); supplierItemVos.add(supplierItemVo);
//售出数量
long selledNum = distributionOrderDao.countSelledNum(supplierItem.getId());
supplierItemVo.setSelledNum(selledNum);
}); });
return Result.success(PageSearchResult.of(pageInfo, supplierItemVos)); return Result.success(PageSearchResult.of(pageInfo, supplierItemVos));
} catch (Exception e) { } catch (Exception e) {
...@@ -137,6 +142,11 @@ public class SysSupplierItemServiceImpl implements SysSupplierItemService { ...@@ -137,6 +142,11 @@ public class SysSupplierItemServiceImpl implements SysSupplierItemService {
return Result.failed(); return Result.failed();
} }
@Override
public Result update(SupplierItemRequestDto dto) {
return null;
}
public Result updateDistributionPrice(SupplierItemRequestDto dto) { public Result updateDistributionPrice(SupplierItemRequestDto dto) {
try { try {
SupplierItem supplierItem = new SupplierItem(); SupplierItem supplierItem = new SupplierItem();
......
...@@ -29,6 +29,14 @@ public interface SysSupplierItemService { ...@@ -29,6 +29,14 @@ public interface SysSupplierItemService {
Result findDetail(SupplierItemRequestDto dto); Result findDetail(SupplierItemRequestDto dto);
/**
* 编辑更新
* @param dto
* @return
*/
Result update(SupplierItemRequestDto dto);
} }
...@@ -100,4 +100,9 @@ public class SupplierItemVo implements Entity { ...@@ -100,4 +100,9 @@ public class SupplierItemVo implements Entity {
* 最近一次购买的商品所属分享商的分享id * 最近一次购买的商品所属分享商的分享id
*/ */
private String shareId; private String shareId;
/**
* 商品售出的数量
*/
private Long selledNum;
} }
...@@ -14,4 +14,6 @@ public class DistributionOrderNum implements Entity { ...@@ -14,4 +14,6 @@ public class DistributionOrderNum implements Entity {
private String stateName; private String stateName;
private Integer num; private Integer num;
private Integer selledNum;
} }
...@@ -71,6 +71,14 @@ public interface DistributionOrderDao { ...@@ -71,6 +71,14 @@ public interface DistributionOrderDao {
*/ */
List<DistributionOrder> findByPage(DistributionOrderRequestDto dto); List<DistributionOrder> findByPage(DistributionOrderRequestDto dto);
/**
* 统计商品卖出数量
* @param itemId
* @return
*/
Long countSelledNum(long itemId);
/** /**
* 根据状态统计订单数量 * 根据状态统计订单数量
* @param buyerId * @param buyerId
......
...@@ -92,8 +92,12 @@ public class DistributionOrderDaoImpl implements DistributionOrderDao { ...@@ -92,8 +92,12 @@ public class DistributionOrderDaoImpl implements DistributionOrderDao {
example.setOrderByClause("create_time desc"); example.setOrderByClause("create_time desc");
PageHelper.startPage(dto.getPage(), dto.getLimit()); PageHelper.startPage(dto.getPage(), dto.getLimit());
return distributionOrderMapper.selectByExample(example); return distributionOrderMapper.selectByExample(example);
}
@Override
public Long countSelledNum(long itemId) {
return distributionOrderMapper.countSelledNum(itemId);
} }
@Override @Override
......
...@@ -82,4 +82,7 @@ public interface DistributionOrderMapper { ...@@ -82,4 +82,7 @@ public interface DistributionOrderMapper {
*/ */
List<DistributionOrderNum> countGroupByStateForUser(@Param("buyerId")Long userId); List<DistributionOrderNum> countGroupByStateForUser(@Param("buyerId")Long userId);
Long countSelledNum(@Param("itemId")Long itemId);
} }
\ No newline at end of file
...@@ -637,4 +637,8 @@ ...@@ -637,4 +637,8 @@
<select id="countGroupByStateForUser" parameterType="java.lang.Long" resultType="com.wwdz.ch.db.bean.DistributionOrderNum"> <select id="countGroupByStateForUser" parameterType="java.lang.Long" resultType="com.wwdz.ch.db.bean.DistributionOrderNum">
select state, count(distribution_order_id) as num from distribution_order where buyer_id = #{buyerId} group by state select state, count(distribution_order_id) as num from distribution_order where buyer_id = #{buyerId} group by state
</select> </select>
<select id="countSelledNum" parameterType="java.lang.Long" resultType="java.lang.Long">
select sum(item_num) as selledNum from distribution_order where item_id = #{itemId} and state not in (1, 101)
</select>
</mapper> </mapper>
\ No newline at end of file
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