0) { $data['buyer_nums'] = $params['buyer_nums']; $find = PurchaseProductOffer::where('order_id', $params['poid'])->where('product_id', $params['product_id'])->find(); if ($find) { PurchaseProductOffer::where('id', $find['id'])->inc('buyer_nums', $params['buyer_nums'])->update(); } else { $arr['order_id'] = $params['poid']; $arr['product_id'] = $params['product_id']; $arr['need_num'] = $params['cart_num']; $arr['buyer_nums'] = $params['buyer_nums']; $arr['unit'] = StoreProduct::where('id', $params['product_id'])->value('unit'); PurchaseProductOffer::create($arr); } } PurchaseOrderInfo::where('id', $params['id'])->update($data); Db::commit(); return true; } catch (\Exception $e) { Db::rollback(); throw new BusinessException($e->getMessage()); } } }