文章目录
概要
派送订单是电子商务、外卖平台、在线零售等多个行业中的一项重要业务流程。这项功能允许商家或平台将订单状态更新为“正在派送”,通常发生在订单准备完成后,即将交给物流或快递公司进行配送。
需求分析以及接口设计

技术细节
1.Controller层:
@ApiOperation("派送订单")
@PutMapping("/delivery/{id}")
public Result delivery(Long id){
log.info("派送订单,订单id:{}",id);
orderService.delivery(id);
return Result.success();
}
2.Service层:
public void delivery(Long id) {
Orders ordersDB = orderMapper.getById(id);
// 校验订单是否存在,并且状态为3
if (ordersDB == null || !ordersDB.getStatus().equals(Orders.CONFIRMED)) {
throw new OrderBusinessException(MessageConstant.ORDER_STATUS_ERROR);
}
//修改订单状态为配送中
Orders orders = new Orders();
orders.setId(id);
orders.setStatus(Orders.COMPLETED);
orderMapper.update(orders);
}
3.Mapper层
<update id="update" parameterType="com.sky.entity.Orders">
update orders
<set>
<if test="cancelReason != null and cancelReason!='' ">
cancel_reason=#{cancelReason},
</if>
<if test="rejectionReason != null and rejectionReason!='' ">
rejection_reason=#{rejectionReason},
</if>
<if test="cancelTime != null">
cancel_time=#{cancelTime},
</if>
<if test="payStatus != null">
pay_status=#{payStatus},
</if>
<if test="payMethod != null">
pay_method=#{payMethod},
</if>
<if test="checkoutTime != null">
checkout_time=#{checkoutTime},
</if>
<if test="status != null">
status = #{status},
</if>
<if test="deliveryTime != null">
delivery_time = #{deliveryTime}
</if>
</set>
where id = #{id}
</update>

211

被折叠的 条评论
为什么被折叠?



