| | |
| | | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.module.erp.api.sale.dto.ErpSaleOrderCreateReqDTO; |
| | | import cn.iocoder.yudao.module.erp.api.sale.dto.ErpSaleOrderItemRespDTO; |
| | | import cn.iocoder.yudao.module.erp.api.sale.dto.ErpSaleOrderRespDTO; |
| | | import cn.iocoder.yudao.module.erp.controller.admin.sale.vo.order.ErpSaleOrderSaveReqVO; |
| | | import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOrderDO; |
| | | import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpSaleOrderItemDO; |
| | | import cn.iocoder.yudao.module.erp.dal.mysql.sale.ErpSaleOrderItemMapper; |
| | | import cn.iocoder.yudao.module.erp.dal.mysql.sale.ErpSaleOrderMapper; |
| | | import cn.iocoder.yudao.module.erp.service.sale.ErpSaleOrderService; |
| | | import jakarta.annotation.Resource; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | | |
| | |
| | | |
| | | @Resource |
| | | private ErpSaleOrderMapper saleOrderMapper; |
| | | |
| | | @Resource |
| | | private ErpSaleOrderItemMapper saleOrderItemMapper; |
| | | |
| | | @Override |
| | | public CommonResult<Long> createSaleOrder(ErpSaleOrderCreateReqDTO createReqDTO) { |
| | |
| | | return success(BeanUtils.toBean(order, ErpSaleOrderRespDTO.class)); |
| | | } |
| | | |
| | | @Override |
| | | public CommonResult<List<ErpSaleOrderItemRespDTO>> getSaleOrderItemList(Long orderId) { |
| | | if (orderId == null) { |
| | | return success(Collections.emptyList()); |
| | | } |
| | | List<ErpSaleOrderItemDO> items = saleOrderService.getSaleOrderItemListByOrderId(orderId); |
| | | return success(BeanUtils.toBean(items, ErpSaleOrderItemRespDTO.class)); |
| | | } |
| | | |
| | | @Override |
| | | public CommonResult<ErpSaleOrderItemRespDTO> getSaleOrderItem(Long id) { |
| | | if (id == null) { |
| | | return success(null); |
| | | } |
| | | ErpSaleOrderItemDO item = saleOrderItemMapper.selectById(id); |
| | | return success(BeanUtils.toBean(item, ErpSaleOrderItemRespDTO.class)); |
| | | } |
| | | |
| | | @Override |
| | | public CommonResult<Boolean> updateOrderItemOutCount(Long orderItemId, BigDecimal outCount) { |
| | | if (orderItemId == null || outCount == null) { |
| | | return success(false); |
| | | } |
| | | ErpSaleOrderItemDO item = saleOrderItemMapper.selectById(orderItemId); |
| | | if (item == null) { |
| | | return success(false); |
| | | } |
| | | // 累加出库数量 |
| | | BigDecimal newOutCount = (item.getOutCount() != null ? item.getOutCount() : BigDecimal.ZERO).add(outCount); |
| | | ErpSaleOrderItemDO updateItem = new ErpSaleOrderItemDO(); |
| | | updateItem.setId(orderItemId); |
| | | updateItem.setOutCount(newOutCount); |
| | | saleOrderItemMapper.updateById(updateItem); |
| | | return success(true); |
| | | } |
| | | |
| | | @Override |
| | | public CommonResult<Boolean> updateOrderOutStatus(Long orderId) { |
| | | if (orderId == null) { |
| | | return success(false); |
| | | } |
| | | saleOrderService.updateSaleOrderOutStatus(orderId); |
| | | return success(true); |
| | | } |
| | | |
| | | } |