我的客户在市场上工作并想开始在线销售
当他收到订单时,他应该确认该商品是否真的有货,以及他是否能够满足需求。
更新> 我已经有一些回调来检查文章是否有货,但是......我实际上需要某种双重检查......(首先通过回调完成,然后手动......但我没有知道我如何以卖家身份编辑 OrderItem....
(当您在市场上工作时可能会发生,您没有时间登记您的销售,甚至某些物品可能被盗......所以这会弄乱库存)
更新 >如果缺少商品(表示库存错误),我如何编辑收到的订单
我的模型是:
Size
belongs_to :product
Order
has_many :order_items
OrderItem
belongs_to :order
belongs_to :product
belongs_to :size
Product
has_many :order_items
has_many :sizes
OrderItem 属性是::id, :quantity, :product_id, :user_id, :size_id, :order_id
假设订单已到:
#here is how are orders are created
order_1 = Order.create(
payment: "{'stub','stripe'}",
created_at: 1.day.ago,
user_id: 1,
token: SecureRandom.hex(8),
status: 1,
shipping_fees: 5,
sub_total: [product_1.price + product_1.price].sum ,
total: 135
)
order_item_1 = OrderItem.create(
price: product_1.price,
order_id: order_1.id,
product_id: 10,
quantity: 1,
size_id: 3
)
order_item_2 = OrderItem.create(
price: product_2.price,
order_id: order_1.id,
product_id: 42,
quantity: 2,
size_id: 8
)
在order_item_2中,客户需要 2 件商品,但我的客户发现他只剩下一件了……
我的客户想要一个清单,上面写着每个项目:
- 是的,它是可用的
- 呜呜我只剩一个了
- 它不再可用
然后它会更新库存并向客户发送电子邮件,警告他某些商品不可用等......
做这个的最好方式是什么?
是否可以在订单控制器中进行管理?还是我应该创建一个发票控制器?
欢迎所有建议。